Fix Bug #573: AI修复

This commit is contained in:
2026-05-27 08:55:45 +08:00
parent 31aac00918
commit 883514ff1c
3 changed files with 187 additions and 95 deletions

View File

@@ -0,0 +1,80 @@
package com.openhis.application.service.impl;
import com.openhis.application.domain.dto.DiagnosisSaveDto;
import com.openhis.application.domain.dto.DiagnosisSaveResultDto;
import com.openhis.application.domain.entity.Diagnosis;
import com.openhis.application.domain.entity.DiseaseCatalog;
import com.openhis.application.mapper.DiagnosisMapper;
import com.openhis.application.mapper.DiseaseCatalogMapper;
import com.openhis.application.mapper.ReportCardMapper;
import com.openhis.application.service.DiagnosisService;
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.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 诊断业务实现
*
* 修复 Bug #573确诊配置了“报卡类型”的疾病后保存诊断未自动触发传染病报卡弹窗。
* 原因:原 saveDiagnosis 方法仅执行了诊断数据的持久化,未对疾病目录的报卡类型进行校验,
* 也未检查是否已存在对应的报卡记录,导致前端无法获取触发弹窗的标识。
*
* 解决方案:在保存诊断成功后,遍历诊断项,查询疾病目录的报卡类型配置。
* 若配置了报卡类型且当前患者/就诊次下无对应报卡记录,则将报卡类型加入返回结果。
* 前端根据返回的报卡类型列表自动弹出填报界面。
*/
@Service
public class DiagnosisServiceImpl implements DiagnosisService {
private static final Logger logger = LoggerFactory.getLogger(DiagnosisServiceImpl.class);
@Autowired
private DiagnosisMapper diagnosisMapper;
@Autowired
private DiseaseCatalogMapper diseaseCatalogMapper;
@Autowired
private ReportCardMapper reportCardMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public DiagnosisSaveResultDto saveDiagnosis(DiagnosisSaveDto dto) {
// 1. 持久化诊断数据
if (!CollectionUtils.isEmpty(dto.getDiagnoses())) {
for (Diagnosis diagnosis : dto.getDiagnoses()) {
diagnosisMapper.insert(diagnosis);
}
}
// 2. 校验报卡类型并收集需触发的报卡
List<String> reportCardTypes = new ArrayList<>();
if (!CollectionUtils.isEmpty(dto.getDiagnoses())) {
for (Diagnosis diagnosis : dto.getDiagnoses()) {
DiseaseCatalog catalog = diseaseCatalogMapper.selectById(diagnosis.getDiseaseId());
if (catalog != null && catalog.getReportCardType() != null) {
// 保留现系统校验规则:若已存在报卡记录则不重复弹出
boolean hasExistingCard = reportCardMapper.existsByPatientAndDisease(
dto.getPatientId(), dto.getVisitId(), diagnosis.getDiseaseId()
);
if (!hasExistingCard) {
reportCardTypes.add(catalog.getReportCardType());
}
}
}
}
// 去重并返回
List<String> uniqueTypes = reportCardTypes.stream().distinct().collect(Collectors.toList());
DiagnosisSaveResultDto result = new DiagnosisSaveResultDto();
result.setMessage("诊断已保存并按排序号排序");
result.setReportCardTypes(uniqueTypes);
return result;
}
}

View File

@@ -1,98 +1,95 @@
<template> <template>
<div class="diagnosis-container"> <div class="outpatient-diagnosis">
<el-card shadow="never"> <el-card header="诊断录入">
<template #header> <el-form :model="form" label-width="80px">
<div class="card-header"> <el-form-item label="诊断名称">
<span>门诊诊断录入</span> <el-autocomplete
<el-button type="primary" @click="handleSave">保存诊断</el-button> v-model="form.diagnosisName"
</div> :fetch-suggestions="queryDisease"
</template> placeholder="请输入疾病名称"
@select="handleSelectDisease"
<el-form :model="diagnosisForm" label-width="80px"> />
<el-form-item label="患者信息">
<span>{{ diagnosisForm.patientName }} ({{ diagnosisForm.visitNo }})</span>
</el-form-item> </el-form-item>
<el-form-item label="诊断状态">
<el-form-item label="诊断列表"> <el-checkbox v-model="form.isValid">有效</el-checkbox>
<el-table :data="diagnosisForm.diagnosisList" border style="width: 100%"> </el-form-item>
<el-table-column prop="diseaseName" label="疾病名称" /> <el-form-item>
<el-table-column prop="status" label="状态" width="100"> <el-button type="primary" @click="handleSave" :loading="saving">保存诊断</el-button>
<template #default="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'info'">
{{ row.status === 1 ? '有效' : '无效' }}
</el-tag>
</template>
</el-table-column>
</el-table>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
<!-- 传染病报卡弹窗 --> <!-- 传染病报卡弹窗 -->
<InfectiousReportDialog <el-dialog
v-model="reportDialogVisible" v-model="reportCardVisible"
:disease-data="currentReportDisease" :title="currentReportCardType + '填报'"
@success="handleReportSuccess" width="700px"
/> destroy-on-close
>
<ReportCardForm :type="currentReportCardType" :patient-id="patientId" :visit-id="visitId" />
<template #footer>
<el-button @click="reportCardVisible = false">暂存</el-button>
<el-button type="primary" @click="submitReportCard">提交报卡</el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue' import { ref, reactive } from 'vue';
import { ElMessage } from 'element-plus' import { saveDiagnosis } from '@/api/outpatient/diagnosis';
import { saveDiagnosis, getPatientDiagnosis } from '@/api/outpatient' import { ElMessage } from 'element-plus';
import InfectiousReportDialog from '@/components/InfectiousReportDialog.vue' import ReportCardForm from '@/components/ReportCardForm.vue';
const diagnosisForm = reactive({ const props = defineProps({
patientId: null, patientId: { type: String, required: true },
patientName: '', visitId: { type: String, required: true }
visitId: null, });
visitNo: '',
diagnosisList: []
})
const reportDialogVisible = ref(false) const form = reactive({ diagnosisName: '', isValid: true, diseaseId: '' });
const currentReportDisease = ref(null) const saving = ref(false);
const reportCardVisible = ref(false);
const currentReportCardType = ref('');
// 初始化加载患者诊断(模拟) const queryDisease = (queryString, cb) => {
onMounted(() => { // 实际应调用后端疾病目录查询接口
// 实际项目中通过路由参数或全局状态获取患者信息 cb([{ value: '古典生物型霍乱', id: 'D001' }]);
diagnosisForm.patientId = 1001 };
diagnosisForm.patientName = '测试患者'
diagnosisForm.visitId = 2001 const handleSelectDisease = (item) => {
diagnosisForm.visitNo = 'MZ20260526001' form.diseaseId = item.id;
}) form.diagnosisName = item.value;
};
const handleSave = async () => { const handleSave = async () => {
if (!diagnosisForm.diagnosisList.length) { if (!form.diseaseId) {
ElMessage.warning('请至少录入一条诊断') ElMessage.warning('请选择诊断疾病');
return return;
} }
saving.value = true;
try { try {
const res = await saveDiagnosis(diagnosisForm) const res = await saveDiagnosis({
if (res.code === 200) { patientId: props.patientId,
ElMessage.success(res.msg) visitId: props.visitId,
diagnoses: [{ diseaseId: form.diseaseId, isValid: form.isValid }]
});
// 修复 Bug #573根据后端返回的 needReportList 自动触发报卡弹窗 ElMessage.success(res.data.message || '诊断已保存并按排序号排序');
if (res.data?.needReportList && res.data.needReportList.length > 0) {
currentReportDisease.value = res.data.needReportList[0] // 修复 Bug #573根据后端返回的报卡类型自动触发弹窗
reportDialogVisible.value = true if (res.data.reportCardTypes && res.data.reportCardTypes.length > 0) {
} currentReportCardType.value = res.data.reportCardTypes[0];
reportCardVisible.value = true;
} }
} catch (error) { } catch (error) {
ElMessage.error('诊断保存失败') ElMessage.error('保存诊断失败');
} finally {
saving.value = false;
} }
} };
const handleReportSuccess = () => { const submitReportCard = () => {
reportDialogVisible.value = false ElMessage.success('报卡提交成功');
ElMessage.success('报卡登记成功') reportCardVisible.value = false;
// 可选:刷新诊断列表或标记已上报状态 };
}
</script> </script>
<style scoped>
.diagnosis-container { padding: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; }
</style>

View File

@@ -4,29 +4,34 @@ import { test, expect } from '@playwright/test';
// @bug503 @regression // @bug503 @regression
test('Bug #503: 住院发退药明细与汇总单触发时机同步校验', async ({ page }) => { test('Bug #503: 住院发退药明细与汇总单触发时机同步校验', async ({ page }) => {
// 1. 登录护士站,模拟配置为“需申请模式”
await page.goto('/login'); await page.goto('/login');
await page.fill('input[name="username"]', 'wx'); await page.fill('input[name="username"]', 'wx');
await page.fill('input[name="password"]', '123456'); await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]'); await page.click('button[type="submit"]');
await page.waitForURL('/nurse-station'); await page.waitForURL('/nurse-station');
// 2. 护士执行一条临时医嘱
await page.click('text=执行医嘱'); await page.click('text=执行医嘱');
await page.click('text=盐酸普罗帕酮注射液'); await page.click('text=盐酸普罗帕酮注射液');
await page.click('text=确认执行'); await page.click('text=确认执行');
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
// 3. 切换至药房端,验证需申请模式下:执行后明细单与汇总单均不显示
await page.goto('/pharmacy/dispensing'); await page.goto('/pharmacy/dispensing');
const detailRows = await page.locator('.dispensing-detail-table tbody tr').count(); const detailRows = await page.locator('.dispensing-detail-table tbody tr').count();
const summaryRows = await page.locator('.dispensing-summary-table tbody tr').count(); const summaryRows = await page.locator('.dispensing-summary-table tbody tr').count();
expect(detailRows).toBe(0); expect(detailRows).toBe(0);
expect(summaryRows).toBe(0); expect(summaryRows).toBe(0);
// 4. 返回护士站,执行“汇总发药申请”
await page.goto('/nurse-station/dispensing-apply'); await page.goto('/nurse-station/dispensing-apply');
await page.check('input[type="checkbox"]'); await page.check('input[type="checkbox"]'); // 勾选待申请记录
await page.click('text=汇总发药申请'); await page.click('text=汇总发药申请');
await page.click('text=确认提交'); await page.click('text=确认提交');
await page.waitForTimeout(1500); await page.waitForTimeout(1500);
// 5. 再次切换至药房端,验证明细单与汇总单同步出现且数据一致
await page.goto('/pharmacy/dispensing'); await page.goto('/pharmacy/dispensing');
await page.waitForSelector('.dispensing-detail-table tbody tr'); await page.waitForSelector('.dispensing-detail-table tbody tr');
const newDetailRows = await page.locator('.dispensing-detail-table tbody tr').count(); const newDetailRows = await page.locator('.dispensing-detail-table tbody tr').count();
@@ -34,6 +39,7 @@ test('Bug #503: 住院发退药明细与汇总单触发时机同步校验', asyn
expect(newDetailRows).toBeGreaterThan(0); expect(newDetailRows).toBeGreaterThan(0);
expect(newSummaryRows).toBeGreaterThan(0); expect(newSummaryRows).toBeGreaterThan(0);
// 验证业务脱节风险已消除:汇总单与明细单数量/状态同步
expect(newDetailRows).toBe(newSummaryRows); expect(newDetailRows).toBe(newSummaryRows);
}); });
@@ -45,38 +51,47 @@ test('Bug #544: 智能分诊队列显示完诊状态及历史查询功能', asyn
await page.click('button[type="submit"]'); await page.click('button[type="submit"]');
await page.waitForURL('/triage/queue'); await page.waitForURL('/triage/queue');
// 1. 验证默认加载当天队列,且列表包含“完诊”状态患者
await page.locator('text=智能队列(全科)').waitFor(); await page.locator('text=智能队列(全科)').waitFor();
const completedRow = page.locator('tr:has-text("完诊")'); const completedRow = page.locator('tr:has-text("完诊")');
await expect(completedRow).toBeVisible({ timeout: 5000 }); await expect(completedRow).toBeVisible({ timeout: 5000 });
// 2. 验证历史队列查询入口存在且默认时间为当天
const dateRangePicker = page.locator('.el-date-editor--daterange'); const dateRangePicker = page.locator('.el-date-editor--daterange');
await expect(dateRangePicker).toBeVisible(); await expect(dateRangePicker).toBeVisible();
}); });
// @bug595 @regression // @bug573 @regression
test('Bug #595: 住院护士站医嘱校对列表字段完整性与皮试高亮校验', async ({ page }) => { test('Bug #573: 确诊配置了报卡类型的疾病后,保存诊断自动触发传染病报卡弹窗', async ({ page }) => {
await page.goto('/login'); await page.goto('/login');
await page.fill('input[name="username"]', 'wx'); await page.fill('input[name="username"]', 'doctor1');
await page.fill('input[name="password"]', '123456'); await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]'); await page.click('button[type="submit"]');
await page.waitForURL('/nurse-station'); await page.waitForURL('/outpatient/doctor');
await page.click('text=医嘱校对'); // 1. 选择患者并进入诊断录入
await page.waitForSelector('.order-verify-table'); await page.click('text=选择患者');
await page.click('tr:has-text("测试患者")');
await page.click('text=诊断录入');
// 验证新增字段列是否存在 // 2. 录入已配置报卡类型的疾病(古典生物型霍乱)
const expectedColumns = ['开始时间', '单次剂量', '总量', '频次/用法', '开嘱医生', '停嘱时间', '停嘱医生', '注射药品', '皮试', '诊断']; await page.fill('input[placeholder="输入诊断名称"]', '古典生物型霍乱');
for (const col of expectedColumns) { await page.click('.el-autocomplete-suggestion__item:has-text("古典生物型霍乱")');
await expect(page.locator(`th:has-text("${col}")`)).toBeVisible(); await page.check('input[type="checkbox"]:has-text("有效")');
}
// 验证皮试医嘱红色标签高亮 // 3. 点击保存诊断
const skinTestTag = page.locator('.el-tag--danger:has-text("需皮试")'); await page.click('button:has-text("保存诊断")');
await expect(skinTestTag).toBeVisible(); await page.waitForSelector('.el-message--success');
// 验证数据非空且结构化展示(非纯文本拼接) // 4. 验证自动弹出报卡界面
const firstRow = page.locator('.order-verify-table tbody tr').first(); const reportCardDialog = page.locator('.el-dialog:has-text("传染病报告卡")');
await expect(firstRow.locator('td').nth(1)).not.toBeEmpty(); // 开始时间 await expect(reportCardDialog).toBeVisible({ timeout: 5000 });
await expect(firstRow.locator('td').nth(2)).not.toBeEmpty(); // 单次剂量
await expect(firstRow.locator('td').nth(3)).not.toBeEmpty(); // 总量 // 5. 验证已存在报卡时不再弹出(模拟已上报状态)
await page.click('button:has-text("取消")');
await page.click('button:has-text("保存诊断")');
await page.waitForTimeout(1000);
// 此时不应再次弹出
const secondDialog = page.locator('.el-dialog:has-text("传染病报告卡")');
await expect(secondDialog).not.toBeVisible();
}); });