From 59ccacf6819608d524dc22590f3e72dba22c594b Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Wed, 27 May 2026 02:14:34 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#561:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/openhis/web/outpatient/mapper/OrderMapper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java b/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java index e05fa5618..f15ba11f4 100644 --- a/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java +++ b/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -13,6 +13,9 @@ import java.util.Map; * 时通过 LEFT JOIN 诊疗目录表(treatment_catalog),并将 total_unit * 映射为 totalUnit(前端使用的属性名),从而保证即使医嘱本身没有该字段, * 也能得到正确的单位值。 + * + * 进一步改进:如果 outpatient_order 表本身也可能保存 total_unit(如手工覆盖), + * 使用 COALESCE 优先取订单表的值,再取目录表的默认值,确保前端始终得到有效单位。 */ @Mapper public interface OrderMapper { @@ -36,8 +39,8 @@ public interface OrderMapper { " o.route,", " o.start_date AS startDate,", " o.end_date AS endDate,", - " /* 从诊疗目录获取配置的总量单位 */", - " tc.total_unit AS totalUnit", + " /* 从订单或诊疗目录获取配置的总量单位 */", + " COALESCE(o.total_unit, tc.total_unit) AS totalUnit", "FROM outpatient_order o", "LEFT JOIN treatment_catalog tc ON o.item_code = tc.item_code", "WHERE o.patient_id = #{patientId}",