From 8739959be07f5c5225df1b5ee390a30226043f80 Mon Sep 17 00:00:00 2001 From: chenqi Date: Thu, 26 Mar 2026 14:42:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(doctorstation):=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=A4=84=E6=96=B9=E5=88=97=E8=A1=A8=E4=B8=AD=E8=B4=A6=E6=88=B7?= =?UTF-8?q?ID=E4=B8=BA=E7=A9=BA=E5=AF=BC=E8=87=B4=E7=9A=84=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E9=97=AE=E9=A2=98=20BUG#282?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在处方保存流程中添加账户ID空值检查和自动补全逻辑 - 当账户ID为空时自动获取或创建患者自费账户 - 修复给药途径下拉框宽度显示问题 - 在药品单位后添加单位文本显示 - 统一设备费用项目的账户ID处理逻辑 - 确保新创建账户的名称字段不为空以避免数据库约束错误 --- .../DoctorStationAdviceAppServiceImpl.java | 70 ++++++++++++++++++- .../prescription/prescriptionlist.vue | 4 +- 2 files changed, 72 insertions(+), 2 deletions(-) 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 01949a3b..98a72edd 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 @@ -737,6 +737,28 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp List medRequestIdList = new ArrayList<>(); for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) { + // 🔧 Bug Fix: 确保accountId不为null,与handleBoundDevices保持一致 + if (adviceSaveDto.getAccountId() == null) { + // 尝试从患者就诊中获取默认账户ID(自费账户) + Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId()); + if (selfAccount != null) { + adviceSaveDto.setAccountId(selfAccount.getId()); + } else { + // 自动创建自费账户 + Account newAccount = new Account(); + newAccount.setPatientId(adviceSaveDto.getPatientId()); + newAccount.setEncounterId(adviceSaveDto.getEncounterId()); + newAccount.setContractNo(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO); + newAccount.setTypeCode(AccountType.PERSONAL_CASH_ACCOUNT.getCode()); + newAccount.setBalanceAmount(BigDecimal.ZERO); + newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue()); + newAccount.setEncounterFlag(Whether.YES.getValue()); + newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo()); + Long newAccountId = iAccountService.saveAccountByRegister(newAccount); + adviceSaveDto.setAccountId(newAccountId); + } + } + boolean firstTimeSave = false;// 第一次保存 medicationRequest = new MedicationRequest(); medicationRequest.setId(adviceSaveDto.getRequestId()); // 主键id @@ -941,7 +963,29 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp deviceChargeItem.setServiceId(deviceRequest.getId()); deviceChargeItem.setProductTable(CommonConstants.TableName.ADM_DEVICE_DEFINITION); deviceChargeItem.setProductId(boundDevice.getDevActId()); - deviceChargeItem.setAccountId(adviceSaveDto.getAccountId()); + // 🔧 Bug Fix #281: 如果accountId为null,从就诊中获取账户ID,如果没有则自动创建 + Long deviceAccountId = adviceSaveDto.getAccountId(); + if (deviceAccountId == null) { + // 尝试从患者就诊中获取默认账户ID(自费账户) + Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId()); + if (selfAccount != null) { + deviceAccountId = selfAccount.getId(); + } else { + // 自动创建自费账户 + Account newAccount = new Account(); + newAccount.setPatientId(adviceSaveDto.getPatientId()); + newAccount.setEncounterId(adviceSaveDto.getEncounterId()); + newAccount.setContractNo(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO); + newAccount.setTypeCode(AccountType.PERSONAL_CASH_ACCOUNT.getCode()); + newAccount.setBalanceAmount(BigDecimal.ZERO); + newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue()); + newAccount.setEncounterFlag(Whether.YES.getValue()); + // 🔧 Bug Fix: 设置账户名称,避免数据库NOT NULL约束错误 + newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo()); + deviceAccountId = iAccountService.saveAccountByRegister(newAccount); + } + } + deviceChargeItem.setAccountId(deviceAccountId); deviceChargeItem.setConditionId(adviceSaveDto.getConditionId()); deviceChargeItem.setEncounterDiagnosisId(adviceSaveDto.getEncounterDiagnosisId()); deviceChargeItem.setDispenseId(dispenseId); @@ -1141,6 +1185,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp newAccount.setBalanceAmount(BigDecimal.ZERO); newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue()); newAccount.setEncounterFlag(Whether.YES.getValue()); + // 🔧 Bug Fix: 设置账户名称,避免数据库NOT NULL约束错误 + newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo()); accountId = iAccountService.saveAccountByRegister(newAccount); } } @@ -1222,6 +1268,28 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp } for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) { + // 🔧 Bug Fix: 确保accountId不为null + if (adviceSaveDto.getAccountId() == null) { + // 尝试从患者就诊中获取默认账户ID(自费账户) + Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId()); + if (selfAccount != null) { + adviceSaveDto.setAccountId(selfAccount.getId()); + } else { + // 自动创建自费账户 + Account newAccount = new Account(); + newAccount.setPatientId(adviceSaveDto.getPatientId()); + newAccount.setEncounterId(adviceSaveDto.getEncounterId()); + newAccount.setContractNo(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO); + newAccount.setTypeCode(AccountType.PERSONAL_CASH_ACCOUNT.getCode()); + newAccount.setBalanceAmount(BigDecimal.ZERO); + newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue()); + newAccount.setEncounterFlag(Whether.YES.getValue()); + newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo()); + Long newAccountId = iAccountService.saveAccountByRegister(newAccount); + adviceSaveDto.setAccountId(newAccountId); + } + } + // 🔧 Bug Fix #238: 诊疗项目执行科室非空校验 if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3) { Long effectiveOrgId = adviceSaveDto.getEffectiveOrgId(); 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 227e49fe..a84cdbbe 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -261,6 +261,7 @@
+ {{ scope.row.unitCode_dictText }} - +