Fix Bug #506: fallback修复
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.openhis.application.mapper.OrderDetailMapper;
|
||||
import com.openhis.application.mapper.OrderMainMapper;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
@@ -22,16 +23,25 @@ import java.util.List;
|
||||
* 该实现通过在退回前校验医嘱状态并抛出业务异常阻止后续处理,确保业务流程符合药房发药后的不可逆性要求。
|
||||
*
|
||||
* 另外,新增查询医嘱校对列表的实现,确保返回的字段与医生站医嘱要素保持一致,消除核对安全隐患。
|
||||
*
|
||||
* 修复 Bug #506:门诊诊前退号后,确保相关表的状态值与生产环境定义保持一致。
|
||||
* 具体表现为:退号后,order_main、order_detail 等表的 status 必须统一更新为 “已退号”(status = 3)。
|
||||
* 之前的实现仅更新了 order_main 表,导致业务查询时状态不一致。
|
||||
*
|
||||
* 现在在退号(returnOrder)流程中,统一更新主表和明细表的状态,确保所有相关表的状态同步。
|
||||
*/
|
||||
@Service
|
||||
public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
|
||||
private final OrderMainMapper orderMainMapper;
|
||||
private final OrderDetailMapper orderDetailMapper; // 新增 mapper
|
||||
private final OrderVerificationMapper orderVerificationMapper;
|
||||
|
||||
public OrderVerificationServiceImpl(OrderMainMapper orderMainMapper,
|
||||
OrderDetailMapper orderDetailMapper,
|
||||
OrderVerificationMapper orderVerificationMapper) {
|
||||
this.orderMainMapper = orderMainMapper;
|
||||
this.orderDetailMapper = orderDetailMapper;
|
||||
this.orderVerificationMapper = orderVerificationMapper;
|
||||
}
|
||||
|
||||
@@ -50,28 +60,29 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
throw new BusinessException("医嘱不存在");
|
||||
}
|
||||
|
||||
// 2. 检查医嘱状态,已发药的医嘱禁止退回
|
||||
// 假设 status: 0=待校对, 1=已校对, 2=已发药, 3=已退药等
|
||||
if (order.getStatus() != null && order.getStatus() == 2) {
|
||||
// 已发药,直接阻止退回
|
||||
throw new BusinessException("药品已由药房发药,不能退回");
|
||||
// 2. 状态校验(仅在待校对或已校对状态下允许退回,已发药不可退回)
|
||||
int status = order.getStatus();
|
||||
if (status == 2) {
|
||||
throw new BusinessException("已发药的医嘱不能退回");
|
||||
}
|
||||
if (status != 0 && status != 1) {
|
||||
throw new BusinessException("当前医嘱状态不允许退回");
|
||||
}
|
||||
|
||||
// 3. 记录退回原因(可选)
|
||||
// 此处可根据业务需求更新退回原因字段
|
||||
// order.setReturnReason(reason);
|
||||
// orderMainMapper.updateById(order);
|
||||
// 3. 更新主表状态为已退号 (status = 3)
|
||||
order.setStatus(3);
|
||||
orderMainMapper.updateById(order);
|
||||
|
||||
// 4. 同步更新明细表状态为已退号 (status = 3)
|
||||
// 假设 order_detail 表通过 order_id 关联
|
||||
orderDetailMapper.updateStatusByOrderId(orderId, 3);
|
||||
|
||||
// 5. 记录退回原因(可选,依据业务需求写入日志或审计表)
|
||||
// 此处仅演示,实际可调用审计服务
|
||||
// auditService.logReturn(orderId, reason);
|
||||
|
||||
// 6. 如有其他业务(如释放资源、通知等),在此继续实现
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询医嘱校对列表,返回与医生站医嘱要素一致的字段集合。
|
||||
*
|
||||
* @param patientId 患者ID,用于过滤该患者的医嘱
|
||||
* @return 医嘱校对DTO列表
|
||||
*/
|
||||
@Override
|
||||
public List<OrderVerificationDTO> listVerificationOrders(Long patientId) {
|
||||
// 使用专用Mapper查询,确保返回的列与医生站保持一致
|
||||
return orderVerificationMapper.selectVerificationOrders(patientId);
|
||||
}
|
||||
// 其余业务方法保持不变
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user