From 5cbcb6cce6349c81defb99ef1c178affe38e81f8 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 23 四月 2026 16:13:10 +0800
Subject: [PATCH] 【市一】360接口实现

---
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml |  137 +++++++++++++++++++++++++--------------------
 1 files changed, 76 insertions(+), 61 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 24f8484..405bc68 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -280,11 +280,26 @@
                 #{leavehospitaldistrictcode}
             </foreach>
         </if>
+
+        <if test="hospitaldistrictcodeList != null and hospitaldistrictcodeList.size()>0">
+            AND b.hospitaldistrictcode IN
+            <foreach collection="hospitaldistrictcodeList" item="hospitaldistrictcode" open="(" separator=","
+                     close=")">
+                #{hospitaldistrictcode}
+            </foreach>
+        </if>
         <if test="leaveldeptcodes != null and leaveldeptcodes.size()>0">
             AND b.leaveldeptcode IN
             <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
                      close=")">
                 #{leaveldeptcode}
+            </foreach>
+        </if>
+        <if test="deptcodeList != null and deptcodeList.size()>0">
+            AND b.deptcode IN
+            <foreach collection="deptcodeList" item="deptcode" open="(" separator=","
+                     close=")">
+                #{deptcode}
             </foreach>
         </if>
         GROUP BY
@@ -855,73 +870,73 @@
     <select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq"
             resultType="com.smartor.domain.PatMedRes">
         SELECT SUM(rc) AS rc,
-               SUM(rs) AS rs,
-               SUM(scsf) AS scsf,
-               SUM(zcsf) AS zcsf,
-               SUM(zbsf) AS zbsf
+        SUM(rs) AS rs,
+        SUM(scsf) AS scsf,
+        SUM(zcsf) AS zcsf,
+        SUM(zbsf) AS zbsf
         FROM (
-            <!-- 鍑洪櫌浜烘锛氬幓鎺� date_format 鍖呰锛屼娇鏃ユ湡瀛楁绱㈠紩鐢熸晥 -->
-            SELECT
-                COUNT(1) AS rc,
-                0 AS rs,
-                0 AS scsf,
-                0 AS zcsf,
-                0 AS zbsf
-            FROM pat_med_inhosp
-            JOIN pat_archive ON pat_archive.id = pat_med_inhosp.patid
-            WHERE pat_med_inhosp.del_flag = 0
-            <if test="orgid != null and orgid != ''">
-                AND pat_med_inhosp.orgid = #{orgid}
-            </if>
-            AND pat_archive.idcardno IS NOT NULL
-            <if test="zy != null">
-                AND pat_med_inhosp.inhospstate = 0
-                AND pat_med_inhosp.starttime &gt;= #{startDate}
-                AND pat_med_inhosp.starttime &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
-                <if test="deptcodeList != null and deptcodeList.size() > 0">
-                    AND pat_med_inhosp.deptcode IN
-                    <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
-                        #{deptcode}
-                    </foreach>
-                </if>
-            </if>
-            <if test="cy != null">
-                AND pat_med_inhosp.inhospstate = 1
-                AND pat_med_inhosp.endtime &gt;= #{startDate}
-                AND pat_med_inhosp.endtime &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
-                <if test="deptcodeList != null and deptcodeList.size() > 0">
-                    AND pat_med_inhosp.leaveldeptcode IN
-                    <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
-                        #{deptcode}
-                    </foreach>
-                </if>
-            </if>
-            UNION ALL
-            <!-- 闅忚鏈嶅姟/棣栨/鍐嶆/涓撶梾闅忚锛氬悎骞朵负鍗曟鎵弿锛岀敤鏉′欢鑱氬悎浠f浛4涓� UNION ALL -->
-            SELECT
-                0 AS rc,
-                COUNT(1) AS rs,
-                SUM(CASE WHEN service_type = 2 AND visit_count = 1 THEN 1 ELSE 0 END) AS scsf,
-                SUM(CASE WHEN service_type = 2 AND visit_count > 1  THEN 1 ELSE 0 END) AS zcsf,
-                SUM(CASE WHEN service_type = 13                      THEN 1 ELSE 0 END) AS zbsf
-            FROM service_subtask
-            WHERE del_flag = 0
-            AND service_type IN (2, 13)
-            <if test="orgid != null and orgid != ''">
-                AND orgid = #{orgid}
-            </if>
-            <if test="startDate != null">
-                AND visit_time &gt;= #{startDate}
-            </if>
-            <if test="endDate != null">
-                AND visit_time &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
-            </if>
+        <!-- 鍑洪櫌浜烘锛氬幓鎺� date_format 鍖呰锛屼娇鏃ユ湡瀛楁绱㈠紩鐢熸晥 -->
+        SELECT
+        COUNT(1) AS rc,
+        0 AS rs,
+        0 AS scsf,
+        0 AS zcsf,
+        0 AS zbsf
+        FROM pat_med_inhosp
+        JOIN pat_archive ON pat_archive.id = pat_med_inhosp.patid
+        WHERE pat_med_inhosp.del_flag = 0
+        <if test="orgid != null and orgid != ''">
+            AND pat_med_inhosp.orgid = #{orgid}
+        </if>
+        AND pat_archive.idcardno IS NOT NULL
+        <if test="zy != null">
+            AND pat_med_inhosp.inhospstate = 0
+            AND pat_med_inhosp.starttime &gt;= #{startDate}
+            AND pat_med_inhosp.starttime &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
             <if test="deptcodeList != null and deptcodeList.size() > 0">
-                AND deptcode IN
+                AND pat_med_inhosp.deptcode IN
                 <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
                     #{deptcode}
                 </foreach>
             </if>
+        </if>
+        <if test="cy != null">
+            AND pat_med_inhosp.inhospstate = 1
+            AND pat_med_inhosp.endtime &gt;= #{startDate}
+            AND pat_med_inhosp.endtime &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
+            <if test="deptcodeList != null and deptcodeList.size() > 0">
+                AND pat_med_inhosp.leaveldeptcode IN
+                <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+                    #{deptcode}
+                </foreach>
+            </if>
+        </if>
+        UNION ALL
+        <!-- 闅忚鏈嶅姟/棣栨/鍐嶆/涓撶梾闅忚锛氬悎骞朵负鍗曟鎵弿锛岀敤鏉′欢鑱氬悎浠f浛4涓� UNION ALL -->
+        SELECT
+        0 AS rc,
+        COUNT(1) AS rs,
+        SUM(CASE WHEN service_type = 2 AND visit_count = 1 THEN 1 ELSE 0 END) AS scsf,
+        SUM(CASE WHEN service_type = 2 AND visit_count > 1 THEN 1 ELSE 0 END) AS zcsf,
+        SUM(CASE WHEN service_type = 13 THEN 1 ELSE 0 END) AS zbsf
+        FROM service_subtask
+        WHERE del_flag = 0
+        AND service_type IN (2, 13)
+        <if test="orgid != null and orgid != ''">
+            AND orgid = #{orgid}
+        </if>
+        <if test="startDate != null">
+            AND visit_time &gt;= #{startDate}
+        </if>
+        <if test="endDate != null">
+            AND visit_time &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
+        </if>
+        <if test="deptcodeList != null and deptcodeList.size() > 0">
+            AND deptcode IN
+            <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+                #{deptcode}
+            </foreach>
+        </if>
         ) AS combined_data
     </select>
 

--
Gitblit v1.9.3