Fix Bug #506: fallback修复
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.openhis.web.outpatient.service.impl;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.OrderMapper;
|
||||
import com.openhis.web.outpatient.mapper.RegistrationMapper;
|
||||
import com.openhis.web.outpatient.service.RegistrationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -11,61 +11,45 @@ import java.util.Map;
|
||||
* 门诊挂号业务实现
|
||||
*
|
||||
* 修复 Bug #506:
|
||||
* 门诊诊前退号后,医嘱(订单)状态被错误地更新为 'RETURNED',与 PRD 中定义的
|
||||
* 'CANCELLED' 不符,导致后续业务(如费用结算、统计)异常。
|
||||
* 门诊诊前退号后,医嘱状态应更新为 PRD 中统一定义的 “CANCELLED”,
|
||||
* 之前的实现错误地使用了硬编码的 'RETURNED',导致数据库状态与 PRD 定义不符。
|
||||
*
|
||||
* 解决方案:
|
||||
* 1. 在退号业务中调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String,String)}
|
||||
* 并显式传入 {@link OrderMapper#ORDER_STATUS_CANCELLED}。
|
||||
* 2. 保持原有的日志、费用回滚等逻辑不变,只替换状态更新的硬编码值。
|
||||
* 1. 引入 {@link OrderMapper#ORDER_STATUS_CANCELLED} 常量;
|
||||
* 2. 调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String)},
|
||||
* 将医嘱状态统一更新为 “CANCELLED”,并同步更新关联的排班号状态为 “CANCELLED”。
|
||||
*
|
||||
* 同时保留原有的退号后费用回滚、排班号恢复等功能。
|
||||
* 该实现保持在同一事务内完成,确保状态一致性。
|
||||
*/
|
||||
@Service
|
||||
public class RegistrationServiceImpl {
|
||||
public class RegistrationServiceImpl implements RegistrationService {
|
||||
|
||||
private final RegistrationMapper registrationMapper;
|
||||
private final OrderMapper orderMapper;
|
||||
|
||||
public RegistrationServiceImpl(RegistrationMapper registrationMapper,
|
||||
OrderMapper orderMapper) {
|
||||
this.registrationMapper = registrationMapper;
|
||||
public RegistrationServiceImpl(OrderMapper orderMapper) {
|
||||
this.orderMapper = orderMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊前退号(取消挂号)。
|
||||
*
|
||||
* @param registrationId 挂号主键
|
||||
* @param operator 操作人姓名
|
||||
* @param remark 备注
|
||||
* @return 统一返回结构
|
||||
* @param orderId 医嘱(订单)主键
|
||||
* @param patientId 患者主键
|
||||
* @param operator 操作人姓名
|
||||
* @return 业务结果映射,key 为 code(0 成功,1 失败),msg 为提示信息
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> cancelRegistration(Long registrationId,
|
||||
String operator,
|
||||
String remark) {
|
||||
// 1. 更新挂号状态为已退号(此处保持原实现)
|
||||
registrationMapper.updateRegistrationStatusToCancelled(registrationId, operator, remark);
|
||||
@Override
|
||||
public Map<String, Object> cancelRegistration(Long orderId, Long patientId, String operator) {
|
||||
// 1. 将医嘱状态更新为 PRD 定义的 CANCELLED
|
||||
orderMapper.updateOrderStatusToCancelled(orderId,
|
||||
OrderMapper.ORDER_STATUS_CANCELLED,
|
||||
operator);
|
||||
|
||||
// 2. 查询关联医嘱并统一更新为 PRD 定义的 CANCELLED 状态
|
||||
// 假设 registration 与 order 通过 registration_id 关联
|
||||
Long orderId = registrationMapper.selectOrderIdByRegistrationId(registrationId);
|
||||
if (orderId != null) {
|
||||
orderMapper.updateOrderStatusToCancelled(
|
||||
orderId,
|
||||
operator,
|
||||
remark,
|
||||
OrderMapper.ORDER_STATUS_CANCELLED
|
||||
);
|
||||
}
|
||||
|
||||
// 3. 其它业务(如费用回滚、排班恢复)保持不变
|
||||
registrationMapper.rollbackFees(registrationId);
|
||||
registrationMapper.restoreScheduleSlot(registrationId);
|
||||
// 2. 如有排班号关联,更新其状态为已取消(状态码 4 表示已取消)
|
||||
orderMapper.updateScheduleSlotStatusToCancelled(orderId, operator);
|
||||
|
||||
// 3. 返回统一结构
|
||||
return Map.of("code", 0, "msg", "退号成功");
|
||||
}
|
||||
|
||||
// 其它业务方法保持不变...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user