package com.openhis.web.outpatient.service.impl;
import com.openhis.web.outpatient.mapper.LabApplyMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 检验申请业务实现
*
* 修复 Bug #571:
* 原来的撤回实现直接调用 {@code updateStatus(applyId, "RETURNED")},状态码与 PRD 不匹配,
* 并且缺少对当前状态的校验,导致在已执行、已报告等状态下仍能撤回,引发系统异常。
*
* 现在通过调用 {@link LabApplyMapper#withdrawLabApply(Long)} 完成撤回,确保:
*
* - 仅在可撤回的状态(APPLIED、PENDING)下执行。
* - 撤回后统一使用 PRD 定义的 CANCELLED 状态。
* - 异常信息更加友好,前端可直接展示。
*
*/
@Service
public class LabApplyServiceImpl {
private final LabApplyMapper labApplyMapper;
public LabApplyServiceImpl(LabApplyMapper labApplyMapper) {
this.labApplyMapper = labApplyMapper;
}
/**
* 撤回检验申请。
*
* @param applyId 检验申请主键
*/
@Transactional(rollbackFor = Exception.class)
public void withdrawApply(Long applyId) {
// LabApplyMapper 已经在内部完成状态校验并抛出异常
labApplyMapper.withdrawLabApply(applyId);
}
// 其余业务方法保持不变
}