|
@@ -2978,4 +2978,281 @@
|
|
|
where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
|
|
|
</foreach>
|
|
|
</update>
|
|
|
+
|
|
|
+ <!-- 关键条目缺陷统计报表-->
|
|
|
+ <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
|
|
|
+ SELECT
|
|
|
+ deptId,
|
|
|
+ deptName,
|
|
|
+ consultationNum,
|
|
|
+ 2511 AS consultationEntryId,
|
|
|
+ ROUND( consultationNum / consultationMRNum, 4 ) AS consultationPercent,
|
|
|
+ CONCAT( ROUND( consultationNum / consultationMRNum * 100, 2 ), '%' ) AS consultationPercentStr,
|
|
|
+ consultationMRNum,
|
|
|
+ 2594 AS operationNameEntryId,
|
|
|
+ operationNameNum,
|
|
|
+ ROUND( operationNameNum / operationMRNum, 4 ) AS operationNamePercent,
|
|
|
+ CONCAT( ROUND( operationNameNum / operationMRNum * 100, 2 ), '%' ) AS operationNamePercentStr,
|
|
|
+ 2594 AS operationTimeEntryId,
|
|
|
+ operationTimeNum,
|
|
|
+ ROUND( operationTimeNum / operationMRNum, 4 ) AS operationTimePercent,
|
|
|
+ CONCAT( ROUND( operationTimeNum / operationMRNum * 100, 2 ), '%' ) AS operationTimePercentStr,
|
|
|
+ operationMRNum,
|
|
|
+ 2419 AS crisisEntryId,
|
|
|
+ crisisNum,
|
|
|
+ ROUND( crisisNum / crisisMRNum, 4 ) AS crisisPercent,
|
|
|
+ CONCAT( ROUND( crisisNum / crisisMRNum * 100, 2 ), '%' ) AS crisisPercentStr,
|
|
|
+ crisisMRNum,
|
|
|
+ 2495 AS stageSummaryEntryId,
|
|
|
+ stageSummaryNum,
|
|
|
+ ROUND( stageSummaryNum / stageSummaryMRNum, 4 ) AS stageSummaryPercent,
|
|
|
+ CONCAT( ROUND( stageSummaryNum / stageSummaryMRNum * 100, 2 ), '%' ) AS stageSummaryPercentStr,
|
|
|
+ stageSummaryMRNum
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ tt.deptId,
|
|
|
+ tt.deptName,
|
|
|
+ sum( tt.consultationMRNum )- sum( tt.consultationNum ) AS consultationNum,
|
|
|
+ sum( tt.consultationMRNum ) AS consultationMRNum,
|
|
|
+ sum( tt.operationMRNum )- sum( tt.operationNameNum ) AS operationNameNum,
|
|
|
+ sum( tt.operationMRNum )- sum( tt.operationTimeNum ) AS operationTimeNum,
|
|
|
+ sum( tt.operationMRNum ) AS operationMRNum,
|
|
|
+ sum( tt.crisisMRNum )- sum( tt.crisisNum ) AS crisisNum,
|
|
|
+ sum( tt.crisisMRNum ) AS crisisMRNum,
|
|
|
+ sum( tt.stageSummaryMRNum )- sum( tt.stageSummaryNum ) AS stageSummaryNum,
|
|
|
+ sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ sum( c.cases_entry_id = 2511 ) AS consultationNum,
|
|
|
+ count( DISTINCT a.behospital_code ) AS consultationMRNum,
|
|
|
+ 0 AS operationNameNum,
|
|
|
+ 0 AS operationTimeNum,
|
|
|
+ 0 AS operationMRNum,
|
|
|
+ 0 AS crisisNum,
|
|
|
+ 0 AS crisisMRNum,
|
|
|
+ 0 AS stageSummaryNum,
|
|
|
+ 0 AS stageSummaryMRNum
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_medical_record b,
|
|
|
+ med_qcresult_detail c
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.hospital_id = c.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.behospital_code = c.behospital_code
|
|
|
+ AND b.mode_id = 30
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ AND a.qc_type_id !=0
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ 0 AS consultationNum,
|
|
|
+ 0 AS consultationMRNum,
|
|
|
+ sum( c.cases_entry_id = 2594 ) AS operationNameNum,
|
|
|
+ sum( c.cases_entry_id = 2594 ) AS operationTimeNum,
|
|
|
+ count( DISTINCT a.behospital_code ) AS operationMRNum,
|
|
|
+ 0 AS crisisNum,
|
|
|
+ 0 AS crisisMRNum,
|
|
|
+ 0 AS stageSummaryNum,
|
|
|
+ 0 AS stageSummaryMRNum
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b,
|
|
|
+ med_qcresult_detail c
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.hospital_id = c.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.behospital_code = c.behospital_code
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ AND a.qc_type_id !=0
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ sum( c.cases_entry_id = 2419 ) AS crisisNum,
|
|
|
+ count( DISTINCT a.behospital_code ) AS crisisMRNum,
|
|
|
+ 0 AS consultationNum,
|
|
|
+ 0 AS consultationMRNum,
|
|
|
+ 0 AS operationNameNum,
|
|
|
+ 0 AS operationTimeNum,
|
|
|
+ 0 AS operationMRNum,
|
|
|
+ 0 AS stageSummaryNum,
|
|
|
+ 0 AS stageSummaryMRNum
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_crisis_info b,
|
|
|
+ med_qcresult_detail c
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ AND a.qc_type_id !=0
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ sum( b.cases_entry_id = 2495 ) AS stageSummaryNum,
|
|
|
+ count( DISTINCT a.behospital_code ) AS stageSummaryMRNum,
|
|
|
+ 0 AS consultationNum,
|
|
|
+ 0 AS consultationMRNum,
|
|
|
+ 0 AS operationNameNum,
|
|
|
+ 0 AS operationTimeNum,
|
|
|
+ 0 AS operationMRNum,
|
|
|
+ 0 AS crisisNum,
|
|
|
+ 0 AS crisisMRNum
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_qcresult_detail b
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND TIMESTAMPDIFF(
|
|
|
+ DAY,
|
|
|
+ DATE( behospital_date ),
|
|
|
+ DATE( leave_hospital_date ))> 30
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ AND a.qc_type_id !=0
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ )
|
|
|
+ ) tt
|
|
|
+ GROUP BY
|
|
|
+ tt.deptId,
|
|
|
+ tt.deptName
|
|
|
+ ) t
|
|
|
+ <if test="asc != null and asc !=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='asc=="deptId"'>deptId asc</when>
|
|
|
+ <when test='asc=="deptName"'>deptName asc</when>
|
|
|
+ <when test='asc=="consultationNum"'>consultationNum asc</when>
|
|
|
+ <when test='asc=="consultationPercent"'>consultationPercent asc</when>
|
|
|
+ <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
|
|
|
+ <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
|
|
|
+ <when test='asc=="operationNameNum"'>operationNameNum asc</when>
|
|
|
+ <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
|
|
|
+ <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
|
|
|
+ <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
|
|
|
+ <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
|
|
|
+ <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
|
|
|
+ <when test='asc=="operationMRNum"'>operationMRNum asc</when>
|
|
|
+ <when test='asc=="crisisNum"'>crisisNum asc</when>
|
|
|
+ <when test='asc=="crisisPercent"'>crisisPercent asc</when>
|
|
|
+ <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
|
|
|
+ <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
|
|
|
+ <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
|
|
|
+ <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
|
|
|
+ <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
|
|
|
+ <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
|
|
|
+ <otherwise>deptName asc</otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="desc != null and desc!=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='desc=="deptId"'>deptId desc</when>
|
|
|
+ <when test='desc=="deptName"'>deptName desc</when>
|
|
|
+ <when test='desc=="consultationNum"'>consultationNum desc</when>
|
|
|
+ <when test='desc=="consultationPercent"'>consultationPercent desc</when>
|
|
|
+ <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
|
|
|
+ <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
|
|
|
+ <when test='desc=="operationNameNum"'>operationNameNum desc</when>
|
|
|
+ <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
|
|
|
+ <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
|
|
|
+ <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
|
|
|
+ <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
|
|
|
+ <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
|
|
|
+ <when test='desc=="operationMRNum"'>operationMRNum desc</when>
|
|
|
+ <when test='desc=="crisisNum"'>crisisNum desc</when>
|
|
|
+ <when test='desc=="crisisPercent"'>crisisPercent desc</when>
|
|
|
+ <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
|
|
|
+ <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
|
|
|
+ <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
|
|
|
+ <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
|
|
|
+ <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
|
|
|
+ <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
|
|
|
+ <otherwise>deptName desc</otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|