Fix Bug #505: AI修复
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.openhis.web.inpatient.service.impl;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.OrderMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 住院医嘱校对业务实现
|
||||
*
|
||||
* 修复 Bug #505:
|
||||
* 增加前置状态校验,拦截已执行或已发药的药品医嘱直接退回。
|
||||
* 严格遵循“逆向闭环”原则:已发药必须走退药流程,不可跨状态直接退回。
|
||||
*/
|
||||
@Service
|
||||
public class OrderVerifyServiceImpl {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
|
||||
public OrderVerifyServiceImpl(OrderMapper orderMapper) {
|
||||
this.orderMapper = orderMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量退回已校对医嘱
|
||||
*
|
||||
* @param orderIds 医嘱ID列表
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnOrders(List<Long> orderIds) {
|
||||
if (orderIds == null || orderIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("退回医嘱列表不能为空");
|
||||
}
|
||||
|
||||
for (Long orderId : orderIds) {
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new IllegalArgumentException("医嘱不存在,ID=" + orderId);
|
||||
}
|
||||
|
||||
String execStatus = String.valueOf(order.get("exec_status"));
|
||||
String dispenseStatus = String.valueOf(order.get("dispense_status"));
|
||||
|
||||
// 核心状态约束校验:执行状态或物理发药状态已流转,严禁直接退回
|
||||
if ("EXECUTED".equals(execStatus) || "DISPENSED".equals(dispenseStatus)) {
|
||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
}
|
||||
|
||||
// 校验通过后,执行原有退回逻辑(状态流转至医生站)
|
||||
for (Long orderId : orderIds) {
|
||||
orderMapper.updateOrderStatus(orderId, "RETURNED");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user