Fix Bug #498: 【住院医生工作站-检查申请】检查申请列表状态筛选HAVING子句与SELECT映射不一致导致筛选失败

SELECT的CASE映射将status_enum=4映射为3(待接收),但HAVING子句将status_enum=4映射为4,
导致按"待接收"或"已接收"状态筛选时无结果返回。同时修正status_enum=5/6/7的映射从5→7。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
荀彧
2026-05-15 00:26:23 +08:00
parent 58f9947a49
commit 2d2fa64772

View File

@@ -61,15 +61,14 @@
GROUP BY drf.id, drf.encounter_id, drf.prescription_no, drf.name, drf.desc_json,
drf.requester_id, drf.create_time, ap.name
<if test="status != null and status != ''">
HAVING CASE MIN(wsr.status_enum)
WHEN 1 THEN 0
WHEN 2 THEN 1
WHEN 3 THEN 4
WHEN 4 THEN 4
WHEN 5 THEN 5
WHEN 6 THEN 5
WHEN 7 THEN 5
WHEN 8 THEN 6
HAVING CASE
WHEN MIN(wsr.status_enum) = 1 THEN 0
WHEN MIN(wsr.status_enum) = 2 THEN 1
WHEN MIN(wsr.status_enum) = 3 AND MAX(CASE WHEN wsr.performer_check_id IS NOT NULL THEN 1 ELSE 0 END) = 1 THEN 2
WHEN MIN(wsr.status_enum) = 3 THEN 4
WHEN MIN(wsr.status_enum) = 4 THEN 3
WHEN MIN(wsr.status_enum) = 5 OR MIN(wsr.status_enum) = 6 OR MIN(wsr.status_enum) = 7 THEN 7
WHEN MIN(wsr.status_enum) = 8 THEN 6
ELSE NULL
END = #{status}::integer
</if>