Browse Source

出院人数统计

zhaops 4 years ago
parent
commit
8538e09d06

+ 4 - 4
src/main/java/com/diagbot/aggregate/MrStatisticsAggregate.java

@@ -88,8 +88,8 @@ public class MrStatisticsAggregate {
         retMap.put("死亡人数", 0);
         retMap.put("新生儿人数", 0);
         retMap.put("手术病人数", 0);
-        retMap.put("非医嘱离院人数", 0);
-        retMap.put("31日再入院人数", 0);
+        retMap.put("非医嘱离院人数", 0);
+        retMap.put("31日再入院人数", 0);
         Integer totleNum = behospitalInfoFacade.leaveHosCount(filterVO);
         Integer deathNum = behospitalInfoFacade.deathCount(filterVO);
         Integer newBornNum = behospitalInfoFacade.newBornCount(filterVO);
@@ -100,8 +100,8 @@ public class MrStatisticsAggregate {
         retMap.put("死亡人数", deathNum);
         retMap.put("新生儿人数", newBornNum);
         retMap.put("手术病人数", operationNum);
-        retMap.put("非医嘱离院人数", nonAdviceNum);
-        retMap.put("31日再入院人数", reBehospitalNum);
+        retMap.put("非医嘱离院人数", nonAdviceNum);
+        retMap.put("31日再入院人数", reBehospitalNum);
         return retMap;
     }
 

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -126,6 +126,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/console/export/entryCountGroupByCaseExport").permitAll()
                 .antMatchers("/console/export/entryStatisticsExport").permitAll()
                 .antMatchers("/console/export/qcResultShortPageExport").permitAll()
+                .antMatchers("/console/export/leaveHosMrPageExport").permitAll()
                 .antMatchers("/qc/data/sendDoctorInfos").permitAll()
                 .antMatchers("/qc/data/sendDeptInfos").permitAll()
                 .antMatchers("/qc/data/sendRecordTypes").permitAll()

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -169,6 +169,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/console/export/entryCountGroupByCaseExport", request)
                 || matchers("/console/export/entryStatisticsExport", request)
                 || matchers("/console/export/qcResultShortPageExport", request)
+                || matchers("/console/export/leaveHosMrPageExport", request)
                 || matchers("/qc/data/sendDoctorInfos", request)
                 || matchers("/qc/data/sendDeptInfos", request)
                 || matchers("/qc/data/sendRecordTypes", request)

+ 15 - 0
src/main/java/com/diagbot/facade/ConsoleExportFacade.java

@@ -208,4 +208,19 @@ public class ConsoleExportFacade {
         String fileName = "缺陷详情质控评分页.xls";
         ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", QcResultShortDTO.class, fileName, response, 12.8f);
     }
+
+    /**
+     * 出院人数统计导出
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public void leaveHosMrPageExport(HttpServletResponse response, QcResultShortPageVO qcResultShortPageVO) {
+        qcResultShortPageVO.setCurrent(1L);
+        qcResultShortPageVO.setSize(Long.MAX_VALUE);
+        qcResultShortPageVO.setSearchCount(false);
+        IPage<QcResultShortDTO> page = consoleFacade.leaveHosMRPage(qcResultShortPageVO);
+        String fileName = "出院人数统计.xls";
+        ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", QcResultShortDTO.class, fileName, response, 12.8f);
+    }
 }

+ 15 - 1
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -28,6 +28,7 @@ import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcResultShortPageVO;
 import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -780,10 +781,11 @@ public class ConsoleFacade {
 
     /**
      * 病案首页合格率、完整率、改善率统计
+     *
      * @param filterVO
      * @return
      */
-    public Map<String,Object> homePageMRCount(FilterVO filterVO) {
+    public Map<String, Object> homePageMRCount(FilterVO filterVO) {
         Map<String, Object> retMap = new HashMap<>();
         retMap.put("合格率", null);
         retMap.put("完整率", null);
@@ -802,4 +804,16 @@ public class ConsoleFacade {
         retMap.put("改善率", null);
         return retMap;
     }
+
+    /**
+     * 离院病人质控评分详情页
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public IPage<QcResultShortDTO> leaveHosMRPage(QcResultShortPageVO qcResultShortPageVO) {
+        filterFacade.qcResultShortPageVOSet(qcResultShortPageVO);
+        IPage<QcResultShortDTO> page = behospitalInfoFacade.leaveHosMRPage(qcResultShortPageVO);
+        return page;
+    }
 }

+ 8 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -286,4 +286,12 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      */
     public HomePageNumDTO hmEmptyEntryPercent(FilterVO filterVO);
+
+    /**
+     * 离院病人质控评分详情页
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public IPage<QcResultShortDTO> leaveHosMRPage(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO);
 }

+ 8 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -279,4 +279,12 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @return
      */
     public HomePageNumDTO hmEmptyEntryPercent(FilterVO filterVO);
+
+    /**
+     * 离院病人质控评分详情页
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public IPage<QcResultShortDTO> leaveHosMRPage(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO);
 }

+ 11 - 0
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -380,4 +380,15 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public HomePageNumDTO hmEmptyEntryPercent(FilterVO filterVO) {
         return baseMapper.hmEmptyEntryPercent(filterVO);
     }
+
+    /**
+     * 离院病人质控评分详情页
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    @Override
+    public IPage<QcResultShortDTO> leaveHosMRPage(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO) {
+        return baseMapper.leaveHosMRPage(qcResultShortPageVO);
+    }
 }

+ 5 - 0
src/main/java/com/diagbot/vo/QcResultShortPageVO.java

@@ -66,4 +66,9 @@ public class QcResultShortPageVO extends Page {
      * 规则类型(0:无,1:空项,2:错误)
      */
     private Integer ruleType;
+
+    /**
+     * 离院人员类型(0/null:总人数,1:死亡人数,2:新生儿,3:手术病人数,4:非医嘱离院病人,5:31日再入院病人)
+     */
+    private Integer leaveHosType;
 }

+ 22 - 0
src/main/java/com/diagbot/web/ConsoleController.java

@@ -507,4 +507,26 @@ public class ConsoleController {
     public RespDTO<Map<String, Object>> homePageMRCount(@RequestBody @Valid FilterVO filterVO) {
         return RespDTO.onSuc(consoleFacade.homePageMRCount(filterVO));
     }
+
+    /**
+     * 出院人数统计
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    @ApiOperation(value = "出院人数统计[by:zhaops]",
+            notes = "behospitalCode: 病历号<br>" +
+                    "patName: 病人姓名 <br>" +
+                    "behDeptName:科室名称 <br>" +
+                    "doctorId:医生工号 <br>" +
+                    "doctorName:医生姓名 <br>" +
+                    "level: 病历等级 <br>" +
+                    "leaveHosType: 离院人员类型(0/null:总人数,1:死亡人数,2:新生儿,3:手术病人数,4:非医嘱离院病人,5:31日再入院病人) <br>" +
+                    "startDate: 起始时间 <br>" +
+                    "endDate: 截止时间 <br>")
+    @PostMapping("/leaveHosMRPage")
+    @SysLogger("leaveHosMRPage")
+    public RespDTO<IPage<QcResultShortDTO>> leaveHosMRPage(@RequestBody @Valid QcResultShortPageVO qcResultShortPageVO) {
+        return RespDTO.onSuc(consoleFacade.leaveHosMRPage(qcResultShortPageVO));
+    }
 }

+ 22 - 0
src/main/java/com/diagbot/web/ConsoleExportController.java

@@ -220,4 +220,26 @@ public class ConsoleExportController {
     public void qcResultShortPageExport(HttpServletResponse response, @RequestBody @Valid QcResultShortPageVO qcResultShortPageVO) {
         consoleExportFacade.qcResultShortPageExport(response, qcResultShortPageVO);
     }
+
+    /**
+     * 出院人数统计导出
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    @ApiOperation(value = "出院人数统计导出[by:zhaops]",
+            notes = "behospitalCode: 病历号<br>" +
+                    "patName: 病人姓名 <br>" +
+                    "behDeptName:科室名称 <br>" +
+                    "doctorId:医生工号 <br>" +
+                    "doctorName:医生姓名 <br>" +
+                    "level: 病历等级 <br>" +
+                    "leaveHosType: 离院人员类型(0/null:总人数,1:死亡人数,2:新生儿,3:手术病人数,4:非医嘱离院病人,5:31日再入院病人) <br>" +
+                    "startDate: 起始时间 <br>" +
+                    "endDate: 截止时间 <br>")
+    @PostMapping("/leaveHosMrPageExport")
+    @SysLogger("leaveHosMrPageExport")
+    public void leaveHosMrPageExport(HttpServletResponse response, @RequestBody @Valid QcResultShortPageVO qcResultShortPageVO) {
+        consoleExportFacade.leaveHosMrPageExport(response, qcResultShortPageVO);
+    }
 }

+ 618 - 0
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -3475,8 +3475,19 @@
         med_behospital_info tt2
         WHERE
         tt2.is_deleted = 'N'
+        AND tt2.is_placefile = 1
+        AND tt2.qc_type_id != 0
         AND tt1.file_code = tt2.file_code
         AND tt1.diagnose = tt2.diagnose
+        <if test="hospitalId != null and hospitalId != ''">
+            AND tt2.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
         ORDER BY
         tt1.file_code,
         tt1.diagnose,
@@ -3511,8 +3522,19 @@
         med_behospital_info tt2
         WHERE
         tt2.is_deleted = 'N'
+        AND tt2.is_placefile = 1
+        AND tt2.qc_type_id != 0
         AND tt1.file_code = tt2.file_code
         AND tt1.diagnose = tt2.diagnose
+        <if test="hospitalId != null and hospitalId != ''">
+            AND tt2.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
         ORDER BY
         tt1.file_code,
         tt1.diagnose,
@@ -3578,8 +3600,19 @@
         med_behospital_info tt2
         WHERE
         tt2.is_deleted = 'N'
+        AND tt2.is_placefile = 1
+        AND tt2.qc_type_id != 0
         AND tt1.file_code = tt2.file_code
         AND tt1.diagnose = tt2.diagnose
+        <if test="hospitalId != null and hospitalId != ''">
+            AND tt2.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
         ORDER BY
         tt1.file_code,
         tt1.diagnose,
@@ -3614,8 +3647,19 @@
         med_behospital_info tt2
         WHERE
         tt2.is_deleted = 'N'
+        AND tt2.is_placefile = 1
+        AND tt2.qc_type_id != 0
         AND tt1.file_code = tt2.file_code
         AND tt1.diagnose = tt2.diagnose
+        <if test="hospitalId != null and hospitalId != ''">
+            AND tt2.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
         ORDER BY
         tt1.file_code,
         tt1.diagnose,
@@ -3719,4 +3763,578 @@
         AND cases_id = 243
         ) h2
     </select>
+
+    <!-- 离院病人评分详情页-->
+    <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
+        SELECT DISTINCT
+        t1.hospital_id AS hospitalId,
+        t1.behospital_code AS behospitalCode,
+        t1.bed_code AS bedCode,
+        t1.LEVEL AS LEVEL,
+        t1.grade_type AS gradeType,
+        t1.score_res AS scoreRes,
+        t1.NAME AS NAME,
+        t1.sex AS sex,
+        t1.beh_dept_id AS behDeptId,
+        t1.beh_dept_name AS behDeptName,
+        t1.doctor_id AS doctorId,
+        t1.doctor_name AS doctorName,
+        t1.beh_doctor_id AS behDoctorId,
+        t1.beh_doctor_name AS behDoctorName,
+        t1.director_doctor_id AS directorDoctorId,
+        t1.director_doctor_name AS directorDoctorName,
+        t1.birthday AS birthday,
+        t1.behospital_date AS behospitalDate,
+        t1.leave_hospital_date AS leaveHospitalDate,
+        t1.placefile_date AS placefileDate,
+        t1.gmt_create AS gradeTime,
+        t1.diagnose,
+        t1.ward_name AS wardName,
+        t2.age,
+        t2.file_code AS fileCode
+        FROM
+        (
+        SELECT DISTINCT
+        tt1.*
+        FROM
+        (
+        SELECT
+        b.*,
+        c.LEVEL,
+        c.grade_type,
+        c.score_res,
+        c.gmt_create
+        FROM
+        (
+        SELECT DISTINCT
+        a.hospital_id,
+        a.behospital_code,
+        a.bed_code,
+        a.NAME,
+        a.sex,
+        a.beh_dept_id,
+        a.beh_dept_name,
+        a.birthday,
+        a.behospital_date,
+        a.leave_hospital_date,
+        a.doctor_id,
+        a.doctor_name,
+        a.beh_doctor_id,
+        a.beh_doctor_name,
+        a.director_doctor_id,
+        a.director_doctor_name,
+        a.diagnose,
+        a.placefile_date,
+        a.ward_name
+        FROM
+        med_behospital_info a
+        WHERE
+        a.is_deleted = 'N'
+        AND a.qc_type_id != 0
+        AND a.is_placefile = 1
+        <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+            AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
+        </if>
+        <if test="qcResultShortPageVO.startDate != null">
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+        </if>
+        <if test="qcResultShortPageVO.endDate != null ">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+        </if>
+        <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+            AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+        </if>
+        <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+            AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+        </if>
+        <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+            AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+        </if>
+        <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+            AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+            OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+            OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+        </if>
+        <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+            AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+            OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+            OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+        </if>
+        ) b
+        LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
+        AND b.hospital_id = c.hospital_id
+        AND b.behospital_code = c.behospital_code
+        <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
+            AND c.`level` = #{qcResultShortPageVO.level}
+        </if>
+        ) tt1
+        <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
+            ,med_medical_record tt2,
+            qc_mode tt3
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt3.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+            AND tt2.mode_id = tt3.id
+            AND tt3.`name` = '手术记录'
+        </if>
+        <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==5">
+            ,(
+            SELECT
+            bc1.file_code,
+            bc1.diagnose,
+            bc1.behospitalCode,
+            bc1.behospitalDate,
+            bc1.leaveHospitalDate
+            FROM
+            (
+            SELECT
+            t1.file_code,
+            t1.diagnose,
+            t1.behospital_code AS behospitalCode,
+            t1.leave_hospital_date AS leaveHospitalDate,
+            t2.behospital_code AS lastBehospitalCode,
+            t2.behospital_date AS lastBehospitalDate,
+            t1.behospital_date AS behospitalDate,
+            t2.leave_hospital_date AS lastLeaveHospitalDate
+            FROM
+            (
+            SELECT
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_code,
+            tt2.behospital_date,
+            tt2.leave_hospital_date
+            FROM
+            (
+            SELECT
+            a.file_code,
+            a.diagnose
+            FROM
+            med_behospital_info a
+            WHERE
+            a.is_deleted = 'N'
+            AND a.is_placefile = 1
+            AND a.qc_type_id != 0
+            AND IFNULL( a.diagnose, '' )!= ''
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            GROUP BY
+            a.file_code,
+            a.diagnose
+            HAVING
+            count(*)> 1
+            ) tt1,
+            med_behospital_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt2.is_placefile = 1
+            AND tt2.qc_type_id != 0
+            AND tt1.file_code = tt2.file_code
+            AND tt1.diagnose = tt2.diagnose
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            ORDER BY
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_date DESC
+            ) t1,
+            (
+            SELECT
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_code,
+            tt2.behospital_date,
+            tt2.leave_hospital_date
+            FROM
+            (
+            SELECT
+            a.file_code,
+            a.diagnose
+            FROM
+            med_behospital_info a
+            WHERE
+            a.is_deleted = 'N'
+            AND a.is_placefile = 1
+            AND a.qc_type_id != 0
+            AND IFNULL( a.diagnose, '' )!= ''
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            GROUP BY
+            a.file_code,
+            a.diagnose
+            HAVING
+            count(*)> 1
+            ) tt1,
+            med_behospital_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt2.is_placefile = 1
+            AND tt2.qc_type_id != 0
+            AND tt1.file_code = tt2.file_code
+            AND tt1.diagnose = tt2.diagnose
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            ORDER BY
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_date DESC
+            ) t2
+            WHERE
+            t1.file_code = t2.file_code
+            AND t1.diagnose = t2.diagnose
+            AND t1.behospital_code != t2.behospital_code
+            AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
+            SELECT
+            bc2.file_code,
+            bc2.diagnose,
+            bc2.lastBehospitalCode,
+            bc2.lastBehospitalDate,
+            bc2.lastLeaveHospitalDate
+            FROM
+            (
+            SELECT
+            t1.file_code,
+            t1.diagnose,
+            t1.behospital_code AS behospitalCode,
+            t1.leave_hospital_date AS leaveHospitalDate,
+            t2.behospital_code AS lastBehospitalCode,
+            t2.behospital_date AS lastBehospitalDate,
+            t1.behospital_date AS behospitalDate,
+            t2.leave_hospital_date AS lastLeaveHospitalDate
+            FROM
+            (
+            SELECT
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_code,
+            tt2.behospital_date,
+            tt2.leave_hospital_date
+            FROM
+            (
+            SELECT
+            a.file_code,
+            a.diagnose
+            FROM
+            med_behospital_info a
+            WHERE
+            a.is_deleted = 'N'
+            AND a.is_placefile = 1
+            AND a.qc_type_id != 0
+            AND IFNULL( a.diagnose, '' )!= ''
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            GROUP BY
+            a.file_code,
+            a.diagnose
+            HAVING
+            count(*)> 1
+            ) tt1,
+            med_behospital_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt2.is_placefile = 1
+            AND tt2.qc_type_id != 0
+            AND tt1.file_code = tt2.file_code
+            AND tt1.diagnose = tt2.diagnose
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            ORDER BY
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_date DESC
+            ) t1,
+            (
+            SELECT
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_code,
+            tt2.behospital_date,
+            tt2.leave_hospital_date
+            FROM
+            (
+            SELECT
+            a.file_code,
+            a.diagnose
+            FROM
+            med_behospital_info a
+            WHERE
+            a.is_deleted = 'N'
+            AND a.is_placefile = 1
+            AND a.qc_type_id != 0
+            AND IFNULL( a.diagnose, '' )!= ''
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            GROUP BY
+            a.file_code,
+            a.diagnose
+            HAVING
+            count(*)> 1
+            ) tt1,
+            med_behospital_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt2.is_placefile = 1
+            AND tt2.qc_type_id != 0
+            AND tt1.file_code = tt2.file_code
+            AND tt1.diagnose = tt2.diagnose
+            <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
+                AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
+            </if>
+            <if test="qcResultShortPageVO.startDate != null">
+                <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.endDate != null ">
+                <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
+            </if>
+            <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
+                AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
+            </if>
+            <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
+                AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
+                AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
+            </if>
+            <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
+                AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
+                OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
+            </if>
+            <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
+                AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
+                OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            </if>
+            ORDER BY
+            tt1.file_code,
+            tt1.diagnose,
+            tt2.behospital_date DESC
+            ) t2
+            WHERE
+            t1.file_code = t2.file_code
+            AND t1.diagnose = t2.diagnose
+            AND t1.behospital_code != t2.behospital_code
+            AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
+            ) tt2
+            WHERE
+            tt1.behospital_code = tt2.behospitalCode
+        </if>
+        ) t1
+        <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
+            ,med_home_page t2
+            WHERE
+            t2.is_deleted = 'N'
+            AND t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND (
+            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' )
+            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' )
+            )
+        </if>
+        <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
+            ,med_home_page t2
+            WHERE
+            t2.is_deleted = 'N'
+            AND t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.return_to_type = '死亡'
+        </if>
+        <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
+            ,med_home_page t2
+            WHERE
+            t2.is_deleted = 'N'
+            AND t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.leave_hospital_type = '非医嘱离院'
+        </if>
+        <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3 or qcResultShortPageVO.leaveHosType == 5">
+            LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
+            AND t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+        </if>
+    </select>
 </mapper>