|
@@ -1208,6 +1208,222 @@
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(上级科室允许为空) -->
|
|
|
+ <select id="levelStatisticsByDeptClass2" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
|
|
|
+ SELECT
|
|
|
+ t1.deptId,
|
|
|
+ t1.deptName,
|
|
|
+ t1.deptClassId,
|
|
|
+ t1.deptClass,
|
|
|
+ t2.entryNum,
|
|
|
+ t1.mrNum,
|
|
|
+ t1.totleValue,
|
|
|
+ t1.averageValue,
|
|
|
+ t1.firstLevelNum,
|
|
|
+ t1.secondLevelNum,
|
|
|
+ t1.thirdLevelNum,
|
|
|
+ t1.firstLevelPercent,
|
|
|
+ t1.secondLevelPercent,
|
|
|
+ t1.thirdLevelPercent,
|
|
|
+ t1.firstLevelPercentStr,
|
|
|
+ t1.secondLevelPercentStr,
|
|
|
+ t1.thirdLevelPercentStr
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ tt1.deptId,
|
|
|
+ tt1.deptName,
|
|
|
+ e.dept_id AS deptClassId,
|
|
|
+ e.dept_name AS deptClass,
|
|
|
+ count( DISTINCT tt1.behospitalCode ) AS mrNum,
|
|
|
+ ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
|
|
|
+ ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
|
|
|
+ COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END ) AS firstLevelNum,
|
|
|
+ COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END ) AS secondLevelNum,
|
|
|
+ COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END ) AS thirdLevelNum,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS firstLevelPercent,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS secondLevelPercent,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS thirdLevelPercent,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS firstLevelPercentStr,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS secondLevelPercentStr,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS thirdLevelPercentStr
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ d.parent_dept_id AS parentDeptId,
|
|
|
+ a.hospital_id AS hospitalId,
|
|
|
+ a.behospital_code AS behospitalCode,
|
|
|
+ c.score_res AS score,
|
|
|
+ c.LEVEL
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_qcresult_info c,
|
|
|
+ bas_dept_info d
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND d.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.beh_dept_id = d.dept_id
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ <![CDATA[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="level != null and level != ''">
|
|
|
+ and c.level = #{level}
|
|
|
+ </if>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ and a.beh_dept_name like CONCAT('%',#{name},'%')
|
|
|
+ </if>
|
|
|
+ ) tt1
|
|
|
+ LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
|
|
|
+ AND e.is_deleted = 'N'
|
|
|
+ AND tt1.hospitalId = e.hospital_id
|
|
|
+ <if test="deptClass != null and deptClass != ''">
|
|
|
+ WHERE e.dept_name = #{deptClass}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ tt1.deptId,
|
|
|
+ tt1.deptName,
|
|
|
+ e.dept_id,
|
|
|
+ e.dept_name
|
|
|
+ ) t1,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ tt2.deptId,
|
|
|
+ tt2.deptName,
|
|
|
+ g.dept_id AS deptClassId,
|
|
|
+ g.dept_name AS deptClass,
|
|
|
+ count( * ) AS entryNum
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS deptId,
|
|
|
+ a.beh_dept_name AS deptName,
|
|
|
+ f.parent_dept_id AS parentDeptId,
|
|
|
+ a.hospital_id AS hospitalId,
|
|
|
+ a.behospital_code AS behospitalCode
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_qcresult_info c,
|
|
|
+ med_qcresult_detail d,
|
|
|
+ qc_cases_entry e,
|
|
|
+ bas_dept_info f
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND d.is_deleted = 'N'
|
|
|
+ AND e.is_deleted = 'N'
|
|
|
+ AND f.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = c.hospital_id
|
|
|
+ AND a.hospital_id = d.hospital_id
|
|
|
+ AND a.hospital_id = f.hospital_id
|
|
|
+ AND a.behospital_code = c.behospital_code
|
|
|
+ AND a.behospital_code = d.behospital_code
|
|
|
+ AND d.cases_id = e.cases_id
|
|
|
+ AND d.cases_entry_id = e.id
|
|
|
+ AND a.beh_dept_id = f.dept_id
|
|
|
+ AND a.is_placefile = '1'
|
|
|
+ <![CDATA[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="level != null and level != ''">
|
|
|
+ and c.level = #{level}
|
|
|
+ </if>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ and a.beh_dept_name like CONCAT('%',#{name},'%')
|
|
|
+ </if>
|
|
|
+ ) tt2
|
|
|
+ LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
|
|
|
+ AND g.is_deleted = 'N'
|
|
|
+ AND tt2.hospitalId = g.hospital_id
|
|
|
+ <if test="deptClass != null and deptClass != ''">
|
|
|
+ WHERE g.dept_name = #{deptClass}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ tt2.deptId,
|
|
|
+ tt2.deptName,
|
|
|
+ g.dept_id,
|
|
|
+ g.dept_name
|
|
|
+ ) t2
|
|
|
+ WHERE
|
|
|
+ t1.deptId = t2.deptId
|
|
|
+ AND t1.deptName = t2.deptName
|
|
|
+ <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=="deptClassId"'>deptClassId asc</when>
|
|
|
+ <when test='asc=="deptClass"'>deptClass asc</when>
|
|
|
+ <when test='asc=="entryNum"'>entryNum asc</when>
|
|
|
+ <when test='asc=="mrNum"'>mrNum asc</when>
|
|
|
+ <when test='asc=="totleValue"'>totleValue asc</when>
|
|
|
+ <when test='asc=="averageValue"'>averageValue asc</when>
|
|
|
+ <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
|
|
|
+ <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
|
|
|
+ <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
|
|
|
+ <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
|
|
|
+ <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
|
|
|
+ <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
|
|
|
+ <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
|
|
|
+ <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
|
|
|
+ <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent 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=="deptClassId"'>deptClassId desc</when>
|
|
|
+ <when test='desc=="deptClass"'>deptClass desc</when>
|
|
|
+ <when test='desc=="entryNum"'>entryNum desc</when>
|
|
|
+ <when test='desc=="mrNum"'>mrNum desc</when>
|
|
|
+ <when test='desc=="totleValue"'>totleValue desc</when>
|
|
|
+ <when test='desc=="averageValue"'>averageValue desc</when>
|
|
|
+ <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
|
|
|
+ <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
|
|
|
+ <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
|
|
|
+ <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
|
|
|
+ <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
|
|
|
+ <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
|
|
|
+ <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
|
|
|
+ <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
|
|
|
+ <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
|
|
|
+ <otherwise>deptName desc</otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
<!-- 病案首页合格率占比 -全院-->
|
|
|
<select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
|
|
|
resultType="com.diagbot.dto.HomePageNumDTO">
|