Fix Bug #503: AI修复
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.openhis.web.nurse.service.impl;
|
||||
|
||||
import com.openhis.web.nurse.mapper.OrderMapper;
|
||||
import com.openhis.web.nurse.service.OrderExecutionService;
|
||||
import com.openhis.web.system.service.SysConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 护士医嘱执行业务实现
|
||||
*
|
||||
* 修复 Bug #503:执行医嘱时根据系统配置自动流转申请状态。
|
||||
* - 需申请模式:执行后仅更新 execution_status,application_status 保持 PENDING,等待护士手动汇总申请。
|
||||
* - 自动模式:执行后同步将 application_status 更新为 APPLIED,实现明细与汇总即时同步。
|
||||
*/
|
||||
@Service
|
||||
public class OrderExecutionServiceImpl implements OrderExecutionService {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
private final SysConfigService sysConfigService;
|
||||
|
||||
private static final String CONFIG_KEY_SUBMIT_MODE = "WARD_NURSE_DRUG_SUBMIT_MODE";
|
||||
private static final String MODE_AUTO = "AUTO";
|
||||
|
||||
public OrderExecutionServiceImpl(OrderMapper orderMapper, SysConfigService sysConfigService) {
|
||||
this.orderMapper = orderMapper;
|
||||
this.sysConfigService = sysConfigService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeOrders(List<Long> orderIds) {
|
||||
if (orderIds == null || orderIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("医嘱ID列表不能为空");
|
||||
}
|
||||
|
||||
String mode = sysConfigService.getConfigValue(CONFIG_KEY_SUBMIT_MODE);
|
||||
boolean isAutoMode = MODE_AUTO.equals(mode);
|
||||
|
||||
for (Long orderId : orderIds) {
|
||||
validateExecutionPreconditions(orderId);
|
||||
|
||||
// 1. 更新执行状态为已执行
|
||||
orderMapper.updateExecutionStatus(orderId, "EXECUTED");
|
||||
|
||||
// 2. 根据模式同步申请状态 (Bug #503 核心修复)
|
||||
if (isAutoMode) {
|
||||
orderMapper.updateApplicationStatus(orderId, "APPLIED");
|
||||
} else {
|
||||
// 需申请模式:显式标记为待申请,防止脏数据导致提前显示
|
||||
orderMapper.updateApplicationStatus(orderId, "PENDING");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateExecutionPreconditions(Long orderId) {
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new RuntimeException("医嘱不存在,orderId=" + orderId);
|
||||
}
|
||||
String status = (String) order.get("execution_status");
|
||||
if ("EXECUTED".equals(status)) {
|
||||
throw new RuntimeException("该医嘱已执行,请勿重复操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user