陈昶聿
8 小时以前 7ca6d7d7da579f9a32c7d253eccb0f4e1ba6b6ef
smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -180,8 +180,8 @@
    <select id="selectPatArchiveList" parameterType="com.smartor.domain.PatArchive" resultMap="PatArchiveResult">
        <include refid="selectPatArchiveVo"/>
        <where>
            del_flag=0
        where 1=1
            and del_flag = 0
            <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>
@@ -212,7 +212,6 @@
            <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>
        </where>
    </select>
@@ -250,9 +249,10 @@
        a.filter_drcode,
        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
        where 1=1
            and a.del_flag = 0
            and a.id = b.patid
            and b.tagid = c.tagid
            <if test="filterDrname != null ">and filter_drname = #{filterDrname}</if>
            <if test="filterDrcode != null ">and filter_drcode = #{filterDrcode}</if>
            <if test="name != null  and name != ''">and a.name like concat('%', #{name}, '%')</if>
@@ -264,7 +264,6 @@
                    #{tagId}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectPatArchiveByPatid" parameterType="Long" resultMap="PatArchiveResult">
@@ -513,8 +512,8 @@
        FROM
        pat_archive a
        LEFT JOIN pat_archivetag b ON a.id = b.patid AND b.del_flag = 0
        <where>
            a.del_flag = 0
        where 1=1
            and a.del_flag = 0
            and a.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>
@@ -528,7 +527,6 @@
                    #{tagId}
                </foreach>
            </if>
        </where>
        order by a.update_time desc
        <if test="pn != null  and ps != null">limit ${pn},${ps}</if>
@@ -588,16 +586,12 @@
        d.nurse_id,
        d.out_way_id,
        d.leavehospitaldistrictname AS leavehospitaldistrictname,
        d.leavehospitaldistrictcode AS leavehospitaldistrictcode,
        t.tagname
        d.leavehospitaldistrictcode AS leavehospitaldistrictcode
        FROM
        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
        <where>
            d.del_flag != 1
        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>
@@ -672,7 +666,6 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        -- order by a.update_time desc
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
@@ -728,8 +721,8 @@
        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
        <where>
            d.del_flag != 1
        where 1=1
            and d.del_flag != 1
            AND a.del_flag != 1
            and d.orgid = #{orgid}
            <if test="pid != null  and pid != ''">and a.id = #{pid}</if>
@@ -766,7 +759,6 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        -- order by a.update_time desc
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
    </select>
@@ -816,14 +808,10 @@
        a.upload_time,
        a.filter_drname,
        a.filter_drcode,
        t.tagname,
        a.pattype
        from pat_med_physical 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
        <where>
            d.del_flag != 1
        where 1=1
            and d.del_flag != 1
            AND a.del_flag != 1
            and d.orgid = #{orgid}
            <if test="pid != null  and pid != ''">and a.id = #{pid}</if>
@@ -861,7 +849,6 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        -- order by a.update_time desc
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
    </select>
@@ -922,16 +909,12 @@
        d.nurse_id,
        d.out_way_id,
        d.leavehospitaldistrictname AS leavehospitaldistrictname,
        d.leavehospitaldistrictcode AS leavehospitaldistrictcode,
        t.tagname
        d.leavehospitaldistrictcode AS leavehospitaldistrictcode
        FROM
        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
        <where>
            d.del_flag != 1
        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>
@@ -1010,7 +993,6 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
        ) as tmp
    </select>
@@ -1060,14 +1042,10 @@
        a.upload_time,
        a.filter_drname,
        a.filter_drcode,
        t.tagname,
        a.pattype
        from pat_med_outhosp 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
        <where>
            d.del_flag != 1
        where 1=1
            and d.del_flag != 1
            AND a.del_flag != 1
            and d.orgid = #{orgid}
            <if test="pid != null  and pid != ''">and a.id = #{pid}</if>
@@ -1107,7 +1085,6 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
    </select>
@@ -1156,14 +1133,10 @@
        a.create_time,
        a.isupload,
        a.upload_time,
        t.tagname,
        a.pattype
        from pat_med_physical 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
        <where>
            d.del_flag != 1
        where 1=1
            and d.del_flag != 1
            AND a.del_flag != 1
            and d.orgid = #{orgid}
            <if test="pid != null  and pid != ''">and a.id = #{pid}</if>
@@ -1201,8 +1174,133 @@
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
        </where>
        -- order by a.update_time desc
        <if test="pageSize != null  and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
    </select>
    <!-- 住院患者总数统计(去重) -->
    <select id="countPatArchiveInfoByInhospQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long">
        SELECT COUNT(DISTINCT a.id)
        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>
            <if test="endtime != null">AND d.endtime = #{endtime}</if>
            <if test="drname != null and drname != ''">AND d.drname LIKE concat('%',#{drname}, '%')</if>
            <if test="drcode != null">AND d.drcode = #{drcode}</if>
            <if test="campusid != null">AND d.campusid = #{campusid}</if>
            <if test="allhosp != null and allhosp == 1 ">AND d.endtime is null</if>
            <if test="allhosp != null and allhosp == 4 ">AND d.endtime is not null</if>
            <if test="visitno != null and visitno != ''">AND d.inhospno = #{visitno}</if>
            <if test="deptname != null and deptname != ''">AND d.deptname LIKE concat('%', #{deptname}, '%')</if>
            <if test="leavediagname != null and leavediagname != ''">AND d.leavediagname LIKE concat('%',#{leavediagname}, '%')</if>
            <if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size()>0">
                AND d.leavehospitaldistrictcode IN
                <foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="(" separator="," close=")">
                    #{leavehospitaldistrictcode}
                </foreach>
            </if>
            <if test="leaveldeptcodes != null and leaveldeptcodes.size() > 0">
                AND d.leaveldeptcode IN
                <foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator="," close=")">
                    #{leaveldeptcode}
                </foreach>
            </if>
            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0">
                AND d.hospitaldistrictcode IN
                <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator="," close=")">
                    #{hospitaldistrictcode}
                </foreach>
            </if>
            <if test="deptcodes != null and deptcodes.size() > 0">
                AND d.deptcode IN
                <foreach collection="deptcodes" item="deptcode" open="(" separator="," close=")">
                    #{deptcode}
                </foreach>
            </if>
            <if test="pids != null">
                AND a.id NOT IN
                <foreach collection="pids" item="pid" open="(" separator="," close=")">
                    #{pid}
                </foreach>
            </if>
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
    </select>
    <!-- 门诊患者总数统计(去重) -->
    <select id="countPatArchiveInfoByOuthospQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long">
        SELECT COUNT(DISTINCT a.id)
        FROM pat_med_outhosp 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="pid != null  and pid != ''">AND a.id = #{pid}</if>
            <if test="campusid != null  and campusid != ''">AND a.campusid = #{campusid}</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="telcode != null  and telcode != ''">AND a.telcode = #{telcode}</if>
            <if test="hospitaldistrictname != null and hospitaldistrictname != ''">AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')</if>
            <if test="notrequiredFlag != null  and notrequiredFlag != ''">AND a.notrequired_flag = #{notrequiredFlag}</if>
            <if test="leavediagname != null and leavediagname != ''">AND d.diagname LIKE concat('%',#{leavediagname}, '%')</if>
            <if test="hospitalname != null and hospitalname != ''">AND d.hospitalname = #{hospitalname}</if>
            <if test="visitno != null and visitno != ''">AND d.outhospno = #{visitno}</if>
            <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="drcode != null">AND d.drcode = #{drcode}</if>
            <if test="pids != null">
                AND a.id NOT IN
                <foreach collection="pids" item="pid" open="(" separator="," close=")">
                    #{pid}
                </foreach>
            </if>
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
    </select>
    <!-- 体检患者总数统计(去重) -->
    <select id="countPatArchiveInfoByPhysicalQC" parameterType="com.smartor.domain.PatArchiveReq" resultType="long">
        SELECT COUNT(DISTINCT a.id)
        FROM pat_med_physical 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="pid != null  and pid != ''">AND a.id = #{pid}</if>
            <if test="campusid != null  and campusid != ''">AND a.campusid = #{campusid}</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="telcode != null  and telcode != ''">AND a.telcode = #{telcode}</if>
            <if test="hospitaldistrictname != null and hospitaldistrictname != ''">AND d.hospitaldistrictname LIKE concat('%',#{hospitaldistrictname}, '%')</if>
            <if test="diagname != null and diagname != ''">AND d.diagname LIKE concat('%',#{diagname}, '%')</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="visitno != null and visitno != ''">AND d.physno = #{visitno}</if>
            <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="pids != null">
                AND a.id NOT IN
                <foreach collection="pids" item="pid" open="(" separator="," close=")">
                    #{pid}
                </foreach>
            </if>
            <if test="isFilter == true">
                AND NOT exists ( SELECT 1 FROM pat_filterlist f where d.patid=f.patid)
            </if>
    </select>
</mapper>