Pārlūkot izejas kodu

质控核查统计病历列表sql逻辑调整

chengyao 3 gadi atpakaļ
vecāks
revīzija
805937500b
1 mainītis faili ar 86 papildinājumiem un 15 dzēšanām
  1. 86 15
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 86 - 15
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -15129,7 +15129,7 @@
     <!-- 病案首页改善率质控评分页(内页)-科室-->
     <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
         SELECT
-        t.*,t3.name as medoupName
+        t.*
         FROM
         (
         SELECT DISTINCT
@@ -15141,6 +15141,7 @@
         t1.score_res AS scoreRes,
         t1.NAME AS NAME,
         t1.scoreBn,
+        t1.medoupName,
         t1.sex AS sex,
         t1.beh_dept_id AS behDeptId,
         t1.beh_dept_name AS behDeptName,
@@ -15169,6 +15170,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -15355,19 +15357,20 @@
         and be.hospital_id = e.hospital_id
         AND e.is_deleted = 'N'
         and e.cases_id = 243
+        LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         ) t1
         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'
-        ) t LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
-        AND t.hospitalId = t2.hospital_id
-        AND t2.is_deleted = 'N'
-        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
-        AND t3.is_deleted = 'N'
+        ) t
         WHERE
         1 = 1
         <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
-            AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
         </if>
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
@@ -15579,7 +15582,7 @@
     <!-- 质控核查质控评分页-科室(内页)-->
     <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
         SELECT
-        t.*,t3.name as medoupName
+        t.*
         FROM
         (
         SELECT DISTINCT
@@ -15590,6 +15593,7 @@
         t1.grade_type AS gradeType,
         t1.score_res AS scoreRes,
         t1.scoreBn,
+        t1.medoupName,
         t1.NAME AS NAME,
         t1.sex AS sex,
         t1.beh_dept_id AS behDeptId,
@@ -15619,6 +15623,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -15733,22 +15738,23 @@
         and be.hospital_id = e.hospital_id
         AND e.is_deleted = 'N'
         and e.cases_id = 243
+        LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         ) t1
         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'
-        ) t LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
-        AND t.hospitalId = t2.hospital_id
-        AND t2.is_deleted = 'N'
-        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
-        AND t3.is_deleted = 'N'
+        ) t
         WHERE
         1 = 1
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
         <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
-            AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
         </if>
         <if test="qcResultShortPageVO.mrStatus != null">
             AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
@@ -15778,6 +15784,8 @@
         SELECT
         f1.behDeptId,
         f1.behDeptName,
+        f1.wardName,
+        f1.medoupName,
         f1.doctorName,
         f1.patName,
         f1.behospitalCode,
@@ -15810,6 +15818,8 @@
         </if>
         t.behDeptId,
         t.behDeptName,
+        t.wardName,
+        t.medoupName,
         t.hospitalId,
         t.checkStatus,
         t.mrStatus,
@@ -15842,6 +15852,7 @@
         t1.placefile_date AS placefileDate,
         t1.gmt_create AS gradeTime,
         t1.diagnose,
+        t1.medoupName,
         t1.ward_name AS wardName,
         t2.age,
         t1.file_code AS fileCode,
@@ -15855,6 +15866,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -15922,6 +15934,9 @@
         <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
             AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
             <if test="qcResultShortPageVO.startDate != null ">
                 <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
@@ -15969,6 +15984,9 @@
         <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
             AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
             <if test="qcResultShortPageVO.startDate != null ">
                 <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
@@ -16022,6 +16040,11 @@
         AND hm_mci.check_type = 1
         AND be.hospital_id = hm_mci.hospital_id
         AND be.behospital_code = hm_mci.behospital_code
+        LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         ) t1
         LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
         AND t1.behospital_code = t2.behospital_code
@@ -16041,6 +16064,9 @@
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
+        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.mrStatus != null">
             AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
         </if>
@@ -16092,6 +16118,7 @@
         t1.placefile_date AS placefileDate,
         t1.gmt_create AS gradeTime,
         t1.diagnose,
+        t1.medoupName,
         t1.ward_name AS wardName,
         t2.age,
         t1.file_code AS fileCode,
@@ -16105,6 +16132,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -16172,6 +16200,9 @@
         <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
             AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
             <if test="qcResultShortPageVO.startDate != null ">
                 <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
@@ -16219,6 +16250,9 @@
         <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
             AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
             <if test="qcResultShortPageVO.startDate != null ">
                 <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
@@ -16272,6 +16306,11 @@
         AND hm_mci.check_type = 1
         AND be.hospital_id = hm_mci.hospital_id
         AND be.behospital_code = hm_mci.behospital_code
+        LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         ) t1
         LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
         AND t1.behospital_code = t2.behospital_code
@@ -16284,6 +16323,9 @@
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
+        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.mrStatus != null">
             AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
         </if>
@@ -16918,6 +16960,8 @@
         SELECT
         f1.behDeptId,
         f1.behDeptName,
+        f1.wardName,
+        f1.medoupName,
         f1.doctorName,
         f1.patName,
         f1.behospitalCode,
@@ -16946,6 +16990,8 @@
         t.leaveHospitalDate AS leaveHospitalDate,
         qi.score_res AS score,
         t.scoreBn,
+        t.wardName,
+        t.medoupName,
         <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
         qd.msg AS msg,
         qc.NAME AS caseName,
@@ -16985,6 +17031,7 @@
         t1.placefile_date AS placefileDate,
         t1.gmt_create AS gradeTime,
         t1.diagnose,
+        t1.medoupName,
         t1.ward_name AS wardName,
         t2.age,
         t1.file_code AS fileCode,
@@ -16998,6 +17045,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -17066,9 +17114,11 @@
         <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
             AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
             AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
-
         </if>
         <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
             AND c.`level` = #{qcResultShortPageVO.level}
@@ -17103,6 +17153,11 @@
         and be.hospital_id = e.hospital_id
         AND e.is_deleted = 'N'
         and e.cases_id = 243
+        LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         ) t1
         LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
         AND t1.behospital_code = t2.behospital_code
@@ -17122,6 +17177,9 @@
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
+        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.mrStatus != null">
             AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
         </if>
@@ -17173,6 +17231,7 @@
         t1.placefile_date AS placefileDate,
         t1.gmt_create AS gradeTime,
         t1.diagnose,
+        t1.medoupName,
         t1.ward_name AS wardName,
         t2.age,
         t1.file_code AS fileCode,
@@ -17186,6 +17245,7 @@
         (
         SELECT
         be.*,
+        t3.name as medoupName,
         ifnull( mci.STATUS, 0 ) AS checkStatus,
         ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
         mci.check_name AS chName,
@@ -17231,6 +17291,9 @@
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
         </if>
+        <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
+            AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
             AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
         </if>
@@ -17293,10 +17356,18 @@
         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 bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
+        and be.hospital_id = t2.hospital_id
+        AND t2.is_deleted = 'N'
+        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
+        AND t3.is_deleted = 'N'
         where 1=1
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
+        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.mrStatus != null">
             AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
         </if>