MedCheckInfoMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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.MedCheckInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.MedCheckInfo">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="behospital_code" property="behospitalCode" />
  13. <result column="hospital_id" property="hospitalId" />
  14. <result column="check_id" property="checkId" />
  15. <result column="check_name" property="checkName" />
  16. <result column="check_time" property="checkTime" />
  17. <result column="status" property="status" />
  18. <result column="check_type" property="checkType" />
  19. <result column="job_creator" property="jobCreator" />
  20. <result column="job_creator_name" property="jobCreatorName" />
  21. <result column="job_create_time" property="jobCreateTime" />
  22. <result column="job_type" property="jobType" />
  23. <result column="job_distributor" property="jobDistributor" />
  24. <result column="job_distribution_name" property="jobDistributionName" />
  25. <result column="job_distribution_time" property="jobDistributionTime" />
  26. </resultMap>
  27. <!--获取核查人员用户科室、姓名、角色-->
  28. <select id="getCheckUser" resultType="com.diagbot.dto.CheckUserDTO">
  29. SELECT DISTINCT
  30. a.id doctorId,
  31. a.linkman doctorName,
  32. c.dept_id deptId,
  33. d.dept_name deptName,
  34. b.role_id roleId
  35. from
  36. sys_user a,sys_user_role b,sys_user_dept c ,bas_dept_info d
  37. where a.id = b.user_id and a.is_deleted = "N" and b.is_deleted = "N" and c.is_deleted = "N" and a.id = c.user_id
  38. and d.dept_id = c.dept_id and c.hospital_id = d.hospital_id
  39. and c.hospital_id = #{hospitalId}
  40. <if test="roleIds !=null and roleIds.size()!=0 and roleId ==null and userId ==null">
  41. and b.role_id in
  42. <foreach collection="roleIds" item="item" open="(" close=")" separator=",">
  43. #{item}
  44. </foreach>
  45. </if>
  46. <if test="roleIds !=null and roleIds.size()!=0 and roleId !=null and userId !=null">
  47. and (b.role_id in
  48. <foreach collection="roleIds" item="item" open="(" close=")" separator=",">
  49. #{item}
  50. </foreach>
  51. or (b.role_id =#{roleId} and a.id = #{userId}))
  52. </if>
  53. <if test="deptIds !=null and deptIds.size()!=0">
  54. and c.dept_id in
  55. <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
  56. #{item}
  57. </foreach>
  58. </if>
  59. <if test="deptStations !=null and deptStations.size()!=0">
  60. and d.station in
  61. <foreach collection="deptStations" item="item" open="(" close=")" separator=",">
  62. #{item}
  63. </foreach>
  64. </if>
  65. </select>
  66. <!--通过核查人员id获取核查人员的核查任务数-->
  67. <select id="getJobNumByUserId" resultType="com.diagbot.dto.DeptCheckUserDTO">
  68. SELECT
  69. check_id doctorId,
  70. count(*) as jobNum
  71. from
  72. med_check_info
  73. where is_deleted = 'N' and job_distribution_name is not null
  74. <if test="jobType != null and jobType != ''">
  75. and job_type = #{jobType}
  76. </if>
  77. <if test="userList !=null">
  78. and check_id in
  79. <foreach collection="userList" item="item" open="(" close=")" separator=",">
  80. #{item}
  81. </foreach>
  82. </if>
  83. GROUP BY check_id
  84. </select>
  85. <!--获取待分配核查任务列表-->
  86. <select id="getCheckList" resultType="com.diagbot.dto.CheckJobDTO">
  87. SELECT
  88. a.behospital_code behospitalCode,
  89. a.beh_dept_name behospitalDept,
  90. a.doctor_name attendingDoctor,
  91. a.leave_hospital_date leaveHospitalDate,
  92. a.`name`,
  93. b.`value`,
  94. a.id
  95. from
  96. (select
  97. a.behospital_code,
  98. a.`name`,
  99. a.beh_dept_name,
  100. a.doctor_name,
  101. a.leave_hospital_date,
  102. a.hospital_id,
  103. a.beh_dept_id,
  104. b.id
  105. from
  106. med_behospital_info a ,med_check_info b
  107. where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
  108. and b.is_deleted = 'N' and b.job_distribution_name is NULL and b.`status` = 0
  109. <if test="jobType !=null and jobType != ''">
  110. and b.job_type = #{jobType}
  111. </if>
  112. <if test="startTime != null and startTime != ''">
  113. <![CDATA[ AND b.job_create_time >= #{startTime}]]>
  114. </if>
  115. <if test="endTime != null and endTime != ''">
  116. <![CDATA[ AND b.job_create_time < #{endTime}]]>
  117. </if>
  118. <if test="behosDateStart != null and behosDateStart != ''">
  119. <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
  120. </if>
  121. <if test="behosDateEnd != null and behosDateEnd != ''">
  122. <![CDATA[ AND a.leave_hospital_date < #{behosDateEnd}]]>
  123. </if>
  124. <if test="doctorName !=null and doctorName != ''">
  125. and a.doctor_name = #{doctorName}
  126. </if>
  127. <if test="behospitalCode !=null and behospitalCode != ''">
  128. and a.behospital_code = #{behospitalCode}
  129. </if>
  130. <if test="name !=null and name != ''">
  131. and a.`name` LIKE CONCAT('%',#{name},'%')
  132. </if>
  133. <if test="deptList !=null and deptList.size()!=0 and jobType ==0">
  134. and a.beh_dept_id in
  135. <foreach collection="deptList" item="item" open="(" close=")" separator=",">
  136. #{item}
  137. </foreach>
  138. </if>
  139. <if test="deptList !=null and deptList.size()!=0 and jobType ==1">
  140. and a.beh_dept_id not in
  141. <foreach collection="deptList" item="item" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. ) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
  146. and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
  147. </select>
  148. <!--获取指定核查人员的核查任务-->
  149. <select id="getCheckListByUserId" resultType="com.diagbot.dto.CheckJobDTO">
  150. SELECT
  151. a.behospital_code behospitalCode,
  152. a.beh_dept_name behospitalDept,
  153. a.doctor_name attendingDoctor,
  154. a.leave_hospital_date leaveHospitalDate,
  155. a.`name`,b.`value`,
  156. a.id
  157. from
  158. (select
  159. a.behospital_code,
  160. a.`name`,
  161. a.beh_dept_name,
  162. a.doctor_name,
  163. a.leave_hospital_date,
  164. a.hospital_id,
  165. a.beh_dept_id,
  166. b.id
  167. from
  168. med_behospital_info a ,med_check_info b
  169. where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
  170. and b.is_deleted = 'N' and b.`status` = 0
  171. <if test="startTime != null and startTime != ''">
  172. <![CDATA[ AND b.job_create_time >= #{startTime}]]>
  173. </if>
  174. <if test="endTime != null and endTime != ''">
  175. <![CDATA[ AND b.job_create_time < #{endTime}]]>
  176. </if>
  177. <if test="behosDateStart != null and behosDateStart != ''">
  178. <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
  179. </if>
  180. <if test="behosDateEnd != null and behosDateEnd != ''">
  181. <![CDATA[ AND a.leave_hospital_date < #{behosDateEnd}]]>
  182. </if>
  183. <if test="checkId !=null and checkId != ''">
  184. and b.check_id = #{checkId}
  185. </if>
  186. ) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
  187. and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
  188. </select>
  189. <select id="getCheckWorkPage" resultType="com.diagbot.dto.CheckWorkDTO">
  190. SELECT
  191. mbi.behospital_code behospitalCode,
  192. mbi.name,
  193. mbi.file_code fileCode,
  194. mbi.sex,
  195. mhp.age,
  196. mbi.beh_dept_name behospitalDept,
  197. mbi.leave_hospital_date leaveHospitalDate,
  198. mhp.behospital_day_num behospitalDayNum,
  199. mbi.doctor_name attendingDoctor,
  200. mqi.score_res scoreRes,
  201. mqi.level,
  202. mbi.diagnose,
  203. CASE WHEN mbt.behospital_type='出院病人' THEN '6'
  204. WHEN mbt.behospital_type='死亡病人' THEN '6'
  205. WHEN mbt.behospital_type='危重病人' THEN '4'
  206. WHEN mbt.behospital_type='抢救病人' THEN '5'
  207. WHEN mbt.behospital_type='手术病人' THEN '2'
  208. WHEN mbt.behospital_type='疑难病人' THEN '3'
  209. WHEN mbt.behospital_type='输血病人' THEN '4' ELSE '0' END AS score,
  210. CASE WHEN ISNULL(mci.job_create_time) THEN '未生成' ELSE '已生成' END AS creatStatus,
  211. mci.job_create_time jobCreateTime,
  212. mci.job_creator_name jobCreatorName,
  213. mci.check_time checkTime,
  214. mci.job_distribution_time jobDistributionTime
  215. FROM
  216. med_behospital_info mbi
  217. LEFT JOIN med_home_page mhp
  218. ON mbi.behospital_code=mhp.behospital_code
  219. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  220. LEFT JOIN med_check_info mci
  221. ON mbi.behospital_code = mci.behospital_code
  222. AND mbi.hospital_id = mci.hospital_id AND mci.is_deleted = 'N'
  223. LEFT JOIN med_qcresult_info mqi
  224. ON mbi.behospital_code = mqi.behospital_code
  225. AND mbi.hospital_id = mqi.hospital_id AND mqi.is_deleted = 'N'
  226. LEFT JOIN med_behospital_type mbt ON mbi.behospital_code = mbt.behospital_code
  227. AND mbi.hospital_id = mbt.hospital_id AND mbt.is_deleted = 'N'
  228. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N' and mqi.score_res is not null
  229. <if test="startDate != null">
  230. <![CDATA[ AND mbi.leave_hospital_date >= #{startDate}]]>
  231. </if>
  232. <if test="endDate != null">
  233. <![CDATA[ AND mbi.leave_hospital_date < #{endDate}]]>
  234. </if>
  235. <if test="creatStatus != null and creatStatus == '1'">
  236. AND mci.job_create_time is not null
  237. <if test="jobType != null and jobType != ''">
  238. AND mci.job_type=#{jobType}
  239. </if>
  240. </if>
  241. <if test="creatStatus != null and creatStatus == 0">
  242. AND mci.job_create_time is null
  243. </if>
  244. <if test="name != null and name != ''">
  245. AND mbi.name like CONCAT('%',#{name},'%')
  246. </if>
  247. <if test="behospitalCode != null and behospitalCode != ''">
  248. AND mbi.behospital_code like CONCAT('%',#{behospitalCode},'%')
  249. </if>
  250. <if test="departments !=null and departments.size > 0">
  251. and mbi.beh_dept_id in
  252. <foreach collection="departments" item="item" open="(" close=")" separator=",">
  253. #{item}
  254. </foreach>
  255. </if>
  256. <if test="smallDay != null">
  257. <![CDATA[ AND mhp.behospital_day_num >= #{smallDay}]]>
  258. </if>
  259. <if test="bigDay != null">
  260. <![CDATA[ AND mhp.behospital_day_num < #{bigDay}]]>
  261. </if>
  262. <if test="doctorName != null and doctorName != ''">
  263. AND mbi.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  264. </if>
  265. <if test="diagnose != null and diagnose != ''">
  266. AND mbi.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  267. </if>
  268. <if test="level != null and level != ''">
  269. AND mqi.level= #{level}
  270. </if>
  271. <if test="isPlacefile != null and isPlacefile != ''">
  272. AND mbi.is_placefile = #{isPlacefile}
  273. </if>
  274. </select>
  275. <!--通过住院号,取消核查任务-->
  276. <update id="deleteBatchCodes">
  277. <foreach collection="list" item="item" separator=";">
  278. delete from
  279. med_check_info
  280. where behospital_code = #{item} and is_deleted = 'N'
  281. </foreach>
  282. </update>
  283. <select id="checkedRecordList" resultType="com.diagbot.dto.CheckedRecordListDTO">
  284. SELECT *
  285. from
  286. (select
  287. b.behospital_code as behospitalCode,
  288. a.`status` as status,
  289. b.beh_dept_id as behDeptId,
  290. b.beh_dept_name as behDeptName,
  291. b.`name` as name,
  292. b.file_code as fileCode,
  293. b.doctor_name as doctorName,
  294. b.leave_hospital_date as leaveHospitalDate,
  295. a.job_create_time as jobCreateTime,
  296. a.job_distribution_time as jobDistributionTime,
  297. a.check_id as checkId,
  298. a.check_name as checkName,
  299. a.check_time as checkTime,
  300. c.`level` as level,
  301. c.score_res as scoreRes,
  302. case when a.check_type='0' and FIND_IN_SET(b.beh_dept_id,#{currentDeptIds}) then 0 else 1 end as isDel
  303. from med_check_info a join med_behospital_info b on a.hospital_id=b.hospital_id and
  304. a.behospital_code=b.behospital_code
  305. join med_qcresult_info c on b.hospital_id=c.hospital_id and b.behospital_code=c.behospital_code and
  306. b.is_deleted='N'
  307. where a.hospital_id=#{hospitalId} and a.is_deleted='N'
  308. and b.hospital_id=#{hospitalId} and b.is_deleted='N'
  309. and c.hospital_id=#{hospitalId}
  310. and a.check_id in
  311. <foreach collection="currentGeneralUserIds" item="currentGeneralUserId" separator="," close=")" open="(">
  312. #{currentGeneralUserId}
  313. </foreach>
  314. <if test="status!=null">
  315. and a.`status`=#{status}
  316. </if>
  317. <if test="behDeptId!=null and behDeptId!=''">
  318. and b.beh_dept_id=#{behDeptId}
  319. </if>
  320. <if test="name!=null and name!=''">
  321. and b.`name` like concat('%',#{name},'%')
  322. </if>
  323. <if test="behospitalCode!=null and behospitalCode!=''">
  324. and b.behospital_code like concat('%',#{behospitalCode},'%')
  325. </if>
  326. <if test="doctorName!=null and doctorName!=''">
  327. and b.doctor_name like concat('%',#{doctorName},'%')
  328. </if>
  329. <if test="jobDistributionTimeStart!=null">
  330. and a.job_distribution_time >= #{jobDistributionTimeStart}
  331. </if>
  332. <if test="jobDistributionTimeEnd!=null">
  333. and #{jobDistributionTimeEnd} >= a.job_distribution_time
  334. </if>
  335. <if test="checkName!=null and checkName!=''">
  336. and a.check_name like concat('%',#{checkName},'%')
  337. </if>
  338. <if test="level!=null and level!=''">
  339. and c.`level`=#{level}
  340. </if>
  341. <if test="checkJobTypes!=null and checkJobTypes.size>0">
  342. and a.job_type in
  343. <foreach collection="checkJobTypes" item="checkJobType" separator="," close=")" open="(">
  344. #{checkJobType}
  345. </foreach>
  346. </if>
  347. ) tab
  348. where isDel>0
  349. order by jobDistributionTime desc
  350. </select>
  351. </mapper>