浏览代码

关键条目缺陷占比

zhaops 5 年之前
父节点
当前提交
4a243d00ed
共有 1 个文件被更改,包括 42 次插入24 次删除
  1. 42 24
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 42 - 24
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -3047,10 +3047,10 @@
         (
         (
         SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
-        sum( c.cases_entry_id = 2511 ) AS consultationNum,
-        count( DISTINCT a.behospital_code ) AS consultationMRNum,
+        c.beh_dept_id AS deptId,
+        c.beh_dept_name AS deptName,
+        sum( d.cases_entry_id = 2511 ) AS consultationNum,
+        count( DISTINCT c.behospital_code ) AS consultationMRNum,
         0 AS operationNameNum,
         0 AS operationTimeNum,
         0 AS operation15MinuteNum,
@@ -3060,20 +3060,23 @@
         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_medical_record 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 = 30
         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>
@@ -3086,9 +3089,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
@@ -3136,10 +3145,10 @@
         ) UNION
         (
         SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
-        sum( c.cases_entry_id = 2419 ) AS crisisNum,
-        count( DISTINCT a.behospital_code ) AS crisisMRNum,
+        c.beh_dept_id AS deptId,
+        c.beh_dept_name AS deptName,
+        sum( d.cases_entry_id = 2419 ) AS crisisNum,
+        count( DISTINCT c.behospital_code ) AS crisisMRNum,
         0 AS consultationNum,
         0 AS consultationMRNum,
         0 AS operationNameNum,
@@ -3149,19 +3158,22 @@
         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_crisis_info b,
-        med_qcresult_detail c
+        med_crisis_info 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 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>
@@ -3174,9 +3186,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