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();
|
||||
|
||||
@@ -261,6 +261,7 @@
|
||||
<div class="form-group">
|
||||
<el-form-item label="给药途径:" prop="methodCode" class="required-field" data-prop="methodCode">
|
||||
<el-select v-model="scope.row.methodCode" placeholder="给药途径" clearable filterable
|
||||
style="width: 150px"
|
||||
:ref="(el) => (inputRefs.methodCode = el)" @keyup.enter.prevent="
|
||||
() => {
|
||||
if (scope.row.methodCode) {
|
||||
@@ -341,6 +342,7 @@
|
||||
" />
|
||||
</template>
|
||||
</el-select>
|
||||
<span v-if="scope.row.unitCode_dictText" class="unit-text">{{ scope.row.unitCode_dictText }}</span>
|
||||
</el-form-item>
|
||||
<!-- 🔧 Bug #273 拆零比提示 -->
|
||||
<span v-if="scope.row.partPercent !== null && scope.row.partPercent !== undefined && scope.row.partPercent - 1 > 0 && scope.row.unitCode !== scope.row.minUnitCode"
|
||||
@@ -732,7 +734,7 @@
|
||||
size="small"
|
||||
/>
|
||||
<span style="margin: 0 2px; font-size: 12px;">天</span>
|
||||
<el-select v-model="scope.row.methodCode" size="small" style="width: 65px" placeholder="用法">
|
||||
<el-select v-model="scope.row.methodCode" size="small" style="width: 120px" placeholder="用法">
|
||||
<el-option v-for="item in method_code" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user