diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml
index fafd10ae4..8a9479fdb 100755
--- a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml
+++ b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml
@@ -45,18 +45,6 @@
AND drf.create_time <= (#{endDate}::date + INTERVAL '1 day' - INTERVAL '1 second')
-
- AND 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
-
AND (drf.prescription_no ILIKE '%' || #{keyword} || '%'
OR EXISTS (
@@ -72,6 +60,19 @@
GROUP BY drf.id, drf.encounter_id, drf.prescription_no, drf.name, drf.desc_json,
drf.requester_id, drf.create_time, ap.name
+
+ 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
+ ELSE NULL
+ END = #{status}::integer
+