Fix Bug #505: AI修复
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.openhis.web.inpatient.service.impl;
|
||||
|
||||
import com.openhis.web.inpatient.mapper.OrderMapper;
|
||||
import com.openhis.web.inpatient.service.OrderVerificationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 医嘱校对业务实现
|
||||
* 修复 Bug #505:增加退回操作的前置状态校验,防止已发药/已执行/已计费医嘱被非法退回。
|
||||
*/
|
||||
@Service
|
||||
public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
|
||||
public OrderVerificationServiceImpl(OrderMapper orderMapper) {
|
||||
this.orderMapper = orderMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnOrder(Long orderId) {
|
||||
if (orderId == null) {
|
||||
throw new IllegalArgumentException("医嘱ID不能为空");
|
||||
}
|
||||
|
||||
// 1. 查询医嘱当前全量状态
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new IllegalArgumentException("医嘱不存在或已被删除");
|
||||
}
|
||||
|
||||
String execStatus = String.valueOf(order.get("exec_status"));
|
||||
String dispenseStatus = String.valueOf(order.get("dispense_status"));
|
||||
String chargeStatus = String.valueOf(order.get("charge_status"));
|
||||
|
||||
// 2. 核心状态约束校验(修复 Bug #505 根因)
|
||||
// 执行状态:必须为“未执行”
|
||||
if ("已执行".equals(execStatus) || "EXECUTED".equals(execStatus)) {
|
||||
throw new RuntimeException("该医嘱已执行,请先在【医嘱执行】模块取消执行");
|
||||
}
|
||||
// 物理状态:必须为“未发药/未领药”
|
||||
if ("已发药".equals(dispenseStatus) || "DISPENSED".equals(dispenseStatus)) {
|
||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
// 财务状态:必须为“未计费”
|
||||
if ("已计费".equals(chargeStatus) || "CHARGED".equals(chargeStatus)) {
|
||||
throw new RuntimeException("该医嘱已产生费用,请先完成退费流程");
|
||||
}
|
||||
|
||||
// 3. 校验通过,执行状态流转
|
||||
orderMapper.updateOrderStatus(orderId, "已退回");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user