fix(doctorstation): 解决处方列表中账户ID为空导致的保存问题 BUG#282
- 在处方保存流程中添加账户ID空值检查和自动补全逻辑 - 当账户ID为空时自动获取或创建患者自费账户 - 修复给药途径下拉框宽度显示问题 - 在药品单位后添加单位文本显示 - 统一设备费用项目的账户ID处理逻辑 - 确保新创建账户的名称字段不为空以避免数据库约束错误
This commit is contained in:
@@ -737,6 +737,28 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
|
||||
List<String> 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();
|
||||
|
||||
Reference in New Issue
Block a user