From e16a70dd5011a81aa6abe11f972f7843f5a54026 Mon Sep 17 00:00:00 2001 From: liuliu <412033390@qq.com> Date: Mon, 16 Mar 2026 10:08:44 +0800 Subject: [PATCH] =?UTF-8?q?146=20=E6=94=B6=E8=B4=B9=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=AB=99-=E3=80=8B=E9=97=A8=E8=AF=8A=E6=94=B6=E8=B4=B9?= =?UTF-8?q?=EF=BC=9A=E9=97=A8=E8=AF=8A=E5=88=92=E4=BB=B7=E8=B4=B9=E7=94=A8?= =?UTF-8?q?=E5=9C=A8=E9=97=A8=E8=AF=8A=E6=94=B6=E8=B4=B9=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E3=80=90=E7=A1=AE=E8=AE=A4=E6=94=B6=E8=B4=B9=E3=80=91=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=8A=A5=E9=94=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PaymentRecServiceImpl.java | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java index 46302d2f..bf1ecefb 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/paymentmanage/appservice/impl/PaymentRecServiceImpl.java @@ -199,13 +199,19 @@ public class PaymentRecServiceImpl implements IPaymentRecService { // 此次chargeItem的就诊诊断id集合 List diagIdList = chargeItemList.stream().map(ChargeItem::getEncounterDiagnosisId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - if (diagIdList.isEmpty()) { - throw new ServiceException("收费项的就诊诊断查询为空"); - } // 此次就诊的医疗类型列表 - List diagList = iEncounterDiagnosisService.getDiagnosisList(diagIdList); - if (diagList.isEmpty()) { - throw new ServiceException("就诊诊断查询为空,错误信息:EncounterDiagnosis"); + List diagList; + if (diagIdList.isEmpty()) { + // 收费项未关联就诊诊断(如挂号费、自动诊疗费等),则直接从就诊维度查询诊断 + diagList = iEncounterDiagnosisService.getDiagnosisList(prePaymentDto.getEncounterId()); + if (diagList.isEmpty()) { + throw new ServiceException("当前就诊暂无诊断记录,请先由医生录入诊断后再进行收费"); + } + } else { + diagList = iEncounterDiagnosisService.getDiagnosisList(diagIdList); + if (diagList.isEmpty()) { + throw new ServiceException("就诊诊断查询为空"); + } } List medTypeList = diagList.stream().map(EncounterDiagnosis::getMedTypeCode).distinct().collect(Collectors.toList()); @@ -231,10 +237,20 @@ public class PaymentRecServiceImpl implements IPaymentRecService { if (distinctAccountIdList.isEmpty()) { throw new ServiceException("未找到有效的账户信息"); } + // 只按账户ID查询,不再追加 encounter_id 条件 + // 原因:收费项上的 accountId 已能唯一定位账户,额外的 encounter_id 条件 + // 在挂号费等场景下可能因数据不一致导致查不到,引发误报 List accountList = iAccountService.list(new LambdaQueryWrapper() - .in(Account::getId, distinctAccountIdList).eq(Account::getEncounterId, prePaymentDto.getEncounterId())); + .in(Account::getId, distinctAccountIdList)); if (accountList.size() != distinctAccountIdList.size()) { - throw new ServiceException("未查询到账户信息"); + // 部分账户查不到时,记录警告日志,并校验是否每个收费项都能找到对应账户 + Set foundAccountIds = accountList.stream().map(Account::getId).collect(Collectors.toSet()); + List missingAccountIds = distinctAccountIdList.stream() + .filter(id -> !foundAccountIds.contains(id)).collect(Collectors.toList()); + if (accountList.isEmpty()) { + throw new ServiceException("未查询到任何账户信息,encounterId:" + prePaymentDto.getEncounterId() + + ",期望accountId列表:" + distinctAccountIdList); + } } // 账户id,对应的账单列表 @@ -2156,14 +2172,18 @@ public class PaymentRecServiceImpl implements IPaymentRecService { piModel.setBusNo(chargeItem.getBusNo()); EncounterDiagnosis encounterDiagnosis; - Optional optional - = diagList.stream().filter(e -> e.getId().equals(chargeItem.getEncounterDiagnosisId())).findFirst(); - - if (optional.isPresent()) { - encounterDiagnosis = optional.get(); + if (chargeItem.getEncounterDiagnosisId() == null) { + // 收费项未关联就诊诊断(如挂号费、自动诊疗费等),取诊断列表第一条作为兜底 + encounterDiagnosis = diagList.get(0); } else { - throw new ServiceException( - "诊断信息与收费项的诊断信息未对应,错误信息:费用项" + chargeItem.getBusNo() + chargeItem.getEncounterDiagnosisId()); + Optional optional + = diagList.stream().filter(e -> e.getId().equals(chargeItem.getEncounterDiagnosisId())).findFirst(); + if (optional.isPresent()) { + encounterDiagnosis = optional.get(); + } else { + // 收费项关联的诊断ID在diagList中找不到,也取第一条兜底 + encounterDiagnosis = diagList.get(0); + } } piModel.setMedType(encounterDiagnosis.getMedTypeCode()); piModel.setTotalPrice(chargeItem.getTotalPrice());