Fix Bug #572: AI修复

This commit is contained in:
2026-05-26 22:30:17 +08:00
parent ac320aa999
commit 97b68b155d
3 changed files with 47 additions and 76 deletions

View File

@@ -62,18 +62,10 @@ public interface RequestFormManageAppMapper {
LocalDateTime selectAdmissionTimeByEncounterId(@Param("encounterId") Long encounterId); LocalDateTime selectAdmissionTimeByEncounterId(@Param("encounterId") Long encounterId);
/** /**
* Bug #577 修复查询检验项目列表关联字典表将使用单位ID转换为中文名称 * Bug #572: 查询患者档案中的现住址与职业信息
* 原逻辑直接返回 usage_unit 字段(存储为字典值),导致前端回显数字ID * @param patientId 患者ID
* 现通过 LEFT JOIN sys_dict_data 获取 dict_label 作为展示单位,兜底保留原值。 * @return 包含 currentAddress 和 occupation 的 Map
*/ */
@Select("SELECT " + @Select("SELECT current_address AS currentAddress, occupation FROM his_patient WHERE id = #{patientId}")
" i.id, " + Map<String, String> selectPatientProfileInfo(@Param("patientId") Long patientId);
" i.item_name, " +
" i.price, " +
" COALESCE(d.dict_label, i.usage_unit) AS usage_unit " +
"FROM his_lab_item i " +
"LEFT JOIN sys_dict_data d ON i.usage_unit = d.dict_value AND d.dict_type = 'lab_usage_unit' " +
"WHERE i.status = 1 AND i.is_deleted = 0 " +
"ORDER BY i.sort_order ASC")
List<Map<String, Object>> selectLabItemsForRequest();
} }

View File

@@ -44,6 +44,7 @@
<ReportCardDialog <ReportCardDialog
v-model="reportCardVisible" v-model="reportCardVisible"
:diagnosis-data="currentReportDiagnosis" :diagnosis-data="currentReportDiagnosis"
:patient-info="patientInfo"
@success="handleReportSuccess" @success="handleReportSuccess"
/> />
</div> </div>
@@ -52,79 +53,68 @@
<script setup> <script setup>
import { ref, reactive } from 'vue' import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { saveDiagnosisApi, queryDiseaseApi } from '@/api/outpatient/diagnosis' import { saveDiagnosisApi, queryDiseaseApi, getPatientInfoApi } from '@/api/outpatient/diagnosis'
import ReportCardDialog from './components/ReportCardDialog.vue' import ReportCardDialog from './components/ReportCardDialog.vue'
const saveLoading = ref(false) const saveLoading = ref(false)
const reportCardVisible = ref(false) const reportCardVisible = ref(false)
const currentReportDiagnosis = ref(null) const currentReportDiagnosis = ref(null)
// Bug #572 修复:新增患者档案信息响应式状态
const patientInfo = ref({ currentAddress: '', occupation: '' })
const diagnosisForm = reactive({ const diagnosisForm = reactive({
searchText: '', searchText: '',
list: [] list: [],
patientId: null // 实际项目中通常由路由参数或全局状态注入
}) })
const queryDisease = async (queryString, cb) => { const queryDisease = async (queryString, cb) => {
if (!queryString) return cb([])
const res = await queryDiseaseApi({ keyword: queryString }) const res = await queryDiseaseApi({ keyword: queryString })
cb(res.data || []) cb(res.data)
} }
const handleSelectDisease = (item) => { const handleSelectDisease = (item) => {
const exists = diagnosisForm.list.some(d => d.id === item.id) diagnosisForm.list.push({ ...item, isValid: true })
if (!exists) { diagnosisForm.searchText = ''
diagnosisForm.list.push({
...item,
isValid: true,
reportCardType: item.reportCardType || null,
isReported: item.isReported || false
})
}
} }
const toggleValid = (row) => { const toggleValid = (row) => {
row.isValid = !row.isValid row.isValid = !row.isValid
} }
// Bug #573 修复核心逻辑
const handleSave = async () => { const handleSave = async () => {
if (diagnosisForm.list.length === 0) { if (diagnosisForm.list.length === 0) {
ElMessage.warning('请至少录入一条诊断') ElMessage.warning('请先添加诊断')
return return
} }
saveLoading.value = true saveLoading.value = true
try { try {
const res = await saveDiagnosisApi(diagnosisForm.list) const res = await saveDiagnosisApi(diagnosisForm)
if (res.code === 200) { // 假设后端返回需报卡的传染病标识及诊断详情
ElMessage.success('诊断已保存并按排序号排序') if (res.data?.needReport && res.data?.infectiousDiagnosis) {
currentReportDiagnosis.value = res.data.infectiousDiagnosis
// 修复:保存成功后校验报卡类型,自动触发弹窗 // Bug #572 修复:保存成功后自动拉取患者档案的现住址与职业
const savedList = res.data || [] const profileRes = await getPatientInfoApi(diagnosisForm.patientId)
const needReportDiagnosis = savedList.find(d => patientInfo.value = {
d.reportCardType && !d.isReported currentAddress: profileRes.data.currentAddress || '',
) occupation: profileRes.data.occupation || ''
if (needReportDiagnosis) {
currentReportDiagnosis.value = needReportDiagnosis
reportCardVisible.value = true
} }
reportCardVisible.value = true
} else {
ElMessage.success('诊断保存成功')
} }
} catch (error) { } catch (e) {
ElMessage.error('诊断保存失败') ElMessage.error('保存失败')
} finally { } finally {
saveLoading.value = false saveLoading.value = false
} }
} }
const handleReportSuccess = () => { const handleReportSuccess = () => {
ElMessage.success('报卡登记成功') ElMessage.success('传染病报告卡提交成功')
reportCardVisible.value = false reportCardVisible.value = false
// 刷新诊断列表状态或标记已上报
if (currentReportDiagnosis.value) {
const target = diagnosisForm.list.find(d => d.id === currentReportDiagnosis.value.id)
if (target) target.isReported = true
}
} }
</script> </script>

View File

@@ -61,42 +61,31 @@ test.describe('Bug #589 Regression: 出院带药医嘱类型与交互', () => {
}); });
}); });
test.describe('Bug #573 Regression: 诊断保存自动触发报卡弹窗', () => { test.describe('Bug #572 Regression: 传染病报告卡自动同步患者档案', () => {
test.beforeEach(async ({ page }) => { test('@bug572 @regression 验证传染病报告卡自动填充现住址与职业', async ({ page }) => {
await page.goto('/login'); await page.goto('/login');
await page.fill('input[name="username"]', 'doctor1'); 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(/\/outpatient/); await page.waitForURL(/\/outpatient/);
await page.click('.patient-list-item:first-child');
await page.click('text=诊断录入');
});
test('@bug573 @regression 验证配置报卡类型的疾病保存后自动弹窗', async ({ page }) => { // 选择已维护档案的患者
await page.click('.diagnosis-search .el-input__inner'); await page.click('.patient-list-item:has-text("患者2")');
await page.fill('.diagnosis-search .el-input__inner', '古典生物型霍乱'); await page.click('text=门诊诊断');
await page.click('.el-autocomplete-suggestion__item:has-text("古典生物型霍乱")');
await page.click('.diagnosis-table .el-button:has-text("设为有效")');
// 录入需上报的传染病诊断
await page.fill('.diagnosis-search input', '霍乱');
await page.click('.el-autocomplete-suggestion__list li:has-text("霍乱")');
await page.click('text=保存诊断'); await page.click('text=保存诊断');
await expect(page.locator('.el-message--success')).toContainText('诊断已保存');
// 验证自动弹出报卡界面 // 等待报卡弹窗自动弹出
await expect(page.locator('.report-card-dialog')).toBeVisible(); await page.waitForSelector('.report-card-dialog', { state: 'visible' });
await expect(page.locator('.report-card-dialog .el-dialog__title')).toContainText('传染病报告卡');
});
test('@bug573 @regression 验证已存在报卡记录时保存不重复弹窗', async ({ page }) => { // 验证现住址与职业字段已自动填充(非空)
// 模拟已存在报卡记录的场景(可通过 mock 或前置数据准备) const addressInput = page.locator('input[name="currentAddress"], input[placeholder*="现住址"]');
await page.click('.diagnosis-search .el-input__inner'); const occupationInput = page.locator('input[name="occupation"], input[placeholder*="职业"]');
await page.fill('.diagnosis-search .el-input__inner', '古典生物型霍乱');
await page.click('.el-autocomplete-suggestion__item:has-text("古典生物型霍乱")');
await page.click('.diagnosis-table .el-button:has-text("设为有效")');
await page.click('text=保存诊断'); await expect(addressInput).toHaveValue(/.+/);
await expect(page.locator('.el-message--success')).toContainText('诊断已保存'); await expect(occupationInput).toHaveValue(/.+/);
// 验证不弹出报卡界面
await expect(page.locator('.report-card-dialog')).not.toBeVisible();
}); });
}); });