Fix Bug #573: fallback修复
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.openhis.application.domain.dto.DiagnosisDto;
|
||||
import com.openhis.application.domain.entity.Diagnosis;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.mapper.DiagnosisMapper;
|
||||
import com.openhis.application.mapper.DiseaseReportTypeMapper;
|
||||
import com.openhis.application.service.DiagnosisService;
|
||||
import com.openhis.application.service.InfectionReportService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 诊断业务实现
|
||||
*
|
||||
* 修复 Bug #573:确诊配置了“报卡类型”的疾病后,保存诊断未自动触发传染病报卡弹窗。
|
||||
* 解决方案:
|
||||
* 1. 保存诊断后查询该疾病是否在 disease_report_type 表中配置了报卡类型;
|
||||
* 2. 若配置了报卡类型,调用 InfectionReportService.triggerReportPopup 触发前端弹窗。
|
||||
*/
|
||||
@Service
|
||||
public class DiagnosisServiceImpl implements DiagnosisService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DiagnosisServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private DiagnosisMapper diagnosisMapper;
|
||||
|
||||
@Autowired
|
||||
private DiseaseReportTypeMapper diseaseReportTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private InfectionReportService infectionReportService;
|
||||
|
||||
/**
|
||||
* 保存诊断(包括主诊断和其他诊断)。
|
||||
*
|
||||
* @param diagnosisDto 诊断信息
|
||||
* @throws BusinessException 业务异常
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveDiagnosis(DiagnosisDto diagnosisDto) throws BusinessException {
|
||||
// 1. 参数校验
|
||||
if (diagnosisDto == null || diagnosisDto.getPatientId() == null) {
|
||||
throw new BusinessException("诊断信息不完整");
|
||||
}
|
||||
|
||||
// 2. 删除原有诊断(如果是编辑场景)
|
||||
diagnosisMapper.deleteByVisitId(diagnosisDto.getVisitId());
|
||||
|
||||
// 3. 批量插入新的诊断记录
|
||||
List<Diagnosis> entities = diagnosisDto.toEntityList();
|
||||
if (!CollectionUtils.isEmpty(entities)) {
|
||||
diagnosisMapper.batchInsert(entities);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// 4. 新增:检查是否需要弹出传染病报卡弹窗
|
||||
// --------------------------------------------------------------
|
||||
try {
|
||||
// 只要有一条诊断对应的疾病配置了报卡类型,即触发弹窗
|
||||
boolean needReport = entities.stream().anyMatch(d -> {
|
||||
// disease_report_type 表结构假设为 (disease_id, report_type)
|
||||
// report_type 为非空即表示需要报卡
|
||||
return diseaseReportTypeMapper.selectReportTypeByDiseaseId(d.getDiseaseId()) != null;
|
||||
});
|
||||
|
||||
if (needReport) {
|
||||
// 触发报卡弹窗,传递必要的上下文(患者ID、就诊ID、诊断列表等)
|
||||
infectionReportService.triggerReportPopup(diagnosisDto.getPatientId(),
|
||||
diagnosisDto.getVisitId(),
|
||||
entities);
|
||||
logger.info("诊断保存后触发传染病报卡弹窗,patientId={}, visitId={}", diagnosisDto.getPatientId(),
|
||||
diagnosisDto.getVisitId());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// 业务不应因弹窗触发失败而回滚诊断保存,记录日志即可
|
||||
logger.error("诊断保存后检查报卡类型或触发弹窗异常,patientId={}, visitId={}",
|
||||
diagnosisDto.getPatientId(), diagnosisDto.getVisitId(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
// 其它诊断相关业务方法保持不变...
|
||||
}
|
||||
Reference in New Issue
Block a user