Fix Bug #401: 门诊完诊审计日志错误:div_log 表中 pool_id 与 slot_id 存值与设计规范不符
根因:部分 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, 确保所有完诊审计日志都能正确记录号源信息。
This commit is contained in:
@@ -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<Order>()
|
||||||
|
.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
|
// Bug #401:在更新前记录队列原始完成状态,用于判断是否需要写入 div_log
|
||||||
|
|||||||
Reference in New Issue
Block a user