From 08991aa2c46b697462fc2e512140b5dfb70cfcbf Mon Sep 17 00:00:00 2001 From: guanyu Date: Tue, 26 May 2026 23:58:46 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#505:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/OrderVerificationServiceImpl.java | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java index 550635039..b54ce6088 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java @@ -44,19 +44,25 @@ public class OrderVerificationServiceImpl implements OrderVerificationService { String chargeStatus = String.valueOf(order.get("charge_status")); // 2. 核心状态约束校验(修复 Bug #505 根因) - // 执行状态:必须为“未执行” + // - 执行状态:必须为“未执行” + // - 发药状态:必须为“未发药” + // - 计费状态:必须为“未计费” if ("已执行".equals(execStatus) || "EXECUTED".equals(execStatus)) { - throw new RuntimeException("该医嘱已执行,请先在【医嘱执行】模块取消执行"); + throw new RuntimeException("该医嘱已执行,请先在【医嘱执行】模块取消执行后再退回"); } - // 物理状态:必须为“未发药/未领药” if ("已发药".equals(dispenseStatus) || "DISPENSED".equals(dispenseStatus)) { - throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回"); + throw new RuntimeException("该医嘱已发药,不能退回,请在【药房发药】模块进行相应处理"); + } + if ("已计费".equals(chargeStatus) || "CHARGED".equals(chargeStatus)) { + throw new RuntimeException("该医嘱已计费,请先在【费用】模块取消计费后再退回"); } - // 3. 更新状态为 CANCELLED(符合 PRD 定义)——修复 Bug #506 + // 3. 更新状态为已退回(或取消状态) + // 这里使用统一的取消状态,以保持与 PRD 定义一致 int updated = orderMapper.updateOrderStatusToCancelled(orderId, OrderMapper.ORDER_STATUS_CANCELLED); if (updated == 0) { - throw new RuntimeException("医嘱状态更新失败,可能已被其他操作修改"); + // 若未更新成功,说明状态已被其他操作修改 + throw new RuntimeException("医嘱状态更新失败,可能已被其他业务修改"); } } @@ -64,34 +70,19 @@ public class OrderVerificationServiceImpl implements OrderVerificationService { @Transactional(rollbackFor = Exception.class) public void withdrawOrder(Long orderId) { if (orderId == null) { - throw new IllegalArgumentException("医嘱ID不能为空"); + throw new IllegalArgumentException("检验医嘱ID不能为空"); } - // 1. 查询医嘱当前全量状态 + // 1. 查询医嘱,确保存在 Map order = orderMapper.selectOrderById(orderId); if (order == null) { - throw new IllegalArgumentException("医嘱不存在或已被删除"); + throw new IllegalArgumentException("检验医嘱不存在或已被删除"); } - // 2. 状态校验:仅在未执行、未报告、未计费时允许撤回 - String execStatus = String.valueOf(order.get("exec_status")); - String reportStatus = String.valueOf(order.get("report_status")); - String chargeStatus = String.valueOf(order.get("charge_status")); - - if (!("未执行".equals(execStatus) || "NOT_EXECUTED".equals(execStatus) || execStatus == null)) { - throw new RuntimeException("医嘱已执行,不能撤回"); - } - if (!("未报告".equals(reportStatus) || "NOT_REPORTED".equals(reportStatus) || reportStatus == null)) { - throw new RuntimeException("医嘱已报告,不能撤回"); - } - if (!("未计费".equals(chargeStatus) || "NOT_CHARGED".equals(chargeStatus) || chargeStatus == null)) { - throw new RuntimeException("医嘱已计费,不能撤回"); - } - - // 3. 执行撤回 + // 2. 直接使用已实现的 SQL 进行状态撤回,SQL 已包含执行、报告、计费的前置校验 int updated = orderMapper.updateOrderStatusToWithdrawn(orderId); if (updated == 0) { - throw new RuntimeException("撤回失败,可能状态已变更"); + throw new RuntimeException("检验医嘱撤回失败,可能已执行、报告或计费,无法撤回"); } } }