Browse Source

病案首页合格病历列表sql逻辑调整

chengyao 3 years ago
parent
commit
c54c04822e

+ 15 - 0
src/main/java/com/diagbot/vo/FilterPageVO.java

@@ -51,6 +51,21 @@ public class FilterPageVO extends Page {
      */
     private String deptName;
 
+    /**
+     * 科室id
+     */
+    private String deptId;
+
+    /**
+     * 医生姓名
+     */
+    private String doctorName;
+
+    /**
+     * 医生id
+     */
+    private String doctorId;
+
     /**
      * 模块id:243=病案首页
      */

+ 5 - 0
src/main/java/com/diagbot/vo/QcResultShortPageVO.java

@@ -75,6 +75,11 @@ public class QcResultShortPageVO extends Page {
      * 科室名称
      */
     private String deptName;
+
+    /**
+     * 科室id
+     */
+    private String deptId;
     /**
      * 医生姓名
      */

+ 47 - 32
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -5404,7 +5404,7 @@
 
     <!-- 条目缺陷质控评分页-科室(内页)-->
     <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDeptDTO">
-        SELECT t.*,t3.name as medoupName
+        SELECT t.*
         FROM
         (SELECT DISTINCT
         t1.hospital_id AS hospitalId,
@@ -5414,6 +5414,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,
@@ -5446,6 +5447,7 @@
         FROM
         (SELECT
         be.*,
+        t3.name as medoupName,
         ifnull(mci.status,0) AS checkStatus,
         ifnull(hm_mci.status,0) AS mrStatus,
         mci.check_name as chName,
@@ -5535,6 +5537,9 @@
         <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
             AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
         </if>
+        <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
+            AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
+        </if>
         <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
             AND b.`level` = #{qcResultShortPageVO.level}
         </if>
@@ -5557,9 +5562,9 @@
             AND d.cases_id = #{qcResultShortPageVO.casesId}
         </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}, '%' ))
+            AND (a.doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.beh_doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.director_doctor_id = #{qcResultShortPageVO.doctorId})
         </if>
         <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
             AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
@@ -5600,6 +5605,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'
         )tt1
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
             ,med_medical_record tt2
@@ -5632,16 +5642,10 @@
             AND t3.is_deleted = 'N'
         </if>
         ) t
-        LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
-        AND t2.is_deleted = 'N'
-        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
-        AND t3.is_deleted = 'N'
         where
-        <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
-             t2.hospital_id = #{qcResultShortPageVO.hospitalId}
-        </if>
+        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}
@@ -9510,7 +9514,6 @@
 
     <!--缺陷详情质控评分页导出-科室-->
     <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
-        SELECT m.*, t3.name as medoupName from(
         SELECT
         f1.*,
         f2.avgScore
@@ -9530,6 +9533,7 @@
         t1.score_res AS scoreRes,
         t1.scoreBn AS scoreBn,
         t1.NAME AS patName,
+        t1.medoupName,
         t1.sex AS sex,
         t1.beh_dept_id AS behDeptId,
         t1.beh_dept_name AS behDeptName,
@@ -9560,6 +9564,7 @@
         FROM
         (SELECT
         be.*,
+        t3.name as medoupName,
         ifnull(mci.status,0) AS checkStatus,
         ifnull(hm_mci.status,0) AS mrStatus,
         mci.check_name as chName,
@@ -9649,13 +9654,13 @@
         <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
             AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
         </if>
-        <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
-            AND a.doctor_name = #{qcResultShortPageVO.doctorName}
+        <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
+            AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
         </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}, '%' ))
+            AND (a.doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.beh_doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.director_doctor_id = #{qcResultShortPageVO.doctorId})
         </if>
         <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
             AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
@@ -9711,6 +9716,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'
         )tt1
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
             ,med_medical_record tt2
@@ -9758,6 +9768,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>
@@ -9807,6 +9820,7 @@
         t1.grade_type AS gradeType,
         t1.score_res AS scoreRes,
         t1.NAME AS NAME,
+        t1.medoupName,
         t1.sex AS sex,
         t1.beh_dept_id AS behDeptId,
         t1.beh_dept_name AS behDeptName,
@@ -9838,6 +9852,7 @@
         FROM
         (SELECT
         be.*,
+        t3.name as medoupName,
         ifnull(mci.status,0) AS checkStatus,
         ifnull(hm_mci.status,0) AS mrStatus,
         mci.check_name as chName,
@@ -9923,6 +9938,9 @@
         <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
             AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
         </if>
+        <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
+            AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
+        </if>
         <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
             AND b.`level` = #{qcResultShortPageVO.level}
         </if>
@@ -9945,9 +9963,9 @@
             AND d.cases_id = #{qcResultShortPageVO.casesId}
         </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}, '%' ))
+            AND (a.doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.beh_doctor_id = #{qcResultShortPageVO.doctorId}
+            OR a.director_doctor_id = #{qcResultShortPageVO.doctorId})
         </if>
         <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
             AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
@@ -9983,6 +10001,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'
         )tt1
         <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
             ,med_medical_record tt2
@@ -10019,6 +10042,9 @@
         AND t.hospitalId = qi.hospital_id
         AND t.behospitalCode = qi.behospital_code
         where 1=1
+        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
+            AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
+        </if>
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
         </if>
@@ -10053,17 +10079,6 @@
         f1.doctorId = f2.doctorId
         AND f1.doctorName = f2.doctorName
         AND f1.doctorName = f2.doctorName
-        )m LEFT JOIN bas_doctor_info t2 ON m.doctorId = t2.doctor_id
-        AND t2.is_deleted = 'N'
-        LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
-        AND t3.is_deleted = 'N'
-        where
-        <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
-             t2.hospital_id = #{qcResultShortPageVO.hospitalId}
-        </if>
-        <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
-            AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
-        </if>
     </select>
     <!-- 条目缺陷评分详情页导出-->
     <select id="qcResultShortPageExport" resultMap="ExportExcelMap">