zhanghang 4 лет назад
Родитель
Сommit
d21973d57a

+ 121 - 111
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -17553,72 +17553,85 @@
     <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
         SELECT
         count(
+        DISTINCT
         CASE
-        WHEN c.cases_entry_id = 2170
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
-        THEN
-        1
+        WHEN q.type=5 THEN
+        a.behospital_code
         ELSE
         NULL
         END
         ) AS '2170手术记录未在术后24h内完成',
         count(
+        DISTINCT
         CASE
-        WHEN c.cases_entry_id = 2658
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
-        THEN
-        1
+        WHEN q.type = 4 THEN
+        a.behospital_code
         ELSE
         NULL
         END
         ) AS '2658入院记录未在患者入院24小时内完成',
         count(
+        DISTINCT
         CASE
-        WHEN c.cases_entry_id = 2635
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
-        THEN
-        1
+        WHEN q.type = 6 THEN
+        a.behospital_code
         ELSE
         NULL
         END
         ) AS '2635出院记录未在患者出院24小时内完成',
         count(
+        DISTINCT
         CASE
-        WHEN c.cases_entry_id = 3110
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
-        THEN
-        1
+        WHEN q.type = 7 THEN
+        a.behospital_code
         ELSE
         NULL
         END
         ) AS '3110病案首页未在患者出院24小时内完成'
         FROM
-        med_qcresult_info b,
+        (
+        SELECT
+        a.behospital_code,
+        a.cases_entry_id,
+        a.hospital_id
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        c.cases_entry_id,
+        a.hospital_id
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        a.hospital_id
+        FROM
         med_behospital_info a,
-        med_qcresult_detail c
+        med_qcresult_info c
         WHERE
-        a.hospital_id = #{filterVO.hospitalId}
-        AND a.hospital_id = b.hospital_id
-        AND a.hospital_id = c.hospital_id
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
         AND a.is_placefile = #{filterVO.isPlacefile}
-        AND a.behospital_code = b.behospital_code
+        <if test="filterVO.startDate != null and  filterVO.endDate != null">
+            <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
+            <![CDATA[ AND a
+
+            .leave_hospital_date <= #{filterVO.endDate}]]>
+        </if>
+        <![CDATA[ and  a.qc_type_id <>'0' ]]>
         AND a.behospital_code = c.behospital_code
-        AND a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        <![CDATA[ and  a.qc_type_id <>'0']]>
+        AND a.hospital_id = #{filterVO.hospitalId}
+        AND a.hospital_id = c.hospital_id
+        ) a
+        LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
+        AND a.behospital_code = c.behospital_code
+        AND a.hospital_id = c.hospital_id
+        ) a
+        JOIN qc_cases_entry d ON d.id = a.cases_entry_id
+        AND d.is_deleted = 'N'
+        ) a
+        LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
+        AND a.hospital_id = q.hospital_id
 
     </select>
 
@@ -17648,10 +17661,6 @@
         count(
         CASE
         WHEN   b.operation_fee > 0
-        <if test="filterVO.startDate != null and  filterVO.endDate != null">
-        <![CDATA[ and d.leave_hospital_date >= #{filterVO.startDate}]]>
-        <![CDATA[ AND d.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
         THEN
         1
         ELSE
@@ -17661,10 +17670,6 @@
         count(
         CASE
         WHEN   b.antibiosis_fee > 0
-        <if test="filterVO.startDate != null and  filterVO.endDate != null">
-            <![CDATA[ and d.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND d.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
         THEN
         1
         ELSE
@@ -17675,10 +17680,6 @@
         CASE
         WHEN   b.operation_fee > 0
         AND   b.pathology_fee > 0
-        <if test="filterVO.startDate != null and  filterVO.endDate != null">
-            <![CDATA[ and d.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND d.leave_hospital_date <= #{filterVO.endDate}]]>
-        </if>
         THEN
         1
         ELSE
@@ -17696,13 +17697,17 @@
         med_behospital_info a,
         med_qcresult_info c
         WHERE
-        a.behospital_code = c.behospital_code
-        AND a.hospital_id = #{filterVO.hospitalId}
-        AND a.is_placefile = #{filterVO.isPlacefile}
-        AND a.hospital_id = c.hospital_id
-        AND a.is_deleted = 'N'
+            a.is_deleted = 'N'
         AND c.is_deleted = 'N'
+        AND a.is_placefile = #{filterVO.isPlacefile}
+        <if test="filterVO.startDate != null and  filterVO.endDate != null">
+            <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
+            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
+        </if>
         <![CDATA[ and  a.qc_type_id <>'0' ]]>
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = #{filterVO.hospitalId}
+        and a.behospital_code = c.behospital_code
         ) d
         LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
         AND d.hospital_id = b.hospital_id
@@ -17711,69 +17716,74 @@
 <!--    关于触发规则不符合人数-->
     <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
         SELECT
-	count(
-		DISTINCT CASE
-		WHEN (b.cases_entry_id = 2762
-		OR b.cases_entry_id = 2370) THEN
-			b.behospital_code
-		ELSE
-			NULL
-		END
-	) as 'antibiosisNum',
-    count(
-        DISTINCT CASE
-        WHEN (b.cases_entry_id = 2658
-        OR b.cases_entry_id = 2537) THEN
-            b.behospital_code
+        count(
+        DISTINCT
+        CASE
+        WHEN q.type=8 THEN
+        a.behospital_code
         ELSE
-            NULL
+        NULL
         END
-        ) as 'CT',
-    count(
-        DISTINCT CASE
-        WHEN (b.cases_entry_id = 2522
-        OR b.cases_entry_id = 2658) THEN
-            b.behospital_code
+        ) AS 'CT',
+        count(
+        DISTINCT
+        CASE
+        WHEN q.type = 9 THEN
+        a.behospital_code
         ELSE
-            NULL
+        NULL
         END
-        ) as 'MR',
-    count(
-        DISTINCT CASE
-        WHEN (b.cases_entry_id = 2522
-        OR b.cases_entry_id = 2658) THEN
-            b.behospital_code
+        ) AS 'MR',
+        count(
+        DISTINCT
+        CASE
+        WHEN q.type = 10 THEN
+        a.behospital_code
         ELSE
-            NULL
+        NULL
         END
-        ) as 'bacterialCulture'
-    FROM
-	(
-		SELECT
-			a.behospital_code,
-			c.cases_entry_id
-		FROM
-			med_qcresult_info a,
-			med_behospital_info b,
-			med_qcresult_detail c,
-            qc_cases_entry d
-		WHERE
-			a.hospital_id = #{filterVO.hospitalId}
-		AND a.hospital_id = b.hospital_id
-		AND d.id=c.cases_entry_id
-		AND a.hospital_id = c.hospital_id
-		AND b.is_placefile = #{filterVO.isPlacefile}
-		AND a.behospital_code = b.behospital_code
-		AND a.behospital_code = c.behospital_code
-		AND a.is_deleted = 'N'
-		AND b.is_deleted = 'N'
-		AND c.is_deleted = 'N'
-        <![CDATA[ and b.qc_type_id <>'0']]>
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND b.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND b.leave_hospital_date <= #{filterVO.endDate}]]>
+        ) AS 'antibiosisNum'
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        a.cases_entry_id,
+        a.hospital_id
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        c.cases_entry_id,
+        a.hospital_id
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        a.hospital_id
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.is_placefile = #{filterVO.isPlacefile}
+        <if test="filterVO.startDate != null and  filterVO.endDate != null">
+            <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
+            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
         </if>
-	) b
+        AND a.behospital_code = c.behospital_code
+        AND a.hospital_id = #{filterVO.hospitalId}
+        AND a.hospital_id = c.hospital_id
+        ) a
+        LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
+        AND a.behospital_code = c.behospital_code
+        AND a.hospital_id = c.hospital_id
+        ) a
+        JOIN qc_cases_entry d ON d.id = a.cases_entry_id
+        AND d.is_deleted = 'N'
+        ) a
+        JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
+        AND a.hospital_id = q.hospital_id
     </select>
 
 <!--    跟病案首页关联的出院病历-->

+ 27 - 20
src/main/resources/mapper/DoctorAdviceMapper.xml

@@ -218,28 +218,35 @@
 <!--    根据条件获取医嘱-->
     <select id="getDoctorAdviceNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
         SELECT
-        b.behospital_code,
+        a.behospital_code,
         b.da_item_name
-    FROM
-	    med_behospital_info a,
-	    med_qcresult_info c,
-	    med_doctor_advice b
-    WHERE
-    	a.behospital_code = c.behospital_code
-    and a.behospital_code = b.behospital_code
-    AND a.hospital_id = #{filterVO.hospitalId}
-    AND a.is_placefile = #{filterVO.isPlacefile}
-    AND a.hospital_id = c.hospital_id
-    AND a.hospital_id = b.hospital_id
-    AND a.is_deleted = 'N'
-    AND c.is_deleted = 'N'
-    AND b.is_deleted = 'N'
-    AND b.doctor_advice_type = '临时医嘱'
-    <![CDATA[ and  a.qc_type_id <>'0' ]]>
-    <![CDATA[ and  b.da_status <>'作废' ]]>
-        <if test="filterVO.startDate != null and  filterVO.endDate != null ">
-            <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
+        FROM
+        (
+        SELECT
+        a.behospital_code,
+        a.hospital_id
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.is_placefile = #{filterVO.isPlacefile}
+        <if test="filterVO.startDate != null and  filterVO.endDate != null">
+            <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
             <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
         </if>
+        <![CDATA[ and  a.qc_type_id <>'0' ]]>
+        AND a.behospital_code = c.behospital_code
+        AND a.hospital_id = #{filterVO.hospitalId}
+        AND a.hospital_id = c.hospital_id
+        ) a,
+        med_doctor_advice b
+        WHERE
+        b.is_deleted = 'N'
+        AND b.doctor_advice_type = '临时医嘱'
+        <![CDATA[ and  b.da_status <> '作废' ]]>
+        AND a.behospital_code = b.behospital_code
+        AND a.hospital_id = b.hospital_id
     </select>
 </mapper>