From c0bcb629a5083ab0c977fa34815656d236720100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Sat, 16 May 2026 16:21:06 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#401:=20=E9=97=A8=E8=AF=8A=E5=AE=8C?= =?UTF-8?q?=E8=AF=8A=E5=AE=A1=E8=AE=A1=E6=97=A5=E5=BF=97=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=9Adiv=5Flog=20=E8=A1=A8=E4=B8=AD=20pool=5Fid=20=E4=B8=8E?= =?UTF-8?q?=20slot=5Fid=20=E5=AD=98=E5=80=BC=E4=B8=8E=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:部分 encounter 记录的 order_id 字段为空(挂号流程中未正确赋值), 且无 triage_queue_item 队列记录,导致完诊时 div_log 的 pool_id/slot_id 为 NULL。 修复:在 completeEncounter 中新增第二条回退链路——当 encounter.order_id 为空时, 通过 patient_id + 当天日期查询 order_main 表中的有效挂号订单,从中获取 slot_id 和 pool_id, 确保所有完诊审计日志都能正确记录号源信息。 --- .../impl/DoctorStationMainAppServiceImpl.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationMainAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationMainAppServiceImpl.java index 583cf34eb..842b2d662 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationMainAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationMainAppServiceImpl.java @@ -324,6 +324,34 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer } } + // 回退链路2:当 encounter 无 orderId 且队列项无 poolId/slotId 时, + // 查询患者当天有效挂号订单(order_main),获取 slot_id/pool_id + // (挂号流程中 encounter.order_id 可能未被正确赋值,但 order_main 中存在有效记录) + if ((divPoolId == null || divSlotId == null) && encounter.getPatientId() != null) { + try { + Order order = iOrderService.getOne( + new LambdaQueryWrapper() + .eq(Order::getPatientId, encounter.getPatientId()) + .eq(Order::getStatus, OrderStatus.ACTIVE.getValue()) + .eq(Order::getDeleteFlag, "0") + .apply("appointment_date::date = %s", LocalDate.now().toString()) + .orderByDesc(Order::getCreateTime) + .last("LIMIT 1") + ); + if (order != null && order.getSlotId() != null) { + ScheduleSlot slot = scheduleSlotMapper.selectById(order.getSlotId()); + if (slot != null) { + divSlotId = slot.getId(); + divPoolId = slot.getPoolId(); + log.info("完诊:通过患者当天挂号订单获取号源,orderId={}, slotId={}, poolId={}", + order.getId(), divSlotId, divPoolId); + } + } + } catch (Exception e) { + log.warn("通过挂号订单获取完诊div_log的pool_id/slot_id失败,encounterId={}", encounterId, e); + } + } + // 如果队列项存在且未完成,更新队列状态为已完成 // 使用排除法而非白名单:只要不是"已完成"就可以完诊,覆盖跳过、等待等非标准流转状态 // Bug #401:在更新前记录队列原始完成状态,用于判断是否需要写入 div_log