Parcourir la source

调整了手术数据的统计

攻心小虫 il y a 2 ans
Parent
commit
0d86276641
1 fichiers modifiés avec 207 ajouts et 20 suppressions
  1. 207 20
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 207 - 20
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -803,8 +803,54 @@
 
     <!-- 手术人数统计-全院-首页 -->
     <select id="operationMap" parameterType="com.diagbot.vo.FilterVO" resultType="map">
-	 	select count(1) ss,sum(a) four,sum(if(a>1,0,b)) three,sum(if(a+b>1,0,c)) two,sum(if(a+b+c>1,0,d)) one  from (
-			SELECT a.behospital_code,if(LOCATE('四级手术',f.ssdj) >0,1,0) a,if(LOCATE('三级手术',f.ssdj) >0,1,0) b,if(LOCATE('二级手术',f.ssdj) >0 ,1,0) c,if(LOCATE('一级手术',f.ssdj) >0,1,0) d
+		select count(1) ss,sum(a) four,sum(if(a>0,0,b)) three,sum(if(a+b>0,0,c)) two,sum(if(a+b+c>0,0,d)) one  from (
+			SELECT behospital_code,if(sum(a)>0,1,0) a,if(sum(b)>0,1,0) b,if(sum(c)>0,1,0) c,if(sum(d)>0,1,0) d  from (
+				SELECT a.behospital_code,1 a,0 b,0 c,0 d
+				FROM
+				med_behospital_info a,
+				med_home_page e,
+				med_home_operation_info f, 
+				med_medical_record tt2, 
+				qc_mode tt3 
+				WHERE a.is_deleted = 'N'
+				AND e.is_deleted = 'N'
+				and tt2.is_deleted = 'N' 
+				AND tt3.is_deleted = 'N' 
+				AND a.hospital_id = tt2.hospital_id 
+				AND a.behospital_code = tt2.behospital_code 
+				AND tt2.mode_id = tt3.id 
+				AND tt3.`name` = '手术记录'
+				AND f.is_deleted = 'N'
+				AND a.hospital_id = e.hospital_id
+				AND a.hospital_id = f.hospital_id
+				AND a.behospital_code = e.behospital_code
+				AND e.home_page_id = f.home_page_id
+		        and f.operation_code is not null and f.operation_code !='[]'  and f.ssdj like '%四级手术%'
+		        <if test="isPlacefile != null and isPlacefile != ''">
+		            and a.is_placefile = #{isPlacefile}
+		        </if>
+		        <![CDATA[AND a.qc_type_id <>0 ]]>
+		        <if test="hospitalId != null and hospitalId != ''">
+		            AND a.hospital_id = #{hospitalId}
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 0">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 1">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+			union all
+        	SELECT a.behospital_code,0,1 ,0,0
 			FROM
 			med_behospital_info a,
 			med_home_page e,
@@ -825,7 +871,100 @@
 			AND a.behospital_code = e.behospital_code
 			AND e.home_page_id = f.home_page_id
 	        and f.operation_code is not null and f.operation_code !='[]'
-	        <if test="isPlacefile != null and isPlacefile != ''">
+            and f.ssdj like '%三级手术%'
+            <if test="isPlacefile != null and isPlacefile != ''">
+		            and a.is_placefile = #{isPlacefile}
+		        </if>
+		        <![CDATA[AND a.qc_type_id <>0 ]]>
+		        <if test="hospitalId != null and hospitalId != ''">
+		            AND a.hospital_id = #{hospitalId}
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 0">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 1">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+			union all
+ 			SELECT a.behospital_code,0,0 ,1,0
+			FROM
+			med_behospital_info a,
+			med_home_page e,
+			med_home_operation_info f, 
+			med_medical_record tt2, 
+			qc_mode tt3 
+			WHERE a.is_deleted = 'N'
+			AND e.is_deleted = 'N'
+			and tt2.is_deleted = 'N' 
+			AND tt3.is_deleted = 'N' 
+			AND a.hospital_id = tt2.hospital_id 
+			AND a.behospital_code = tt2.behospital_code 
+			AND tt2.mode_id = tt3.id 
+			AND tt3.`name` = '手术记录'
+			AND f.is_deleted = 'N'
+			AND a.hospital_id = e.hospital_id
+			AND a.hospital_id = f.hospital_id
+			AND a.behospital_code = e.behospital_code
+			AND e.home_page_id = f.home_page_id
+	        and f.operation_code is not null and f.operation_code !='[]'
+            and f.ssdj like '%二级手术%'
+            <if test="isPlacefile != null and isPlacefile != ''">
+		            and a.is_placefile = #{isPlacefile}
+		        </if>
+		        <![CDATA[AND a.qc_type_id <>0 ]]>
+		        <if test="hospitalId != null and hospitalId != ''">
+		            AND a.hospital_id = #{hospitalId}
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 0">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+		        <if test="isPlacefile != null and isPlacefile == 1">
+		            <if test="startDate != null and startDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+		            </if>
+		            <if test="endDate != null and endDate != ''">
+		                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+		            </if>
+		        </if>
+			union all
+         	SELECT a.behospital_code,0,0 ,0,1
+			FROM
+			med_behospital_info a,
+			med_home_page e,
+			med_home_operation_info f, 
+			med_medical_record tt2, 
+			qc_mode tt3 
+			WHERE a.is_deleted = 'N'
+			AND e.is_deleted = 'N'
+			and tt2.is_deleted = 'N' 
+			AND tt3.is_deleted = 'N' 
+			AND a.hospital_id = tt2.hospital_id 
+			AND a.behospital_code = tt2.behospital_code 
+			AND tt2.mode_id = tt3.id 
+			AND tt3.`name` = '手术记录'
+			AND f.is_deleted = 'N'
+			AND a.hospital_id = e.hospital_id
+			AND a.hospital_id = f.hospital_id
+			AND a.behospital_code = e.behospital_code
+			AND e.home_page_id = f.home_page_id
+	        and f.operation_code is not null and f.operation_code !='[]'
+            and f.ssdj like '%一级手术%'
+            <if test="isPlacefile != null and isPlacefile != ''">
 	            and a.is_placefile = #{isPlacefile}
 	        </if>
 	        <![CDATA[AND a.qc_type_id <>0 ]]>
@@ -848,7 +987,53 @@
 	                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
 	            </if>
 	        </if>
-		    group by a.behospital_code
+	        union all 
+	        SELECT a.behospital_code,0,0 ,0,0
+			FROM
+			med_behospital_info a,
+			med_home_page e,
+			med_home_operation_info f, 
+			med_medical_record tt2, 
+			qc_mode tt3 
+			WHERE a.is_deleted = 'N'
+			AND e.is_deleted = 'N'
+			and tt2.is_deleted = 'N' 
+			AND tt3.is_deleted = 'N' 
+			AND a.hospital_id = tt2.hospital_id 
+			AND a.behospital_code = tt2.behospital_code 
+			AND tt2.mode_id = tt3.id 
+			AND tt3.`name` = '手术记录'
+			AND f.is_deleted = 'N'
+			AND a.hospital_id = e.hospital_id
+			AND a.hospital_id = f.hospital_id
+			AND a.behospital_code = e.behospital_code
+			AND e.home_page_id = f.home_page_id
+			and f.operation_code is not null and f.operation_code !='[]'
+			and f.ssdj is null
+			<if test="isPlacefile != null and isPlacefile != ''">
+	            and a.is_placefile = #{isPlacefile}
+	        </if>
+	        <![CDATA[AND a.qc_type_id <>0 ]]>
+	        <if test="hospitalId != null and hospitalId != ''">
+	            AND a.hospital_id = #{hospitalId}
+	        </if>
+	        <if test="isPlacefile != null and isPlacefile == 0">
+	            <if test="startDate != null and startDate != ''">
+	                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+	            </if>
+	            <if test="endDate != null and endDate != ''">
+	                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+	            </if>
+	        </if>
+	        <if test="isPlacefile != null and isPlacefile == 1">
+	            <if test="startDate != null and startDate != ''">
+	                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+	            </if>
+	            <if test="endDate != null and endDate != ''">
+	                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+	            </if>
+	        </if>
+			) a group by behospital_code
 		) a 
     </select>
     
@@ -5251,11 +5436,15 @@
     <!-- 离院病人评分详情页-->
     <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
         SELECT DISTINCT t.*
-        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.hospitalId == "7"'>
-            ,
-            GROUP_CONCAT(case when t4.operation_doctor_id is not null then t4.operation_doctor_id else '' end separator ',') AS operationDoctorName,
-            ifnull(GROUP_CONCAT(t4.ssdj),'') AS operationLevel
-        </if>
+        <choose>
+	        <when test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.leaveHosType != 2 and qcResultShortPageVO.leaveHosType != 4 and qcResultShortPageVO.leaveHosType != 6 and qcResultShortPageVO.leaveHosType != 7  and qcResultShortPageVO.hospitalId == "7"'>
+	            ,GROUP_CONCAT(case when t4.operation_doctor_id is not null then t4.operation_doctor_id else '' end separator ',') AS operationDoctorName,
+	            ifnull(GROUP_CONCAT(t4.ssdj),'') AS operationLevel
+	        </when>
+			<otherwise>  
+				,'' operationDoctorName,'' operationLevel
+            </otherwise>
+		</choose>
         FROM
         (SELECT
 	        t1.hospital_id AS hospitalId,
@@ -5416,16 +5605,15 @@
 	            WHERE t2.is_deleted = 'N' AND t1.hospital_id = t2.hospital_id AND t1.behospital_code = t2.behospital_code AND ( t2.blood_fee != 0 or t2.blood_fee != 0.00 or t2.blood_fee != null )
 	        </if>
 	        <if test='qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType == 7 and qcResultShortPageVO.hospitalId == "7"'>
-	            ,med_home_page t2
-	            WHERE t2.is_deleted = 'N' AND t1.hospital_id = t2.hospital_id AND t1.behospital_code = t2.behospital_code 
-	            and (t2.outpatient_emr_diagnose_code like 'C%')
+	            ,med_home_page t2,(select home_page_id from med_home_diagnose_info ty where ty.is_deleted= 'N' and #{qcResultShortPageVO.hospitalId}=ty.hospital_id and ty.icd_code like 'C%') ty
+	            WHERE t2.is_deleted = 'N' AND t1.hospital_id = t2.hospital_id AND t1.behospital_code = t2.behospital_code and t2.home_page_id = ty.home_page_id
 	        </if>
     	)t
-        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.hospitalId == "7"'>
+        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.leaveHosType != 2 and qcResultShortPageVO.leaveHosType != 4 and qcResultShortPageVO.leaveHosType != 6 and qcResultShortPageVO.leaveHosType != 7  and qcResultShortPageVO.hospitalId == "7"'>
             ,med_home_page t3,med_home_operation_info t4
         </if>
         where 1=1
-        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.hospitalId == "7"'>
+        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.leaveHosType != 2 and qcResultShortPageVO.leaveHosType != 4 and qcResultShortPageVO.leaveHosType != 6 and qcResultShortPageVO.leaveHosType != 7 and qcResultShortPageVO.hospitalId == "7"'>
             AND t.hospitalId = t3.hospital_id
             AND t.hospitalId = t4.hospital_id
             AND t.behospitalCode = t3.behospital_code
@@ -5459,12 +5647,12 @@
         <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
             AND t.`level` = #{qcResultShortPageVO.level}
         </if>
-        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.hospitalId == "7"'>
+        <if test='qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != "" and qcResultShortPageVO.isPlacefile == "1" and qcResultShortPageVO.leaveHosType != 2 and qcResultShortPageVO.leaveHosType != 4 and qcResultShortPageVO.leaveHosType != 6 and qcResultShortPageVO.leaveHosType != 7 and qcResultShortPageVO.hospitalId == "7"'>
             <if test="qcResultShortPageVO.operationDoctor != null and qcResultShortPageVO.operationDoctor != ''">
                 AND t4.`operation_doctor_id` like concat('%', #{qcResultShortPageVO.operationDoctor}, '%')
             </if>
             <if test="qcResultShortPageVO.operationLevel != null and qcResultShortPageVO.operationLevel != ''">
-                AND t4.ssdj = if(#{qcResultShortPageVO.operationLevel}='1','一级手术',if(#{qcResultShortPageVO.operationLevel}='2','二级手术',if(#{qcResultShortPageVO.operationLevel}='3','三级手术','四级手术')))
+                AND t4.ssdj like concat('%',if(#{qcResultShortPageVO.operationLevel}='1','一级手术',if(#{qcResultShortPageVO.operationLevel}='2','二级手术',if(#{qcResultShortPageVO.operationLevel}='3','三级手术','四级手术'))),'%')
             </if>
             GROUP BY t.behospitalCode
         </if>
@@ -10463,11 +10651,10 @@
     <select id="cancerCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
         SELECT count(1) from (
 	        select a.behospital_code 
-	        FROM med_behospital_info a,med_home_page b, med_home_operation_info t4
-	        WHERE a.hospital_id=b.hospital_id and a.behospital_code=b.behospital_code
+	        FROM med_behospital_info a,med_home_page b,
+	        (select home_page_id from med_home_diagnose_info ty where ty.is_deleted= 'N' and #{hospitalId}=ty.hospital_id and ty.icd_code like 'C%') ty
+	        WHERE a.hospital_id=b.hospital_id and a.behospital_code=b.behospital_code and  b.home_page_id = ty.home_page_id
 	        AND a.qc_type_id != 0 and a.is_deleted = 'N' and b.is_deleted = 'N' 
-	        and (b.outpatient_emr_diagnose_code like 'C%') AND b.home_page_id = t4.home_page_id AND t4.operation_code IS NOT NULL AND t4.operation_code != '[]' 
-	        AND a.hospital_id = t4.hospital_id
 	        <if test="isPlacefile != null and isPlacefile != ''">
 	            and a.is_placefile = #{isPlacefile}
 	        </if>