Fix Bug #505: AI修复
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.openhis.web.nurse.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 NurseOrderServiceImpl {
|
||||
|
||||
private final OrderMapper orderMapper;
|
||||
|
||||
public NurseOrderServiceImpl(OrderMapper orderMapper) {
|
||||
this.orderMapper = orderMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行医嘱退回操作
|
||||
* @param orderIds 医嘱ID列表
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnOrders(List<Long> orderIds) {
|
||||
for (Long orderId : orderIds) {
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new RuntimeException("医嘱不存在");
|
||||
}
|
||||
|
||||
String execStatus = (String) order.get("execution_status");
|
||||
String dispStatus = (String) order.get("dispensing_status");
|
||||
String billStatus = (String) order.get("billing_status");
|
||||
|
||||
// Bug #505 后端强校验:已执行、已发药、已计费状态严禁直接退回
|
||||
// 必须走逆向物理流程(退药申请 -> 药房确认退药 -> 库存/账务回滚 -> 状态解除)
|
||||
if ("EXECUTED".equals(execStatus) || "DISPENSED".equals(dispStatus) || "BILLED".equals(billStatus)) {
|
||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
|
||||
// 状态校验通过,执行退回逻辑
|
||||
orderMapper.updateOrderStatus(orderId, OrderMapper.ORDER_STATUS_RETURNED);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user