From e1dc5c895f3e1341d752af1257e1b9dc171780f4 Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 24 Mar 2026 11:53:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(prescription):=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=A4=84=E6=96=B9=E5=88=97=E8=A1=A8=E6=82=A3=E8=80=85=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=8D=E5=AE=8C=E6=95=B4=E5=AF=BC=E8=87=B4=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20BUG#22?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在前端处方组件中添加患者信息完整性校验 - 当患者信息缺失时显示错误提示并阻止保存操作 - 确保处方项目正确携带patientId和encounterId信息 - 在后端服务中验证并自动补全缺失的patientId信息 - 当encounterId为空时返回相应错误提示 - 添加详细的日志记录以便问题追踪 --- .../DoctorStationAdviceAppServiceImpl.java | 31 ++++++++++++++++++- .../prescription/prescriptionlist.vue | 17 ++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index 0cbd3d1e..10feadbd 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -16,9 +16,11 @@ import com.core.common.utils.SecurityUtils; import com.core.common.utils.StringUtils; import com.core.web.util.TenantOptionUtil; import com.openhis.administration.domain.Account; -import com.openhis.administration.service.IAccountService; import com.openhis.administration.domain.ChargeItem; +import com.openhis.administration.domain.Encounter; +import com.openhis.administration.service.IAccountService; import com.openhis.administration.service.IChargeItemService; +import com.openhis.administration.service.IEncounterService; import com.openhis.common.constant.CommonConstants; import com.openhis.common.constant.PromptMsgConstant; import com.openhis.common.enums.*; @@ -106,6 +108,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp @Resource RedisCache redisCache; + @Resource + IEncounterService iEncounterService; + // 缓存 key 前缀 private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:"; // 缓存过期时间(小时) @@ -480,6 +485,30 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp Long organizationId = adviceSaveParam.getOrganizationId(); // 医嘱分类信息 List adviceSaveList = adviceSaveParam.getAdviceSaveList(); + + // 🔧 Bug Fix: 校验并补全patientId(如果为null,从encounter查询获取) + for (AdviceSaveDto adviceSaveDto : adviceSaveList) { + // 首先检查encounterId是否为null + if (adviceSaveDto.getEncounterId() == null) { + log.error("encounterId为null,无法保存医嘱"); + return R.fail(null, "就诊信息不完整,请重新选择患者后再试"); + } + + // 如果patientId为null,尝试从encounter获取 + if (adviceSaveDto.getPatientId() == null) { + // 从就诊记录中获取patientId + Encounter encounter = iEncounterService.getById(adviceSaveDto.getEncounterId()); + if (encounter != null && encounter.getPatientId() != null) { + adviceSaveDto.setPatientId(encounter.getPatientId()); + log.info("自动补全patientId: encounterId={}, patientId={}", + adviceSaveDto.getEncounterId(), encounter.getPatientId()); + } else { + log.error("无法获取patientId: encounterId={}", adviceSaveDto.getEncounterId()); + return R.fail(null, "无法获取患者信息,请重新选择患者"); + } + } + } + // 药品 List medicineList = adviceSaveList.stream() .filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList()); diff --git a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue index 8b973667..08c9b9ab 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -674,6 +674,7 @@ :controls="false" style="width: 60px" size="small" + @change="calculateTotalPrice(scope.row, scope.$index)" /> {{ scope.row.unitCode_dictText }} @@ -2154,6 +2155,13 @@ function handleSave(prescriptionId) { finalAccountId = null; } + // 🔧 Bug Fix: 校验患者信息完整性 + if (!props.patientInfo || !props.patientInfo.patientId || !props.patientInfo.encounterId) { + console.error('患者信息不完整:', props.patientInfo); + proxy.$modal.msgError('患者信息不完整,请重新选择患者后再试'); + return; + } + saveList.forEach((item) => { item.patientId = props.patientInfo.patientId; item.encounterId = props.patientInfo.encounterId; @@ -2686,6 +2694,13 @@ function handleSaveBatch(prescriptionId) { return; } + // 🔧 Bug Fix: 校验患者信息完整性 + if (!props.patientInfo || !props.patientInfo.patientId || !props.patientInfo.encounterId) { + console.error('患者信息不完整:', props.patientInfo); + proxy.$modal.msgError('患者信息不完整,请重新选择患者后再试'); + return; + } + // --- 【修改开始:优先使用选中行】 --- // 1. 获取表格当前选中的行 @@ -2785,6 +2800,8 @@ function handleSaveBatch(prescriptionId) { return { ...item, + patientId: props.patientInfo.patientId, + encounterId: props.patientInfo.encounterId, adviceType: saveAdviceType, dbOpType: item.requestId ? '2' : '1', isSaved: true,