Fix Bug #505: AI修复
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.openhis.web.inpatient.service.impl;
|
||||
|
||||
import com.openhis.web.inpatient.mapper.OrderMapper;
|
||||
import com.openhis.web.inpatient.domain.Order;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 护士站医嘱业务实现
|
||||
*
|
||||
* 修复 Bug #505:
|
||||
* 原逻辑未校验药房发药状态,导致已发药医嘱可被直接退回,破坏逆向闭环。
|
||||
* 修复方案:在退回操作入口增加 dispense_status 与 execute_status 前置校验,
|
||||
* 拦截非法流转,强制走“取消执行->退药申请->药房确认->状态回滚”标准流程。
|
||||
*/
|
||||
@Service
|
||||
public class NurseOrderServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
/**
|
||||
* 护士端医嘱退回操作
|
||||
*
|
||||
* @param orderIds 待退回的医嘱ID列表
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnOrders(List<Long> orderIds) {
|
||||
if (orderIds == null || orderIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("医嘱ID列表不能为空");
|
||||
}
|
||||
|
||||
for (Long orderId : orderIds) {
|
||||
Order order = orderMapper.selectById(orderId);
|
||||
if (order == null) {
|
||||
throw new IllegalArgumentException("医嘱不存在: " + orderId);
|
||||
}
|
||||
|
||||
// ================= Bug #505 核心修复 =================
|
||||
// 1. 物理状态校验:已发药严禁直接退回
|
||||
if (order.getDispenseStatus() != null && order.getDispenseStatus() == 1) {
|
||||
throw new IllegalStateException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
|
||||
// 2. 执行状态校验:已执行需先走取消执行流程
|
||||
if (order.getExecuteStatus() != null && order.getExecuteStatus() == 1) {
|
||||
throw new IllegalStateException("该医嘱已执行,请先在【医嘱执行】模块取消执行后再退回");
|
||||
}
|
||||
// ==================================================
|
||||
|
||||
// 原有退回逻辑:状态回退至医生站待审核/未执行状态
|
||||
order.setStatus(0); // 0: 未执行/已退回
|
||||
order.setDispenseStatus(0);
|
||||
order.setExecuteStatus(0);
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user