Browse Source

关键条目缺陷占比

zhaops 5 years ago
parent
commit
2beceb6ab4
1 changed files with 48 additions and 27 deletions
  1. 48 27
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 48 - 27
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -3101,32 +3101,36 @@
         ) UNION
         (
         SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
+        c.beh_dept_id AS deptId,
+        c.beh_dept_name AS deptName,
         0 AS consultationNum,
         0 AS consultationMRNum,
-        sum( c.cases_entry_id = 2594 ) AS operationNameNum,
-        sum( c.cases_entry_id = 2973 ) AS operationTimeNum,
-        sum( c.cases_entry_id = 2166 ) AS operation15MinuteNum,
-        count( DISTINCT a.behospital_code ) AS operationMRNum,
+        sum( d.cases_entry_id = 2594 ) AS operationNameNum,
+        sum( d.cases_entry_id = 2973 ) AS operationTimeNum,
+        sum( d.cases_entry_id = 2166 ) AS operation15MinuteNum,
+        count( DISTINCT c.behospital_code ) AS operationMRNum,
         0 AS crisisNum,
         0 AS crisisMRNum,
         0 AS stageSummaryNum,
         0 AS stageSummaryMRNum
         FROM
+        (
+        SELECT DISTINCT
+        a.hospital_id,
+        a.behospital_code,
+        a.beh_dept_name,
+        a.beh_dept_id
+        FROM
         med_behospital_info a,
-        med_home_page b,
-        med_qcresult_detail c
+        med_medical_record b
         WHERE
         a.is_deleted = 'N'
         AND b.is_deleted = 'N'
-        AND c.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 b.mode_id = 17
         AND a.is_placefile = '1'
-        AND a.qc_type_id !=0
+        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -3139,9 +3143,15 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
+        ) c,
+        med_qcresult_detail d
+        WHERE
+        d.is_deleted = 'N'
+        AND c.hospital_id = d.hospital_id
+        AND c.behospital_code = d.behospital_code
         GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name
+        c.beh_dept_id,
+        c.beh_dept_name
         ) UNION
         (
         SELECT
@@ -3166,12 +3176,13 @@
         a.beh_dept_id
         FROM
         med_behospital_info a,
-        med_crisis_info b
+        med_medical_record b
         WHERE
         a.is_deleted = 'N'
         AND b.is_deleted = 'N'
         AND a.hospital_id = b.hospital_id
         AND a.behospital_code = b.behospital_code
+        AND b.mode_id = 23
         AND a.is_placefile = '1'
         AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
@@ -3198,8 +3209,8 @@
         ) UNION
         (
         SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
+        c.beh_dept_id AS deptId,
+        c.beh_dept_name AS deptName,
         0 AS consultationNum,
         0 AS consultationMRNum,
         0 AS operationNameNum,
@@ -3208,22 +3219,26 @@
         0 AS operationMRNum,
         0 AS crisisNum,
         0 AS crisisMRNum,
-        sum( b.cases_entry_id = 2495 ) AS stageSummaryNum,
-        count( DISTINCT a.behospital_code ) AS stageSummaryMRNum
+        sum( d.cases_entry_id = 2495 ) AS stageSummaryNum,
+        count( DISTINCT c.behospital_code ) AS stageSummaryMRNum
+        FROM
+        (
+        SELECT DISTINCT
+        a.hospital_id,
+        a.behospital_code,
+        a.beh_dept_name,
+        a.beh_dept_id
         FROM
         med_behospital_info a,
-        med_qcresult_detail b
+        med_medical_record b
         WHERE
         a.is_deleted = 'N'
         AND b.is_deleted = 'N'
         AND a.hospital_id = b.hospital_id
         AND a.behospital_code = b.behospital_code
-        AND TIMESTAMPDIFF(
-        DAY,
-        DATE( behospital_date ),
-        DATE( leave_hospital_date ))> 30
+        AND b.mode_id = 23
         AND a.is_placefile = '1'
-        AND a.qc_type_id !=0
+        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -3236,9 +3251,15 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
+        ) c,
+        med_qcresult_detail d
+        WHERE
+        d.is_deleted = 'N'
+        AND c.hospital_id = d.hospital_id
+        AND c.behospital_code = d.behospital_code
         GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name
+        c.beh_dept_id,
+        c.beh_dept_name
         )
         ) tt
         GROUP BY