瀏覽代碼

出院人数统计质控详情页导出

zhaops 4 年之前
父節點
當前提交
5653aabbe2

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

@@ -8,6 +8,7 @@ import com.diagbot.dto.AverageStatisticsMonthDTO;
 import com.diagbot.dto.EntryNumDTO;
 import com.diagbot.dto.EntryNumGroupDTO;
 import com.diagbot.dto.EntryStatisticsDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.HomePageImproveDTO;
 import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
@@ -15,8 +16,11 @@ import com.diagbot.dto.LevelStatisticsTZDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.dto.QcResultShortDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.EntryStatisticsVO;
 import com.diagbot.vo.FilterOrderVO;
 import com.diagbot.vo.FilterPageByAverageVO;
@@ -26,6 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletResponse;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -40,6 +46,8 @@ public class ConsoleExportFacade {
     private ConsoleFacade consoleFacade;
     @Autowired
     private QcCasesFacade qcCasesFacade;
+    @Autowired
+    private BehospitalInfoFacade behospitalInfoFacade;
 
     /**
      * 病案首页合格率占比
@@ -217,12 +225,25 @@ public class ConsoleExportFacade {
      * @return
      */
     public void leaveHosMrPageExport(HttpServletResponse response, QcResultShortPageVO qcResultShortPageVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        qcResultShortPageVO.setHospitalId(hospitalId);
+        Date startDate = qcResultShortPageVO.getStartDate();
+        Date endDate = qcResultShortPageVO.getEndDate();
+        //时间间隔7天
+        long interval = 7 * 24 * 60 * 60 * 1000;
+        if (endDate.getTime() < startDate.getTime()) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "截止时间不能小于起始时间");
+        }
+        if (endDate.getTime() - startDate.getTime() > interval) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "统计区间不能大于7天");
+        }
+
         qcResultShortPageVO.setCurrent(1L);
         qcResultShortPageVO.setSize(Long.MAX_VALUE);
         qcResultShortPageVO.setSearchCount(false);
-        IPage<QcResultShortDTO> page = consoleFacade.leaveHosMRPage(qcResultShortPageVO);
+        List<ExportExcelDTO> records = behospitalInfoFacade.leaveHosMRPageExport(qcResultShortPageVO);
         String fileName = "出院人数统计.xls";
-        ExcelUtils.exportExcel(page.getRecords(), null, "sheet1", QcResultShortDTO.class, fileName, response, 12.8f);
+        ExcelUtils.exportExcel(records, null, "sheet1", ExportExcelDTO.class, fileName, response, 12.8f);
     }
 
     /**

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

@@ -311,4 +311,12 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      */
     public List<HomePageImproveDTO> qcCheckStatistics(FilterOrderVO filterOrderVO);
+
+    /**
+     * 离院病人质控评分详情页导出到excel
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public List<ExportExcelDTO> leaveHosMRPageExport(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO);
 }

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

@@ -304,4 +304,12 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @return
      */
     public List<HomePageImproveDTO> qcCheckStatistics(FilterOrderVO filterOrderVO);
+
+    /**
+     * 离院病人质控评分详情页导出到excel
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public List<ExportExcelDTO> leaveHosMRPageExport(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO);
 }

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

@@ -414,4 +414,14 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<HomePageImproveDTO> qcCheckStatistics(FilterOrderVO filterOrderVO) {
         return baseMapper.qcCheckStatistics(filterOrderVO);
     }
+
+    /**
+     * 离院病人质控评分详情页导出到excel
+     *
+     * @param qcResultShortPageVO
+     * @return
+     */
+    public List<ExportExcelDTO> leaveHosMRPageExport(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO) {
+        return baseMapper.leaveHosMRPageExport(qcResultShortPageVO);
+    }
 }

+ 381 - 2
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -3885,8 +3885,7 @@
         </if>
         ) be
         left join med_check_info mci
-        on
-        mci.is_deleted = 'N'
+        on mci.is_deleted = 'N'
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         )t1
@@ -4306,4 +4305,384 @@
             </choose>
         </if>
     </select>
+
+    <!-- 离院病人评分详情页导出-->
+    <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
+        SELECT
+        f1.behDeptId,
+        f1.behDeptName,
+        f1.behDoctorName,
+        f1.patName,
+        f1.behospitalCode,
+        f1.hospitalId,
+        f1.behospitalDate,
+        f1.leaveHospitalDate,
+        f1.score,
+        f2.avgScore,
+        f1.msg,
+        f1.caseName
+        FROM
+        (SELECT
+        CONCAT(
+        ( CASE WHEN t.directorDoctorName IS NOT NULL AND t.directorDoctorName != '' THEN concat( t.directorDoctorName,
+        '\n' ) ELSE '' END ),
+        t.doctorName
+        ) AS behDoctorName,
+        t.`name` AS patName,
+        t.behospitalCode AS behospitalCode,
+        t.behospitalDate AS behospitalDate,
+        t.leaveHospitalDate AS leaveHospitalDate,
+        qi.score_res AS score,
+        qd.msg AS msg,
+        qc.NAME AS caseName,
+        t.behDeptId,
+        t.behDeptName,
+        t.hospitalId,
+        t.checkStatus
+        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,
+        ifnull(t1.status,0) AS checkStatus,
+        t2.age,
+        t1.file_code AS fileCode
+        FROM
+        (
+        SELECT be.*,mci.status
+        FROM
+        (
+        SELECT DISTINCT
+        tt1.*
+        FROM
+        (
+        SELECT
+        b.*,
+        ifnull(c.LEVEL,'未评分') as 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,
+        a.file_code
+        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 >= #{qcResultShortPageVO.startDate}]]>
+        </if>
+        <if test="qcResultShortPageVO.endDate != null ">
+            <![CDATA[ AND a.leave_hospital_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
+        ) 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>
+        ) be
+        left join med_check_info mci
+        on mci.is_deleted = 'N'
+        AND be.hospital_id = mci.hospital_id
+        AND be.behospital_code = mci.behospital_code
+        )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">
+            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>
+        )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
+        where 1=1
+        <if test="qcResultShortPageVO.checkStatus != null">
+            and t.checkStatus = #{qcResultShortPageVO.checkStatus}
+        </if>
+        <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
+            AND t.`level` = #{qcResultShortPageVO.level}
+        </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,
+        ifnull(t1.status,0) AS checkStatus,
+        t2.age,
+        t1.file_code AS fileCode
+        FROM
+        (
+        SELECT be.*,mci.status
+        FROM
+        (
+        SELECT DISTINCT
+        tt1.*
+        FROM
+        (
+        SELECT
+        b.*,
+        ifnull(c.LEVEL,'未评分') as 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,
+        a.file_code
+        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 >= #{qcResultShortPageVO.startDate}]]>
+        </if>
+        <if test="qcResultShortPageVO.endDate != null ">
+            <![CDATA[ AND a.leave_hospital_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
+        ) 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>
+        ) be
+        left join med_check_info mci
+        on mci.is_deleted = 'N'
+        AND be.hospital_id = mci.hospital_id
+        AND be.behospital_code = mci.behospital_code
+        )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">
+            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>
+        )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="qcResultShortPageVO.checkStatus != null">
+            and t.checkStatus = #{qcResultShortPageVO.checkStatus}
+        </if>
+        <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
+            AND t.`level` = #{qcResultShortPageVO.level}
+        </if>
+        GROUP BY
+        t.behDeptId,
+        t.behDeptName
+        )f2
+        WHERE
+        f1.behDeptId = f2.behDeptId
+        AND f1.behDeptName = f2.behDeptName
+    </select>
 </mapper>