|
@@ -940,4 +940,218 @@
|
|
|
</choose>
|
|
|
</if>
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- 各科室缺陷占比(主任医生) -->
|
|
|
+ <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
|
|
|
+ SELECT
|
|
|
+ a.doctor_id AS doctorId,
|
|
|
+ a.doctor_name AS doctorName,
|
|
|
+ count( DISTINCT d.id ) AS entryNum,
|
|
|
+ count( DISTINCT c.id ) AS mrNum,
|
|
|
+ ROUND( sum( c.score_res ), 2 ) AS totleValue,
|
|
|
+ ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
|
|
|
+ COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
|
|
|
+ COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
|
|
|
+ COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
|
|
|
+ 1-ROUND ( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) - ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS thirdLevelPercent,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS firstLevelPercentStr,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS sencondLevelPercentStr,
|
|
|
+ concat(
|
|
|
+ (
|
|
|
+ 100-ROUND ( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ) - ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 )),
|
|
|
+ '%'
|
|
|
+ ) AS thirdLevelPercentStr
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b,
|
|
|
+ med_qcresult_info c,
|
|
|
+ med_qcresult_detail d,
|
|
|
+ sys_user_dept e
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND d.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.hospital_id = c.hospital_id
|
|
|
+ AND a.hospital_id = d.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.behospital_code = c.behospital_code
|
|
|
+ AND a.behospital_code = d.behospital_code
|
|
|
+ AND a.beh_dept_id = e.dept_id
|
|
|
+ <![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.doctor_name like CONCAT('%',#{name},'%')
|
|
|
+ </if>
|
|
|
+ <if test="userId!=null and userId !=''">
|
|
|
+ AND e.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName!=null and deptName !=''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.doctor_id,
|
|
|
+ a.doctor_name
|
|
|
+ <if test="asc != null and asc !=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='asc=="doctorId"'>doctorId asc</when>
|
|
|
+ <when test='asc=="doctorName"'>doctorName 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>
|
|
|
+ <otherwise> doctorName asc </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="desc != null and desc!=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='desc=="doctorId"'>doctorId desc</when>
|
|
|
+ <when test='desc=="doctorName"'>doctorName 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>
|
|
|
+ <otherwise> doctorName desc </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 病案首页合格率占比(主任医生) -->
|
|
|
+ <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
|
|
|
+ SELECT
|
|
|
+ a.doctor_id AS doctorId,
|
|
|
+ a.doctor_name AS doctorName,
|
|
|
+ count( DISTINCT d.id ) AS entryNum,
|
|
|
+ count( DISTINCT c.id ) AS mrNum,
|
|
|
+ ROUND( sum( c.score_res ), 2 ) AS totleValue,
|
|
|
+ ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
|
|
|
+ COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
|
|
|
+ COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
|
|
|
+ 1-ROUND ( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
|
|
|
+ concat(
|
|
|
+ ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS firstLevelPercentStr,
|
|
|
+ concat(
|
|
|
+ 100-ROUND ( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
|
|
|
+ '%'
|
|
|
+ ) AS secondLevelPercentStr
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b,
|
|
|
+ med_qcresult_cases c,
|
|
|
+ med_qcresult_detail d,
|
|
|
+ sys_user_dept e
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ AND c.is_deleted = 'N'
|
|
|
+ AND d.is_deleted = 'N'
|
|
|
+ AND e.is_deleted = 'N'
|
|
|
+ AND a.hospital_id = b.hospital_id
|
|
|
+ AND a.hospital_id = c.hospital_id
|
|
|
+ AND a.hospital_id = d.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.behospital_code = c.behospital_code
|
|
|
+ AND a.behospital_code = d.behospital_code
|
|
|
+ AND a.beh_dept_id = e.dept_id
|
|
|
+ AND c.cases_id = d.cases_id
|
|
|
+ AND c.cases_id = 243
|
|
|
+ <![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.doctor_name like CONCAT('%',#{name},'%')
|
|
|
+ </if>
|
|
|
+ <if test="userId!=null and userId !=''">
|
|
|
+ AND e.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName!=null and deptName !=''">
|
|
|
+ AND a.beh_dept_name = #{deptName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.doctor_id,
|
|
|
+ a.doctor_name
|
|
|
+ <if test="asc != null and asc !=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='asc=="doctorId"'>doctorId asc</when>
|
|
|
+ <when test='asc=="doctorName"'>doctorName 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>
|
|
|
+ <otherwise> doctorName asc </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="desc != null and desc!=''">
|
|
|
+ order by
|
|
|
+ <choose>
|
|
|
+ <when test='desc=="doctorId"'>doctorId desc</when>
|
|
|
+ <when test='desc=="doctorName"'>doctorName 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>
|
|
|
+ <otherwise> doctorName desc </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|