1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555 |
- <?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.BehospitalInfoMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
- <id column="behospital_code" property="behospitalCode" />
- <result column="hospital_id" property="hospitalId" />
- <result column="name" property="name" />
- <result column="sex" property="sex" />
- <result column="birthday" property="birthday" />
- <result column="file_code" property="fileCode" />
- <result column="qc_type_id" property="qcTypeId" />
- <result column="ward_code" property="wardCode" />
- <result column="ward_name" property="wardName" />
- <result column="beh_dept_id" property="behDeptId" />
- <result column="beh_dept_name" property="behDeptName" />
- <result column="bed_code" property="bedCode" />
- <result column="bed_name" property="bedName" />
- <result column="insurance_name" property="insuranceName" />
- <result column="job_type" property="jobType" />
- <result column="behospital_date" property="behospitalDate" />
- <result column="leave_hospital_date" property="leaveHospitalDate" />
- <result column="diagnose_icd" property="diagnoseIcd" />
- <result column="diagnose" property="diagnose" />
- <result column="beh_doctor_id" property="behDoctorId" />
- <result column="beh_doctor_name" property="behDoctorName" />
- <result column="doctor_id" property="doctorId" />
- <result column="doctor_name" property="doctorName" />
- <result column="director_doctor_id" property="directorDoctorId" />
- <result column="director_doctor_name" property="directorDoctorName" />
- <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" />
- </resultMap>
- <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
- select * from (
- select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as grade_time, c.age from med_behospital_info a
- LEFT JOIN med_qcresult_info b
- on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
- left join med_home_page c
- on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
- ) t
- where t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="doctorName != null and doctorName != ''">
- and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- and (t.doctor_id = #{doctorCode}
- or t.beh_doctor_id = #{doctorCode}
- or t.director_doctor_id = #{doctorCode})
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="hospitalId != null">
- and t.hospital_id = #{hospitalId}
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- and t.qc_type_id != 0
- </select>
- <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
- SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
- a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg
- FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
- where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
- and a.id = c.cases_entry_id
- and a.mode_id = b.id
- AND c.cases_id = d.cases_id
- and c.hospital_id = d.hospital_id
- and c.hospital_id = #{hospitalId}
- and c.behospital_code = #{behospitalCode}
- order by b.order_no, a.order_no
- </select>
- <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
- SELECT b.id model_id,b.`name` model_name,
- d.score,d.msg,d.cases_entry_id,d.is_reject,
- a.cases_id cases_id, a.name standard_msg,a.code
- FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
- where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
- and a.mode_id = b.id
- and a.id = d.cases_entry_id
- and d.is_used = 1
- and d.hospital_id = #{hospitalId}
- and a.code in
- <foreach collection="codeList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="modeId != null">
- and a.mode_id = #{modeId}
- </if>
- order by b.order_no, a.order_no;
- </select>
- <!-- 缺陷排行列表 -->
- <select id="resultStatistics" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- t1.msg AS name,
- t1.num AS num,
- round( t1.num / t2.totle, 4) AS percent
- FROM
- (
- (
- SELECT
- d.msg,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- GROUP BY
- d.msg
- ORDER BY
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- ) t2
- )
- <if test="limitCount != null and limitCount != ''">
- limit 0,#{limitCount}
- </if>
- </select>
- <!-- 各科室缺陷占比 -->
- <select id="resultStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- t1.beh_dept_name AS name,
- t1.num AS num,
- round( t1.num / t2.totle, 4 ) AS percent
- FROM
- (
- (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ORDER BY
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- ) t2
- )
- </select>
- <!-- 缺陷排行列表 -->
- <select id="resultStatistics2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- d.msg as name,
- count(*) AS num
- FROM
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- GROUP BY
- d.msg
- ORDER BY
- count(*) DESC
- <if test="limitCount != null and limitCount != ''">
- limit 0,#{limitCount}
- </if>
- </select>
- <!-- 各科室缺陷占比 -->
- <select id="resultStatisticsByDept2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id,
- a.beh_dept_name as name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ORDER BY
- count(*) DESC
- </select>
- <!-- 缺陷总数查询-->
- <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.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>
- </select>
- <!--获取未评分病历-->
- <select id="getNoGrade" resultMap="BaseResultMap">
- select * from med_behospital_info a
- where a.is_deleted = 'N'
- and
- not EXISTS (
- SELECT
- 1
- FROM
- med_qcresult_info b
- WHERE
- b.is_deleted = 'N'
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = b.behospital_code
- )
- and a.qc_type_id != 0
- <if test="leaveDate != null">
- <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
- </if>
- </select>
- <!--质控评分(科室)分页-->
- <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
- SELECT
- *
- FROM
- ( SELECT
- a.*,
- IFNULL(b.level, '未评分') AS `level`,
- b.grade_type,
- b.score_res,
- b.gmt_create AS grade_time,
- c.age
- FROM
- med_behospital_info a
- JOIN sys_user_dept d
- ON a.hospital_id = d.hospital_id
- AND a.beh_dept_id = d.dept_id
- LEFT JOIN med_qcresult_info b
- ON a.behospital_code = b.behospital_code
- AND b.is_deleted = 'N'
- LEFT JOIN med_home_page c
- ON a.behospital_code = c.behospital_code
- AND c.is_deleted = 'N'
- WHERE d.is_deleted = 'N'
- AND d.user_id = #{userId}
- ) t
- where t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="doctorName != null and doctorName != ''">
- and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
- </if>
- <if test="doctorCode != null and doctorCode != ''">
- and (t.doctor_id = #{doctorCode}
- or t.beh_doctor_id = #{doctorCode}
- or t.director_doctor_id = #{doctorCode})
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="hospitalId != null">
- and t.hospital_id = #{hospitalId}
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- and t.qc_type_id != 0
- </select>
- <!--质控评分(个人)分页-->
- <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
- select * from (SELECT
- a.*,
- IFNULL(b.level, '未评分') AS `level`,
- b.grade_type,
- b.score_res,
- b.gmt_create AS grade_time,
- c.age
- FROM
- med_behospital_info a
- JOIN
- (SELECT
- u.id,
- u.linkman AS linkman,
- uh.hospital_id
- FROM
- sys_user u
- JOIN sys_user_hospital uh
- ON u.id = uh.user_id
- WHERE u.is_deleted = "N"
- AND u.id = #{userId}
- AND uh.hospital_id = #{hospitalId}) u1
- ON a.hospital_id = u1.hospital_id
- LEFT JOIN med_qcresult_info b
- ON a.behospital_code = b.behospital_code
- AND b.is_deleted = 'N'
- LEFT JOIN med_home_page c
- ON a.behospital_code = c.behospital_code
- AND c.is_deleted = 'N'
- WHERE CONCAT(
- IFNULL(a.doctor_name, ''),
- IFNULL(a.beh_doctor_name, ''),
- IFNULL(a.director_doctor_name, '')
- ) LIKE CONCAT('%', u1.linkman, '%')
- ) t
- where t.is_deleted = 'N'
- <if test="deptId != null and deptId != ''">
- and t.beh_dept_id = #{deptId}
- </if>
- <if test="name != null and name != ''">
- and t.name like CONCAT('%',#{name},'%')
- </if>
- <if test="fileCode != null and fileCode != ''">
- and t.file_code like CONCAT('%',#{fileCode},'%')
- </if>
- <if test="behospitalCode != null and behospitalCode != ''">
- and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
- </if>
- <if test="behosDateStart != null">
- <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null">
- <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
- </if>
- <if test="leaveHosDateStart != null">
- <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
- </if>
- <if test="leaveHosDateEnd != null">
- <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
- </if>
- <if test="level != null and level != ''">
- and t.level = #{level}
- </if>
- and t.qc_type_id != 0
- </select>
- <!-- 病案首页病历数统计 -->
- <select id="homePageCount" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="int">
- SELECT
- COUNT(*)
- FROM
- med_behospital_info a,
- med_home_page 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
- <![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="death!=null and death==1">
- AND b.leave_hospital_type = '死亡'
- </if>
- <if test="newBorn!=null and newBorn==1">
- AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
- <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
- </if>
- </select>
- <!-- 病案首页手术病历数统计 -->
- <select id="homePageCountForOperation" parameterType="com.diagbot.vo.FilterVO" resultType="int">
- SELECT
- COUNT(DISTINCT a.behospital_code)
- FROM
- med_behospital_info a,
- med_home_page b,
- med_home_operation_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 b.home_page_id = c.home_page_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>
- </select>
- <!-- 按科室统计病案首页病历数 -->
- <select id="homePageCountByDept" parameterType="com.diagbot.vo.HomePageFilterVO" 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,
- sys_user_dept 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.beh_dept_id = c.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="death!=null and death==1">
- AND b.leave_hospital_type = '死亡'
- </if>
- <if test="userId!=null">
- AND c.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
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 按科室病案首页手术病历数 -->
- <select id="homePageCountForOperationByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
- SELECT
- a.beh_dept_id AS id,
- a.beh_dept_name AS NAME,
- COUNT(DISTINCT a.behospital_code) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- sys_user_dept c,
- med_home_operation_info 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 b.home_page_id = d.home_page_id
- AND a.beh_dept_id = c.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="userId!=null">
- AND c.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
- a.beh_dept_id,
- a.beh_dept_name
- </select>
- <!-- 各科室缺陷占比排行(分页) -->
- <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
- SELECT t.*
- FROM
- (SELECT
- t1.beh_dept_name AS NAME,
- t1.num AS num,
- t2.totle AS totleNum,
- round( t1.num / t2.totle, 4 ) AS percent,
- concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- a.beh_dept_id,
- a.beh_dept_name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <![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
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- <![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>
- ) t2
- )t
- </select>
- <!-- 科室缺陷占比(主任医生) -->
- <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
- SELECT
- t.*
- FROM
- (
- SELECT
- t1.NAME,
- t1.num AS num,
- t2.totle AS totleNum,
- round( t1.num / t2.totle, 4 ) AS percent,
- concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
- FROM
- (
- SELECT
- d.msg as name,
- count(*) AS num
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- sys_user_dept e
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND 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.beh_dept_id = e.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND e.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 d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name = #{filterPageByDeptVO.doctorName}
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- GROUP BY
- d.msg
- ORDER BY
- count(*) DESC
- ) t1,
- (
- SELECT
- count(*) AS totle
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_info c,
- med_qcresult_detail d,
- sys_user_dept e
- WHERE
- a.behospital_code = b.behospital_code
- AND a.hospital_id = b.hospital_id
- AND a.behospital_code = c.behospital_code
- AND a.hospital_id = c.hospital_id
- AND a.behospital_code = d.behospital_code
- AND a.hospital_id = d.hospital_id
- AND 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.beh_dept_id = e.dept_id
- <![CDATA[AND a.qc_type_id <>0 ]]>
- <if test="filterPageByDeptVO.userId!=null">
- AND e.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 d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
- </if>
- <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
- AND a.doctor_name = #{filterPageByDeptVO.doctorName}
- </if>
- <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
- AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
- </if>
- ) t2
- )t
- </select>
- <!-- 各科室缺陷占比(组合) -->
- <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- 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
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- 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,
- 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 secondLevelPercentStr,
- concat(
- 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
- 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="level != null and level != ''">
- and c.level = #{level}
- </if>
- <if test="name != null and name != ''">
- and a.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_detail c,
- qc_cases_entry 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.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.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.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_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=="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=="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.LevelStatisticsDTO">
- SELECT
- t1.deptId,
- t1.deptName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr
- FROM
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- 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,
- 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(
- 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
- 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 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.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_dept_name
- ) t1,
- (
- SELECT
- a.beh_dept_id AS deptId,
- a.beh_dept_name AS deptName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_detail c,
- qc_cases_entry 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.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.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.beh_dept_name like CONCAT('%',#{name},'%')
- </if>
- GROUP BY
- a.beh_dept_id,
- a.beh_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=="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=="firstLevelPercent"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent 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=="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=="firstLevelPercent"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <otherwise> deptName desc </otherwise>
- </choose>
- </if>
- </select>
- <!-- 各科室缺陷占比(主任医生) -->
- <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
- SELECT
- t1.doctorId,
- t1.doctorName,
- 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
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- 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,
- 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 secondLevelPercentStr,
- concat(
- 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,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND e.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.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
- ) t1,
- (
- SELECT
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_detail c,
- qc_cases_entry 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.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.id
- 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
- ) t2
- WHERE
- t1.doctorId = t2.doctorId
- AND t1.doctorName = t2.doctorName
- <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>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>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>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise> doctorName desc </otherwise>
- </choose>
- </if>
- </select>
- <!-- 病案首页合格率占比(主任医生) -->
- <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
- SELECT
- t1.doctorId,
- t1.doctorName,
- t2.entryNum,
- t1.mrNum,
- t1.totleValue,
- t1.averageValue,
- t1.firstLevelNum,
- t1.secondLevelNum,
- t1.firstLevelPercent,
- t1.secondLevelPercent,
- t1.firstLevelPercentStr,
- t1.secondLevelPercentStr
- FROM
- (
- SELECT
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- 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,
- 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(
- 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,
- sys_user_dept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND e.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.beh_dept_id = e.dept_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
- ) t1,
- (
- SELECT
- a.doctor_id AS doctorId,
- a.doctor_name AS doctorName,
- count( * ) AS entryNum
- FROM
- med_behospital_info a,
- med_home_page b,
- med_qcresult_detail c,
- qc_cases_entry 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.behospital_code = b.behospital_code
- AND a.behospital_code = c.behospital_code
- AND a.beh_dept_id = e.dept_id
- AND c.cases_id = d.cases_id
- AND c.cases_entry_id = d.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
- ) t2
- WHERE
- t1.doctorId = t2.doctorId
- AND t1.doctorName = t2.doctorName
- <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>
- <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
- <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
- <when test='asc=="thirdLevelPercentStr"'>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>
- <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
- <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
- <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
- <otherwise> doctorName desc </otherwise>
- </choose>
- </if>
- </select>
- </mapper>
|