BehospitalInfoMapper.xml 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  6. <id column="behospital_code" property="behospitalCode" />
  7. <result column="hospital_id" property="hospitalId" />
  8. <result column="name" property="name" />
  9. <result column="sex" property="sex" />
  10. <result column="birthday" property="birthday" />
  11. <result column="file_code" property="fileCode" />
  12. <result column="qc_type_id" property="qcTypeId" />
  13. <result column="ward_code" property="wardCode" />
  14. <result column="ward_name" property="wardName" />
  15. <result column="beh_dept_id" property="behDeptId" />
  16. <result column="beh_dept_name" property="behDeptName" />
  17. <result column="bed_code" property="bedCode" />
  18. <result column="bed_name" property="bedName" />
  19. <result column="insurance_name" property="insuranceName" />
  20. <result column="job_type" property="jobType" />
  21. <result column="behospital_date" property="behospitalDate" />
  22. <result column="leave_hospital_date" property="leaveHospitalDate" />
  23. <result column="diagnose_icd" property="diagnoseIcd" />
  24. <result column="diagnose" property="diagnose" />
  25. <result column="beh_doctor_id" property="behDoctorId" />
  26. <result column="beh_doctor_name" property="behDoctorName" />
  27. <result column="doctor_id" property="doctorId" />
  28. <result column="doctor_name" property="doctorName" />
  29. <result column="director_doctor_id" property="directorDoctorId" />
  30. <result column="director_doctor_name" property="directorDoctorName" />
  31. <result column="is_deleted" property="isDeleted" />
  32. <result column="gmt_create" property="gmtCreate" />
  33. <result column="gmt_modified" property="gmtModified" />
  34. <result column="creator" property="creator" />
  35. <result column="modifier" property="modifier" />
  36. </resultMap>
  37. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  38. select * from (
  39. 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
  40. LEFT JOIN med_qcresult_info b
  41. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  42. left join med_home_page c
  43. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  44. ) t
  45. where t.is_deleted = 'N'
  46. <if test="deptId != null and deptId != ''">
  47. and t.beh_dept_id = #{deptId}
  48. </if>
  49. <if test="doctorName != null and doctorName != ''">
  50. and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
  51. </if>
  52. <if test="name != null and name != ''">
  53. and t.name like CONCAT('%',#{name},'%')
  54. </if>
  55. <if test="doctorCode != null and doctorCode != ''">
  56. and (t.doctor_id = #{doctorCode}
  57. or t.beh_doctor_id = #{doctorCode}
  58. or t.director_doctor_id = #{doctorCode})
  59. </if>
  60. <if test="fileCode != null and fileCode != ''">
  61. and t.file_code like CONCAT('%',#{fileCode},'%')
  62. </if>
  63. <if test="hospitalId != null">
  64. and t.hospital_id = #{hospitalId}
  65. </if>
  66. <if test="behospitalCode != null and behospitalCode != ''">
  67. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  68. </if>
  69. <if test="behosDateStart != null">
  70. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  71. </if>
  72. <if test="behosDateEnd != null">
  73. <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
  74. </if>
  75. <if test="leaveHosDateStart != null">
  76. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  77. </if>
  78. <if test="leaveHosDateEnd != null">
  79. <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
  80. </if>
  81. <if test="level != null and level != ''">
  82. and t.level = #{level}
  83. </if>
  84. and t.qc_type_id != 0
  85. </select>
  86. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  87. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  88. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg
  89. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  90. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  91. and a.id = c.cases_entry_id
  92. and a.mode_id = b.id
  93. AND c.cases_id = d.cases_id
  94. and c.hospital_id = d.hospital_id
  95. and c.hospital_id = #{hospitalId}
  96. and c.behospital_code = #{behospitalCode}
  97. order by b.order_no, a.order_no
  98. </select>
  99. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  100. SELECT b.id model_id,b.`name` model_name,
  101. d.score,d.msg,d.cases_entry_id,d.is_reject,
  102. a.cases_id cases_id, a.name standard_msg,a.code
  103. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  104. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  105. and a.mode_id = b.id
  106. and a.id = d.cases_entry_id
  107. and d.is_used = 1
  108. and d.hospital_id = #{hospitalId}
  109. and a.code in
  110. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  111. #{item}
  112. </foreach>
  113. <if test="modeId != null">
  114. and a.mode_id = #{modeId}
  115. </if>
  116. order by b.order_no, a.order_no;
  117. </select>
  118. <!-- 缺陷排行列表 -->
  119. <select id="resultStatistics" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  120. SELECT
  121. t1.msg AS name,
  122. t1.num AS num,
  123. round( t1.num / t2.totle, 4) AS percent
  124. FROM
  125. (
  126. (
  127. SELECT
  128. d.msg,
  129. count(*) AS num
  130. FROM
  131. med_behospital_info a,
  132. med_home_page b,
  133. med_qcresult_info c,
  134. med_qcresult_detail d
  135. WHERE
  136. a.behospital_code = b.behospital_code
  137. AND a.hospital_id = b.hospital_id
  138. AND a.behospital_code = c.behospital_code
  139. AND a.hospital_id = c.hospital_id
  140. AND a.behospital_code = d.behospital_code
  141. AND a.hospital_id = d.hospital_id
  142. AND a.is_deleted = 'N'
  143. AND b.is_deleted = 'N'
  144. AND c.is_deleted = 'N'
  145. AND d.is_deleted = 'N'
  146. <![CDATA[AND a.qc_type_id <>0 ]]>
  147. <if test="hospitalId != null and hospitalId != ''">
  148. AND a.hospital_id = #{hospitalId}
  149. </if>
  150. <if test="startDate != null and startDate != ''">
  151. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  152. </if>
  153. <if test="endDate != null and endDate != ''">
  154. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  155. </if>
  156. GROUP BY
  157. d.msg
  158. ORDER BY
  159. count(*) DESC
  160. ) t1,
  161. (
  162. SELECT
  163. count(*) AS totle
  164. FROM
  165. med_behospital_info a,
  166. med_home_page b,
  167. med_qcresult_info c,
  168. med_qcresult_detail d
  169. WHERE
  170. a.behospital_code = b.behospital_code
  171. AND a.hospital_id = b.hospital_id
  172. AND a.behospital_code = c.behospital_code
  173. AND a.hospital_id = c.hospital_id
  174. AND a.behospital_code = d.behospital_code
  175. AND a.hospital_id = d.hospital_id
  176. AND a.is_deleted = 'N'
  177. AND b.is_deleted = 'N'
  178. AND c.is_deleted = 'N'
  179. AND d.is_deleted = 'N'
  180. <![CDATA[AND a.qc_type_id <>0 ]]>
  181. <if test="hospitalId != null and hospitalId != ''">
  182. AND a.hospital_id = #{hospitalId}
  183. </if>
  184. <if test="startDate != null and startDate != ''">
  185. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  186. </if>
  187. <if test="endDate != null and endDate != ''">
  188. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  189. </if>
  190. ) t2
  191. )
  192. <if test="limitCount != null and limitCount != ''">
  193. limit 0,#{limitCount}
  194. </if>
  195. </select>
  196. <!-- 各科室缺陷占比 -->
  197. <select id="resultStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  198. SELECT
  199. t1.beh_dept_name AS name,
  200. t1.num AS num,
  201. round( t1.num / t2.totle, 4 ) AS percent
  202. FROM
  203. (
  204. (
  205. SELECT
  206. a.beh_dept_id,
  207. a.beh_dept_name,
  208. count(*) AS num
  209. FROM
  210. med_behospital_info a,
  211. med_home_page b,
  212. med_qcresult_info c,
  213. med_qcresult_detail d
  214. WHERE
  215. a.behospital_code = b.behospital_code
  216. AND a.hospital_id = b.hospital_id
  217. AND a.behospital_code = c.behospital_code
  218. AND a.hospital_id = c.hospital_id
  219. AND a.behospital_code = d.behospital_code
  220. AND a.hospital_id = d.hospital_id
  221. AND a.is_deleted = 'N'
  222. AND b.is_deleted = 'N'
  223. AND c.is_deleted = 'N'
  224. AND d.is_deleted = 'N'
  225. <![CDATA[AND a.qc_type_id <>0 ]]>
  226. <if test="hospitalId != null and hospitalId != ''">
  227. AND a.hospital_id = #{hospitalId}
  228. </if>
  229. <if test="startDate != null and startDate != ''">
  230. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  231. </if>
  232. <if test="endDate != null and endDate != ''">
  233. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  234. </if>
  235. GROUP BY
  236. a.beh_dept_id,
  237. a.beh_dept_name
  238. ORDER BY
  239. count(*) DESC
  240. ) t1,
  241. (
  242. SELECT
  243. count(*) AS totle
  244. FROM
  245. med_behospital_info a,
  246. med_home_page b,
  247. med_qcresult_info c,
  248. med_qcresult_detail d
  249. WHERE
  250. a.behospital_code = b.behospital_code
  251. AND a.hospital_id = b.hospital_id
  252. AND a.behospital_code = c.behospital_code
  253. AND a.hospital_id = c.hospital_id
  254. AND a.behospital_code = d.behospital_code
  255. AND a.hospital_id = d.hospital_id
  256. AND a.is_deleted = 'N'
  257. AND b.is_deleted = 'N'
  258. AND c.is_deleted = 'N'
  259. AND d.is_deleted = 'N'
  260. <![CDATA[AND a.qc_type_id <>0 ]]>
  261. <if test="hospitalId != null and hospitalId != ''">
  262. AND a.hospital_id = #{hospitalId}
  263. </if>
  264. <if test="startDate != null and startDate != ''">
  265. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  266. </if>
  267. <if test="endDate != null and endDate != ''">
  268. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  269. </if>
  270. ) t2
  271. )
  272. </select>
  273. <!-- 缺陷排行列表 -->
  274. <select id="resultStatistics2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  275. SELECT
  276. d.msg as name,
  277. count(*) AS num
  278. FROM
  279. FROM
  280. med_behospital_info a,
  281. med_home_page b,
  282. med_qcresult_info c,
  283. med_qcresult_detail d
  284. WHERE
  285. a.behospital_code = b.behospital_code
  286. AND a.hospital_id = b.hospital_id
  287. AND a.behospital_code = c.behospital_code
  288. AND a.hospital_id = c.hospital_id
  289. AND a.behospital_code = d.behospital_code
  290. AND a.hospital_id = d.hospital_id
  291. AND a.is_deleted = 'N'
  292. AND b.is_deleted = 'N'
  293. AND c.is_deleted = 'N'
  294. AND d.is_deleted = 'N'
  295. <![CDATA[AND a.qc_type_id <>0 ]]>
  296. <if test="hospitalId != null and hospitalId != ''">
  297. AND a.hospital_id = #{hospitalId}
  298. </if>
  299. <if test="startDate != null and startDate != ''">
  300. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  301. </if>
  302. <if test="endDate != null and endDate != ''">
  303. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  304. </if>
  305. GROUP BY
  306. d.msg
  307. ORDER BY
  308. count(*) DESC
  309. <if test="limitCount != null and limitCount != ''">
  310. limit 0,#{limitCount}
  311. </if>
  312. </select>
  313. <!-- 各科室缺陷占比 -->
  314. <select id="resultStatisticsByDept2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  315. SELECT
  316. a.beh_dept_id,
  317. a.beh_dept_name as name,
  318. count(*) AS num
  319. FROM
  320. med_behospital_info a,
  321. med_home_page b,
  322. med_qcresult_info c,
  323. med_qcresult_detail d
  324. WHERE
  325. a.behospital_code = b.behospital_code
  326. AND a.hospital_id = b.hospital_id
  327. AND a.behospital_code = c.behospital_code
  328. AND a.hospital_id = c.hospital_id
  329. AND a.behospital_code = d.behospital_code
  330. AND a.hospital_id = d.hospital_id
  331. AND a.is_deleted = 'N'
  332. AND b.is_deleted = 'N'
  333. AND c.is_deleted = 'N'
  334. AND d.is_deleted = 'N'
  335. <![CDATA[AND a.qc_type_id <>0 ]]>
  336. <if test="hospitalId != null and hospitalId != ''">
  337. AND a.hospital_id = #{hospitalId}
  338. </if>
  339. <if test="startDate != null and startDate != ''">
  340. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  341. </if>
  342. <if test="endDate != null and endDate != ''">
  343. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  344. </if>
  345. GROUP BY
  346. a.beh_dept_id,
  347. a.beh_dept_name
  348. ORDER BY
  349. count(*) DESC
  350. </select>
  351. <!-- 缺陷总数查询-->
  352. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  353. SELECT
  354. count(*) AS totle
  355. FROM
  356. med_behospital_info a,
  357. med_home_page b,
  358. med_qcresult_info c,
  359. med_qcresult_detail d
  360. WHERE
  361. a.behospital_code = b.behospital_code
  362. AND a.hospital_id = b.hospital_id
  363. AND a.behospital_code = c.behospital_code
  364. AND a.hospital_id = c.hospital_id
  365. AND a.behospital_code = d.behospital_code
  366. AND a.hospital_id = d.hospital_id
  367. AND a.is_deleted = 'N'
  368. AND b.is_deleted = 'N'
  369. AND c.is_deleted = 'N'
  370. AND d.is_deleted = 'N'
  371. <![CDATA[AND a.qc_type_id <>0 ]]>
  372. <if test="hospitalId != null and hospitalId != ''">
  373. AND a.hospital_id = #{hospitalId}
  374. </if>
  375. <if test="startDate != null and startDate != ''">
  376. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  377. </if>
  378. <if test="endDate != null and endDate != ''">
  379. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  380. </if>
  381. </select>
  382. <!--获取未评分病历-->
  383. <select id="getNoGrade" resultMap="BaseResultMap">
  384. select * from med_behospital_info a
  385. where a.is_deleted = 'N'
  386. and
  387. not EXISTS (
  388. SELECT
  389. 1
  390. FROM
  391. med_qcresult_info b
  392. WHERE
  393. b.is_deleted = 'N'
  394. AND a.hospital_id = b.hospital_id
  395. AND a.behospital_code = b.behospital_code
  396. )
  397. and a.qc_type_id != 0
  398. <if test="leaveDate != null">
  399. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  400. </if>
  401. </select>
  402. <!--质控评分(科室)分页-->
  403. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  404. SELECT
  405. *
  406. FROM
  407. ( SELECT
  408. a.*,
  409. IFNULL(b.level, '未评分') AS `level`,
  410. b.grade_type,
  411. b.score_res,
  412. b.gmt_create AS grade_time,
  413. c.age
  414. FROM
  415. med_behospital_info a
  416. JOIN sys_user_dept d
  417. ON a.hospital_id = d.hospital_id
  418. AND a.beh_dept_id = d.dept_id
  419. LEFT JOIN med_qcresult_info b
  420. ON a.behospital_code = b.behospital_code
  421. AND b.is_deleted = 'N'
  422. LEFT JOIN med_home_page c
  423. ON a.behospital_code = c.behospital_code
  424. AND c.is_deleted = 'N'
  425. WHERE d.is_deleted = 'N'
  426. AND d.user_id = #{userId}
  427. ) t
  428. where t.is_deleted = 'N'
  429. <if test="deptId != null and deptId != ''">
  430. and t.beh_dept_id = #{deptId}
  431. </if>
  432. <if test="doctorName != null and doctorName != ''">
  433. and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
  434. </if>
  435. <if test="doctorCode != null and doctorCode != ''">
  436. and (t.doctor_id = #{doctorCode}
  437. or t.beh_doctor_id = #{doctorCode}
  438. or t.director_doctor_id = #{doctorCode})
  439. </if>
  440. <if test="name != null and name != ''">
  441. and t.name like CONCAT('%',#{name},'%')
  442. </if>
  443. <if test="fileCode != null and fileCode != ''">
  444. and t.file_code like CONCAT('%',#{fileCode},'%')
  445. </if>
  446. <if test="hospitalId != null">
  447. and t.hospital_id = #{hospitalId}
  448. </if>
  449. <if test="behospitalCode != null and behospitalCode != ''">
  450. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  451. </if>
  452. <if test="behosDateStart != null">
  453. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  454. </if>
  455. <if test="behosDateEnd != null">
  456. <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
  457. </if>
  458. <if test="leaveHosDateStart != null">
  459. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  460. </if>
  461. <if test="leaveHosDateEnd != null">
  462. <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
  463. </if>
  464. <if test="level != null and level != ''">
  465. and t.level = #{level}
  466. </if>
  467. and t.qc_type_id != 0
  468. </select>
  469. <!--质控评分(个人)分页-->
  470. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  471. select * from (SELECT
  472. a.*,
  473. IFNULL(b.level, '未评分') AS `level`,
  474. b.grade_type,
  475. b.score_res,
  476. b.gmt_create AS grade_time,
  477. c.age
  478. FROM
  479. med_behospital_info a
  480. JOIN
  481. (SELECT
  482. u.id,
  483. u.linkman AS linkman,
  484. uh.hospital_id
  485. FROM
  486. sys_user u
  487. JOIN sys_user_hospital uh
  488. ON u.id = uh.user_id
  489. WHERE u.is_deleted = "N"
  490. AND u.id = #{userId}
  491. AND uh.hospital_id = #{hospitalId}) u1
  492. ON a.hospital_id = u1.hospital_id
  493. LEFT JOIN med_qcresult_info b
  494. ON a.behospital_code = b.behospital_code
  495. AND b.is_deleted = 'N'
  496. LEFT JOIN med_home_page c
  497. ON a.behospital_code = c.behospital_code
  498. AND c.is_deleted = 'N'
  499. WHERE CONCAT(
  500. IFNULL(a.doctor_name, ''),
  501. IFNULL(a.beh_doctor_name, ''),
  502. IFNULL(a.director_doctor_name, '')
  503. ) LIKE CONCAT('%', u1.linkman, '%')
  504. ) t
  505. where t.is_deleted = 'N'
  506. <if test="deptId != null and deptId != ''">
  507. and t.beh_dept_id = #{deptId}
  508. </if>
  509. <if test="name != null and name != ''">
  510. and t.name like CONCAT('%',#{name},'%')
  511. </if>
  512. <if test="fileCode != null and fileCode != ''">
  513. and t.file_code like CONCAT('%',#{fileCode},'%')
  514. </if>
  515. <if test="behospitalCode != null and behospitalCode != ''">
  516. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  517. </if>
  518. <if test="behosDateStart != null">
  519. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  520. </if>
  521. <if test="behosDateEnd != null">
  522. <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
  523. </if>
  524. <if test="leaveHosDateStart != null">
  525. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  526. </if>
  527. <if test="leaveHosDateEnd != null">
  528. <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
  529. </if>
  530. <if test="level != null and level != ''">
  531. and t.level = #{level}
  532. </if>
  533. and t.qc_type_id != 0
  534. </select>
  535. <!-- 病案首页病历数统计 -->
  536. <select id="homePageCount" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="int">
  537. SELECT
  538. COUNT(*)
  539. FROM
  540. med_behospital_info a,
  541. med_home_page b
  542. WHERE
  543. a.is_deleted = 'N'
  544. AND b.is_deleted = 'N'
  545. AND a.hospital_id = b.hospital_id
  546. AND a.behospital_code = b.behospital_code
  547. <![CDATA[AND a.qc_type_id <>0 ]]>
  548. <if test="hospitalId != null and hospitalId != ''">
  549. AND a.hospital_id = #{hospitalId}
  550. </if>
  551. <if test="startDate != null and startDate != ''">
  552. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  553. </if>
  554. <if test="endDate != null and endDate != ''">
  555. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  556. </if>
  557. <if test="death!=null and death==1">
  558. AND b.leave_hospital_type = '死亡'
  559. </if>
  560. <if test="newBorn!=null and newBorn==1">
  561. AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
  562. <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
  563. </if>
  564. </select>
  565. <!-- 病案首页手术病历数统计 -->
  566. <select id="homePageCountForOperation" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  567. SELECT
  568. COUNT(DISTINCT a.behospital_code)
  569. FROM
  570. med_behospital_info a,
  571. med_home_page b,
  572. med_home_operation_info c
  573. WHERE
  574. a.is_deleted = 'N'
  575. AND b.is_deleted = 'N'
  576. AND c.is_deleted = 'N'
  577. AND a.hospital_id = b.hospital_id
  578. AND a.hospital_id = c.hospital_id
  579. AND a.behospital_code = b.behospital_code
  580. AND b.home_page_id = c.home_page_id
  581. <![CDATA[AND a.qc_type_id <>0 ]]>
  582. <if test="hospitalId != null and hospitalId != ''">
  583. AND a.hospital_id = #{hospitalId}
  584. </if>
  585. <if test="startDate != null and startDate != ''">
  586. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  587. </if>
  588. <if test="endDate != null and endDate != ''">
  589. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  590. </if>
  591. </select>
  592. <!-- 按科室统计病案首页病历数 -->
  593. <select id="homePageCountByDept" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="com.diagbot.dto.NumDTO">
  594. SELECT
  595. a.beh_dept_id AS id,
  596. a.beh_dept_name AS NAME,
  597. COUNT(*) AS num
  598. FROM
  599. med_behospital_info a,
  600. med_home_page b,
  601. sys_user_dept c
  602. WHERE
  603. a.is_deleted = 'N'
  604. AND b.is_deleted = 'N'
  605. AND c.is_deleted = 'N'
  606. AND a.hospital_id = b.hospital_id
  607. AND a.hospital_id = c.hospital_id
  608. AND a.behospital_code = b.behospital_code
  609. AND a.beh_dept_id = c.dept_id
  610. <![CDATA[AND a.qc_type_id <>0 ]]>
  611. <if test="death!=null and death==1">
  612. AND b.leave_hospital_type = '死亡'
  613. </if>
  614. <if test="userId!=null">
  615. AND c.user_id = #{userId}
  616. </if>
  617. <if test="hospitalId != null and hospitalId != ''">
  618. AND a.hospital_id = #{hospitalId}
  619. </if>
  620. <if test="startDate != null and startDate != ''">
  621. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  622. </if>
  623. <if test="endDate != null and endDate != ''">
  624. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  625. </if>
  626. GROUP BY
  627. a.beh_dept_id,
  628. a.beh_dept_name
  629. </select>
  630. <!-- 按科室病案首页手术病历数 -->
  631. <select id="homePageCountForOperationByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  632. SELECT
  633. a.beh_dept_id AS id,
  634. a.beh_dept_name AS NAME,
  635. COUNT(DISTINCT a.behospital_code) AS num
  636. FROM
  637. med_behospital_info a,
  638. med_home_page b,
  639. sys_user_dept c,
  640. med_home_operation_info d
  641. WHERE
  642. a.is_deleted = 'N'
  643. AND b.is_deleted = 'N'
  644. AND c.is_deleted = 'N'
  645. AND d.is_deleted = 'N'
  646. AND a.hospital_id = b.hospital_id
  647. AND a.hospital_id = c.hospital_id
  648. AND a.hospital_id = d.hospital_id
  649. AND a.behospital_code = b.behospital_code
  650. AND b.home_page_id = d.home_page_id
  651. AND a.beh_dept_id = c.dept_id
  652. <![CDATA[AND a.qc_type_id <>0 ]]>
  653. <if test="userId!=null">
  654. AND c.user_id = #{userId}
  655. </if>
  656. <if test="hospitalId != null and hospitalId != ''">
  657. AND a.hospital_id = #{hospitalId}
  658. </if>
  659. <if test="startDate != null and startDate != ''">
  660. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  661. </if>
  662. <if test="endDate != null and endDate != ''">
  663. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  664. </if>
  665. GROUP BY
  666. a.beh_dept_id,
  667. a.beh_dept_name
  668. </select>
  669. <!-- 各科室缺陷占比排行(分页) -->
  670. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  671. SELECT t.*
  672. FROM
  673. (SELECT
  674. t1.beh_dept_name AS NAME,
  675. t1.num AS num,
  676. t2.totle AS totleNum,
  677. round( t1.num / t2.totle, 4 ) AS percent,
  678. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  679. FROM
  680. (
  681. SELECT
  682. a.beh_dept_id,
  683. a.beh_dept_name,
  684. count(*) AS num
  685. FROM
  686. med_behospital_info a,
  687. med_home_page b,
  688. med_qcresult_info c,
  689. med_qcresult_detail d
  690. WHERE
  691. a.behospital_code = b.behospital_code
  692. AND a.hospital_id = b.hospital_id
  693. AND a.behospital_code = c.behospital_code
  694. AND a.hospital_id = c.hospital_id
  695. AND a.behospital_code = d.behospital_code
  696. AND a.hospital_id = d.hospital_id
  697. AND a.is_deleted = 'N'
  698. AND b.is_deleted = 'N'
  699. AND c.is_deleted = 'N'
  700. AND d.is_deleted = 'N'
  701. <![CDATA[AND a.qc_type_id <>0 ]]>
  702. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  703. AND a.hospital_id = #{filterPageVO.hospitalId}
  704. </if>
  705. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  706. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  707. </if>
  708. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  709. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  710. </if>
  711. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  712. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  713. </if>
  714. GROUP BY
  715. a.beh_dept_id,
  716. a.beh_dept_name
  717. ORDER BY
  718. count(*) DESC
  719. ) t1,
  720. (
  721. SELECT
  722. count(*) AS totle
  723. FROM
  724. med_behospital_info a,
  725. med_home_page b,
  726. med_qcresult_info c,
  727. med_qcresult_detail d
  728. WHERE
  729. a.behospital_code = b.behospital_code
  730. AND a.hospital_id = b.hospital_id
  731. AND a.behospital_code = c.behospital_code
  732. AND a.hospital_id = c.hospital_id
  733. AND a.behospital_code = d.behospital_code
  734. AND a.hospital_id = d.hospital_id
  735. AND a.is_deleted = 'N'
  736. AND b.is_deleted = 'N'
  737. AND c.is_deleted = 'N'
  738. AND d.is_deleted = 'N'
  739. <![CDATA[AND a.qc_type_id <>0 ]]>
  740. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  741. AND a.hospital_id = #{filterPageVO.hospitalId}
  742. </if>
  743. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  744. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  745. </if>
  746. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  747. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  748. </if>
  749. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  750. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  751. </if>
  752. ) t2
  753. )t
  754. </select>
  755. <!-- 科室缺陷占比(主任医生) -->
  756. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  757. SELECT
  758. t.*
  759. FROM
  760. (
  761. SELECT
  762. t1.NAME,
  763. t1.num AS num,
  764. t2.totle AS totleNum,
  765. round( t1.num / t2.totle, 4 ) AS percent,
  766. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  767. FROM
  768. (
  769. SELECT
  770. d.msg as name,
  771. count(*) AS num
  772. FROM
  773. med_behospital_info a,
  774. med_home_page b,
  775. med_qcresult_info c,
  776. med_qcresult_detail d,
  777. sys_user_dept e
  778. WHERE
  779. a.behospital_code = b.behospital_code
  780. AND a.hospital_id = b.hospital_id
  781. AND a.behospital_code = c.behospital_code
  782. AND a.hospital_id = c.hospital_id
  783. AND a.behospital_code = d.behospital_code
  784. AND a.hospital_id = d.hospital_id
  785. AND a.is_deleted = 'N'
  786. AND b.is_deleted = 'N'
  787. AND c.is_deleted = 'N'
  788. AND d.is_deleted = 'N'
  789. AND e.is_deleted = 'N'
  790. AND a.beh_dept_id = e.dept_id
  791. <![CDATA[AND a.qc_type_id <>0 ]]>
  792. <if test="filterPageByDeptVO.userId!=null">
  793. AND e.user_id = #{filterPageByDeptVO.userId}
  794. </if>
  795. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  796. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  797. </if>
  798. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  799. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  800. </if>
  801. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  802. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  803. </if>
  804. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  805. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  806. </if>
  807. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  808. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  809. </if>
  810. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  811. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  812. </if>
  813. GROUP BY
  814. d.msg
  815. ORDER BY
  816. count(*) DESC
  817. ) t1,
  818. (
  819. SELECT
  820. count(*) AS totle
  821. FROM
  822. med_behospital_info a,
  823. med_home_page b,
  824. med_qcresult_info c,
  825. med_qcresult_detail d,
  826. sys_user_dept e
  827. WHERE
  828. a.behospital_code = b.behospital_code
  829. AND a.hospital_id = b.hospital_id
  830. AND a.behospital_code = c.behospital_code
  831. AND a.hospital_id = c.hospital_id
  832. AND a.behospital_code = d.behospital_code
  833. AND a.hospital_id = d.hospital_id
  834. AND a.is_deleted = 'N'
  835. AND b.is_deleted = 'N'
  836. AND c.is_deleted = 'N'
  837. AND d.is_deleted = 'N'
  838. AND e.is_deleted = 'N'
  839. AND a.beh_dept_id = e.dept_id
  840. <![CDATA[AND a.qc_type_id <>0 ]]>
  841. <if test="filterPageByDeptVO.userId!=null">
  842. AND e.user_id = #{filterPageByDeptVO.userId}
  843. </if>
  844. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  845. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  846. </if>
  847. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  848. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  849. </if>
  850. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  851. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  852. </if>
  853. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  854. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  855. </if>
  856. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  857. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  858. </if>
  859. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  860. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  861. </if>
  862. ) t2
  863. )t
  864. </select>
  865. <!-- 各科室缺陷占比(组合) -->
  866. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  867. SELECT
  868. t1.deptId,
  869. t1.deptName,
  870. t2.entryNum,
  871. t1.mrNum,
  872. t1.totleValue,
  873. t1.averageValue,
  874. t1.firstLevelNum,
  875. t1.secondLevelNum,
  876. t1.thirdLevelNum,
  877. t1.firstLevelPercent,
  878. t1.secondLevelPercent,
  879. t1.thirdLevelPercent,
  880. t1.firstLevelPercentStr,
  881. t1.secondLevelPercentStr,
  882. t1.thirdLevelPercentStr
  883. FROM
  884. (
  885. SELECT
  886. a.beh_dept_id AS deptId,
  887. a.beh_dept_name AS deptName,
  888. count( DISTINCT c.id ) AS mrNum,
  889. ROUND( sum( c.score_res ), 2 ) AS totleValue,
  890. ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
  891. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  892. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  893. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  894. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  895. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  896. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS thirdLevelPercent,
  897. concat(
  898. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  899. '%'
  900. ) AS firstLevelPercentStr,
  901. concat(
  902. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  903. '%'
  904. ) AS secondLevelPercentStr,
  905. concat(
  906. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  907. '%'
  908. ) AS thirdLevelPercentStr
  909. FROM
  910. med_behospital_info a,
  911. med_home_page b,
  912. med_qcresult_info c
  913. WHERE
  914. a.is_deleted = 'N'
  915. AND b.is_deleted = 'N'
  916. AND c.is_deleted = 'N'
  917. AND a.hospital_id = b.hospital_id
  918. AND a.hospital_id = c.hospital_id
  919. AND a.behospital_code = b.behospital_code
  920. AND a.behospital_code = c.behospital_code
  921. <![CDATA[AND a.qc_type_id <>0 ]]>
  922. <if test="hospitalId != null and hospitalId != ''">
  923. AND a.hospital_id = #{hospitalId}
  924. </if>
  925. <if test="startDate != null and startDate != ''">
  926. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  927. </if>
  928. <if test="endDate != null and endDate != ''">
  929. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  930. </if>
  931. <if test="level != null and level != ''">
  932. and c.level = #{level}
  933. </if>
  934. <if test="name != null and name != ''">
  935. and a.beh_dept_name like CONCAT('%',#{name},'%')
  936. </if>
  937. GROUP BY
  938. a.beh_dept_id,
  939. a.beh_dept_name
  940. ) t1,
  941. (
  942. SELECT
  943. a.beh_dept_id AS deptId,
  944. a.beh_dept_name AS deptName,
  945. count( * ) AS entryNum
  946. FROM
  947. med_behospital_info a,
  948. med_home_page b,
  949. med_qcresult_detail c,
  950. qc_cases_entry d
  951. WHERE
  952. a.is_deleted = 'N'
  953. AND b.is_deleted = 'N'
  954. AND c.is_deleted = 'N'
  955. AND d.is_deleted = 'N'
  956. AND a.hospital_id = b.hospital_id
  957. AND a.hospital_id = c.hospital_id
  958. AND a.behospital_code = b.behospital_code
  959. AND a.behospital_code = c.behospital_code
  960. AND c.cases_id = d.cases_id
  961. AND c.cases_entry_id = d.id
  962. <![CDATA[AND a.qc_type_id <>0 ]]>
  963. <if test="hospitalId != null and hospitalId != ''">
  964. AND a.hospital_id = #{hospitalId}
  965. </if>
  966. <if test="startDate != null and startDate != ''">
  967. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  968. </if>
  969. <if test="endDate != null and endDate != ''">
  970. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  971. </if>
  972. <if test="level != null and level != ''">
  973. and c.level = #{level}
  974. </if>
  975. <if test="name != null and name != ''">
  976. and a.beh_dept_name like CONCAT('%',#{name},'%')
  977. </if>
  978. GROUP BY
  979. a.beh_dept_id,
  980. a.beh_dept_name
  981. ) t2
  982. WHERE
  983. t1.deptId = t2.deptId
  984. AND t1.deptName = t2.deptName
  985. <if test="asc != null and asc !=''">
  986. order by
  987. <choose>
  988. <when test='asc=="deptId"'>deptId asc</when>
  989. <when test='asc=="deptName"'>deptName asc</when>
  990. <when test='asc=="entryNum"'>entryNum asc</when>
  991. <when test='asc=="mrNum"'>mrNum asc</when>
  992. <when test='asc=="totleValue"'>totleValue asc</when>
  993. <when test='asc=="averageValue"'>averageValue asc</when>
  994. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  995. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  996. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  997. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  998. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  999. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1000. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1001. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1002. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1003. <otherwise> deptName asc </otherwise>
  1004. </choose>
  1005. </if>
  1006. <if test="desc != null and desc!=''">
  1007. order by
  1008. <choose>
  1009. <when test='desc=="deptId"'>deptId desc</when>
  1010. <when test='desc=="deptName"'>deptName desc</when>
  1011. <when test='desc=="entryNum"'>entryNum desc</when>
  1012. <when test='desc=="mrNum"'>mrNum desc</when>
  1013. <when test='desc=="totleValue"'>totleValue desc</when>
  1014. <when test='desc=="averageValue"'>averageValue desc</when>
  1015. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1016. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1017. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1018. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1019. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1020. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1021. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1022. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1023. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1024. <otherwise> deptName desc </otherwise>
  1025. </choose>
  1026. </if>
  1027. </select>
  1028. <!-- 病案首页合格率占比 -->
  1029. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1030. SELECT
  1031. t1.deptId,
  1032. t1.deptName,
  1033. t2.entryNum,
  1034. t1.mrNum,
  1035. t1.totleValue,
  1036. t1.averageValue,
  1037. t1.firstLevelNum,
  1038. t1.secondLevelNum,
  1039. t1.firstLevelPercent,
  1040. t1.secondLevelPercent,
  1041. t1.firstLevelPercentStr,
  1042. t1.secondLevelPercentStr
  1043. FROM
  1044. (
  1045. SELECT
  1046. a.beh_dept_id AS deptId,
  1047. a.beh_dept_name AS deptName,
  1048. count( DISTINCT c.id ) AS mrNum,
  1049. ROUND( sum( c.score_res ), 2 ) AS totleValue,
  1050. ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
  1051. COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
  1052. COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
  1053. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1054. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1055. concat(
  1056. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1057. '%'
  1058. ) AS firstLevelPercentStr,
  1059. concat(
  1060. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1061. '%'
  1062. ) AS secondLevelPercentStr
  1063. FROM
  1064. med_behospital_info a,
  1065. med_home_page b,
  1066. med_qcresult_cases c
  1067. WHERE
  1068. a.is_deleted = 'N'
  1069. AND b.is_deleted = 'N'
  1070. AND c.is_deleted = 'N'
  1071. AND a.hospital_id = b.hospital_id
  1072. AND a.hospital_id = c.hospital_id
  1073. AND a.behospital_code = b.behospital_code
  1074. AND a.behospital_code = c.behospital_code
  1075. AND c.cases_id = 243
  1076. <![CDATA[AND a.qc_type_id <>0 ]]>
  1077. <if test="hospitalId != null and hospitalId != ''">
  1078. AND a.hospital_id = #{hospitalId}
  1079. </if>
  1080. <if test="startDate != null and startDate != ''">
  1081. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1082. </if>
  1083. <if test="endDate != null and endDate != ''">
  1084. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1085. </if>
  1086. <if test="level != null and level != ''">
  1087. and c.level = #{level}
  1088. </if>
  1089. <if test="name != null and name != ''">
  1090. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1091. </if>
  1092. GROUP BY
  1093. a.beh_dept_id,
  1094. a.beh_dept_name
  1095. ) t1,
  1096. (
  1097. SELECT
  1098. a.beh_dept_id AS deptId,
  1099. a.beh_dept_name AS deptName,
  1100. count( * ) AS entryNum
  1101. FROM
  1102. med_behospital_info a,
  1103. med_home_page b,
  1104. med_qcresult_detail c,
  1105. qc_cases_entry d
  1106. WHERE
  1107. a.is_deleted = 'N'
  1108. AND b.is_deleted = 'N'
  1109. AND c.is_deleted = 'N'
  1110. AND d.is_deleted = 'N'
  1111. AND a.hospital_id = b.hospital_id
  1112. AND a.hospital_id = c.hospital_id
  1113. AND a.behospital_code = b.behospital_code
  1114. AND a.behospital_code = c.behospital_code
  1115. AND c.cases_id = d.cases_id
  1116. AND c.cases_entry_id = d.id
  1117. AND c.cases_id = 243
  1118. <![CDATA[AND a.qc_type_id <>0 ]]>
  1119. <if test="hospitalId != null and hospitalId != ''">
  1120. AND a.hospital_id = #{hospitalId}
  1121. </if>
  1122. <if test="startDate != null and startDate != ''">
  1123. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1124. </if>
  1125. <if test="endDate != null and endDate != ''">
  1126. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1127. </if>
  1128. <if test="level != null and level != ''">
  1129. and c.level = #{level}
  1130. </if>
  1131. <if test="name != null and name != ''">
  1132. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1133. </if>
  1134. GROUP BY
  1135. a.beh_dept_id,
  1136. a.beh_dept_name
  1137. ) t2
  1138. WHERE
  1139. t1.deptId = t2.deptId
  1140. AND t1.deptName = t2.deptName
  1141. <if test="asc != null and asc !=''">
  1142. order by
  1143. <choose>
  1144. <when test='asc=="deptId"'>deptId asc</when>
  1145. <when test='asc=="deptName"'>deptName asc</when>
  1146. <when test='asc=="entryNum"'>entryNum asc</when>
  1147. <when test='asc=="mrNum"'>mrNum asc</when>
  1148. <when test='asc=="totleValue"'>totleValue asc</when>
  1149. <when test='asc=="averageValue"'>averageValue asc</when>
  1150. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1151. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1152. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1153. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1154. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1155. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1156. <otherwise> deptName asc </otherwise>
  1157. </choose>
  1158. </if>
  1159. <if test="desc != null and desc!=''">
  1160. order by
  1161. <choose>
  1162. <when test='desc=="deptId"'>deptId desc</when>
  1163. <when test='desc=="deptName"'>deptName desc</when>
  1164. <when test='desc=="entryNum"'>entryNum desc</when>
  1165. <when test='desc=="mrNum"'>mrNum desc</when>
  1166. <when test='desc=="totleValue"'>totleValue desc</when>
  1167. <when test='desc=="averageValue"'>averageValue desc</when>
  1168. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1169. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1170. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1171. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1172. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1173. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1174. <otherwise> deptName desc </otherwise>
  1175. </choose>
  1176. </if>
  1177. </select>
  1178. <!-- 各科室缺陷占比(主任医生) -->
  1179. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1180. SELECT
  1181. t1.doctorId,
  1182. t1.doctorName,
  1183. t2.entryNum,
  1184. t1.mrNum,
  1185. t1.totleValue,
  1186. t1.averageValue,
  1187. t1.firstLevelNum,
  1188. t1.secondLevelNum,
  1189. t1.thirdLevelNum,
  1190. t1.firstLevelPercent,
  1191. t1.secondLevelPercent,
  1192. t1.thirdLevelPercent,
  1193. t1.firstLevelPercentStr,
  1194. t1.secondLevelPercentStr,
  1195. t1.thirdLevelPercentStr
  1196. FROM
  1197. (
  1198. SELECT
  1199. a.doctor_id AS doctorId,
  1200. a.doctor_name AS doctorName,
  1201. count( DISTINCT c.id ) AS mrNum,
  1202. ROUND( sum( c.score_res ), 2 ) AS totleValue,
  1203. ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
  1204. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1205. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1206. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1207. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1208. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1209. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS thirdLevelPercent,
  1210. concat(
  1211. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1212. '%'
  1213. ) AS firstLevelPercentStr,
  1214. concat(
  1215. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1216. '%'
  1217. ) AS secondLevelPercentStr,
  1218. concat(
  1219. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1220. '%'
  1221. ) AS thirdLevelPercentStr
  1222. FROM
  1223. med_behospital_info a,
  1224. med_home_page b,
  1225. med_qcresult_info c,
  1226. sys_user_dept e
  1227. WHERE
  1228. a.is_deleted = 'N'
  1229. AND b.is_deleted = 'N'
  1230. AND c.is_deleted = 'N'
  1231. AND e.is_deleted = 'N'
  1232. AND a.hospital_id = b.hospital_id
  1233. AND a.hospital_id = c.hospital_id
  1234. AND a.behospital_code = b.behospital_code
  1235. AND a.behospital_code = c.behospital_code
  1236. AND a.beh_dept_id = e.dept_id
  1237. <![CDATA[AND a.qc_type_id <>0 ]]>
  1238. <if test="hospitalId != null and hospitalId != ''">
  1239. AND a.hospital_id = #{hospitalId}
  1240. </if>
  1241. <if test="startDate != null and startDate != ''">
  1242. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1243. </if>
  1244. <if test="endDate != null and endDate != ''">
  1245. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1246. </if>
  1247. <if test="level != null and level != ''">
  1248. and c.level = #{level}
  1249. </if>
  1250. <if test="name != null and name != ''">
  1251. and a.doctor_name like CONCAT('%',#{name},'%')
  1252. </if>
  1253. <if test="userId!=null and userId !=''">
  1254. AND e.user_id = #{userId}
  1255. </if>
  1256. <if test="deptName!=null and deptName !=''">
  1257. AND a.beh_dept_name = #{deptName}
  1258. </if>
  1259. GROUP BY
  1260. a.doctor_id,
  1261. a.doctor_name
  1262. ) t1,
  1263. (
  1264. SELECT
  1265. a.doctor_id AS doctorId,
  1266. a.doctor_name AS doctorName,
  1267. count( * ) AS entryNum
  1268. FROM
  1269. med_behospital_info a,
  1270. med_home_page b,
  1271. med_qcresult_detail c,
  1272. qc_cases_entry d,
  1273. sys_user_dept e
  1274. WHERE
  1275. a.is_deleted = 'N'
  1276. AND b.is_deleted = 'N'
  1277. AND c.is_deleted = 'N'
  1278. AND d.is_deleted = 'N'
  1279. AND e.is_deleted = 'N'
  1280. AND a.hospital_id = b.hospital_id
  1281. AND a.hospital_id = c.hospital_id
  1282. AND a.behospital_code = b.behospital_code
  1283. AND a.behospital_code = c.behospital_code
  1284. AND c.cases_id = d.cases_id
  1285. AND c.cases_entry_id = d.id
  1286. AND a.beh_dept_id = e.dept_id
  1287. <![CDATA[AND a.qc_type_id <>0 ]]>
  1288. <if test="hospitalId != null and hospitalId != ''">
  1289. AND a.hospital_id = #{hospitalId}
  1290. </if>
  1291. <if test="startDate != null and startDate != ''">
  1292. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1293. </if>
  1294. <if test="endDate != null and endDate != ''">
  1295. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1296. </if>
  1297. <if test="level != null and level != ''">
  1298. and c.level = #{level}
  1299. </if>
  1300. <if test="name != null and name != ''">
  1301. and a.doctor_name like CONCAT('%',#{name},'%')
  1302. </if>
  1303. <if test="userId!=null and userId !=''">
  1304. AND e.user_id = #{userId}
  1305. </if>
  1306. <if test="deptName!=null and deptName !=''">
  1307. AND a.beh_dept_name = #{deptName}
  1308. </if>
  1309. GROUP BY
  1310. a.doctor_id,
  1311. a.doctor_name
  1312. ) t2
  1313. WHERE
  1314. t1.doctorId = t2.doctorId
  1315. AND t1.doctorName = t2.doctorName
  1316. <if test="asc != null and asc !=''">
  1317. order by
  1318. <choose>
  1319. <when test='asc=="doctorId"'>doctorId asc</when>
  1320. <when test='asc=="doctorName"'>doctorName asc</when>
  1321. <when test='asc=="entryNum"'>entryNum asc</when>
  1322. <when test='asc=="mrNum"'>mrNum asc</when>
  1323. <when test='asc=="totleValue"'>totleValue asc</when>
  1324. <when test='asc=="averageValue"'>averageValue asc</when>
  1325. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1326. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1327. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1328. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1329. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1330. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1331. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1332. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1333. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1334. <otherwise> doctorName asc </otherwise>
  1335. </choose>
  1336. </if>
  1337. <if test="desc != null and desc!=''">
  1338. order by
  1339. <choose>
  1340. <when test='desc=="doctorId"'>doctorId desc</when>
  1341. <when test='desc=="doctorName"'>doctorName desc</when>
  1342. <when test='desc=="entryNum"'>entryNum desc</when>
  1343. <when test='desc=="mrNum"'>mrNum desc</when>
  1344. <when test='desc=="totleValue"'>totleValue desc</when>
  1345. <when test='desc=="averageValue"'>averageValue desc</when>
  1346. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1347. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1348. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1349. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1350. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1351. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1352. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1353. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1354. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1355. <otherwise> doctorName desc </otherwise>
  1356. </choose>
  1357. </if>
  1358. </select>
  1359. <!-- 病案首页合格率占比(主任医生) -->
  1360. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1361. SELECT
  1362. t1.doctorId,
  1363. t1.doctorName,
  1364. t2.entryNum,
  1365. t1.mrNum,
  1366. t1.totleValue,
  1367. t1.averageValue,
  1368. t1.firstLevelNum,
  1369. t1.secondLevelNum,
  1370. t1.firstLevelPercent,
  1371. t1.secondLevelPercent,
  1372. t1.firstLevelPercentStr,
  1373. t1.secondLevelPercentStr
  1374. FROM
  1375. (
  1376. SELECT
  1377. a.doctor_id AS doctorId,
  1378. a.doctor_name AS doctorName,
  1379. count( DISTINCT c.id ) AS mrNum,
  1380. ROUND( sum( c.score_res ), 2 ) AS totleValue,
  1381. ROUND( sum( c.score_res )/ count(*), 2 ) AS averageValue,
  1382. COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
  1383. COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
  1384. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1385. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1386. concat(
  1387. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1388. '%'
  1389. ) AS firstLevelPercentStr,
  1390. concat(
  1391. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1392. '%'
  1393. ) AS secondLevelPercentStr
  1394. FROM
  1395. med_behospital_info a,
  1396. med_home_page b,
  1397. med_qcresult_cases c,
  1398. sys_user_dept e
  1399. WHERE
  1400. a.is_deleted = 'N'
  1401. AND b.is_deleted = 'N'
  1402. AND c.is_deleted = 'N'
  1403. AND e.is_deleted = 'N'
  1404. AND a.hospital_id = b.hospital_id
  1405. AND a.hospital_id = c.hospital_id
  1406. AND a.behospital_code = b.behospital_code
  1407. AND a.behospital_code = c.behospital_code
  1408. AND a.beh_dept_id = e.dept_id
  1409. AND c.cases_id = 243
  1410. <![CDATA[AND a.qc_type_id <>0 ]]>
  1411. <if test="hospitalId != null and hospitalId != ''">
  1412. AND a.hospital_id = #{hospitalId}
  1413. </if>
  1414. <if test="startDate != null and startDate != ''">
  1415. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1416. </if>
  1417. <if test="endDate != null and endDate != ''">
  1418. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1419. </if>
  1420. <if test="level != null and level != ''">
  1421. and c.level = #{level}
  1422. </if>
  1423. <if test="name != null and name != ''">
  1424. and a.doctor_name like CONCAT('%',#{name},'%')
  1425. </if>
  1426. <if test="userId!=null and userId !=''">
  1427. AND e.user_id = #{userId}
  1428. </if>
  1429. <if test="deptName!=null and deptName !=''">
  1430. AND a.beh_dept_name = #{deptName}
  1431. </if>
  1432. GROUP BY
  1433. a.doctor_id,
  1434. a.doctor_name
  1435. ) t1,
  1436. (
  1437. SELECT
  1438. a.doctor_id AS doctorId,
  1439. a.doctor_name AS doctorName,
  1440. count( * ) AS entryNum
  1441. FROM
  1442. med_behospital_info a,
  1443. med_home_page b,
  1444. med_qcresult_detail c,
  1445. qc_cases_entry d,
  1446. sys_user_dept e
  1447. WHERE
  1448. a.is_deleted = 'N'
  1449. AND b.is_deleted = 'N'
  1450. AND c.is_deleted = 'N'
  1451. AND d.is_deleted = 'N'
  1452. AND e.is_deleted = 'N'
  1453. AND a.hospital_id = b.hospital_id
  1454. AND a.hospital_id = c.hospital_id
  1455. AND a.behospital_code = b.behospital_code
  1456. AND a.behospital_code = c.behospital_code
  1457. AND a.beh_dept_id = e.dept_id
  1458. AND c.cases_id = d.cases_id
  1459. AND c.cases_entry_id = d.id
  1460. AND c.cases_id = 243
  1461. <![CDATA[AND a.qc_type_id <>0 ]]>
  1462. <if test="hospitalId != null and hospitalId != ''">
  1463. AND a.hospital_id = #{hospitalId}
  1464. </if>
  1465. <if test="startDate != null and startDate != ''">
  1466. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1467. </if>
  1468. <if test="endDate != null and endDate != ''">
  1469. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1470. </if>
  1471. <if test="level != null and level != ''">
  1472. and c.level = #{level}
  1473. </if>
  1474. <if test="name != null and name != ''">
  1475. and a.doctor_name like CONCAT('%',#{name},'%')
  1476. </if>
  1477. <if test="userId!=null and userId !=''">
  1478. AND e.user_id = #{userId}
  1479. </if>
  1480. <if test="deptName!=null and deptName !=''">
  1481. AND a.beh_dept_name = #{deptName}
  1482. </if>
  1483. GROUP BY
  1484. a.doctor_id,
  1485. a.doctor_name
  1486. ) t2
  1487. WHERE
  1488. t1.doctorId = t2.doctorId
  1489. AND t1.doctorName = t2.doctorName
  1490. <if test="asc != null and asc !=''">
  1491. order by
  1492. <choose>
  1493. <when test='asc=="doctorId"'>doctorId asc</when>
  1494. <when test='asc=="doctorName"'>doctorName asc</when>
  1495. <when test='asc=="entryNum"'>entryNum asc</when>
  1496. <when test='asc=="mrNum"'>mrNum asc</when>
  1497. <when test='asc=="totleValue"'>totleValue asc</when>
  1498. <when test='asc=="averageValue"'>averageValue asc</when>
  1499. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1500. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1501. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1502. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1503. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1504. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1505. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1506. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1507. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1508. <otherwise> doctorName asc </otherwise>
  1509. </choose>
  1510. </if>
  1511. <if test="desc != null and desc!=''">
  1512. order by
  1513. <choose>
  1514. <when test='desc=="doctorId"'>doctorId desc</when>
  1515. <when test='desc=="doctorName"'>doctorName desc</when>
  1516. <when test='desc=="entryNum"'>entryNum desc</when>
  1517. <when test='desc=="mrNum"'>mrNum desc</when>
  1518. <when test='desc=="totleValue"'>totleValue desc</when>
  1519. <when test='desc=="averageValue"'>averageValue desc</when>
  1520. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1521. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1522. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1523. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1524. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1525. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1526. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1527. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1528. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1529. <otherwise> doctorName desc </otherwise>
  1530. </choose>
  1531. </if>
  1532. </select>
  1533. </mapper>