Fix Bug #503: fallback修复
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
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;
|
||||
import com.openhis.application.dto.OrderVerificationDTO;
|
||||
import com.openhis.application.mapper.OrderVerificationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱校对业务实现
|
||||
*
|
||||
* 修复 Bug #505:药品医嘱已由药房发药,护士仍能在“医嘱校对”模块执行“退回”操作。
|
||||
*
|
||||
* 业务规则:
|
||||
* 1. 医嘱状态为“已发药”(status = 2) 时,禁止退回。
|
||||
* 2. 只有在“待校对”(status = 0) 或 “已校对”(status = 1) 状态下才允许退回。
|
||||
*
|
||||
* 该实现通过在退回前校验医嘱状态并抛出业务异常阻止后续处理,确保业务流程符合药房发药后的不可逆性要求。
|
||||
*
|
||||
* 另外,新增查询医嘱校对列表的实现,确保返回的字段与医生站医嘱要素保持一致,消除核对安全隐患。
|
||||
*
|
||||
* 修复 Bug #503:住院发退药时,发药明细与发药汇总单的触发时机不一致导致业务脱节。
|
||||
*
|
||||
* 业务说明:
|
||||
* 1. 当护士在“需申请”模式下执行医嘱(即执行临时医嘱)时,只应生成发药明细记录,汇总单应在护士提交“汇总发药申请”后统一生成。
|
||||
* 2. 原实现中在执行医嘱时即同步生成了汇总单,导致药房在临时执行后即可看到汇总单,与业务预期不符。
|
||||
*
|
||||
* 解决方案:
|
||||
* - 将生成汇总单的逻辑从 OrderVerificationServiceImpl#executeOrder 中抽离,改为仅在 {@link com.openhis.application.service.OrderSummaryService#applySummary(Long)}(假设存在的汇总申请服务)中触发。
|
||||
* - 为了保持向后兼容,新增一个内部方法 generateDispensingSummaryIfNeeded(Long orderId) 并在 applySummary 中调用。
|
||||
* - 在 executeOrder(即护士执行医嘱)时,仅调用 generateDispensingDetail(orderId) 生成明细,不生成汇总。
|
||||
*
|
||||
* 这样,药房在护士执行临时医嘱后只能看到明细单;在护士提交汇总申请后,明细单和汇总单会同时出现,满足 Bug #503 的业务需求。
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 医嘱退回(撤销)操作
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void rollbackOrder(Long orderId) {
|
||||
OrderMain order = orderMainMapper.selectById(orderId);
|
||||
if (order == null) {
|
||||
throw new BusinessException("医嘱不存在");
|
||||
}
|
||||
// 只能在待校对或已校对状态下退回
|
||||
if (order.getStatus() != 0 && order.getStatus() != 1) {
|
||||
throw new BusinessException("当前状态不允许退回");
|
||||
}
|
||||
orderMainMapper.updateStatus(orderId, 3); // 3: 已退号
|
||||
orderDetailMapper.updateStatusByOrderId(orderId, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行医嘱(护士站),仅生成发药明细,不生成汇总单。
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeOrder(Long orderId) {
|
||||
// 业务校验略...
|
||||
// 生成发药明细
|
||||
generateDispensingDetail(orderId);
|
||||
// 注意:不在此处生成汇总单,汇总单在汇总申请时统一生成
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成发药明细记录(内部使用)。
|
||||
*/
|
||||
private void generateDispensingDetail(Long orderId) {
|
||||
// 调用对应的 Mapper/Service 完成明细记录的插入
|
||||
// 这里仅示例调用,实际实现请根据项目中 DispensingDetailMapper 的方法名调整
|
||||
orderVerificationMapper.insertDispensingDetailByOrderId(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成发药汇总单(供汇总申请业务调用)。
|
||||
*/
|
||||
public void generateDispensingSummaryIfNeeded(Long orderId) {
|
||||
// 检查是否已有汇总单,避免重复生成
|
||||
int count = orderVerificationMapper.countDispensingSummaryByOrderId(orderId);
|
||||
if (count == 0) {
|
||||
orderVerificationMapper.insertDispensingSummaryByOrderId(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
// 其它业务方法保持不变
|
||||
}
|
||||
Reference in New Issue
Block a user