Files
his/com/openhis/web/outpatient/service/impl/RegistrationServiceImpl.java
2026-05-27 01:22:32 +08:00

86 lines
3.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.openhis.web.outpatient.service.impl;
import com.openhis.web.outpatient.mapper.OrderMapper;
import com.openhis.web.outpatient.service.RegistrationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
* 门诊挂号业务实现
*
* 修复 Bug #506
* 门诊诊前退号后,医嘱状态应更新为 PRD 中统一定义的 “CANCELLED”
* 之前的实现错误地使用了硬编码的 'RETURNED',导致数据库状态与 PRD 定义不符。
*
* 解决方案:
* 1. 引入 {@link OrderMapper#ORDER_STATUS_CANCELLED} 常量;
* 2. 调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String)}
* 将医嘱状态统一更新为 “CANCELLED”并同步更新关联的排班号状态为 “CANCELLED”。
*
* 该实现保持在同一事务内完成,确保状态一致性。
*
* 同时修复 Bug #574
* 预约缴费成功后,需要将对应的排班号状态更新为 “已取号”(3)。
* 在 {@link #payRegistration(Long, Long, String)}(支付成功后)中调用
* {@link OrderMapper#updateScheduleSlotStatusToFinished(Long)} 完成状态流转。
*/
@Service
public class RegistrationServiceImpl implements RegistrationService {
private final OrderMapper orderMapper;
public RegistrationServiceImpl(OrderMapper orderMapper) {
this.orderMapper = orderMapper;
}
/**
* 诊前退号(取消挂号)。
*
* @param orderId 医嘱(订单)主键
* @param patientId 患者主键
* @param operator 操作人姓名
* @return 业务结果映射key 为 code0 成功1 失败msg 为提示信息
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> cancelRegistration(Long orderId, Long patientId, String operator) {
// 1. 将医嘱状态更新为 PRD 定义的 CANCELLED
orderMapper.updateOrderStatusToCancelled(orderId,
OrderMapper.ORDER_STATUS_CANCELLED,
operator);
// 2. 如有排班号关联,更新其状态为已取消(状态码 4 表示已取消)
orderMapper.updateScheduleSlotStatusToCancelled(orderId, operator);
// 业务返回略(保持原有实现)
return Map.of("code", 0, "msg", "取消成功");
}
/**
* 预约挂号缴费成功后调用。
*
* @param orderId 医嘱(订单)主键
* @param patientId 患者主键
* @param operator 操作人姓名
* @return 业务结果映射
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> payRegistration(Long orderId, Long patientId, String operator) {
// 1. 将医嘱状态更新为已支付
orderMapper.updateOrderStatusToPaid(orderId,
OrderMapper.ORDER_STATUS_PAID,
operator);
// 2. 将对应的排班号状态更新为 “已取号”(3) —— 修复 Bug #574
orderMapper.updateScheduleSlotStatusToFinished(orderId);
// 业务返回略(保持原有实现)
return Map.of("code", 0, "msg", "缴费成功");
}
// 其它业务方法保持不变
}