瀏覽代碼

缺陷病历数量导出内容有误解决

zhanghang 3 年之前
父節點
當前提交
2185da7dae

+ 0 - 74
src/main/java/com/diagbot/dto/ExportGetDetailRecordListPageDTO.java

@@ -1,74 +0,0 @@
-package com.diagbot.dto;
-
-import cn.afterturn.easypoi.excel.annotation.Excel;
-import io.swagger.annotations.ApiModel;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @Description: 获取医生缺陷数量出参
- * @Author: zhanghang
- * @time: 2022/4/11 19:00
- */
-@ApiModel(value = "获取医生缺陷数量出参-接口出参")
-@Getter
-@Setter
-public class ExportGetDetailRecordListPageDTO implements Serializable {
-
-    @Excel(name = "病历等级", width = 30, orderNum = "1")
-    private String level;
-
-    @Excel(name = "病历得分", width = 30, orderNum = "2")
-    private Double scoreRes;
-
-    @Excel(name = "病案首页得分", width = 30, orderNum = "4")
-    private Double scoreBn;
-
-    @Excel(name = "病人住院序号", width = 40, orderNum = "3")
-    private String behospitalCode;
-
-    @Excel(name = "病案号", width = 30, orderNum = "5")
-    private String fileCode;
-
-    @Excel(name = "病人姓名", width = 30, orderNum = "6")
-    private String name;
-
-    @Excel(name = "性别", width = 20, orderNum = "7")
-    private String sex;
-
-    @Excel(name = "年龄", width = 20, orderNum = "8")
-    private String age;
-
-    @Excel(name = "床号", width = 30, orderNum = "9")
-    private String bedCode;
-
-    @Excel(name = "入院日期", format = "yyyy-MM-dd HH:mm:ss", width = 30, orderNum = "10")
-    private Date behospitalDate;
-
-    @Excel(name = "出院日期", format = "yyyy-MM-dd HH:mm:ss", width = 30, orderNum = "11")
-    private Date leaveHospitalDate;
-
-    @Excel(name = "归档日期", format = "yyyy-MM-dd HH:mm:ss", width = 30, orderNum = "12")
-    private Date placefileDate;
-
-    @Excel(name = "主诊断", width = 60, orderNum = "13")
-    private String diagnose;
-
-    @Excel(name = "住院医生", width = 30, orderNum = "14")
-    private String behDoctorName;
-
-    @Excel(name = "主管医生", width = 30, orderNum = "15")
-    private String doctorName;
-
-    @Excel(name = "主任医生", width = 30, orderNum = "16")
-    private String directorDoctorName;
-
-    @Excel(name = "科室", width = 70, orderNum = "17")
-    private String behDeptName;
-
-    @Excel(name = "评分时间", format = "yyyy-MM-dd HH:mm:ss", width = 30, orderNum = "18")
-    private Date gradeTime;
-}

+ 43 - 17
src/main/java/com/diagbot/facade/ConsoleByDoctorFacade.java

@@ -3,6 +3,7 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.DoctorAverageLevelDTO;
 import com.diagbot.dto.DoctorAverageStatisticsDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.GetDetailRecordListPageDTO;
 import com.diagbot.dto.GetDoctorDetailPageDTO;
 import com.diagbot.exception.CommonErrorCode;
@@ -16,6 +17,8 @@ import com.diagbot.vo.GetDoctorDetailPageVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description:控制台(医生)统计相关处理
  * @Author:songxl
@@ -51,16 +54,16 @@ public class ConsoleByDoctorFacade {
      */
     private void transformParam(DoctorAverageStatisticsVO doctorAverageStatisticsVO) {
 
-        if("-".equals(doctorAverageStatisticsVO.getDeptId())){
+        if ("-".equals(doctorAverageStatisticsVO.getDeptId())) {
             doctorAverageStatisticsVO.setDeptId("-0");
         }
-        if("-".equals(doctorAverageStatisticsVO.getDeptName())){
+        if ("-".equals(doctorAverageStatisticsVO.getDeptName())) {
             doctorAverageStatisticsVO.setDeptName("-0");
         }
-        if("-".equals(doctorAverageStatisticsVO.getDoctorId())){
+        if ("-".equals(doctorAverageStatisticsVO.getDoctorId())) {
             doctorAverageStatisticsVO.setDoctorId("-0");
         }
-        if("-".equals(doctorAverageStatisticsVO.getDoctorName())){
+        if ("-".equals(doctorAverageStatisticsVO.getDoctorName())) {
             doctorAverageStatisticsVO.setDoctorName("-0");
         }
     }
@@ -77,7 +80,6 @@ public class ConsoleByDoctorFacade {
     }
 
 
-
     private void doctorAverageLevelPageSet(DoctorAverageLevelVO doctorAverageLevelVO) {
         //入参验证
         //入院时间
@@ -107,16 +109,16 @@ public class ConsoleByDoctorFacade {
         doctorAverageLevelVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
 
         //医生、科室为空时参数替换
-        if("-".equals(doctorAverageLevelVO.getDeptId())){
+        if ("-".equals(doctorAverageLevelVO.getDeptId())) {
             doctorAverageLevelVO.setDeptId("-0");
         }
-        if("-".equals(doctorAverageLevelVO.getDeptName())){
+        if ("-".equals(doctorAverageLevelVO.getDeptName())) {
             doctorAverageLevelVO.setDeptName("-0");
         }
-        if("-".equals(doctorAverageLevelVO.getDoctorCode())){
+        if ("-".equals(doctorAverageLevelVO.getDoctorCode())) {
             doctorAverageLevelVO.setDoctorCode("-0");
         }
-        if("-".equals(doctorAverageLevelVO.getDoctorName())){
+        if ("-".equals(doctorAverageLevelVO.getDoctorName())) {
             doctorAverageLevelVO.setDoctorName("-0");
         }
     }
@@ -128,16 +130,16 @@ public class ConsoleByDoctorFacade {
      * @return
      */
     public IPage<GetDoctorDetailPageDTO> getDoctorDetailPage(GetDoctorDetailPageVO getDoctorDetailPageVO) {
-        if("-".equals(getDoctorDetailPageVO.getDeptId())){
+        if ("-".equals(getDoctorDetailPageVO.getDeptId())) {
             getDoctorDetailPageVO.setDeptId("-0");
         }
-        if("-".equals(getDoctorDetailPageVO.getDeptName())){
+        if ("-".equals(getDoctorDetailPageVO.getDeptName())) {
             getDoctorDetailPageVO.setDeptName("-0");
         }
-        if("-".equals(getDoctorDetailPageVO.getDoctorId())){
+        if ("-".equals(getDoctorDetailPageVO.getDoctorId())) {
             getDoctorDetailPageVO.setDoctorId("-0");
         }
-        if("-".equals(getDoctorDetailPageVO.getDoctorName())){
+        if ("-".equals(getDoctorDetailPageVO.getDoctorName())) {
             getDoctorDetailPageVO.setDoctorName("-0");
         }
         getDoctorDetailPageVO.setHospitalId(SysUserUtils.getCurrentHospitalID());
@@ -152,16 +154,16 @@ public class ConsoleByDoctorFacade {
      * @return
      */
     public IPage<GetDetailRecordListPageDTO> getDetailRecordListPage(GetDetailRecordListPageVO getDetailRecordListPageVO) {
-        if("-".equals(getDetailRecordListPageVO.getDeptId())){
+        if ("-".equals(getDetailRecordListPageVO.getDeptId())) {
             getDetailRecordListPageVO.setDeptId("-0");
         }
-        if("-".equals(getDetailRecordListPageVO.getDeptName())){
+        if ("-".equals(getDetailRecordListPageVO.getDeptName())) {
             getDetailRecordListPageVO.setDeptName("-0");
         }
-        if("-".equals(getDetailRecordListPageVO.getDoctorId())){
+        if ("-".equals(getDetailRecordListPageVO.getDoctorId())) {
             getDetailRecordListPageVO.setDoctorId("-0");
         }
-        if("-".equals(getDetailRecordListPageVO.getDoctorName())){
+        if ("-".equals(getDetailRecordListPageVO.getDoctorName())) {
             getDetailRecordListPageVO.setDoctorName("-0");
         }
         getDetailRecordListPageVO.setHospitalId(SysUserUtils.getCurrentHospitalID());
@@ -169,4 +171,28 @@ public class ConsoleByDoctorFacade {
         return detailPageList;
     }
 
+    /**
+     * 导出缺陷数量对应的病历
+     *
+     * @param getDetailRecordListPageVO
+     * @return
+     */
+    public List<ExportExcelDTO> getDetailRecordListExport(GetDetailRecordListPageVO getDetailRecordListPageVO) {
+        if ("-".equals(getDetailRecordListPageVO.getDeptId())) {
+            getDetailRecordListPageVO.setDeptId("-0");
+        }
+        if ("-".equals(getDetailRecordListPageVO.getDeptName())) {
+            getDetailRecordListPageVO.setDeptName("-0");
+        }
+        if ("-".equals(getDetailRecordListPageVO.getDoctorId())) {
+            getDetailRecordListPageVO.setDoctorId("-0");
+        }
+        if ("-".equals(getDetailRecordListPageVO.getDoctorName())) {
+            getDetailRecordListPageVO.setDoctorName("-0");
+        }
+        getDetailRecordListPageVO.setHospitalId(SysUserUtils.getCurrentHospitalID());
+        List<ExportExcelDTO> detailPageList = behospitalInfoFacade.getBaseMapper().getDetailRecordListExport(getDetailRecordListPageVO);
+        return detailPageList;
+    }
+
 }

+ 2 - 3
src/main/java/com/diagbot/facade/ConsoleExportFacade.java

@@ -945,10 +945,9 @@ public class ConsoleExportFacade {
         }
         getDetailRecordListPageVO.setSize(Long.MAX_VALUE);
         //1.查询
-        IPage<GetDetailRecordListPageDTO> detailRecordListPage = consoleByDoctorFacade.getDetailRecordListPage(getDetailRecordListPageVO);
-        List<ExportGetDetailRecordListPageDTO> records = BeanUtil.listCopyTo(detailRecordListPage.getRecords(), ExportGetDetailRecordListPageDTO.class);
+        List<ExportExcelDTO> detailRecordListExport = consoleByDoctorFacade.getDetailRecordListExport(getDetailRecordListPageVO);
         String fileName = "缺陷病历信息.xls";
         response.setContentType("text/html;charset=UTF-8");
-        ExcelUtils.exportExcelUser(records, null, "sheet1", ExportGetDetailRecordListPageDTO.class, fileName, response);
+        ExcelUtils.exportExcelUser(detailRecordListExport, null, "sheet1", ExportExcelDTO.class, fileName, response);
     }
 }

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

@@ -826,4 +826,12 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      */
     public IPage<GetDetailRecordListPageDTO> getDetailRecordListPage(@Param("getDetailRecordListPageVO") GetDetailRecordListPageVO getDetailRecordListPageVO);
 
+    /**
+     * 导出缺陷数量对应的病历
+     *
+     * @param getDetailRecordListPageVO
+     * @return
+     */
+    public List<ExportExcelDTO> getDetailRecordListExport(@Param("getDetailRecordListPageVO") GetDetailRecordListPageVO getDetailRecordListPageVO);
+
 }

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

@@ -20807,4 +20807,556 @@
         </if>
     </select>
 
+    <!-- 条目缺陷评分详情页导出-->
+    <select id="getDetailRecordListExport" resultMap="ExportExcelMap">
+        SELECT * from(
+        SELECT
+        f1.*,
+        f2.avgScore
+        FROM
+        (SELECT
+        t.*,
+        qi.score_res AS score,
+        qd.msg AS msg,
+        qc.NAME AS caseName
+        FROM
+        (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.scoreBn AS scoreBn,
+        t1.NAME AS patName,
+        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 AS diagnose,
+        t1.ward_name AS wardName,
+        t1.file_code AS fileCode,
+        t1.checkStatus AS checkStatus,
+        t1.mrStatus AS mrStatus,
+        t1.chName AS chName,
+        t1.mrName AS mrName,
+        t1.chTime AS chTime,
+        t1.mrTime AS mrTime
+        FROM
+        (
+        SELECT DISTINCT
+        tt1.*
+        FROM
+        (SELECT
+        be.*,
+        ifnull(mci.status,0) AS checkStatus,
+        ifnull(hm_mci.status,0) AS mrStatus,
+        mci.check_name as chName,
+        hm_mci.check_name as mrName,
+        mci.gmt_create as chTime,
+        e.score_res as scoreBn,
+        hm_mci.gmt_create as mrTime
+        FROM
+        (
+        SELECT DISTINCT
+        a.hospital_id,
+        a.behospital_code,
+        a.bed_code,
+        a.file_code,
+        b.LEVEL,
+        b.grade_type,
+        b.score_res,
+        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,
+        b.gmt_create
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c,
+        qc_cases_entry d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        AND a.qc_type_id != 0
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile != ''">
+            and a.is_placefile = #{getDetailRecordListPageVO.isPlacefile}
+        </if>
+        <if test="getDetailRecordListPageVO.hospitalId != null and getDetailRecordListPageVO.hospitalId != ''">
+            AND a.hospital_id = #{getDetailRecordListPageVO.hospitalId}
+        </if>
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 0">
+            <if test="getDetailRecordListPageVO.startDate != null ">
+                <![CDATA[ AND a.behospital_date >= #{getDetailRecordListPageVO.startDate}]]>
+            </if>
+            <if test="getDetailRecordListPageVO.endDate != null ">
+                <![CDATA[ AND a.behospital_date <= #{getDetailRecordListPageVO.endDate}]]>
+            </if>
+        </if>
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 1">
+            <if test="getDetailRecordListPageVO.startDate != null ">
+                <![CDATA[ AND a.leave_hospital_date >= #{getDetailRecordListPageVO.startDate}]]>
+            </if>
+            <if test="getDetailRecordListPageVO.endDate != null">
+                <![CDATA[ AND a.leave_hospital_date <= #{getDetailRecordListPageVO.endDate}]]>
+            </if>
+        </if>
+        <if test="getDetailRecordListPageVO.diagnose != null and getDetailRecordListPageVO.diagnose != ''">
+            AND a.diagnose LIKE CONCAT( '%', #{getDetailRecordListPageVO.diagnose}, '%' )
+        </if>
+        <if test="getDetailRecordListPageVO.level != null and getDetailRecordListPageVO.level != ''">
+            AND b.`level` = #{getDetailRecordListPageVO.level}
+        </if>
+        <if test="getDetailRecordListPageVO.behospitalCode != null and getDetailRecordListPageVO.behospitalCode != ''">
+            AND a.behospital_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.behospitalCode}, '%' )
+        </if>
+        <if test="getDetailRecordListPageVO.patName != null and getDetailRecordListPageVO.patName != ''">
+            AND a.NAME LIKE CONCAT( '%', #{getDetailRecordListPageVO.patName}, '%' )
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
+            AND d.NAME = #{getDetailRecordListPageVO.casesEntryName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null ">
+            AND d.id = #{getDetailRecordListPageVO.casesEntryId}
+        </if>
+        <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
+            AND d.cases_name = #{getDetailRecordListPageVO.casesName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesId != null">
+            AND d.cases_id = #{getDetailRecordListPageVO.casesId}
+        </if>
+        <if test="getDetailRecordListPageVO.deptName != null and getDetailRecordListPageVO.deptName != '' and getDetailRecordListPageVO.deptName != '-0'">
+            AND a.beh_dept_name = #{getDetailRecordListPageVO.deptName}
+        </if>
+        <if test="getDetailRecordListPageVO.deptName == '-0'">
+            AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.deptId != null and getDetailRecordListPageVO.deptId != '' and getDetailRecordListPageVO.deptId != '-0'">
+            AND a.beh_dept_id = #{getDetailRecordListPageVO.deptId}
+        </if>
+        <if test="getDetailRecordListPageVO.deptId == '-0'">
+            AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.doctorId != null and getDetailRecordListPageVO.doctorId != '' and getDetailRecordListPageVO.doctorId != '-0'">
+            AND a.doctor_id = #{getDetailRecordListPageVO.doctorId}
+        </if>
+        <if test="getDetailRecordListPageVO.doctorId == '-0'">
+            AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.doctorName != null and getDetailRecordListPageVO.doctorName != '' and getDetailRecordListPageVO.doctorName != '-0' ">
+            AND a.doctor_name =  #{getDetailRecordListPageVO.doctorName}
+        </if>
+        <if test="getDetailRecordListPageVO.doctorName == '-0'">
+            AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.isReject != null">
+            AND c.is_reject = #{getDetailRecordListPageVO.isReject}
+        </if>
+        <if test="getDetailRecordListPageVO.ruleType != null">
+            AND d.rule_type = #{getDetailRecordListPageVO.ruleType}
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2495">
+            AND TIMESTAMPDIFF(
+            DAY,
+            DATE( a.behospital_date ),
+            DATE( a.leave_hospital_date ))> 30
+        </if>
+        <if test="getDetailRecordListPageVO.beHosGT31Days != null and getDetailRecordListPageVO.beHosGT31Days==1">
+            AND TIMESTAMPDIFF(
+            DAY,
+            DATE( a.behospital_date ),
+            DATE( a.leave_hospital_date ))> 31
+        </if>
+        )be
+        left join med_check_info mci
+        on mci.is_deleted = 'N'
+        and mci.check_type in(0,2)
+        and be.hospital_id = mci.hospital_id
+        and be.behospital_code = mci.behospital_code
+        left join med_check_info hm_mci
+        on hm_mci.is_deleted = 'N'
+        and hm_mci.check_type = 1
+        and be.hospital_id = hm_mci.hospital_id
+        and be.behospital_code = hm_mci.behospital_code
+        LEFT JOIN med_qcresult_cases e
+        on  be.behospital_code = e.behospital_code
+        and be.hospital_id = e.hospital_id
+        AND e.is_deleted = 'N'
+        and e.cases_id = 243
+        )tt1
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2511">
+            ,med_medical_record tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+            AND tt2.mode_id = 30
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2419">
+            ,med_crisis_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+        </if>
+        ) t1
+        <if test="getDetailRecordListPageVO.casesEntryId == null or (getDetailRecordListPageVO.casesEntryId!=2594  and getDetailRecordListPageVO.casesEntryId!=2973 and getDetailRecordListPageVO.casesEntryId!=2930)">
+            LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.is_deleted = 'N'
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and( getDetailRecordListPageVO.casesEntryId==2594  or getDetailRecordListPageVO.casesEntryId==2973 or getDetailRecordListPageVO.casesEntryId==2930)">
+            , med_home_page t2
+            , med_home_operation_info t3
+            WHERE t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.home_page_id = t3.home_page_id
+            AND t2.is_deleted = 'N'
+            AND t3.is_deleted = 'N'
+        </if>
+        ) t
+        LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
+        AND t.hospitalId = qi.hospital_id
+        AND t.behospitalCode = qi.behospital_code
+        LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
+        AND t.hospitalId = qd.hospital_id
+        AND t.behospitalCode = qd.behospital_code
+        LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
+        AND qd.cases_id = qc.id
+        LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
+        AND qd.cases_id = qce.cases_id
+        AND qd.cases_entry_id = qce.id
+        where 1=1
+        <if test="getDetailRecordListPageVO.checkStatus != null">
+            AND t.checkStatus = #{getDetailRecordListPageVO.checkStatus}
+        </if>
+        <if test="getDetailRecordListPageVO.mrStatus != null">
+            AND t.mrStatus = #{getDetailRecordListPageVO.mrStatus}
+        </if>
+        <if test="getDetailRecordListPageVO.chName != null and getDetailRecordListPageVO.chName!=''">
+            AND t.chName like concat('%', #{getDetailRecordListPageVO.chName}, '%')
+        </if>
+        <if test="getDetailRecordListPageVO.mrName != null and getDetailRecordListPageVO.mrName!=''">
+            AND t.mrName like concat('%', #{getDetailRecordListPageVO.mrName}, '%')
+        </if>
+        <if test="getDetailRecordListPageVO.chTimeStart != null ">
+            <![CDATA[ AND t.chTime >= #{getDetailRecordListPageVO.chTimeStart}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.chTimeEnd != null ">
+            <![CDATA[ AND t.chTime <= #{getDetailRecordListPageVO.chTimeEnd}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.mrTimeStart != null ">
+            <![CDATA[ AND t.mrTime >= #{getDetailRecordListPageVO.mrTimeStart}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.mrTimeEnd != null ">
+            <![CDATA[ AND t.mrTime <= #{getDetailRecordListPageVO.mrTimeEnd}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
+            AND qce.NAME = #{getDetailRecordListPageVO.casesEntryName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null ">
+            AND qce.id = #{getDetailRecordListPageVO.casesEntryId}
+        </if>
+        <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
+            AND qce.cases_name = #{getDetailRecordListPageVO.casesName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesId != null">
+            AND qce.cases_id = #{getDetailRecordListPageVO.casesId}
+        </if>
+        )f1,
+        (SELECT
+        ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
+        t.behDeptId,
+        t.behDeptName
+        FROM
+        (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,
+        t1.file_code AS fileCode,
+        t1.checkStatus,
+        t1.mrStatus,
+        t1.chName,
+        t1.mrName,
+        t1.chTime,
+        t1.mrTime
+        FROM
+        (
+        SELECT DISTINCT
+        tt1.*
+        FROM
+        (SELECT
+        be.*,
+        ifnull(mci.status,0) AS checkStatus,
+        ifnull(hm_mci.status,0) AS mrStatus,
+        mci.check_name as chName,
+        hm_mci.check_name as mrName,
+        mci.gmt_create as chTime,
+        hm_mci.gmt_create as mrTime
+        FROM
+        (
+        SELECT DISTINCT
+        a.hospital_id,
+        a.behospital_code,
+        a.bed_code,
+        a.file_code,
+        b.LEVEL,
+        b.grade_type,
+        b.score_res,
+        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,
+        b.gmt_create
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c,
+        qc_cases_entry d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        AND a.qc_type_id != 0
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile != ''">
+            and a.is_placefile = #{getDetailRecordListPageVO.isPlacefile}
+        </if>
+        <if test="getDetailRecordListPageVO.hospitalId != null and getDetailRecordListPageVO.hospitalId != ''">
+            AND a.hospital_id = #{getDetailRecordListPageVO.hospitalId}
+        </if>
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 0">
+            <if test="getDetailRecordListPageVO.startDate != null ">
+                <![CDATA[ AND a.behospital_date >= #{getDetailRecordListPageVO.startDate}]]>
+            </if>
+            <if test="getDetailRecordListPageVO.endDate != null ">
+                <![CDATA[ AND a.behospital_date <= #{getDetailRecordListPageVO.endDate}]]>
+            </if>
+        </if>
+        <if test="getDetailRecordListPageVO.isPlacefile != null and getDetailRecordListPageVO.isPlacefile == 1">
+            <if test="getDetailRecordListPageVO.startDate != null ">
+                <![CDATA[ AND a.leave_hospital_date >= #{getDetailRecordListPageVO.startDate}]]>
+            </if>
+            <if test="getDetailRecordListPageVO.endDate != null">
+                <![CDATA[ AND a.leave_hospital_date <= #{getDetailRecordListPageVO.endDate}]]>
+            </if>
+        </if>
+        <if test="getDetailRecordListPageVO.diagnose != null and getDetailRecordListPageVO.diagnose != ''">
+            AND a.diagnose LIKE CONCAT( '%', #{getDetailRecordListPageVO.diagnose}, '%' )
+        </if>
+
+        <if test="getDetailRecordListPageVO.level != null and getDetailRecordListPageVO.level != ''">
+            AND b.`level` = #{getDetailRecordListPageVO.level}
+        </if>
+        <if test="getDetailRecordListPageVO.behospitalCode != null and getDetailRecordListPageVO.behospitalCode != ''">
+            AND a.behospital_code LIKE CONCAT( '%', #{getDetailRecordListPageVO.behospitalCode}, '%' )
+        </if>
+        <if test="getDetailRecordListPageVO.patName != null and getDetailRecordListPageVO.patName != ''">
+            AND a.NAME LIKE CONCAT( '%', #{getDetailRecordListPageVO.patName}, '%' )
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryName != null and getDetailRecordListPageVO.casesEntryName != ''">
+            AND d.NAME = #{getDetailRecordListPageVO.casesEntryName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null ">
+            AND d.id = #{getDetailRecordListPageVO.casesEntryId}
+        </if>
+        <if test="getDetailRecordListPageVO.casesName != null and getDetailRecordListPageVO.casesName != ''">
+            AND d.cases_name = #{getDetailRecordListPageVO.casesName}
+        </if>
+        <if test="getDetailRecordListPageVO.casesId != null">
+            AND d.cases_id = #{getDetailRecordListPageVO.casesId}
+        </if>
+        <if test="getDetailRecordListPageVO.deptName != null and getDetailRecordListPageVO.deptName != '' and getDetailRecordListPageVO.deptName != '-0'">
+            AND a.beh_dept_name = #{getDetailRecordListPageVO.deptName}
+        </if>
+        <if test="getDetailRecordListPageVO.deptName == '-0'">
+            AND (a.beh_dept_name IS NULL OR a.beh_dept_name = '' OR a.beh_dept_name = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.deptId != null and getDetailRecordListPageVO.deptId != '' and getDetailRecordListPageVO.deptId != '-0'">
+            AND a.beh_dept_id = #{getDetailRecordListPageVO.deptId}
+        </if>
+        <if test="getDetailRecordListPageVO.deptId == '-0'">
+            AND (a.beh_dept_id IS NULL OR a.beh_dept_id = '' OR a.beh_dept_id = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.doctorId != null and getDetailRecordListPageVO.doctorId != '' and getDetailRecordListPageVO.doctorId != '-0'">
+            AND a.doctor_id = #{getDetailRecordListPageVO.doctorId}
+        </if>
+        <if test="getDetailRecordListPageVO.doctorId == '-0'">
+            AND (a.doctor_id IS NULL OR a.doctor_id = '' OR a.doctor_id = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.doctorName != null and getDetailRecordListPageVO.doctorName != '' and getDetailRecordListPageVO.doctorName != '-0' ">
+            AND a.doctor_name =  #{getDetailRecordListPageVO.doctorName}
+        </if>
+        <if test="getDetailRecordListPageVO.doctorName == '-0'">
+            AND (a.doctor_name IS NULL OR a.doctor_name = '' OR a.doctor_name = '-')
+        </if>
+        <if test="getDetailRecordListPageVO.isReject != null">
+            AND c.is_reject = #{getDetailRecordListPageVO.isReject}
+        </if>
+        <if test="getDetailRecordListPageVO.ruleType != null">
+            AND d.rule_type = #{getDetailRecordListPageVO.ruleType}
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2495">
+            AND TIMESTAMPDIFF(
+            DAY,
+            DATE( a.behospital_date ),
+            DATE( a.leave_hospital_date ))> 30
+        </if>
+        <if test="getDetailRecordListPageVO.beHosGT31Days != null and getDetailRecordListPageVO.beHosGT31Days==1">
+            AND TIMESTAMPDIFF(
+            DAY,
+            DATE( a.behospital_date ),
+            DATE( a.leave_hospital_date ))> 31
+        </if>
+        )be
+        left join med_check_info mci
+        on mci.is_deleted = 'N'
+        and mci.check_type in(0,2)
+        and be.hospital_id = mci.hospital_id
+        and be.behospital_code = mci.behospital_code
+        left join med_check_info hm_mci
+        on hm_mci.is_deleted = 'N'
+        and hm_mci.check_type = 1
+        and be.hospital_id = hm_mci.hospital_id
+        and be.behospital_code = hm_mci.behospital_code
+        )tt1
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2511">
+            ,med_medical_record tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+            AND tt2.mode_id = 30
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and getDetailRecordListPageVO.casesEntryId==2419">
+            ,med_crisis_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+        </if>
+        ) t1
+        <if test="getDetailRecordListPageVO.casesEntryId == null or (getDetailRecordListPageVO.casesEntryId!=2594  and getDetailRecordListPageVO.casesEntryId!=2973 and getDetailRecordListPageVO.casesEntryId!=2930)">
+            LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.is_deleted = 'N'
+        </if>
+        <if test="getDetailRecordListPageVO.casesEntryId != null and( getDetailRecordListPageVO.casesEntryId==2594  or getDetailRecordListPageVO.casesEntryId==2973 or getDetailRecordListPageVO.casesEntryId==2930)">
+            , med_home_page t2
+            , med_home_operation_info t3
+            WHERE t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.home_page_id = t3.home_page_id
+            AND t2.is_deleted = 'N'
+            AND t3.is_deleted = 'N'
+        </if>
+        ) t
+        LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
+        AND t.hospitalId = qi.hospital_id
+        AND t.behospitalCode = qi.behospital_code
+        where 1=1
+        <if test="getDetailRecordListPageVO.checkStatus != null">
+            AND t.checkStatus = #{getDetailRecordListPageVO.checkStatus}
+        </if>
+        <if test="getDetailRecordListPageVO.mrStatus != null">
+            AND t.mrStatus = #{getDetailRecordListPageVO.mrStatus}
+        </if>
+        <if test="getDetailRecordListPageVO.chName != null and getDetailRecordListPageVO.chName!=''">
+            AND t.chName like concat('%', #{getDetailRecordListPageVO.chName}, '%')
+        </if>
+        <if test="getDetailRecordListPageVO.mrName != null and getDetailRecordListPageVO.mrName!=''">
+            AND t.mrName like concat('%', #{getDetailRecordListPageVO.mrName}, '%')
+        </if>
+        <if test="getDetailRecordListPageVO.chTimeStart != null ">
+            <![CDATA[ AND t.chTime >= #{getDetailRecordListPageVO.chTimeStart}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.chTimeEnd != null ">
+            <![CDATA[ AND t.chTime <= #{getDetailRecordListPageVO.chTimeEnd}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.mrTimeStart != null ">
+            <![CDATA[ AND t.mrTime >= #{getDetailRecordListPageVO.mrTimeStart}]]>
+        </if>
+        <if test="getDetailRecordListPageVO.mrTimeEnd != null ">
+            <![CDATA[ AND t.mrTime <= #{getDetailRecordListPageVO.mrTimeEnd}]]>
+        </if>
+        GROUP BY
+        t.behDeptId,
+        t.behDeptName
+        )f2
+        WHERE
+        f1.behDeptId = f2.behDeptId
+        AND f1.behDeptName = f2.behDeptName
+        )m
+    </select>
+
 </mapper>