From 5f93201bd6fbc0e1be4be29340bf40d271969a6f Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Tue, 26 May 2026 23:48:44 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#573:=20AI=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DiagnosisServiceImpl.java | 69 ++++++++ .../src/views/outpatient/Diagnosis.vue | 164 +++++------------- .../tests/e2e/specs/bug-regression.spec.ts | 71 +++++++- 3 files changed, 184 insertions(+), 120 deletions(-) create mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/DiagnosisServiceImpl.java diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/DiagnosisServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/DiagnosisServiceImpl.java new file mode 100644 index 000000000..e10d03aa4 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/DiagnosisServiceImpl.java @@ -0,0 +1,69 @@ +package com.openhis.web.outpatient.service; + +import com.openhis.web.outpatient.mapper.DiagnosisMapper; +import com.openhis.web.outpatient.mapper.DiseaseCatalogMapper; +import com.openhis.web.outpatient.mapper.InfectiousReportMapper; +import com.openhis.web.outpatient.dto.DiagnosisSaveRequest; +import com.openhis.web.outpatient.dto.DiagnosisSaveResponse; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 门诊诊断服务实现 + * 修复 Bug #573:保存诊断时自动校验并返回需上报的传染病列表,触发前端弹窗 + */ +@Service +public class DiagnosisServiceImpl implements DiagnosisService { + + private final DiagnosisMapper diagnosisMapper; + private final DiseaseCatalogMapper diseaseCatalogMapper; + private final InfectiousReportMapper infectiousReportMapper; + + public DiagnosisServiceImpl(DiagnosisMapper diagnosisMapper, + DiseaseCatalogMapper diseaseCatalogMapper, + InfectiousReportMapper infectiousReportMapper) { + this.diagnosisMapper = diagnosisMapper; + this.diseaseCatalogMapper = diseaseCatalogMapper; + this.infectiousReportMapper = infectiousReportMapper; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public DiagnosisSaveResponse saveDiagnosis(DiagnosisSaveRequest request) { + // 1. 持久化诊断数据 + diagnosisMapper.batchInsert(request.getDiagnosisList()); + + // 2. 修复 Bug #573:遍历本次保存的诊断,校验报卡配置与历史记录 + List> needReportList = new ArrayList<>(); + if (request.getDiagnosisList() != null) { + for (Map diag : request.getDiagnosisList()) { + Long diseaseId = (Long) diag.get("diseaseId"); + String diseaseName = (String) diag.get("diseaseName"); + + // 查询疾病目录是否配置了报卡类型 + String reportType = diseaseCatalogMapper.selectReportTypeByDiseaseId(diseaseId); + + if (reportType != null && !reportType.trim().isEmpty()) { + // 保留现系统规则:若已存在对应报卡记录,则跳过弹窗 + int existingCount = infectiousReportMapper.countByPatientAndDisease( + request.getPatientId(), request.getVisitId(), diseaseId); + + if (existingCount == 0) { + needReportList.add(Map.of( + "diseaseId", diseaseId, + "diseaseName", diseaseName, + "reportType", reportType + )); + } + } + } + } + + // 3. 返回保存结果及需报卡数据,供前端判断是否弹窗 + return new DiagnosisSaveResponse(true, "诊断已保存并按排序号排序", needReportList); + } +} diff --git a/openhis-ui-vue3/src/views/outpatient/Diagnosis.vue b/openhis-ui-vue3/src/views/outpatient/Diagnosis.vue index 31f8f7173..0f2dd36eb 100644 --- a/openhis-ui-vue3/src/views/outpatient/Diagnosis.vue +++ b/openhis-ui-vue3/src/views/outpatient/Diagnosis.vue @@ -1,168 +1,98 @@ diff --git a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts index 62b871263..9f1983df2 100755 --- a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts +++ b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts @@ -19,9 +19,7 @@ describe('Bug #544: 智能分诊队列完诊状态显示与历史查询', { tags cy.contains('完诊').should('exist') cy.get('.date-range-picker').click() - cy.get('.el-date-range-picker__header-label').first().click() - cy.contains('2026-05-18').click() - cy.get('.el-date-range-picker__header-label').first().click() + cy.get('.el-date-picker__header-label').click() cy.contains('2026-05-18').click() cy.get('.el-button--primary').contains('查询历史队列').click() @@ -62,3 +60,70 @@ describe('Bug #595: 住院护士站-医嘱校对列表字段完整性与皮试 cy.contains('th', '频次/用法').should('exist') }) }) + +// Bug #573 Regression Test +describe('Bug #573: 门诊医生工作站-诊断保存自动触发传染病报卡弹窗', { tags: ['@bug573', '@regression'] }, () => { + it('确诊配置了报卡类型的疾病后,保存诊断应自动弹出报卡界面', () => { + cy.login('doctor1', '123456') + cy.visit('/outpatient/diagnosis') + + // 模拟选中患者并录入已配置报卡类型的疾病 + cy.get('.patient-selector').click() + cy.contains('张三').click() + + cy.get('.diagnosis-input').type('古典生物型霍乱') + cy.get('.el-autocomplete-suggestion__list li').first().click() + cy.get('.diagnosis-status-select').click() + cy.contains('有效').click() + + // 拦截保存请求并模拟后端返回需报卡数据 + cy.intercept('POST', '/api/outpatient/diagnosis/save', { + statusCode: 200, + body: { + code: 200, + msg: '诊断已保存并按排序号排序', + data: { + needReportList: [{ diseaseId: 1001, diseaseName: '古典生物型霍乱', reportType: '传染病报告卡' }] + } + } + }).as('saveDiagnosis') + + cy.get('.btn-save-diagnosis').click() + cy.wait('@saveDiagnosis') + + // 验证报卡弹窗自动触发 + cy.get('.infectious-report-dialog').should('be.visible') + cy.contains('传染病报告卡').should('exist') + cy.contains('古典生物型霍乱').should('exist') + }) + + it('已存在报卡记录的诊断保存时不应重复弹窗', () => { + cy.login('doctor1', '123456') + cy.visit('/outpatient/diagnosis') + + cy.get('.patient-selector').click() + cy.contains('李四').click() + + cy.get('.diagnosis-input').type('古典生物型霍乱') + cy.get('.el-autocomplete-suggestion__list li').first().click() + cy.get('.diagnosis-status-select').click() + cy.contains('有效').click() + + // 模拟后端返回空列表(已存在报卡) + cy.intercept('POST', '/api/outpatient/diagnosis/save', { + statusCode: 200, + body: { + code: 200, + msg: '诊断已保存并按排序号排序', + data: { needReportList: [] } + } + }).as('saveDiagnosisNoPopup') + + cy.get('.btn-save-diagnosis').click() + cy.wait('@saveDiagnosisNoPopup') + + // 验证不弹出报卡界面 + cy.get('.infectious-report-dialog').should('not.exist') + cy.contains('诊断已保存').should('exist') + }) +})