Fix Bug #573: AI修复
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.openhis.web.outpatient.service;
|
||||
|
||||
import com.openhis.web.outpatient.dto.DiagnosisSaveDTO;
|
||||
import com.openhis.web.outpatient.dto.DiagnosisSaveResult;
|
||||
import com.openhis.web.outpatient.entity.Diagnosis;
|
||||
import com.openhis.web.outpatient.mapper.DiagnosisMapper;
|
||||
import com.openhis.web.outpatient.mapper.DiseaseCatalogMapper;
|
||||
import com.openhis.web.outpatient.mapper.ReportCardMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 门诊诊断服务实现
|
||||
* 负责门诊医生工作站的诊断录入、保存及关联业务触发
|
||||
*/
|
||||
@Service
|
||||
public class OutpatientDiagnosisServiceImpl implements OutpatientDiagnosisService {
|
||||
|
||||
private final DiagnosisMapper diagnosisMapper;
|
||||
private final DiseaseCatalogMapper diseaseCatalogMapper;
|
||||
private final ReportCardMapper reportCardMapper;
|
||||
|
||||
public OutpatientDiagnosisServiceImpl(DiagnosisMapper diagnosisMapper,
|
||||
DiseaseCatalogMapper diseaseCatalogMapper,
|
||||
ReportCardMapper reportCardMapper) {
|
||||
this.diagnosisMapper = diagnosisMapper;
|
||||
this.diseaseCatalogMapper = diseaseCatalogMapper;
|
||||
this.reportCardMapper = reportCardMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #573 Fix: 保存诊断并自动校验报卡类型
|
||||
* 逻辑:
|
||||
* 1. 持久化诊断数据
|
||||
* 2. 遍历有效诊断,查询疾病目录配置的【报卡类型】
|
||||
* 3. 校验该患者/就诊次是否已存在对应报卡记录(防重复弹窗)
|
||||
* 4. 将需上报的疾病信息返回前端,由前端触发弹窗
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DiagnosisSaveResult saveDiagnoses(DiagnosisSaveDTO dto) {
|
||||
// 1. 保存/更新诊断数据
|
||||
List<Diagnosis> savedDiagnoses = diagnosisMapper.batchInsertOrUpdate(dto.getDiagnoses());
|
||||
|
||||
// 2. 校验报卡类型并过滤已存在的报卡
|
||||
List<DiagnosisSaveResult.PendingReportCard> pendingCards = new ArrayList<>();
|
||||
for (Diagnosis diag : savedDiagnoses) {
|
||||
// 仅处理有效诊断
|
||||
if (diag.getIsValid() != null && diag.getIsValid()) {
|
||||
// 查询疾病目录配置的报卡类型
|
||||
String reportType = diseaseCatalogMapper.selectReportCardTypeByDiseaseId(diag.getDiseaseId());
|
||||
|
||||
if (reportType != null && !reportType.trim().isEmpty()) {
|
||||
// 保留现系统校验规则:若已存在对应报卡记录,则不重复触发
|
||||
boolean exists = reportCardMapper.existsByPatientAndDisease(
|
||||
dto.getPatientId(),
|
||||
dto.getVisitId(),
|
||||
diag.getDiseaseId(),
|
||||
reportType
|
||||
);
|
||||
if (!exists) {
|
||||
pendingCards.add(new DiagnosisSaveResult.PendingReportCard(
|
||||
diag.getDiseaseId(),
|
||||
diag.getDiseaseName(),
|
||||
reportType
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new DiagnosisSaveResult(true, "诊断已保存并按排序号排序", pendingCards);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user