陈昶聿
3 天以前 d2d33d9e10b6a68b84a43a1b970a94246ffdf801
smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -214,8 +214,8 @@
        pat_archive a ON a.id = b.patid
        LEFT JOIN
        pat_archivetag c ON c.patid = a.id AND (c.del_flag = 0 OR c.del_flag IS NULL)
        <where>
            a.del_flag = 0
        where 1=1
            AND a.del_flag = 0
            AND b.del_flag = 0
            AND a.idcardno IS NOT NULL
            <if test="startOutHospTime != null ">and date_format(b.endtime,'%y%m%d') &gt;=
@@ -289,7 +289,6 @@
                    #{leaveldeptcode}
                </foreach>
            </if>
        </where>
        GROUP BY
        b.inhospid,
        a.age,
@@ -370,11 +369,13 @@
        b.fuspecialadvice
        FROM
        pat_med_inhosp b
        <where>
            <if test="serialnum != null ">and b.serialnum = #{serialnum}</if>
        </where>
        where 1=1
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
        </if>
        <if test="serialnum != null ">
            and b.serialnum = #{serialnum}
        </if>
        order by b.inhospid desc
    </select>
@@ -448,11 +449,14 @@
        FROM
        pat_med_inhosp b,
        pat_archive a
        <where>
            a.del_flag=0
        where 1=1
        and a.del_flag=0
            and b.del_flag=0
            and a.id = b.patid
            AND a.idcardno != ''
        <if test="orgid != null and orgid != ''">
            and a.orgid = #{orgid}
        </if>
            <if test="hospitalname != null  and hospitalname != ''">and hospitalname like concat('%', #{hospitalname},
                '%')
            </if>
@@ -492,7 +496,6 @@
                    #{leaveldeptcode}
                </foreach>
            </if>
        </where>
        order by b.inhospid desc
    </select>
@@ -857,15 +860,17 @@
        <if test="mz != null">
            SELECT deptname
            FROM pat_med_outhosp
            <where>
                del_flag=0
            where 1=1
            and del_flag=0
                <if test="deptcodeList != null   and deptcodeList.size() > 0">
                    and deptcode in
                    <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
                        #{deptcode}
                    </foreach>
                </if>
            </where>
            <if test="orgid != null and orgid != ''">
                and orgid = #{orgid}
            </if>
        </if>
        <if test="mz != null and zy != null">
            UNION ALL
@@ -873,8 +878,8 @@
        <if test="zy != null">
            SELECT deptname
            FROM pat_med_inhosp
            <where>
                del_flag=0
            where 1=1
            and del_flag=0
                and inhospstate=0
                <if test="deptcodeList != null   and deptcodeList.size() > 0">
                    and deptcode in
@@ -882,14 +887,16 @@
                        #{deptcode}
                    </foreach>
                </if>
            </where>
            <if test="orgid != null and orgid != ''">
                and orgid = #{orgid}
            </if>
        </if>
        <if test="cy != null and zy != null">
            UNION ALL
            SELECT deptname
            FROM pat_med_inhosp
            <where>
                del_flag=0
            where 1=1
            and del_flag=0
                and inhospstate=1
                <if test="deptcodeList != null   and deptcodeList.size() > 0">
                    and deptcode in
@@ -897,14 +904,16 @@
                        #{deptcode}
                    </foreach>
                </if>
            </where>
            <if test="orgid != null and orgid != ''">
                and orgid = #{orgid}
            </if>
        </if>
        <if test="mz != null and zy != null and cy==null">
            UNION ALL
            SELECT deptname
            FROM pat_med_inhosp
            <where>
                del_flag=0
            where 1=1
            and del_flag=0
                and inhospstate=1
                <if test="deptcodeList != null   and deptcodeList.size() > 0">
                    and deptcode in
@@ -912,7 +921,9 @@
                        #{deptcode}
                    </foreach>
                </if>
            </where>
            <if test="orgid != null and orgid != ''">
                and orgid = #{orgid}
            </if>
        </if>
        ) AS combined
        GROUP BY deptname;
@@ -934,10 +945,10 @@
        0 AS zbsf
        FROM
        pat_med_inhosp
        <where>
            del_flag=0
            <if test="orgid != null">
                AND orgid = #{orgid}
        where 1=1
        and del_flag=0
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </if>
            <if test="zy != null">
                and inhospstate=0
@@ -961,7 +972,6 @@
                    </foreach>
                </if>
            </if>
        </where>
        <!-- 随访服务人数 -->
        union all
        select
@@ -972,11 +982,11 @@
        0 AS zbsf
        FROM
        service_subtask
        <where>
            del_flag = 0
        where 1=1
        and del_flag = 0
            and service_type=2
            <if test="orgid != null">
                AND orgid = #{orgid}
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </if>
            <if test="startDate != null">
                AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
@@ -990,7 +1000,6 @@
                    #{deptcode}
                </foreach>
            </if>
        </where>
        <!-- 首次随访人数 -->
        union all
        select
@@ -1001,12 +1010,12 @@
        0 AS zbsf
        FROM
        service_subtask
        <where>
            del_flag = 0
        where 1=1
        and del_flag = 0
            and service_type=2
            and is_visit_again = 0
            <if test="orgid != null">
                AND orgid = #{orgid}
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </if>
            <if test="startDate != null">
                AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
@@ -1020,7 +1029,6 @@
                    #{deptcode}
                </foreach>
            </if>
        </where>
        <!-- 再次随访人数 -->
        union all
        select
@@ -1031,12 +1039,12 @@
        0 AS zbsf
        FROM
        service_subtask
        <where>
            del_flag = 0
        where 1=1
        and del_flag = 0
            and service_type=2
            and is_visit_again = 1
            <if test="orgid != null">
                AND orgid = #{orgid}
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </if>
            <if test="startDate != null">
                AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
@@ -1050,7 +1058,6 @@
                    #{deptcode}
                </foreach>
            </if>
        </where>
        <!-- 专病随访人数 -->
        union all
        select
@@ -1061,11 +1068,11 @@
        count(1) AS zbsf
        FROM
        service_subtask
        <where>
            del_flag = 0
        where 1=1
        and del_flag = 0
            and service_type=13
            <if test="orgid != null">
                AND orgid = #{orgid}
        <if test="orgid != null and orgid != ''">
            and orgid = #{orgid}
            </if>
            <if test="startDate != null">
                AND date_format( visit_time, '%y%m%d' ) &gt;= date_format( #{startDate}, '%y%m%d' )
@@ -1079,7 +1086,6 @@
                    #{deptcode}
                </foreach>
            </if>
        </where>
        ) AS combined_data
    </select>