浏览代码

缺陷列表sql调整

chengyao 3 年之前
父节点
当前提交
25ee0a9e27
共有 1 个文件被更改,包括 37 次插入75 次删除
  1. 37 75
      dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

+ 37 - 75
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -3951,20 +3951,13 @@
         b.gmt_create
         FROM
         med_behospital_info a,
-        med_qcresult_info b,
-        med_qcresult_detail c,
-        qc_cases_entry d
+        med_qcresult_report b
         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 b.cases_id is not null
         AND a.qc_type_id != 0
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
@@ -4004,16 +3997,16 @@
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
         <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
+            AND b.msg = #{qcResultShortPageVO.casesEntryName}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
+            AND b.cases_entry_id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
-            AND d.cases_name = #{qcResultShortPageVO.casesName}
+            AND b.cases_name = #{qcResultShortPageVO.casesName}
         </if>
         <if test="qcResultShortPageVO.casesId != null">
-            AND d.cases_id = #{qcResultShortPageVO.casesId}
+            AND b.cases_id = #{qcResultShortPageVO.casesId}
         </if>
         <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
             AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
@@ -4026,10 +4019,10 @@
             OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
         </if>
         <if test="qcResultShortPageVO.isReject != null">
-            AND c.is_reject = #{qcResultShortPageVO.isReject}
+            AND b.is_reject = #{qcResultShortPageVO.isReject}
         </if>
         <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
+            AND b.rule_type = #{qcResultShortPageVO.ruleType}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
             AND TIMESTAMPDIFF(
@@ -4359,9 +4352,8 @@
         FROM
         (SELECT
         t.*,
-        qi.score_res AS score,
-        qd.msg AS msg,
-        qc.NAME AS caseName
+        tt.msg AS msg,
+        tt.cases_name AS caseName
         FROM
         (SELECT DISTINCT
         t1.hospital_id AS hospitalId,
@@ -4369,7 +4361,7 @@
         t1.bed_code AS bedCode,
         t1.LEVEL AS LEVEL,
         t1.grade_type AS gradeType,
-        t1.score_res AS scoreRes,
+        t1.score_res AS score,
         t1.scoreBn AS scoreBn,
         t1.NAME AS patName,
         t1.sex AS sex,
@@ -4407,7 +4399,6 @@
         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
         (
@@ -4419,6 +4410,7 @@
         b.LEVEL,
         b.grade_type,
         b.score_res,
+        b.home_page_score as scoreBn,
         a.NAME,
         a.sex,
         a.beh_dept_id,
@@ -4438,20 +4430,13 @@
         b.gmt_create
         FROM
         med_behospital_info a,
-        med_qcresult_info b,
-        med_qcresult_detail c,
-        qc_cases_entry d
+        med_qcresult_report b
         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 b.cases_id is not null
         AND a.qc_type_id != 0
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
@@ -4491,16 +4476,16 @@
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
         <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
+            AND b.msg = #{qcResultShortPageVO.casesEntryName}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
+            AND b.cases_entry_id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
-            AND d.cases_name = #{qcResultShortPageVO.casesName}
+            AND b.cases_name = #{qcResultShortPageVO.casesName}
         </if>
         <if test="qcResultShortPageVO.casesId != null">
-            AND d.cases_id = #{qcResultShortPageVO.casesId}
+            AND b.cases_id = #{qcResultShortPageVO.casesId}
         </if>
         <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
             AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
@@ -4513,10 +4498,10 @@
             OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
         </if>
         <if test="qcResultShortPageVO.isReject != null">
-            AND c.is_reject = #{qcResultShortPageVO.isReject}
+            AND b.is_reject = #{qcResultShortPageVO.isReject}
         </if>
         <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
+            AND b.rule_type = #{qcResultShortPageVO.ruleType}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
             AND TIMESTAMPDIFF(
@@ -4541,11 +4526,6 @@
         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="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
             ,med_medical_record tt2
@@ -4578,17 +4558,9 @@
             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
+        LEFT JOIN 	med_qcresult_report tt ON tt.is_deleted = 'N'
+        AND t.hospitalId = tt.hospital_id
+        AND t.behospitalCode = tt.behospital_code
         where 1=1
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
@@ -4615,20 +4587,20 @@
             <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
         </if>
         <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
+            AND tt.msg = #{qcResultShortPageVO.casesEntryName}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND qce.id = #{qcResultShortPageVO.casesEntryId}
+            AND tt.cases_entry_id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
-            AND qce.cases_name = #{qcResultShortPageVO.casesName}
+            AND tt.cases_name = #{qcResultShortPageVO.casesName}
         </if>
         <if test="qcResultShortPageVO.casesId != null">
-            AND qce.cases_id = #{qcResultShortPageVO.casesId}
+            AND tt.cases_id = #{qcResultShortPageVO.casesId}
         </if>
         )f1,
         (SELECT
-        ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
+        ROUND( AVG( t.scoreRes ), 2 ) AS avgScore,
         t.behDeptId,
         t.behDeptName
         FROM
@@ -4706,20 +4678,13 @@
         b.gmt_create
         FROM
         med_behospital_info a,
-        med_qcresult_info b,
-        med_qcresult_detail c,
-        qc_cases_entry d
+        med_qcresult_report b
         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 b.cases_id is not null
         AND a.qc_type_id != 0
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
@@ -4759,16 +4724,16 @@
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
         <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
+            AND b.msg = #{qcResultShortPageVO.casesEntryName}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
+            AND b.cases_entry_id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
-            AND d.cases_name = #{qcResultShortPageVO.casesName}
+            AND b.cases_name = #{qcResultShortPageVO.casesName}
         </if>
         <if test="qcResultShortPageVO.casesId != null">
-            AND d.cases_id = #{qcResultShortPageVO.casesId}
+            AND b.cases_id = #{qcResultShortPageVO.casesId}
         </if>
         <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
             AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
@@ -4781,10 +4746,10 @@
             OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
         </if>
         <if test="qcResultShortPageVO.isReject != null">
-            AND c.is_reject = #{qcResultShortPageVO.isReject}
+            AND b.is_reject = #{qcResultShortPageVO.isReject}
         </if>
         <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
+            AND b.rule_type = #{qcResultShortPageVO.ruleType}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
             AND TIMESTAMPDIFF(
@@ -4841,9 +4806,6 @@
             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="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
@@ -4868,7 +4830,7 @@
         </if>
         <if test="qcResultShortPageVO.mrTimeEnd != null ">
             <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
-        </if>
+        </if>qcCheckMRPage
         GROUP BY
         t.behDeptId,
         t.behDeptName