BehospitalInfoMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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. </select>
  85. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  86. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  87. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg
  88. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  89. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  90. and a.id = c.cases_entry_id
  91. and a.mode_id = b.id
  92. AND c.cases_id = d.cases_id
  93. and c.hospital_id = d.hospital_id
  94. and c.hospital_id = #{hospitalId}
  95. and c.behospital_code = #{behospitalCode}
  96. order by b.order_no, a.order_no
  97. </select>
  98. <!-- 缺陷排行列表 -->
  99. <select id="resultStatistics" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  100. SELECT
  101. t1.msg AS name,
  102. t1.num AS num,
  103. round( t1.num / t2.totle, 4) AS percent
  104. FROM
  105. (
  106. (
  107. SELECT
  108. c.msg,
  109. count(*) AS num
  110. FROM
  111. med_behospital_info a,
  112. med_qcresult_info b,
  113. med_qcresult_detail c
  114. WHERE
  115. a.behospital_code = b.behospital_code
  116. AND a.hospital_id = b.hospital_id
  117. AND b.behospital_code = c.behospital_code
  118. AND b.hospital_id = c.hospital_id
  119. AND a.is_deleted = 'N'
  120. AND b.is_deleted = 'N'
  121. AND c.is_deleted = 'N'
  122. AND a.qc_type_id IS NOT NULL
  123. <if test="hospitalId != null and hospitalId != ''">
  124. AND a.hospital_id = #{hospitalId}
  125. </if>
  126. <if test="startDate != null and startDate != ''">
  127. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  128. </if>
  129. <if test="endDate != null and endDate != ''">
  130. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  131. </if>
  132. GROUP BY
  133. c.msg
  134. ORDER BY
  135. count(*) DESC
  136. ) t1,
  137. (
  138. SELECT
  139. count(*) AS totle
  140. FROM
  141. med_behospital_info a,
  142. med_qcresult_info b,
  143. med_qcresult_detail c
  144. WHERE
  145. a.behospital_code = b.behospital_code
  146. AND a.hospital_id = b.hospital_id
  147. AND b.behospital_code = c.behospital_code
  148. AND b.hospital_id = c.hospital_id
  149. AND a.is_deleted = 'N'
  150. AND b.is_deleted = 'N'
  151. AND c.is_deleted = 'N'
  152. AND a.qc_type_id IS NOT NULL
  153. <if test="hospitalId != null and hospitalId != ''">
  154. AND a.hospital_id = #{hospitalId}
  155. </if>
  156. <if test="startDate != null and startDate != ''">
  157. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  158. </if>
  159. <if test="endDate != null and endDate != ''">
  160. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  161. </if>
  162. ) t2
  163. )
  164. <if test="limitCount != null and limitCount != ''">
  165. limit 0,#{limitCount}
  166. </if>
  167. </select>
  168. <!-- 各科室缺陷占比 -->
  169. <select id="resultStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  170. SELECT
  171. t1.beh_dept_name AS name,
  172. t1.num AS num,
  173. round( t1.num / t2.totle, 4 ) AS percent
  174. FROM
  175. (
  176. (
  177. SELECT
  178. a.beh_dept_id,
  179. a.beh_dept_name,
  180. count(*) AS num
  181. FROM
  182. med_behospital_info a,
  183. med_qcresult_info b,
  184. med_qcresult_detail c
  185. WHERE
  186. a.behospital_code = b.behospital_code
  187. AND a.hospital_id = b.hospital_id
  188. AND b.behospital_code = c.behospital_code
  189. AND b.hospital_id = c.hospital_id
  190. AND a.is_deleted = 'N'
  191. AND b.is_deleted = 'N'
  192. AND c.is_deleted = 'N'
  193. AND a.qc_type_id IS NOT NULL
  194. <if test="hospitalId != null and hospitalId != ''">
  195. AND a.hospital_id = #{hospitalId}
  196. </if>
  197. <if test="startDate != null and startDate != ''">
  198. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  199. </if>
  200. <if test="endDate != null and endDate != ''">
  201. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  202. </if>
  203. GROUP BY
  204. a.beh_dept_id,
  205. a.beh_dept_name
  206. ORDER BY
  207. count(*) DESC
  208. ) t1,
  209. (
  210. SELECT
  211. count(*) AS totle
  212. FROM
  213. med_behospital_info a,
  214. med_qcresult_info b,
  215. med_qcresult_detail c
  216. WHERE
  217. a.behospital_code = b.behospital_code
  218. AND a.hospital_id = b.hospital_id
  219. AND b.behospital_code = c.behospital_code
  220. AND b.hospital_id = c.hospital_id
  221. AND a.is_deleted = 'N'
  222. AND b.is_deleted = 'N'
  223. AND c.is_deleted = 'N'
  224. AND a.qc_type_id IS NOT NULL
  225. <if test="hospitalId != null and hospitalId != ''">
  226. AND a.hospital_id = #{hospitalId}
  227. </if>
  228. <if test="startDate != null and startDate != ''">
  229. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  230. </if>
  231. <if test="endDate != null and endDate != ''">
  232. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  233. </if>
  234. ) t2
  235. )
  236. </select>
  237. <!-- 缺陷排行列表 -->
  238. <select id="resultStatistics2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  239. SELECT
  240. c.msg as name,
  241. count(*) AS num
  242. FROM
  243. med_behospital_info a,
  244. med_qcresult_info b,
  245. med_qcresult_detail c
  246. WHERE
  247. a.behospital_code = b.behospital_code
  248. AND a.hospital_id = b.hospital_id
  249. AND b.behospital_code = c.behospital_code
  250. AND b.hospital_id = c.hospital_id
  251. AND a.is_deleted = 'N'
  252. AND b.is_deleted = 'N'
  253. AND c.is_deleted = 'N'
  254. AND a.qc_type_id IS NOT NULL
  255. <if test="hospitalId != null and hospitalId != ''">
  256. AND a.hospital_id = #{hospitalId}
  257. </if>
  258. <if test="startDate != null and startDate != ''">
  259. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  260. </if>
  261. <if test="endDate != null and endDate != ''">
  262. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  263. </if>
  264. GROUP BY
  265. c.msg
  266. ORDER BY
  267. count(*) DESC
  268. <if test="limitCount != null and limitCount != ''">
  269. limit 0,#{limitCount}
  270. </if>
  271. </select>
  272. <!-- 各科室缺陷占比 -->
  273. <select id="resultStatisticsByDept2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  274. SELECT
  275. a.beh_dept_id,
  276. a.beh_dept_name as name,
  277. count(*) AS num
  278. FROM
  279. med_behospital_info a,
  280. med_qcresult_info b,
  281. med_qcresult_detail c
  282. WHERE
  283. a.behospital_code = b.behospital_code
  284. AND a.hospital_id = b.hospital_id
  285. AND b.behospital_code = c.behospital_code
  286. AND b.hospital_id = c.hospital_id
  287. AND a.is_deleted = 'N'
  288. AND b.is_deleted = 'N'
  289. AND c.is_deleted = 'N'
  290. AND a.qc_type_id IS NOT NULL
  291. <if test="hospitalId != null and hospitalId != ''">
  292. AND a.hospital_id = #{hospitalId}
  293. </if>
  294. <if test="startDate != null and startDate != ''">
  295. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  296. </if>
  297. <if test="endDate != null and endDate != ''">
  298. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  299. </if>
  300. GROUP BY
  301. a.beh_dept_id,
  302. a.beh_dept_name
  303. ORDER BY
  304. count(*) DESC
  305. </select>
  306. <!-- 缺陷总数查询-->
  307. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  308. SELECT
  309. count(*) AS totle
  310. FROM
  311. med_behospital_info a,
  312. med_qcresult_info b,
  313. med_qcresult_detail c
  314. WHERE
  315. a.behospital_code = b.behospital_code
  316. AND a.hospital_id = b.hospital_id
  317. AND b.behospital_code = c.behospital_code
  318. AND b.hospital_id = c.hospital_id
  319. AND a.is_deleted = 'N'
  320. AND b.is_deleted = 'N'
  321. AND c.is_deleted = 'N'
  322. AND a.qc_type_id IS NOT NULL
  323. <if test="hospitalId != null and hospitalId != ''">
  324. AND a.hospital_id = #{hospitalId}
  325. </if>
  326. <if test="startDate != null and startDate != ''">
  327. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  328. </if>
  329. <if test="endDate != null and endDate != ''">
  330. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  331. </if>
  332. </select>
  333. <!--获取未评分病历-->
  334. <select id="getNoGrade" resultMap="BaseResultMap">
  335. select * from med_behospital_info a
  336. where a.is_deleted = 'N'
  337. and
  338. not EXISTS (
  339. SELECT
  340. 1
  341. FROM
  342. med_qcresult_info b
  343. WHERE
  344. b.is_deleted = 'N'
  345. AND a.hospital_id = b.hospital_id
  346. AND a.behospital_code = b.behospital_code
  347. )
  348. </select>
  349. <!--质控评分(科室)分页-->
  350. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  351. SELECT
  352. *
  353. FROM
  354. ( SELECT
  355. a.*,
  356. IFNULL(b.level, '未评分') AS `level`,
  357. b.grade_type,
  358. b.score_res,
  359. b.gmt_create AS grade_time,
  360. c.age
  361. FROM
  362. med_behospital_info a
  363. JOIN sys_user_dept d
  364. ON a.hospital_id = d.hospital_id
  365. AND a.beh_dept_id = d.dept_id
  366. LEFT JOIN med_qcresult_info b
  367. ON a.behospital_code = b.behospital_code
  368. AND b.is_deleted = 'N'
  369. LEFT JOIN med_home_page c
  370. ON a.behospital_code = c.behospital_code
  371. AND c.is_deleted = 'N'
  372. WHERE d.is_deleted = 'N'
  373. AND d.user_id = #{userId}
  374. ) t
  375. where t.is_deleted = 'N'
  376. <if test="deptId != null and deptId != ''">
  377. and t.beh_dept_id = #{deptId}
  378. </if>
  379. <if test="doctorName != null and doctorName != ''">
  380. and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
  381. </if>
  382. <if test="doctorCode != null and doctorCode != ''">
  383. and (t.doctor_id = #{doctorCode}
  384. or t.beh_doctor_id = #{doctorCode}
  385. or t.director_doctor_id = #{doctorCode})
  386. </if>
  387. <if test="name != null and name != ''">
  388. and t.name like CONCAT('%',#{name},'%')
  389. </if>
  390. <if test="fileCode != null and fileCode != ''">
  391. and t.file_code like CONCAT('%',#{fileCode},'%')
  392. </if>
  393. <if test="hospitalId != null">
  394. and t.hospital_id = #{hospitalId}
  395. </if>
  396. <if test="behospitalCode != null and behospitalCode != ''">
  397. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  398. </if>
  399. <if test="behosDateStart != null">
  400. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  401. </if>
  402. <if test="behosDateEnd != null">
  403. <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
  404. </if>
  405. <if test="leaveHosDateStart != null">
  406. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  407. </if>
  408. <if test="leaveHosDateEnd != null">
  409. <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
  410. </if>
  411. <if test="level != null and level != ''">
  412. and t.level = #{level}
  413. </if>
  414. </select>
  415. <!--质控评分(个人)分页-->
  416. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  417. select * from (SELECT
  418. a.*,
  419. IFNULL(b.level, '未评分') AS `level`,
  420. b.grade_type,
  421. b.score_res,
  422. b.gmt_create AS grade_time,
  423. c.age
  424. FROM
  425. med_behospital_info a
  426. JOIN
  427. (SELECT
  428. u.id,
  429. u.linkman AS linkman,
  430. uh.hospital_id
  431. FROM
  432. sys_user u
  433. JOIN sys_user_hospital uh
  434. ON u.id = uh.user_id
  435. WHERE u.is_deleted = "N"
  436. AND u.id = #{userId}
  437. AND uh.hospital_id = #{hospitalId}) u1
  438. ON a.hospital_id = u1.hospital_id
  439. LEFT JOIN med_qcresult_info b
  440. ON a.behospital_code = b.behospital_code
  441. AND b.is_deleted = 'N'
  442. LEFT JOIN med_home_page c
  443. ON a.behospital_code = c.behospital_code
  444. AND c.is_deleted = 'N'
  445. WHERE CONCAT(
  446. IFNULL(a.doctor_name, ''),
  447. IFNULL(a.beh_doctor_name, ''),
  448. IFNULL(a.director_doctor_name, '')
  449. ) LIKE CONCAT('%', u1.linkman, '%')
  450. ) t
  451. where t.is_deleted = 'N'
  452. <if test="deptId != null and deptId != ''">
  453. and t.beh_dept_id = #{deptId}
  454. </if>
  455. <if test="name != null and name != ''">
  456. and t.name like CONCAT('%',#{name},'%')
  457. </if>
  458. <if test="fileCode != null and fileCode != ''">
  459. and t.file_code like CONCAT('%',#{fileCode},'%')
  460. </if>
  461. <if test="behospitalCode != null and behospitalCode != ''">
  462. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  463. </if>
  464. <if test="behosDateStart != null">
  465. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  466. </if>
  467. <if test="behosDateEnd != null">
  468. <![CDATA[ and t.behospital_date <= #{behosDateEnd}]]>
  469. </if>
  470. <if test="leaveHosDateStart != null">
  471. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  472. </if>
  473. <if test="leaveHosDateEnd != null">
  474. <![CDATA[ and t.leave_hospital_date <= #{leaveHosDateEnd}]]>
  475. </if>
  476. <if test="level != null and level != ''">
  477. and t.level = #{level}
  478. </if>
  479. </select>
  480. <!-- 病案首页病历数统计 -->
  481. <select id="homePageCount" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="int">
  482. SELECT
  483. COUNT(*)
  484. FROM
  485. med_behospital_info a,
  486. med_home_page b
  487. WHERE
  488. a.is_deleted = 'N'
  489. AND b.is_deleted = 'N'
  490. AND a.hospital_id = b.hospital_id
  491. AND a.behospital_code = b.behospital_code
  492. AND a.qc_type_id IS NOT NULL
  493. <if test="hospitalId != null and hospitalId != ''">
  494. AND a.hospital_id = #{hospitalId}
  495. </if>
  496. <if test="startDate != null and startDate != ''">
  497. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  498. </if>
  499. <if test="endDate != null and endDate != ''">
  500. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  501. </if>
  502. <if test="death!=null and death==1">
  503. AND b.leave_hospital_type = '死亡'
  504. </if>
  505. <if test="newBorn!=null and newBorn==1">
  506. AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
  507. <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
  508. </if>
  509. </select>
  510. <!-- 病案首页手术病历数统计 -->
  511. <select id="homePageCountForOperation" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  512. SELECT
  513. COUNT(*)
  514. FROM
  515. med_behospital_info a,
  516. med_home_page b,
  517. med_home_operation_info c
  518. WHERE
  519. a.is_deleted = 'N'
  520. AND b.is_deleted = 'N'
  521. AND c.is_deleted = 'N'
  522. AND a.hospital_id = b.hospital_id
  523. AND a.hospital_id = c.hospital_id
  524. AND a.behospital_code = b.behospital_code
  525. AND b.home_page_id = c.home_page_id
  526. AND a.qc_type_id IS NOT NULL
  527. <if test="hospitalId != null and hospitalId != ''">
  528. AND a.hospital_id = #{hospitalId}
  529. </if>
  530. <if test="startDate != null and startDate != ''">
  531. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  532. </if>
  533. <if test="endDate != null and endDate != ''">
  534. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  535. </if>
  536. </select>
  537. <!-- 按科室统计病案首页病历数 -->
  538. <select id="homePageCountByDept" parameterType="com.diagbot.vo.HPFilterByDeptVO" resultType="com.diagbot.dto.NumDTO">
  539. SELECT
  540. a.beh_dept_id AS id,
  541. a.beh_dept_name AS NAME,
  542. COUNT(*) AS num
  543. FROM
  544. med_behospital_info a,
  545. med_home_page b,
  546. sys_user_dept c
  547. WHERE
  548. a.is_deleted = 'N'
  549. AND b.is_deleted = 'N'
  550. AND c.is_deleted = 'N'
  551. AND a.hospital_id = b.hospital_id
  552. AND a.hospital_id = c.hospital_id
  553. AND a.behospital_code = b.behospital_code
  554. AND a.beh_dept_id = c.dept_id
  555. AND a.qc_type_id IS NOT NULL
  556. <if test="death!=null and death==1">
  557. AND b.leave_hospital_type = '死亡'
  558. </if>
  559. <if test="userId!=null">
  560. AND c.user_id = #{userId}
  561. </if>
  562. <if test="hospitalId != null and hospitalId != ''">
  563. AND a.hospital_id = #{hospitalId}
  564. </if>
  565. <if test="startDate != null and startDate != ''">
  566. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  567. </if>
  568. <if test="endDate != null and endDate != ''">
  569. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  570. </if>
  571. GROUP BY
  572. a.beh_dept_id,
  573. a.beh_dept_name
  574. </select>
  575. <!-- 按科室病案首页手术病历数 -->
  576. <select id="homePageCountForOperationByDept" parameterType="com.diagbot.vo.FilterByDeptVO" resultType="com.diagbot.dto.NumDTO">
  577. SELECT
  578. a.beh_dept_id AS id,
  579. a.beh_dept_name AS NAME,
  580. COUNT(*) AS num
  581. FROM
  582. med_behospital_info a,
  583. med_home_page b,
  584. sys_user_dept c,
  585. med_home_operation_info d
  586. WHERE
  587. a.is_deleted = 'N'
  588. AND b.is_deleted = 'N'
  589. AND c.is_deleted = 'N'
  590. AND d.is_deleted = 'N'
  591. AND a.hospital_id = b.hospital_id
  592. AND a.hospital_id = c.hospital_id
  593. AND a.hospital_id = d.hospital_id
  594. AND a.behospital_code = b.behospital_code
  595. AND b.home_page_id = d.home_page_id
  596. AND a.beh_dept_id = c.dept_id
  597. AND a.qc_type_id IS NOT NULL
  598. <if test="userId!=null">
  599. AND c.user_id = #{userId}
  600. </if>
  601. <if test="hospitalId != null and hospitalId != ''">
  602. AND a.hospital_id = #{hospitalId}
  603. </if>
  604. <if test="startDate != null and startDate != ''">
  605. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  606. </if>
  607. <if test="endDate != null and endDate != ''">
  608. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  609. </if>
  610. GROUP BY
  611. a.beh_dept_id,
  612. a.beh_dept_name
  613. </select>
  614. </mapper>