1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.QcresultInfoMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.QcresultInfo">
- <id column="id" property="id" />
- <result column="behospital_code" property="behospitalCode" />
- <result column="hospital_id" property="hospitalId" />
- <result column="level" property="level" />
- <result column="score_res" property="scoreRes" />
- <result column="grade_type" property="gradeType" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="remark" property="remark" />
- </resultMap>
- <!-- 病历数统计 -->
- <select id="getQcresultSelectively" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
- SELECT
- count(1)
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c
- WHERE
- a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.hospital_id = c.hospital_id
- 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 ]]>
- <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="gradeType != null and gradeType != ''">
- AND c.grade_type = #{gradeType}
- </if>
- <if test="level != null and level != ''">
- AND c.level = #{level}
- </if>
- </select>
- <!-- 质控病历数统计 -->
- <select id="resultCount" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
- SELECT
- COUNT(*)
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![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="gradeType != null and gradeType != ''">
- AND c.grade_type = #{gradeType}
- </if>
- <if test="level != null and level != ''">
- AND c.level = #{level}
- </if>
- </select>
- <!-- 按科室统计质控病历数 -->
- <select id="levelPercentGroupByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.QcResultPercentDTO">
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS totleNum,
- sum( c.`level` = '甲' ) AS firstLevelNum,
- sum( c.`level` = '乙' ) AS secondLevelNum,
- sum( c.`level` = '丙' ) AS thirdLevelNum,
- concat( ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstPercent,
- concat( ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS sencondPercent,
- concat( ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdPercent
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![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>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 按模块统计质控缺陷数 -->
- <select id="entryCountGroupByCase" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- d.cases_id AS id,
- e.NAME AS name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases e,
- qc_cases_entry f
- 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 f.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 d.cases_id = e.id
- AND d.cases_entry_id = f.id
- AND e.id = f.cases_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>
- GROUP BY
- d.cases_id,
- e.`name`
- </select>
- <!-- 条目缺陷分组统计 -->
- <select id="entryCountGroupByEntry" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- e.id,
- e.NAME,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry 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 d.cases_id = e.cases_id
- AND d.cases_entry_id = e.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>
- GROUP BY
- e.id,
- e.NAME
- </select>
- <!-- 质控平均分按科室统计 -->
- <select id="getAverageScoreByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS name,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![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>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 按科室统计质控病历数 -->
- <select id="resultCountByDept" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- sys_user_dept d
- 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.beh_dept_id = d.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND d.user_id = #{userId}
- </if>
- <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="gradeType != null and gradeType != ''">
- AND c.grade_type = #{gradeType}
- </if>
- <if test="level != null and level != ''">
- AND c.level = #{level}
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 按模块统计质控缺陷数 -->
- <select id="entryCountGroupByCaseAndDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.DeptNumDTO">
- SELECT
- d.cases_id AS id,
- e.NAME AS NAME,
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases e,
- qc_cases_entry f,
- sys_user_dept g
- 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 f.is_deleted = 'N'
- AND g.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.hospital_id = g.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.id
- AND d.cases_entry_id = f.id
- AND e.id = f.cases_id
- AND a.beh_dept_id = g.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND g.user_id = #{userId}
- </if>
- <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>
- GROUP BY
- d.cases_id,
- e.`name`,
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 条目缺陷分组统计 -->
- <select id="entryCountGroupByEntryAndDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.DeptNumDTO">
- SELECT
- e.id,
- e.NAME,
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases_entry e,
- sys_user_dept f
- 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 f.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.hospital_id = f.hospital_id
- AND a.behospital_code = b.behospital_code
- 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
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND f.user_id = #{userId}
- </if>
- <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>
- GROUP BY
- e.id,
- e.NAME,
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 按模块统计质控缺陷数(分页) -->
- <select id="entryCountGroupByCasePage" resultType="com.diagbot.dto.NumDTO">
- SELECT
- t.id,
- t.`NAME`,
- t.num,
- t.totleNum,
- t.percent,
- t.percentStr
- FROM
- (
- SELECT
- t1.caseId AS id,
- t1.caseName AS NAME,
- t1.num AS num,
- t2.mrNum,
- t3.originalNum,
- t2.mrNum * t3.originalNum AS totleNum,
- ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) AS percent,
- CONCAT( ROUND( t1.num /( t2.mrNum * t3.originalNum )* 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- d.cases_id AS caseId,
- e.NAME AS caseName,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases e,
- qc_cases_entry f
- 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 f.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 d.cases_id = e.id
- AND d.cases_entry_id = f.id
- AND e.id = f.cases_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- <if test="filterPageVO.deptName != null and filterPageVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
- </if>
- GROUP BY
- d.cases_id,
- e.`name`
- ) t1,
- (
- SELECT
- COUNT(*) AS mrNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.deptName != null and filterPageVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
- </if>
- ) t2,
- (
- SELECT
- a.id AS caseId,
- a.NAME AS caseName,
- count(*) AS originalNum
- FROM
- qc_cases a,
- qc_cases_entry b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.id = b.cases_id
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND a.name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- GROUP BY
- a.id,
- a.`name`
- ) t3
- WHERE
- t1.caseId = t3.caseId
- AND t1.caseName = t3.caseName
- ORDER BY
- ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) DESC
- ) t
- </select>
- <!-- 缺陷详情(分页) -->
- <select id="entryCountGroupByEntryPage" resultType="com.diagbot.dto.CaseNumDTO">
- SELECT t.*
- FROM
- (SELECT
- t1.id,
- t1.NAME,
- t1.casesId,
- t1.casesName,
- count(*) AS num,
- t2.totleNum
- FROM
- (
- SELECT
- e.id AS id,
- e.NAME AS NAME,
- e.cases_id as casesId,
- e.cases_name as casesName
- FROM
- med_behospital_info a,
- med_home_page b,
- <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
- med_qcresult_cases c,
- </if>
- <if test="filterPageVO.casesId == null or filterPageVO.casesId ==0">
- med_qcresult_info c,
- </if>
- med_qcresult_detail d,
- qc_cases_entry 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
- <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
- AND c.cases_id = d.cases_id
- </if>
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.casesId != null and filterPageVO.casesId != 0">
- AND d.cases_id = #{filterPageVO.casesId}
- </if>
- <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
- AND e.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
- </if>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- <if test="filterPageVO.deptName != null and filterPageVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
- </if>
- ) t1,(
- SELECT
- count(*) AS totleNum
- FROM
- med_behospital_info a,
- med_home_page b,
- <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
- med_qcresult_cases c,
- </if>
- <if test="filterPageVO.casesId == null or filterPageVO.casesId ==0">
- med_qcresult_info c,
- </if>
- med_qcresult_detail d,
- qc_cases_entry 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
- <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
- AND c.cases_id = d.cases_id
- </if>
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.casesId != null and filterPageVO.casesId != 0">
- AND d.cases_id = #{filterPageVO.casesId}
- </if>
- <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
- AND e.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
- </if>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- <if test="filterPageVO.deptName != null and filterPageVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
- </if>
- ) t2
- GROUP BY
- t1.id,
- t1.NAME,
- t1.casesId,
- t1.casesName
- )t
- </select>
- <!-- 质控平均分按科室统计(分页) -->
- <select id="getAverageScoreByDeptPage" resultType="com.diagbot.dto.AverageStatisticsDTO">
- SELECT t.*
- FROM
- (SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS name,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
- ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ORDER BY averageValue DESC ) t
- </select>
- <!-- 按科室统计质控病历数(分页) -->
- <select id="levelPercentGroupByDeptPage" resultType="com.diagbot.dto.QcResultPercentDTO">
- SELECT t.*
- FROM
- (SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS totleNum,
- sum( c.`level` = '甲' ) AS firstLevelNum,
- sum( c.`level` = '乙' ) AS secondLevelNum,
- sum( c.`level` = '丙' ) AS thirdLevelNum,
- concat( ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstPercent,
- concat( ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS sencondPercent,
- concat( ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdPercent
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info 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
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageVO.hospitalId}
- </if>
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
- </if>
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
- </if>
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- order by ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ) DESC,
- ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ) DESC,
- ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ) DESC) t
- </select>
- <!-- 按模块统计质控缺陷数-科室(分页) -->
- <select id="entryCountGroupByCaseAndDeptPage" resultType="com.diagbot.dto.DeptNumDTO">
- SELECT
- t.id,
- t.`NAME`,
- t.num,
- t.totleNum,
- t.percent,
- t.percentStr
- FROM
- (
- SELECT
- t1.caseId AS id,
- t1.caseName AS NAME,
- t1.num AS num,
- t2.mrNum,
- t3.originalNum,
- t2.mrNum * t3.originalNum AS totleNum,
- ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) AS percent,
- CONCAT( ROUND( t1.num /( t2.mrNum * t3.originalNum )* 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- d.cases_id AS caseId,
- e.NAME AS caseName,
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- qc_cases e,
- qc_cases_entry f,
- sys_user_dept g
- 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 f.is_deleted = 'N'
- AND g.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.hospital_id = g.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- AND d.cases_id = e.id
- AND d.cases_entry_id = f.id
- AND e.id = f.cases_id
- AND a.beh_dept_id = g.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND g.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
- </if>
- <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- GROUP BY
- d.cases_id,
- e.`name`,
- a.beh_dept_id,
- a.beh_dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- COUNT(*) AS mrNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- sys_user_dept d
- 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.beh_dept_id = d.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND d.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t2,
- (
- SELECT
- a.id AS caseId,
- a.NAME AS caseName,
- count(*) AS originalNum
- FROM
- qc_cases a,
- qc_cases_entry b
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.id = b.cases_id
- GROUP BY
- a.id,
- a.`name`
- ) t3
- WHERE
- t1.caseId = t3.caseId
- AND t1.caseName = t3.caseName
- AND t1.deptId = t2.deptId
- AND t1.deptName = t2.deptName
- ORDER BY
- ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) DESC
- ) t
- </select>
- <!-- 缺陷详情-科室(分页) -->
- <select id="entryCountGroupByEntryAndDeptPage" resultType="com.diagbot.dto.CaseAndDeptNumDTO">
- SELECT
- t.*
- FROM
- (
- SELECT
- t1.id,
- t1.NAME,
- t1.casesId,
- t1.casesName,
- t1.deptId,
- t1.deptName,
- count(*) AS num,
- t2.totleNum
- FROM
- (
- SELECT
- e.id,
- e.NAME,
- e.cases_id as casesId,
- e.cases_name as casesName,
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName
- FROM
- med_behospital_info a,
- med_home_page b,
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
- med_qcresult_cases c,
- </if>
- <if test="filterPageByDeptVO.casesId == null or filterPageByDeptVO.casesId ==0">
- med_qcresult_info c,
- </if>
- med_qcresult_detail d,
- qc_cases_entry e,
- sys_user_dept f
- 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 f.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.hospital_id = f.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
- AND c.cases_id = d.cases_id
- </if>
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND a.beh_dept_id = f.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId != 0">
- AND d.cases_id = #{filterPageByDeptVO.casesId}
- </if>
- <if test="filterPageByDeptVO.casesName != null and filterPageByDeptVO.casesName != ''">
- AND e.cases_name like CONCAT('%', #{filterPageByDeptVO.casesName},'%')
- </if>
- <if test="filterPageByDeptVO.userId!=null">
- AND f.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
- </if>
- <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageByDeptVO.deptName},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name like CONCAT('%', #{filterPageByDeptVO.doctorName},'%')
- </if>
- ) t1,(
- SELECT
- count(*) AS totleNum
- FROM
- med_behospital_info a,
- med_home_page b,
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
- med_qcresult_cases c,
- </if>
- <if test="filterPageByDeptVO.casesId == null or filterPageByDeptVO.casesId ==0">
- med_qcresult_info c,
- </if>
- med_qcresult_detail d,
- qc_cases_entry e,
- sys_user_dept f
- 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 f.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.hospital_id = f.hospital_id
- AND a.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.behospital_code = d.behospital_code
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
- AND c.cases_id = d.cases_id
- </if>
- AND d.cases_id = e.cases_id
- AND d.cases_entry_id = e.id
- AND a.beh_dept_id = f.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId != 0">
- AND d.cases_id = #{filterPageByDeptVO.casesId}
- </if>
- <if test="filterPageByDeptVO.casesName != null and filterPageByDeptVO.casesName != ''">
- AND e.cases_name like CONCAT('%', #{filterPageByDeptVO.casesName},'%')
- </if>
- <if test="filterPageByDeptVO.userId!=null">
- AND f.user_id = #{filterPageByDeptVO.userId}
- </if>
- <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
- AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
- </if>
- <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
- </if>
- <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
- </if>
- <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
- AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name like CONCAT('%', #{filterPageByDeptVO.deptName},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name like CONCAT('%', #{filterPageByDeptVO.doctorName},'%')
- </if>
- ) t2
- GROUP BY
- t1.id,
- t1.NAME,
- t1.casesId,
- t1.casesName,
- t1.deptId,
- t1.deptName
- )t
- </select>
- </mapper>
|