QcresultInfoMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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.QcresultInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.QcresultInfo">
  6. <id column="id" property="id" />
  7. <result column="behospital_code" property="behospitalCode" />
  8. <result column="hospital_id" property="hospitalId" />
  9. <result column="level" property="level" />
  10. <result column="score_res" property="scoreRes" />
  11. <result column="grade_type" property="gradeType" />
  12. <result column="is_deleted" property="isDeleted" />
  13. <result column="gmt_create" property="gmtCreate" />
  14. <result column="gmt_modified" property="gmtModified" />
  15. <result column="creator" property="creator" />
  16. <result column="modifier" property="modifier" />
  17. <result column="remark" property="remark" />
  18. </resultMap>
  19. <!-- 病历数统计 -->
  20. <select id="getQcresultSelectively" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
  21. SELECT
  22. count(1)
  23. FROM
  24. med_behospital_info a,
  25. med_qcresult_info b
  26. WHERE
  27. a.hospital_id = b.hospital_id
  28. AND a.behospital_code = b.behospital_code
  29. AND a.is_deleted = 'N'
  30. AND b.is_deleted = 'N'
  31. <![CDATA[AND a.qc_type_id <>0 ]]>
  32. <if test="hospitalId != null and hospitalId != ''">
  33. AND a.hospital_id = #{hospitalId}
  34. </if>
  35. <if test="startDate != null and startDate != ''">
  36. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  37. </if>
  38. <if test="endDate != null and endDate != ''">
  39. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  40. </if>
  41. <if test="gradeType != null and gradeType != ''">
  42. AND b.grade_type = #{gradeType}
  43. </if>
  44. <if test="level != null and level != ''">
  45. AND b.level = #{level}
  46. </if>
  47. </select>
  48. <!-- 质控病历数统计 -->
  49. <select id="resultCount" parameterType="com.diagbot.vo.QcresultFilterVO" resultType="int">
  50. SELECT
  51. COUNT(*)
  52. FROM
  53. med_behospital_info a,
  54. med_home_page b,
  55. med_qcresult_info c
  56. WHERE
  57. a.is_deleted = 'N'
  58. AND b.is_deleted = 'N'
  59. AND c.is_deleted = 'N'
  60. AND a.hospital_id = b.hospital_id
  61. AND a.hospital_id = c.hospital_id
  62. AND a.behospital_code = b.behospital_code
  63. AND a.behospital_code = c.behospital_code
  64. <![CDATA[AND a.qc_type_id <>0 ]]>
  65. <if test="hospitalId != null and hospitalId != ''">
  66. AND a.hospital_id = #{hospitalId}
  67. </if>
  68. <if test="startDate != null and startDate != ''">
  69. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  70. </if>
  71. <if test="endDate != null and endDate != ''">
  72. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  73. </if>
  74. <if test="gradeType != null and gradeType != ''">
  75. AND c.grade_type = #{gradeType}
  76. </if>
  77. <if test="level != null and level != ''">
  78. AND c.level = #{level}
  79. </if>
  80. </select>
  81. <!-- 按科室统计质控病历数 -->
  82. <select id="levelPercentGroupByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.QcResultPercentDTO">
  83. SELECT
  84. a.beh_dept_id AS deptId,
  85. a.beh_dept_name AS deptName,
  86. count(*) AS totleNum,
  87. sum( c.`level` = '甲' ) AS firstLevelNum,
  88. sum( c.`level` = '乙' ) AS secondLevelNum,
  89. sum( c.`level` = '丙' ) AS thirdLevelNum,
  90. concat( ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstPercent,
  91. concat( ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS sencondPercent,
  92. concat( ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdPercent
  93. FROM
  94. med_behospital_info a,
  95. med_home_page b,
  96. med_qcresult_info c
  97. WHERE
  98. a.is_deleted = 'N'
  99. AND b.is_deleted = 'N'
  100. AND c.is_deleted = 'N'
  101. AND a.hospital_id = b.hospital_id
  102. AND a.hospital_id = c.hospital_id
  103. AND a.behospital_code = b.behospital_code
  104. AND a.behospital_code = c.behospital_code
  105. <![CDATA[AND a.qc_type_id <>0 ]]>
  106. <if test="hospitalId != null and hospitalId != ''">
  107. AND a.hospital_id = #{hospitalId}
  108. </if>
  109. <if test="startDate != null and startDate != ''">
  110. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  111. </if>
  112. <if test="endDate != null and endDate != ''">
  113. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  114. </if>
  115. GROUP BY
  116. a.beh_dept_id,
  117. a.beh_dept_name
  118. </select>
  119. <!-- 按模块统计质控缺陷数 -->
  120. <select id="entryCountGroupByCase" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  121. SELECT
  122. d.cases_id AS id,
  123. e.NAME AS name,
  124. count(*) AS num
  125. FROM
  126. med_behospital_info a,
  127. med_home_page b,
  128. med_qcresult_info c,
  129. med_qcresult_detail d,
  130. qc_cases e,
  131. qc_cases_entry f
  132. WHERE
  133. a.is_deleted = 'N'
  134. AND b.is_deleted = 'N'
  135. AND c.is_deleted = 'N'
  136. AND d.is_deleted = 'N'
  137. AND e.is_deleted = 'N'
  138. AND f.is_deleted = 'N'
  139. AND a.hospital_id = b.hospital_id
  140. AND a.hospital_id = c.hospital_id
  141. AND a.hospital_id = d.hospital_id
  142. AND a.behospital_code = b.behospital_code
  143. AND a.behospital_code = c.behospital_code
  144. AND a.behospital_code = d.behospital_code
  145. AND d.cases_id = e.id
  146. AND d.cases_entry_id = f.id
  147. AND e.id = f.cases_id
  148. <![CDATA[AND a.qc_type_id <>0 ]]>
  149. <if test="hospitalId != null and hospitalId != ''">
  150. AND a.hospital_id = #{hospitalId}
  151. </if>
  152. <if test="startDate != null and startDate != ''">
  153. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  154. </if>
  155. <if test="endDate != null and endDate != ''">
  156. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  157. </if>
  158. GROUP BY
  159. d.cases_id,
  160. e.`name`
  161. </select>
  162. <!-- 条目缺陷分组统计 -->
  163. <select id="entryCountGroupByEntry" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  164. SELECT
  165. d.id,
  166. d.NAME,
  167. count(*) AS num
  168. FROM
  169. med_behospital_info a,
  170. med_home_page b,
  171. med_qcresult_detail c,
  172. qc_cases_entry d
  173. WHERE
  174. a.is_deleted = 'N'
  175. AND b.is_deleted = 'N'
  176. AND c.is_deleted = 'N'
  177. AND d.is_deleted = 'N'
  178. AND a.hospital_id = b.hospital_id
  179. AND a.hospital_id = c.hospital_id
  180. AND a.behospital_code = b.behospital_code
  181. AND a.behospital_code = c.behospital_code
  182. AND c.cases_id = d.cases_id
  183. AND c.cases_entry_id = d.id
  184. <![CDATA[AND a.qc_type_id <>0 ]]>
  185. <if test="hospitalId != null and hospitalId != ''">
  186. AND a.hospital_id = #{hospitalId}
  187. </if>
  188. <if test="startDate != null and startDate != ''">
  189. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  190. </if>
  191. <if test="endDate != null and endDate != ''">
  192. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  193. </if>
  194. GROUP BY
  195. d.id,
  196. d.NAME
  197. </select>
  198. <!-- 质控平均分按科室统计 -->
  199. <select id="getAverageScoreByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
  200. SELECT
  201. a.beh_dept_id AS id,
  202. a.beh_dept_name AS name,
  203. ROUND( sum( CAST( c.score_res AS DECIMAL )), 2 ) AS totleValue,
  204. ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  205. count(*) AS num
  206. FROM
  207. med_behospital_info a,
  208. med_home_page b,
  209. med_qcresult_info c
  210. WHERE
  211. a.is_deleted = 'N'
  212. AND b.is_deleted = 'N'
  213. AND c.is_deleted = 'N'
  214. AND a.hospital_id = b.hospital_id
  215. AND a.hospital_id = c.hospital_id
  216. AND a.behospital_code = b.behospital_code
  217. AND a.behospital_code = c.behospital_code
  218. <![CDATA[AND a.qc_type_id <>0 ]]>
  219. <if test="hospitalId != null and hospitalId != ''">
  220. AND a.hospital_id = #{hospitalId}
  221. </if>
  222. <if test="startDate != null and startDate != ''">
  223. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  224. </if>
  225. <if test="endDate != null and endDate != ''">
  226. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  227. </if>
  228. GROUP BY
  229. a.beh_dept_id,
  230. a.beh_dept_name
  231. </select>
  232. <!-- 按科室统计质控病历数 -->
  233. <select id="resultCountByDept" parameterType="com.diagbot.vo.QcresultFilterByDeptVO" resultType="com.diagbot.dto.NumDTO">
  234. SELECT
  235. a.beh_dept_id AS id,
  236. a.beh_dept_name AS NAME,
  237. COUNT(*) AS num
  238. FROM
  239. med_behospital_info a,
  240. med_home_page b,
  241. med_qcresult_info c,
  242. sys_user_dept d
  243. WHERE
  244. a.is_deleted = 'N'
  245. AND b.is_deleted = 'N'
  246. AND c.is_deleted = 'N'
  247. AND d.is_deleted = 'N'
  248. AND a.hospital_id = b.hospital_id
  249. AND a.hospital_id = c.hospital_id
  250. AND a.hospital_id = d.hospital_id
  251. AND a.behospital_code = b.behospital_code
  252. AND a.behospital_code = c.behospital_code
  253. AND a.beh_dept_id = d.dept_id
  254. <![CDATA[AND a.qc_type_id <>0 ]]>
  255. <if test="userId!=null">
  256. AND d.user_id = #{userId}
  257. </if>
  258. <if test="hospitalId != null and hospitalId != ''">
  259. AND a.hospital_id = #{hospitalId}
  260. </if>
  261. <if test="startDate != null and startDate != ''">
  262. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  263. </if>
  264. <if test="endDate != null and endDate != ''">
  265. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  266. </if>
  267. <if test="gradeType != null and gradeType != ''">
  268. AND c.grade_type = #{gradeType}
  269. </if>
  270. <if test="level != null and level != ''">
  271. AND c.level = #{level}
  272. </if>
  273. GROUP BY
  274. a.beh_dept_id,
  275. a.beh_dept_name
  276. </select>
  277. <!-- 按模块统计质控缺陷数 -->
  278. <select id="entryCountGroupByCaseAndDept" parameterType="com.diagbot.vo.FilterByDeptVO" resultType="com.diagbot.dto.DeptNumDTO">
  279. SELECT
  280. d.cases_id AS id,
  281. e.NAME AS NAME,
  282. a.beh_dept_id AS deptId,
  283. a.beh_dept_name AS deptName,
  284. count(*) AS num
  285. FROM
  286. med_behospital_info a,
  287. med_home_page b,
  288. med_qcresult_info c,
  289. med_qcresult_detail d,
  290. qc_cases e,
  291. qc_cases_entry f,
  292. sys_user_dept g
  293. WHERE
  294. a.is_deleted = 'N'
  295. AND b.is_deleted = 'N'
  296. AND c.is_deleted = 'N'
  297. AND d.is_deleted = 'N'
  298. AND e.is_deleted = 'N'
  299. AND f.is_deleted = 'N'
  300. AND g.is_deleted = 'N'
  301. AND a.hospital_id = b.hospital_id
  302. AND a.hospital_id = c.hospital_id
  303. AND a.hospital_id = d.hospital_id
  304. AND a.hospital_id = g.hospital_id
  305. AND a.behospital_code = b.behospital_code
  306. AND a.behospital_code = c.behospital_code
  307. AND a.behospital_code = d.behospital_code
  308. AND d.cases_id = e.id
  309. AND d.cases_entry_id = f.id
  310. AND e.id = f.cases_id
  311. AND a.beh_dept_id = g.dept_id
  312. <![CDATA[AND a.qc_type_id <>0 ]]>
  313. <if test="userId!=null">
  314. AND g.user_id = #{userId}
  315. </if>
  316. <if test="hospitalId != null and hospitalId != ''">
  317. AND a.hospital_id = #{hospitalId}
  318. </if>
  319. <if test="startDate != null and startDate != ''">
  320. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  321. </if>
  322. <if test="endDate != null and endDate != ''">
  323. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  324. </if>
  325. GROUP BY
  326. d.cases_id,
  327. e.`name`,
  328. a.beh_dept_id,
  329. a.beh_dept_name
  330. </select>
  331. <!-- 条目缺陷分组统计 -->
  332. <select id="entryCountGroupByEntryAndDept" parameterType="com.diagbot.vo.FilterByDeptVO" resultType="com.diagbot.dto.DeptNumDTO">
  333. SELECT
  334. d.id,
  335. d.NAME,
  336. a.beh_dept_id AS deptId,
  337. a.beh_dept_name AS deptName,
  338. count(*) AS num
  339. FROM
  340. med_behospital_info a,
  341. med_home_page b,
  342. med_qcresult_detail c,
  343. qc_cases_entry d,
  344. sys_user_dept e
  345. WHERE
  346. a.is_deleted = 'N'
  347. AND b.is_deleted = 'N'
  348. AND c.is_deleted = 'N'
  349. AND d.is_deleted = 'N'
  350. AND e.is_deleted = 'N'
  351. AND a.hospital_id = b.hospital_id
  352. AND a.hospital_id = c.hospital_id
  353. AND a.hospital_id = e.hospital_id
  354. AND a.behospital_code = b.behospital_code
  355. AND a.behospital_code = c.behospital_code
  356. AND c.cases_id = d.cases_id
  357. AND c.cases_entry_id = d.id
  358. AND a.beh_dept_id = e.dept_id
  359. <![CDATA[AND a.qc_type_id <>0 ]]>
  360. <if test="userId!=null">
  361. AND e.user_id = #{userId}
  362. </if>
  363. <if test="hospitalId != null and hospitalId != ''">
  364. AND a.hospital_id = #{hospitalId}
  365. </if>
  366. <if test="startDate != null and startDate != ''">
  367. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  368. </if>
  369. <if test="endDate != null and endDate != ''">
  370. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  371. </if>
  372. GROUP BY
  373. d.id,
  374. d.NAME,
  375. a.beh_dept_id,
  376. a.beh_dept_name
  377. </select>
  378. <!-- 按模块统计质控缺陷数(分页) -->
  379. <select id="entryCountGroupByCasePage" resultType="com.diagbot.dto.NumDTO">
  380. SELECT
  381. d.cases_id AS id,
  382. e.NAME AS name,
  383. count(*) AS num
  384. FROM
  385. med_behospital_info a,
  386. med_home_page b,
  387. med_qcresult_info c,
  388. med_qcresult_detail d,
  389. qc_cases e,
  390. qc_cases_entry f
  391. WHERE
  392. a.is_deleted = 'N'
  393. AND b.is_deleted = 'N'
  394. AND c.is_deleted = 'N'
  395. AND d.is_deleted = 'N'
  396. AND e.is_deleted = 'N'
  397. AND f.is_deleted = 'N'
  398. AND a.hospital_id = b.hospital_id
  399. AND a.hospital_id = c.hospital_id
  400. AND a.hospital_id = d.hospital_id
  401. AND a.behospital_code = b.behospital_code
  402. AND a.behospital_code = c.behospital_code
  403. AND a.behospital_code = d.behospital_code
  404. AND d.cases_id = e.id
  405. AND d.cases_entry_id = f.id
  406. AND e.id = f.cases_id
  407. <![CDATA[AND a.qc_type_id <>0 ]]>
  408. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  409. AND a.hospital_id = #{filterPageVO.hospitalId}
  410. </if>
  411. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  412. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  413. </if>
  414. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  415. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  416. </if>
  417. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  418. AND e.name like CONCAT('%', #{filterPageVO.name},'%')
  419. </if>
  420. GROUP BY
  421. d.cases_id,
  422. e.`name`
  423. </select>
  424. <!-- 条目缺陷分组统计(分页) -->
  425. <select id="entryCountGroupByEntryPage" resultType="com.diagbot.dto.NumDTO">
  426. SELECT t.*
  427. FROM
  428. (SELECT
  429. t1.id,
  430. t1.NAME,
  431. count(*) AS num,
  432. t2.totleNum
  433. FROM
  434. (
  435. SELECT
  436. d.id AS id,
  437. d.NAME AS NAME
  438. FROM
  439. med_behospital_info a,
  440. med_home_page b,
  441. med_qcresult_detail c,
  442. qc_cases_entry d
  443. WHERE
  444. a.is_deleted = 'N'
  445. AND b.is_deleted = 'N'
  446. AND c.is_deleted = 'N'
  447. AND d.is_deleted = 'N'
  448. AND a.hospital_id = b.hospital_id
  449. AND a.hospital_id = c.hospital_id
  450. AND a.behospital_code = b.behospital_code
  451. AND a.behospital_code = c.behospital_code
  452. AND c.cases_id = d.cases_id
  453. AND c.cases_entry_id = d.id
  454. <![CDATA[AND a.qc_type_id <>0 ]]>
  455. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  456. AND a.hospital_id = #{filterPageVO.hospitalId}
  457. </if>
  458. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  459. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  460. </if>
  461. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  462. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  463. </if>
  464. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  465. AND d.name like CONCAT('%', #{filterPageVO.name},'%')
  466. </if>
  467. ) t1,(
  468. SELECT
  469. count(*) AS totleNum
  470. FROM
  471. med_behospital_info a,
  472. med_home_page b,
  473. med_qcresult_detail c,
  474. qc_cases_entry d
  475. WHERE
  476. a.is_deleted = 'N'
  477. AND b.is_deleted = 'N'
  478. AND c.is_deleted = 'N'
  479. AND d.is_deleted = 'N'
  480. AND a.hospital_id = b.hospital_id
  481. AND a.hospital_id = c.hospital_id
  482. AND a.behospital_code = b.behospital_code
  483. AND a.behospital_code = c.behospital_code
  484. AND c.cases_id = d.cases_id
  485. AND c.cases_entry_id = d.id
  486. <![CDATA[AND a.qc_type_id <>0 ]]>
  487. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  488. AND a.hospital_id = #{filterPageVO.hospitalId}
  489. </if>
  490. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  491. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  492. </if>
  493. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  494. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  495. </if>
  496. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  497. AND d.name like CONCAT('%', #{filterPageVO.name},'%')
  498. </if>
  499. ) t2
  500. GROUP BY
  501. t1.id,
  502. t1.NAME
  503. ORDER BY
  504. count(*) DESC)t
  505. </select>
  506. <!-- 质控平均分按科室统计(分页) -->
  507. <select id="getAverageScoreByDeptPage" resultType="com.diagbot.dto.AverageStatisticsDTO">
  508. SELECT t.*
  509. FROM
  510. (SELECT
  511. a.beh_dept_id AS id,
  512. a.beh_dept_name AS name,
  513. ROUND( sum( CAST( c.score_res AS DECIMAL )), 2 ) AS totleValue,
  514. ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  515. count(*) AS num
  516. FROM
  517. med_behospital_info a,
  518. med_home_page b,
  519. med_qcresult_info c
  520. WHERE
  521. a.is_deleted = 'N'
  522. AND b.is_deleted = 'N'
  523. AND c.is_deleted = 'N'
  524. AND a.hospital_id = b.hospital_id
  525. AND a.hospital_id = c.hospital_id
  526. AND a.behospital_code = b.behospital_code
  527. AND a.behospital_code = c.behospital_code
  528. <![CDATA[AND a.qc_type_id <>0 ]]>
  529. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  530. AND a.hospital_id = #{filterPageVO.hospitalId}
  531. </if>
  532. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  533. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  534. </if>
  535. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  536. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  537. </if>
  538. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  539. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  540. </if>
  541. GROUP BY
  542. a.beh_dept_id,
  543. a.beh_dept_name
  544. ORDER BY ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) DESC ) t
  545. </select>
  546. <!-- 按科室统计质控病历数(分页) -->
  547. <select id="levelPercentGroupByDeptPage" resultType="com.diagbot.dto.QcResultPercentDTO">
  548. SELECT t.*
  549. FROM
  550. (SELECT
  551. a.beh_dept_id AS deptId,
  552. a.beh_dept_name AS deptName,
  553. count(*) AS totleNum,
  554. sum( c.`level` = '甲' ) AS firstLevelNum,
  555. sum( c.`level` = '乙' ) AS secondLevelNum,
  556. sum( c.`level` = '丙' ) AS thirdLevelNum,
  557. concat( ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstPercent,
  558. concat( ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS sencondPercent,
  559. concat( ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdPercent
  560. FROM
  561. med_behospital_info a,
  562. med_home_page b,
  563. med_qcresult_info c
  564. WHERE
  565. a.is_deleted = 'N'
  566. AND b.is_deleted = 'N'
  567. AND c.is_deleted = 'N'
  568. AND a.hospital_id = b.hospital_id
  569. AND a.hospital_id = c.hospital_id
  570. AND a.behospital_code = b.behospital_code
  571. AND a.behospital_code = c.behospital_code
  572. <![CDATA[AND a.qc_type_id <>0 ]]>
  573. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  574. AND a.hospital_id = #{filterPageVO.hospitalId}
  575. </if>
  576. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  577. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  578. </if>
  579. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  580. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  581. </if>
  582. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  583. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  584. </if>
  585. GROUP BY
  586. a.beh_dept_id,
  587. a.beh_dept_name
  588. order by ROUND( sum( c.`level` = '甲' )/ count(*)* 100, 2 ) DESC,
  589. ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ) DESC,
  590. ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ) DESC) t
  591. </select>
  592. <!-- 按模块统计质控缺陷数-科室(分页) -->
  593. <select id="entryCountGroupByCaseAndDeptPage" resultType="com.diagbot.dto.DeptNumDTO">
  594. SELECT
  595. d.cases_id AS id,
  596. e.NAME AS NAME,
  597. a.beh_dept_id AS deptId,
  598. a.beh_dept_name AS deptName,
  599. count(*) AS num
  600. FROM
  601. med_behospital_info a,
  602. med_home_page b,
  603. med_qcresult_info c,
  604. med_qcresult_detail d,
  605. qc_cases e,
  606. qc_cases_entry f,
  607. sys_user_dept g
  608. WHERE
  609. a.is_deleted = 'N'
  610. AND b.is_deleted = 'N'
  611. AND c.is_deleted = 'N'
  612. AND d.is_deleted = 'N'
  613. AND e.is_deleted = 'N'
  614. AND f.is_deleted = 'N'
  615. AND g.is_deleted = 'N'
  616. AND a.hospital_id = b.hospital_id
  617. AND a.hospital_id = c.hospital_id
  618. AND a.hospital_id = d.hospital_id
  619. AND a.hospital_id = g.hospital_id
  620. AND a.behospital_code = b.behospital_code
  621. AND a.behospital_code = c.behospital_code
  622. AND a.behospital_code = d.behospital_code
  623. AND d.cases_id = e.id
  624. AND d.cases_entry_id = f.id
  625. AND e.id = f.cases_id
  626. AND a.beh_dept_id = g.dept_id
  627. <![CDATA[AND a.qc_type_id <>0 ]]>
  628. <if test="filterPageByDeptVO.userId!=null">
  629. AND g.user_id = #{filterPageByDeptVO.userId}
  630. </if>
  631. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  632. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  633. </if>
  634. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  635. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  636. </if>
  637. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  638. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  639. </if>
  640. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  641. AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
  642. </if>
  643. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  644. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  645. </if>
  646. GROUP BY
  647. d.cases_id,
  648. e.`name`,
  649. a.beh_dept_id,
  650. a.beh_dept_name
  651. </select>
  652. <!-- 条目缺陷分组统计-科室(分页) -->
  653. <select id="entryCountGroupByEntryAndDeptPage" resultType="com.diagbot.dto.DeptNumDTO">
  654. SELECT
  655. t.*
  656. FROM
  657. (
  658. SELECT
  659. t1.id,
  660. t1.NAME,
  661. count(*) AS num,
  662. t2.totleNum
  663. FROM
  664. (
  665. SELECT
  666. d.id,
  667. d.NAME,
  668. a.beh_dept_id AS deptId,
  669. a.beh_dept_name AS deptName
  670. FROM
  671. med_behospital_info a,
  672. med_home_page b,
  673. med_qcresult_detail c,
  674. qc_cases_entry d,
  675. sys_user_dept e
  676. WHERE
  677. a.is_deleted = 'N'
  678. AND b.is_deleted = 'N'
  679. AND c.is_deleted = 'N'
  680. AND d.is_deleted = 'N'
  681. AND e.is_deleted = 'N'
  682. AND a.hospital_id = b.hospital_id
  683. AND a.hospital_id = c.hospital_id
  684. AND a.hospital_id = e.hospital_id
  685. AND a.behospital_code = b.behospital_code
  686. AND a.behospital_code = c.behospital_code
  687. AND c.cases_id = d.cases_id
  688. AND c.cases_entry_id = d.id
  689. AND a.beh_dept_id = e.dept_id
  690. <![CDATA[AND a.qc_type_id <>0 ]]>
  691. <if test="filterPageByDeptVO.userId!=null">
  692. AND e.user_id = #{filterPageByDeptVO.userId}
  693. </if>
  694. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  695. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  696. </if>
  697. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  698. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  699. </if>
  700. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  701. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  702. </if>
  703. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  704. AND d.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
  705. </if>
  706. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  707. AND a.beh_dept_name like CONCAT('%', #{filterPageByDeptVO.deptName},'%')
  708. </if>
  709. ) t1,(
  710. SELECT
  711. count(*) AS totleNum
  712. FROM
  713. med_behospital_info a,
  714. med_home_page b,
  715. med_qcresult_detail c,
  716. qc_cases_entry d,
  717. sys_user_dept e
  718. WHERE
  719. a.is_deleted = 'N'
  720. AND b.is_deleted = 'N'
  721. AND c.is_deleted = 'N'
  722. AND d.is_deleted = 'N'
  723. AND e.is_deleted = 'N'
  724. AND a.hospital_id = b.hospital_id
  725. AND a.hospital_id = c.hospital_id
  726. AND a.hospital_id = e.hospital_id
  727. AND a.behospital_code = b.behospital_code
  728. AND a.behospital_code = c.behospital_code
  729. AND c.cases_id = d.cases_id
  730. AND c.cases_entry_id = d.id
  731. AND a.beh_dept_id = e.dept_id
  732. <![CDATA[AND a.qc_type_id <>0 ]]>
  733. <if test="filterPageByDeptVO.userId!=null">
  734. AND e.user_id = #{filterPageByDeptVO.userId}
  735. </if>
  736. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  737. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  738. </if>
  739. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  740. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  741. </if>
  742. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  743. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  744. </if>
  745. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  746. AND d.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
  747. </if>
  748. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  749. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  750. </if>
  751. ) t2
  752. GROUP BY
  753. t1.id,
  754. t1.NAME,
  755. t1.deptId,
  756. t1.deptName
  757. ORDER BY
  758. count(*) DESC
  759. )t
  760. </select>
  761. </mapper>