Browse Source

sql逻辑调整

chengyao 3 years ago
parent
commit
76e322ff19
1 changed files with 40 additions and 206 deletions
  1. 40 206
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 40 - 206
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -5567,7 +5567,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -5814,7 +5814,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -6069,7 +6069,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -7755,7 +7755,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -7998,7 +7998,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -9119,7 +9119,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -9352,7 +9352,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -9636,7 +9636,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -9878,7 +9878,7 @@
         ) be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -10147,7 +10147,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -10422,7 +10422,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -10684,7 +10684,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -10952,7 +10952,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -11233,7 +11233,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -11511,7 +11511,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -12342,7 +12342,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -12363,92 +12363,9 @@
         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,
-        (
-        SELECT
-        a.doctor_id as doctorId,
-        a.doctor_name as doctorName
-        FROM
-        med_behospital_info a,
-        sys_user_dept b,
-        med_qcresult_cases c,
-        med_qcresult_detail d,
-        qc_cases_entry e
-        WHERE
-        a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND a.hospital_id = b.hospital_id
-        AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND a.beh_dept_id = b.dept_id
-        AND c.cases_id = d.cases_id
-        AND d.cases_id = e.cases_id
-        AND d.cases_entry_id = e.id
-        AND d.cases_id = 243
-        AND a.qc_type_id != 0
-        <if test="userId!=null">
-            AND b.user_id = #{userId}
-        </if>
-        <if test="deptName != null and deptName != ''">
-            and a.beh_dept_name = #{deptName}
-        </if>
-        <if test="doctorName != null and doctorName != ''">
-            AND (a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
-            OR a.beh_doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
-            OR a.director_doctor_name LIKE CONCAT( '%', #{doctorName}, '%'))
-        </if>
-        <if test="doctorId != null and doctorId != ''">
-            AND a.doctor_id = #{doctorId}
-        </if>
-        <if test="deptClass != null and deptClass != ''">
-            and a.beh_dept_id = #{deptClass}
-        </if>
-        <if test="deptId != null and deptId != ''">
-            and a.beh_dept_id = #{deptId}
-        </if>
-        <if test="isPlacefile != null and isPlacefile != ''">
-            and a.is_placefile = #{isPlacefile}
-        </if>
-        <if test="hospitalId != null and hospitalId != ''">
-            AND a.hospital_id = #{hospitalId}
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 0">
-            <if test="startDate != null ">
-                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
-            </if>
-            <if test="endDate != null ">
-                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
-            </if>
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 1">
-            <if test="startDate != null ">
-                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
-            </if>
-            <if test="endDate != null">
-                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
-            </if>
-        </if>
-        <if test="diagnose != null and diagnose != ''">
-            AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
-        </if>
-        <if test="behospitalCode != null and behospitalCode != ''">
-            AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
-        </if>
-        <if test="patName != null and patName != ''">
-            AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
-        </if>
-        GROUP BY
-        a.doctor_id,
-        a.doctor_name
-        ) t2
+        ) t
         where
-        t.doctorId = t2.doctorId
-        AND t.doctorName = t2.doctorName
+        1=1
         <if test="checkStatus != null">
             AND t.checkStatus = #{checkStatus}
         </if>
@@ -12617,7 +12534,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -12638,92 +12555,9 @@
         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,
-        (
-        SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName
-        FROM
-        med_behospital_info a,
-        med_qcresult_cases c,
-        med_qcresult_detail d,
-        qc_cases_entry e
-        WHERE
-        a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND c.cases_id = d.cases_id
-        AND d.cases_id = e.cases_id
-        AND d.cases_entry_id = e.id
-        AND d.cases_id = 243
-        AND a.qc_type_id != 0
-        <if test="qcResultPageVO.titleName != null ">
-            <if test="qcResultPageVO.titleName == '不合格数'">
-                AND c.`level`='不合格'
-            </if>
-            <if test="qcResultPageVO.titleName == '合格数'">
-                AND c.`level`='合格'
-            </if>
-        </if>
-        <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
-            and a.is_placefile = #{qcResultPageVO.isPlacefile}
-        </if>
-        <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
-            AND a.hospital_id = #{qcResultPageVO.hospitalId}
-        </if>
-        <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
-            <if test="qcResultPageVO.startDate != null ">
-                <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
-            </if>
-            <if test="qcResultPageVO.endDate != null ">
-                <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
-            </if>
-        </if>
-        <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
-            <if test="qcResultPageVO.startDate != null ">
-                <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
-            </if>
-            <if test="qcResultPageVO.endDate != null">
-                <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
-            </if>
-        </if>
-        <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
-            AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
-        </if>
-        <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
-            AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
-        </if>
-        <if test="qcResultPageVO.deptId != null and qcResultPageVO.deptId != ''">
-            AND a.beh_dept_id = #{qcResultPageVO.deptId}
-        </if>
-        <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
-            AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
-        </if>
-        <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
-            AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
-        </if>
-        <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
-            AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
-            OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
-            OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
-        </if>
-        <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
-            AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
-            OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
-            OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
-        </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name
-        ) t2
+        ) t
         where
-        t.behDeptId = t2.deptId
-        AND t.behDeptName = t2.deptName
+        1=1
         <if test="qcResultPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultPageVO.checkStatus}
         </if>
@@ -12909,7 +12743,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -13114,7 +12948,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -13319,7 +13153,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -13547,7 +13381,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -13779,7 +13613,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -14039,7 +13873,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -14251,7 +14085,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -14501,7 +14335,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -14733,7 +14567,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -14984,7 +14818,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -15197,7 +15031,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -15447,7 +15281,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -15669,7 +15503,7 @@
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
-        and mci.check_type = 0
+        and mci.check_type in(0,2)
         and be.hospital_id = mci.hospital_id
         and be.behospital_code = mci.behospital_code
         left join med_check_info hm_mci
@@ -17025,7 +16859,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
@@ -17383,7 +17217,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
@@ -18199,7 +18033,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
@@ -18463,7 +18297,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
@@ -19087,7 +18921,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
@@ -19282,7 +19116,7 @@
         </if>
         ) be
         LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
-        AND mci.check_type = 0
+        AND mci.check_type in(0,2)
         AND be.hospital_id = mci.hospital_id
         AND be.behospital_code = mci.behospital_code
         LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'