From c111e3eff1191b29d2d2baf2f485a4bf3a2edc00 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期六, 16 八月 2025 14:34:07 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml |   68 +++++++++++++++++++++++++++------
 1 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
index 5e154e3..c75a219 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -59,6 +59,7 @@
         <result property="medicareType" column="medicare_type"/>
         <result property="carePerson" column="care_person"/>
         <result property="casePersonAge" column="case_person_age"/>
+        <result property="reservedPhone" column="reserved_phone"/>
     </resultMap>
 
 
@@ -117,6 +118,7 @@
         <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/>
         <result property="leavehospitaldistrictcode" column="leavehospitaldistrictcode"/>
         <result property="admitdate" column="admitdate"/>
+        <result property="reservedPhone" column="reserved_phone"/>
     </resultMap>
 
     <sql id="selectPatArchiveVo">
@@ -143,6 +145,7 @@
                archivetime,
                archiveby,
                telcode,
+               reserved_phone,
                relativetelcode,
                idcardtype,
                orgid,
@@ -198,6 +201,7 @@
             <if test="medicareType != null ">and medicare_type = #{medicareType}</if>
             <if test="carePerson != null ">and care_person = #{carePerson}</if>
             <if test="casePersonAge != null ">and case_person_age = #{casePersonAge}</if>
+            <if test="reservedPhone != null ">and reserved_phone = #{reservedPhone}</if>
         </where>
     </select>
 
@@ -232,11 +236,13 @@
         a.income,
         a.medicare_type,
         a.care_person,
+        a.reserved_phone,
         a.case_person_age
         from pat_archive a,pat_archivetag b ,base_tag c
         <where>
             a.del_flag=0 and
             a.id = b.patid and b.tagid = c.tagid
+            <if test="reservedPhone != null ">and reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and idcardno = #{idcardno}</if>
             <if test="telcode != null  and telcode != ''">and telcode = #{telcode}</if>
@@ -302,6 +308,7 @@
             <if test="medicareType != null ">medicare_type,</if>
             <if test="carePerson != null ">care_person,</if>
             <if test="casePersonAge != null ">case_person_age,</if>
+            <if test="reservedPhone != null ">reserved_phone,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="patientno != null">#{patientno},</if>
@@ -349,6 +356,7 @@
             <if test="medicareType != null ">#{medicareType},</if>
             <if test="carePerson != null ">#{carePerson},</if>
             <if test="casePersonAge != null ">#{casePersonAge},</if>
+            <if test="reservedPhone != null ">#{reservedPhone},</if>
         </trim>
     </insert>
 
@@ -356,14 +364,14 @@
         insert into
         pat_archive(name,viptype,sex,idcardno,birthdate,place_of_residence,age,age2,sourcefrom,archivetime,archiveby,telcode,relativetelcode,idcardtype,orgid,openid,dduserid,update_by,update_time
         ,create_by,create_time,isupload,upload_time,pattype,nation,birthplace,native_place,patientno,patid_his,sd_flag,age_unit,age_unit2,notrequired_flag,notrequiredreason,care_facilities,case_path,
-        degree_of_education,marital_status,income,medicare_type,care_person,case_person_age)
+        degree_of_education,marital_status,income,medicare_type,care_person,case_person_age,reserved_phone)
         values
         <foreach item="item" index="index" collection="list" separator=",">
             (#{item.name},#{item.viptype},#{item.sex},#{item.idcardno},#{item.birthdate},#{item.placeOfResidence},#{item.age},#{item.age2},#{item.sourcefrom},#{item.archivetime},#{item.archiveby}
             ,#{item.telcode},#{item.archiveby},#{item.idcardtype},#{item.orgid},#{item.openid},#{item.dduserid},#{item.updateBy},
             #{item.updateTime},#{item.createBy},#{item.createTime},#{item.isupload},#{item.uploadTime},#{item.pattype},#{item.nation},#{item.birthplace},#{item.nativePlace},#{item.patientno},
             #{item.patidHis},#{item.sdFlag},#{item.ageUnit},#{item.ageUnit2},#{item.notrequiredFlag},#{item.notrequiredreason}
-            ,#{item.careFacilities},#{item.casePath},#{item.degreeOfEducation},#{item.maritalStatus},#{item.income},#{item.medicareType},#{item.carePerson},#{item.casePersonAge})
+            ,#{item.careFacilities},#{item.casePath},#{item.degreeOfEducation},#{item.maritalStatus},#{item.income},#{item.medicareType},#{item.carePerson},#{item.casePersonAge},#{item.reservedPhone})
         </foreach>
     </insert>
 
@@ -394,9 +402,9 @@
             <if test="isupload != null">isupload = #{isupload},</if>
             <if test="uploadTime != null">upload_time = #{uploadTime},</if>
             <if test="viptype != null">viptype = #{viptype},</if>
-            <if test="viptype != null">patientno = #{patientno},</if>
-            <if test="viptype != null">patid_his = #{patidHis},</if>
-            <if test="viptype != null">sd_flag = #{sdFlag},</if>
+            <if test="patientno != null">patientno = #{patientno},</if>
+            <if test="patidHis != null">patid_his = #{patidHis},</if>
+            <if test="sdFlag != null">sd_flag = #{sdFlag},</if>
             <if test="ageUnit != null">age_unit = #{ageUnit},</if>
             <if test="ageUnit2 != null">age_unit2 = #{ageUnit2},</if>
             <if test="notrequiredFlag != null ">notrequired_flag = #{notrequiredFlag},</if>
@@ -409,6 +417,7 @@
             <if test="medicareType != null ">medicare_type = #{medicareType},</if>
             <if test="carePerson != null ">care_person = #{carePerson},</if>
             <if test="casePersonAge != null ">case_person_age = #{casePersonAge},</if>
+            <if test="reservedPhone != null ">reserved_phone = #{reservedPhone},</if>
         </trim>
         where id = #{id}
     </update>
@@ -466,6 +475,7 @@
         a.upload_time,
         a.viptype,
         a.pattype,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(d.tagname, ', ')
         FROM pat_archivetag d
@@ -479,6 +489,7 @@
         LEFT JOIN pat_archivetag b ON a.id = b.patid AND b.del_flag = 0
         <where>
             a.del_flag = 0
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="tagname != null  and tagname != ''">and b.tagname like concat('%', #{tagname}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and a.idcardno = #{idcardno}</if>
@@ -539,6 +550,7 @@
         a.create_by,
         a.create_time,
         a.isupload,
+        a.reserved_phone,
         a.upload_time,
         a.pattype,
         d.bed_no,
@@ -560,11 +572,11 @@
         pat_med_inhosp d
         JOIN pat_archive a ON a.id = d.patid
         LEFT JOIN ( SELECT patid, GROUP_CONCAT( tagname ) AS tagname FROM pat_archivetag where del_flag=0 GROUP BY patid
-        ) t ON t.patid =
-        d.patid
+        ) t ON t.patid = d.patid
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="idcardno != null  and idcardno != ''">and a.idcardno = #{idcardno}</if>
@@ -614,14 +626,15 @@
                 </foreach>
             </if>
 
-            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0">
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0 and deptcodes == null ">
                 AND d.hospitaldistrictcode IN
                 <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
                          close=")">
                     #{hospitaldistrictcode}
                 </foreach>
             </if>
-            <if test="deptcodes != null and deptcodes.size() > 0">
+
+            <if test="deptcodes != null and deptcodes.size() > 0 and hospitaldistrictcodes == null">
                 AND d.deptcode IN
                 <foreach collection="deptcodes" item="deptcode" open="(" separator=","
                          close=")">
@@ -629,6 +642,20 @@
                 </foreach>
             </if>
 
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0 and deptcodes != null ">
+                AND (d.hospitaldistrictcode IN
+                <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{hospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="hospitaldistrictcodes != null and deptcodes != null and deptcodes.size() > 0">
+                OR d.deptcode IN
+                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+                         close="))">
+                    #{deptcode}
+                </foreach>
+            </if>
 
             <if test="patids != null">
                 AND a.id NOT IN
@@ -685,8 +712,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
-        d.leavehospitaldistrictcode AS leavehospitaldistrictcode,
-        d.leavehospitaldistrictname AS leavehospitaldistrictname,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -701,6 +727,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
@@ -784,6 +811,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -798,6 +826,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
@@ -880,6 +909,7 @@
         a.isupload,
         a.upload_time,
         a.pattype,
+        a.reserved_phone,
         d.bed_no,
         d.starttime,
         d.endtime,
@@ -899,6 +929,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <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="tagname != null  and tagname != ''">
@@ -925,8 +956,15 @@
             <if test="deptname != null and deptname != ''">AND d.deptname LIKE concat('%', #{deptname}, '%')</if>
             <if test="drname != null and drname != ''">AND d.drname LIKE concat('%',#{drname}, '%')</if>
             <if test="diagname != null and diagname != ''">AND d.diagname LIKE concat('%',#{diagname}, '%')</if>
-            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0 and leaveldeptcodes == null">
                 AND d.leavehospitaldistrictcode IN
+                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{leavehospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0 and leaveldeptcodes != null and leaveldeptcodes.size() > 0">
+                AND (d.leavehospitaldistrictcode IN
                 <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator=","
                          close=")">
                     #{leavehospitaldistrictcode}
@@ -934,7 +972,7 @@
             </if>
             <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0 and leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
                 OR d.leaveldeptcode IN
-                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
+                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close="))">
                     #{leaveldeptcode}
                 </foreach>
             </if>
@@ -1018,6 +1056,7 @@
         a.create_by,
         a.create_time,
         a.isupload,
+        a.reserved_phone,
         a.upload_time,
         rt.tagname,
         ROW_NUMBER() OVER (PARTITION BY a.idcardno ORDER BY a.update_time DESC) AS rn,
@@ -1030,6 +1069,7 @@
             AND a.del_flag != 1
             AND d.admitdate >= CURRENT_DATE - INTERVAL '90 days' <!-- 寮虹儓鎺ㄨ崘鍔犳椂闂撮檺鍒� -->
             <if test="patid != null and patid != ''">AND a.id = #{patid}</if>
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="tagname != null and tagname != ''">AND rt.tagname LIKE concat('%', #{tagname}, '%')</if>
             <if test="name != null and name != ''">AND a.name LIKE concat('%', #{name}, '%')</if>
             <if test="idcardno != null and idcardno != ''">AND a.idcardno = #{idcardno}</if>
@@ -1129,6 +1169,7 @@
         a.create_time,
         a.isupload,
         a.upload_time,
+        a.reserved_phone,
         COALESCE((
         SELECT string_agg(dd.tagname, ', ')
         FROM pat_archivetag dd
@@ -1144,6 +1185,7 @@
         <where>
             d.del_flag != 1
             AND a.del_flag != 1
+            <if test="reservedPhone != null ">and a.reserved_phone = #{reservedPhone}</if>
             <if test="patid != null  and patid != ''">and a.id = #{patid}</if>
             <if test="tagname != null  and tagname != ''">and t.tagname like concat('%', #{tagname}, '%')</if>
             <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>

--
Gitblit v1.9.3