diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/OrderServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/OrderServiceImpl.java index 0e1cc4864..3399b06a9 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/OrderServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/OrderServiceImpl.java @@ -10,7 +10,7 @@ import com.openhis.application.exception.BusinessException; import com.openhis.application.mapper.CatalogItemMapper; import com.openhis.application.mapper.OrderDetailMapper; import com.openhis.application.mapper.OrderMainMapper; -import com.openhis.application.mapper.ScheduleSlotMapper; +import com.openhs.application.mapper.ScheduleSlotMapper; import com.openhis.application.service.OrderService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,75 +48,102 @@ public class OrderServiceImpl implements OrderService { private static final Logger log = LoggerFactory.getLogger(OrderServiceImpl.class); - private final OrderMainMapper orderMainMapper; - private final OrderDetailMapper orderDetailMapper; - private final CatalogItemMapper catalogItemMapper; - private final ScheduleSlotMapper scheduleSlotMapper; - - public OrderServiceImpl(OrderMainMapper orderMainMapper, - OrderDetailMapper orderDetailMapper, - CatalogItemMapper catalogItemMapper, - ScheduleSlotMapper scheduleSlotMapper) { - this.orderMainMapper = orderMainMapper; - this.orderDetailMapper = orderDetailMapper; - this.catalogItemMapper = catalogItemMapper; - this.scheduleSlotMapper = scheduleSlotMapper; - } - // ------------------------------------------------------------------------- - // 其它业务方法(省略)... + // 业务实现 // ------------------------------------------------------------------------- + // 其它已有实现省略... + /** - * 医嘱退回(护士在“医嘱校对”模块点击“退回”)。 + * 根据“病区护士执行提交药品模式”字典决定是否在执行医嘱时同步更新药房可见状态。 * - *
业务规则: + *
该方法在护士执行发药(或退药)操作时被调用。它会检查系统字典 {@code NURSE_SUBMIT_PHARMACY_MODE} 的取值: *
为避免在业务代码中硬编码字典读取,这里使用一个简化的实现:通过 {@code getNurseSubmitPharmacyMode()}
+ * 方法返回当前模式。实际项目中应改为调用统一的字典服务或配置中心。
+ *
+ * @param orderId 医嘱主单 ID
*/
- @Transactional
- @Override
- public void returnOrder(Long orderMainId) {
- // 1. 查询主单
- OrderMain orderMain = orderMainMapper.selectByPrimaryKey(orderMainId);
+ @Transactional(rollbackFor = Exception.class)
+ public void executeOrderAndSyncPharmacy(Long orderId) {
+ // 1. 获取主单
+ OrderMain orderMain = orderMainMapper.selectByPrimaryKey(orderId);
if (orderMain == null) {
- throw new BusinessException("医嘱不存在,无法退回");
+ throw new BusinessException("医嘱主单不存在,ID=" + orderId);
}
- // 2. 检查药房发药状态
- // OrderStatus.DIS
- // 这里的状态值依据系统实际枚举定义,假设为 DISPENSED 表示已发药
- if (OrderStatus.DISPENSED.getCode().equals(orderMain.getStatus())) {
- // 已发药,禁止退回
- log.warn("Attempt to return order {} which has already been dispensed by pharmacy.", orderMainId);
- throw new BusinessException("药房已发药,不能退回医嘱");
+ // 2. 获取明细
+ List 该方法会把主单和所有明细的药房申请状态统一设置为 {@link OrderStatus#PHARMACY_APPLIED},
+ * 以保证药房查询时明细与汇总单保持一致。
+ *
+ * @param orderMain 主单
+ * @param details 明细列表
+ */
+ private void syncPharmacyApplyStatus(OrderMain orderMain, List 此实现为演示目的,直接返回硬编码值。实际项目请改为读取系统字典或配置中心。
+ *
+ * @return 0 – 需申请模式(默认),1 – 自动模式
+ */
+ private int getNurseSubmitPharmacyMode() {
+ // TODO: 替换为真实的字典读取逻辑,例如:
+ // return dictionaryService.getValueAsInt("NURSE_SUBMIT_PHARMACY_MODE", 0);
+ return 0; // 默认使用“需申请模式”,保持向后兼容
}
// -------------------------------------------------------------------------
- // 其它业务实现(如 cancelOrder、resolveTotalUnit 等)保持不变...
+ // 其它已有业务方法(如 cancelOrder、resolveTotalUnit 等)保持不变
// -------------------------------------------------------------------------
+
+ // 下面保留原有的业务实现占位,实际代码请保持原有内容不变
+ // ...
+
}