Ver código fonte

脚本/病案首页合格数sql调整

chengyao 4 anos atrás
pai
commit
f6dbce7fa9

+ 2 - 0
doc/025.20201021v1.4.7/qc_initv1.4.7.sql

@@ -0,0 +1,2 @@
+use `qc`;
+INSERT INTO `qc`.`sys_dictionary_info`( `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `group_type`, `name`, `val`, `return_type`, `order_no`, `remark`) VALUES ( 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', 3, 'anaesthesiaDoctor', '麻醉医师', 2, 0, '病案首页手术信息');

+ 96 - 14
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -6811,6 +6811,10 @@
         FROM
         (SELECT
         be.*,
+        b.LEVEL,
+        b.grade_type,
+        b.score_res,
+        b.gmt_create,
         ifnull(mci.status,0) AS checkStatus,
         ifnull(hm_mci.status,0) AS mrStatus,
         mci.check_name as chName,
@@ -6824,9 +6828,6 @@
         a.behospital_code,
         a.bed_code,
         a.file_code,
-        b.LEVEL,
-        b.grade_type,
-        b.score_res,
         e.score_res as scoreBn,
         a.NAME,
         a.sex,
@@ -6843,19 +6844,14 @@
         a.director_doctor_name,
         a.diagnose,
         a.placefile_date,
-        a.ward_name,
-        b.gmt_create
+        a.ward_name
         FROM
         med_behospital_info a,
-        med_qcresult_info b,
         med_qcresult_cases e
         WHERE
         a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
         AND e.is_deleted = 'N'
-        AND a.hospital_id = b.hospital_id
         AND a.hospital_id = e.hospital_id
-        AND a.behospital_code = b.behospital_code
         AND a.behospital_code = e.behospital_code
         AND a.qc_type_id != 0
         AND e.cases_id = 243
@@ -6892,9 +6888,7 @@
         <if test="qcResultPageVO.behDeptName != null and qcResultPageVO.behDeptName != ''">
             AND a.beh_dept_name = #{qcResultPageVO.behDeptName}
         </if>
-        <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
-            AND b.`level` = #{qcResultPageVO.level}
-        </if>
+
         <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
             AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
         </if>
@@ -6922,12 +6916,100 @@
         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_info b
+        on  b.is_deleted = 'N'
+        AND be.hospital_id = b.hospital_id
+        AND be.behospital_code = b.behospital_code
+        where
+        1=1
+        <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
+            AND b.`level` = #{qcResultPageVO.level}
+        </if>
         ) 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
-        where 1=1
+        ) 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.behDeptName != null and qcResultPageVO.behDeptName != ''">
+            AND a.beh_dept_name = #{qcResultPageVO.behDeptName}
+        </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
+        where
+        t.behDeptId = t2.deptId
+        AND t.behDeptName = t2.deptName
         <if test="qcResultPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultPageVO.checkStatus}
         </if>