Fix Bug #505: fallback修复
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.openhis.application.mapper.OrderMainMapper;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 医嘱校对业务实现
|
||||
*
|
||||
* 修复 Bug #505:药品医嘱已由药房发药,护士仍能在“医嘱校对”模块执行“退回”操作。
|
||||
*
|
||||
* 业务规则:
|
||||
* 1. 医嘱状态为“已发药”(status = 2) 时,禁止退回。
|
||||
* 2. 只有在“待校对”(status = 0) 或 “已校对”(status = 1) 状态下才允许退回。
|
||||
*
|
||||
* 该实现通过在退回前校验医嘱状态并抛出业务异常阻止后续处理,确保业务流程符合药房发药后的不可逆性要求。
|
||||
*/
|
||||
@Service
|
||||
public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
|
||||
private final OrderMainMapper orderMainMapper;
|
||||
|
||||
public OrderVerificationServiceImpl(OrderMainMapper orderMainMapper) {
|
||||
this.orderMainMapper = orderMainMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 医嘱退回(撤销)操作
|
||||
*
|
||||
* @param orderId 医嘱主表ID
|
||||
* @param reason 退回原因
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnOrder(Long orderId, String reason) {
|
||||
// 1. 查询医嘱
|
||||
OrderMain order = orderMainMapper.selectById(orderId);
|
||||
if (order == null) {
|
||||
throw new BusinessException("医嘱不存在");
|
||||
}
|
||||
|
||||
// 2. 检查医嘱状态,仅在待校对(0)或已校对(1)时允许退回
|
||||
// 已发药(2)及其它状态均不允许退回
|
||||
Integer status = order.getStatus();
|
||||
if (status == null || (status != 0 && status != 1)) {
|
||||
// 已发药或已退药等不可退回状态
|
||||
throw new BusinessException("药品已由药房发药,不能退回");
|
||||
}
|
||||
|
||||
// 3. 业务处理:这里仅示例更新状态为“已退药”(3) 并记录退回原因
|
||||
OrderMain update = new OrderMain();
|
||||
update.setId(orderId);
|
||||
update.setStatus(3); // 已退药
|
||||
update.setCancelReason(reason); // 记录退回原因
|
||||
update.setCancelTime(new java.util.Date());
|
||||
|
||||
orderMainMapper.updateById(update);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user