Fix Bug #505: AI修复
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.openhis.web.nurse.service.impl;
|
||||
|
||||
import com.openhis.web.nurse.mapper.OrderMapper;
|
||||
import com.openhis.web.nurse.service.OrderVerificationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
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 returnOrders(List<Long> orderIds) {
|
||||
if (orderIds == null || orderIds.isEmpty()) {
|
||||
throw new IllegalArgumentException("医嘱ID列表不能为空");
|
||||
}
|
||||
|
||||
for (Long orderId : orderIds) {
|
||||
validateReturnPreconditions(orderId);
|
||||
}
|
||||
|
||||
// 批量更新状态为已退回
|
||||
orderMapper.batchUpdateOrderStatus(orderIds, "RETURNED");
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心状态约束校验 (Bug #505 修复)
|
||||
* 护士能执行“退回”操作必须同时满足:
|
||||
* 1. 执行状态:必须为“未执行”
|
||||
* 2. 物理状态:必须为“未发药/未领药”
|
||||
* 3. 财务状态:必须为“未计费”
|
||||
*/
|
||||
private void validateReturnPreconditions(Long orderId) {
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new RuntimeException("医嘱不存在,orderId=" + orderId);
|
||||
}
|
||||
|
||||
String executionStatus = (String) order.get("execution_status");
|
||||
String dispensingStatus = (String) order.get("dispensing_status");
|
||||
String billingStatus = (String) order.get("billing_status");
|
||||
|
||||
if ("EXECUTED".equals(executionStatus)) {
|
||||
throw new RuntimeException("该医嘱已执行,请先在【医嘱执行】模块取消执行");
|
||||
}
|
||||
if ("DISPENSED".equals(dispensingStatus)) {
|
||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
if ("BILLED".equals(billingStatus)) {
|
||||
throw new RuntimeException("该医嘱已计费,请先撤销计费");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user