From a7de5f44bf83ffa0a5d11b04d16fb4f501ad5ff4 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 20 十月 2026 17:49:48 +0800
Subject: [PATCH] 【丽水】患者档案查询增加时间限制

---
 smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml |   62 ++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
index b51c18d..329cf76 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -185,11 +185,11 @@
         <include refid="selectPatArchiveVo"/>
         where 1=1
             and del_flag = 0
+            <if test="orgid != null and orgid != ''"> and orgid = #{orgid}</if>
             <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and idcardno = #{idcardno}</if>
             <if test="sourcefrom != null ">and sourcefrom = #{sourcefrom}</if>
             <if test="telcode != null  and telcode != ''">and telcode = #{telcode}</if>
-            <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
             <if test="id != null  and id != ''">and id = #{id}</if>
             <if test="isupload != null ">and isupload = #{isupload}</if>
             <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
@@ -214,7 +214,13 @@
             <if test="casePersonAge != null ">and case_person_age = #{casePersonAge}</if>
             <if test="filterDrname != null ">and filter_drname = #{filterDrname}</if>
             <if test="filterDrcode != null ">and filter_drcode = #{filterDrcode}</if>
-            <if test="campusid != null ">and campusid = #{campusid}</if>
+            <if test="createTimeStart != null">
+                AND date_format(create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
+        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
     </select>
 
 
@@ -262,6 +268,12 @@
             <if test="idcardno != null  and idcardno != ''">and idcardno = #{idcardno}</if>
             <if test="telcode != null  and telcode != ''">and telcode = #{telcode}</if>
             <if test="campusid != null  and campusid != ''">and campusid = #{campusid}</if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
             <if test="tagIds != null  and tagIds != ''">and c.tagid in
                 <foreach collection="tagIds" item="tagId" open="(" separator="," close=")">
                     #{tagId}
@@ -543,6 +555,12 @@
                     #{tagId}
                 </foreach>
             </if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
         order by a.update_time desc
         <if test="pn != null  and ps != null">limit ${pn},${ps}</if>
 
@@ -774,6 +792,12 @@
                     #{pid}
                 </foreach>
             </if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
             <if test="isFilter == true">
                 AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
             </if>
@@ -865,6 +889,12 @@
                     #{pid}
                 </foreach>
             </if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
             <if test="isFilter == true">
                 AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
             </if>
@@ -932,16 +962,21 @@
         d.leavehospitaldistrictcode AS leavehospitaldistrictcode
         FROM
         pat_med_inhosp d
-        JOIN pat_archive a ON a.id = d.patid
+        LEFT JOIN pat_archive a ON a.id = d.patid
         where 1=1
             and d.del_flag != 1
-            AND a.del_flag != 1
             and d.orgid = #{orgid}
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and a.idcardno = #{idcardno}</if>
             <if test="pid != null  and pid != ''">and a.id = #{id}</if>
             <if test="telcode != null  and telcode != ''">and a.telcode = #{telcode}</if>
             <if test="notrequiredFlag != null  and notrequiredFlag != ''">and a.notrequired_flag = #{notrequiredFlag}
+            </if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
             </if>
             <if test="hospitalname != null and hospitalname != ''">
                 AND d.hospitalname = #{hospitalname}
@@ -1005,7 +1040,7 @@
             </if>
 
             <if test="pids != null">
-                AND a.id NOT IN
+                AND d.patid NOT IN
                 <foreach collection="pids" item="pid" open="(" separator="," close=")">
                     #{pid}
                 </foreach>
@@ -1192,6 +1227,12 @@
                     #{pid}
                 </foreach>
             </if>
+            <if test="createTimeStart != null">
+                AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{createTimeStart},'%y%m%d')
+            </if>
+            <if test="createTimeEnd != null">
+                AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{createTimeEnd},'%y%m%d ')
+            </if>
             <if test="isFilter == true">
                 AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
             </if>
@@ -1201,18 +1242,11 @@
 
     <!-- 浣忛櫌鎮h�呮�绘暟缁熻锛堝幓閲嶏級 -->
     <select id="countPatArchiveInfoByInhospQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long">
-        SELECT COUNT(DISTINCT a.id)
+        SELECT COUNT(DISTINCT d.patid)
         FROM pat_med_inhosp d
-        JOIN pat_archive a ON a.id = d.patid
         WHERE 1=1
             AND d.del_flag != 1
-            AND a.del_flag != 1
             AND d.orgid = #{orgid}
-            <if test="name != null  and name != ''">AND a.name like concat('%', #{name}, '%')</if>
-            <if test="idcardno != null  and idcardno != ''">AND a.idcardno = #{idcardno}</if>
-            <if test="pid != null  and pid != ''">AND a.id = #{id}</if>
-            <if test="telcode != null  and telcode != ''">AND a.telcode = #{telcode}</if>
-            <if test="notrequiredFlag != null  and notrequiredFlag != ''">AND a.notrequired_flag = #{notrequiredFlag}</if>
             <if test="hospitalname != null and hospitalname != ''">AND d.hospitalname = #{hospitalname}</if>
             <if test="hospitaldistrictname != null and hospitaldistrictname != ''">AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')</if>
             <if test="leaveicd10code != null and leaveicd10code != ''">AND d.leaveicd10code LIKE concat('%',#{leaveicd10code}, '%')</if>
@@ -1250,7 +1284,7 @@
                 </foreach>
             </if>
             <if test="pids != null">
-                AND a.id NOT IN
+                AND d.patid NOT IN
                 <foreach collection="pids" item="pid" open="(" separator="," close=")">
                     #{pid}
                 </foreach>

--
Gitblit v1.9.3