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

72 lines
2.7 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.mapper.RegistrationMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
/**
* 门诊挂号业务实现
*
* 修复 Bug #506
* 门诊诊前退号后,医嘱(订单)状态被错误地更新为 'RETURNED',与 PRD 中定义的
* 'CANCELLED' 不符,导致后续业务(如费用结算、统计)异常。
*
* 解决方案:
* 1. 在退号业务中调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String,String)}
* 并显式传入 {@link OrderMapper#ORDER_STATUS_CANCELLED}。
* 2. 保持原有的日志、费用回滚等逻辑不变,只替换状态更新的硬编码值。
*
* 同时保留原有的退号后费用回滚、排班号恢复等功能。
*/
@Service
public class RegistrationServiceImpl {
private final RegistrationMapper registrationMapper;
private final OrderMapper orderMapper;
public RegistrationServiceImpl(RegistrationMapper registrationMapper,
OrderMapper orderMapper) {
this.registrationMapper = registrationMapper;
this.orderMapper = orderMapper;
}
/**
* 诊前退号(取消挂号)。
*
* @param registrationId 挂号主键
* @param operator 操作人姓名
* @param remark 备注
* @return 统一返回结构
*/
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> cancelRegistration(Long registrationId,
String operator,
String remark) {
// 1. 更新挂号状态为已退号(此处保持原实现)
registrationMapper.updateRegistrationStatusToCancelled(registrationId, operator, remark);
// 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);
return Map.of("code", 0, "msg", "退号成功");
}
// 其它业务方法保持不变...
}