BusClinicMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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.nb.web.service.bus.mapper.BusClinicMapper">
  4. <resultMap id="stats" type="com.nb.web.service.bus.service.dto.ClinicStatsQueryResult">
  5. <result column="continue_dose" property="continueDose"/>
  6. <result column="append_dose" property="appendDose"/>
  7. <result column="input_dose" property="inputDose"/>
  8. <result column="valid_count" property="validCount"/>
  9. <result column="single_append_dose" property="singleAppendDose"/>
  10. <result column="invalid_count" property="inValidCount"/>
  11. <result column="upload_time" property="uploadTime"/>
  12. <result column="infusion_id" property="infusionId"/>
  13. <result column="electric_quantity" property="electricQuantity"/>
  14. <result column="block1" property="block1"/>
  15. <result column="block2" property="block2"/>
  16. </resultMap>
  17. <resultMap id="queryResult" type="com.nb.web.service.bus.service.dto.ClinicResult">
  18. <result column="clinic_id" property="clinicId"/>
  19. <result column="patient_id" property="patientId"/>
  20. <result column="patient_code" property="patientCode"/>
  21. <result column="patient_name" property="patientName"/>
  22. <result column="ward" property="ward"/>
  23. <result column="bed_no" property="bedNo"/>
  24. <result column="surgery_name" property="surgeryName"/>
  25. <result column="surgery_doctor" property="surgeryDoctor"/>
  26. <result column="ana_doctor" property="anaDoctor"/>
  27. <result column="monitor_type" property="monitorType"/>
  28. <result column="finished" property="finished"/>
  29. <result column="clinic_start_time" property="clinicStartTime"/>
  30. <result column="monitor_start_time" property="monitorStartTime"/>
  31. <result column="monitor_end_time" property="monitorEndTime"/>
  32. <result column="monitor_alarm" property="monitorAlarm"/>
  33. <result column="infusion_count" property="infusionCount"/>
  34. <result column="eval_count" property="evalCount"/>
  35. <result column="liquid_executor" property="liquidExecutor"/>
  36. <result column="liquid_checker" property="liquidChecker"/>
  37. <result column="liquid_remark" property="liquidRemark"/>
  38. <result column="liquid_time" property="liquidTime"/>
  39. <result column="liquid_type" property="liquidType"/>
  40. </resultMap>
  41. <select id="stats" resultMap="stats">
  42. SELECT
  43. <if test="query.continueDose!=false">
  44. h.continue_dose as continue_dose,
  45. </if>
  46. <if test="query.electricQuantity!=false">
  47. h.electric_quantity as electric_quantity,
  48. </if>
  49. <if test="query.appendDose!=false">
  50. h.total_append_dose as append_dose,
  51. </if>
  52. <if test="query.inputDose!=false">
  53. h.input_dose as input_dose,
  54. </if>
  55. <if test="query.singleAppendDose!=false">
  56. h.append_dose as single_append_dose,
  57. h.pca_valid_count as valid_count,
  58. </if>
  59. <if test="query.validCount!=false">
  60. h.pca_valid_count as valid_count,
  61. </if>
  62. <if test="query.inValidCount!=false">
  63. h.pca_invalid_count as invalid_count,
  64. </if>
  65. <if test="query.snr!=false">
  66. h.snr as snr,
  67. </if>
  68. <if test="query.rssi!=false">
  69. h.rssi as rssi,
  70. </if>
  71. <if test="query.rsrq!=false">
  72. h.rsrq as rsrq,
  73. </if>
  74. <if test="query.rsrp!=false">
  75. h.rsrp as rsrp,
  76. </if>
  77. h.block1 as block1,
  78. h.block2 as block2,
  79. h.upload_time,
  80. h.infusion_id
  81. FROM
  82. (select id from bus_infusion_history
  83. <where>
  84. -- 不统计开机数据
  85. run_state!=1
  86. <if test="query.clinicId!=null">
  87. and clinic_id = #{query.clinicId}
  88. </if>
  89. <if test="query.infusionId!=null">
  90. and id = #{query.infusionId}
  91. </if>
  92. <if test="query.deviceId!=null">
  93. and device_id = #{query.deviceId}
  94. </if>
  95. </where>)
  96. as i
  97. JOIN (select * from bus_device_history
  98. <where>
  99. <if test="query.infusionModifyIds != null and query.infusionModifyIds.size > 0">
  100. and infusion_modify_id in
  101. <foreach item="infusionModifyId" index="index" collection="query.infusionModifyIds" open="(" separator="," close=")">
  102. #{infusionModifyId, jdbcType=VARCHAR}
  103. </foreach>
  104. </if>
  105. </where>
  106. ) as h on h.infusion_id=i.id
  107. order by h.upload_time asc
  108. </select>
  109. <select id="pageQuery" resultMap="queryResult" parameterType="com.nb.web.service.bus.service.dto.ClinicQuery">
  110. select p.id as patient_id,
  111. c.id as clinic_id,
  112. c.patient_code as patient_code,
  113. c.patient_name as patient_name,
  114. c.ward as ward,
  115. CASE
  116. WHEN c.manual_bedno IS NOT NULL AND c.manual_bedno != '' THEN c.manual_bedno
  117. ELSE c.bed_no
  118. END as bed_no,
  119. c.`surgery_name` as surgery_name,
  120. c.surgery_doctor as surgery_doctor,
  121. c.ana_doctor as ana_doctor,
  122. c.monitor_type as monitor_type,
  123. c.finished as finished,
  124. c.start_time as clinic_start_time,
  125. c.monitor_start_time as monitor_start_time,
  126. c.end_time as monitor_end_time,
  127. c.liquid_type as liquid_type,
  128. c.liquid_executor as liquid_executor,
  129. c.liquid_checker as liquid_checker,
  130. c.liquid_remark as liquid_remark,
  131. c.liquid_time as liquid_time
  132. from bus_clinic as c
  133. left join bus_patient
  134. as p on c.patient_id = p.id
  135. <where>
  136. <if test="query.liquid!=null and query.liquid == true">
  137. and c.finished= 1
  138. </if>
  139. <if test="query.monitorType!=null and query.monitorType!=''">
  140. and c.monitor_type=#{query.monitorType}
  141. </if>
  142. <if test="query.finished!=null">
  143. and c.finished=#{query.finished}
  144. </if>
  145. <if test="query.surgeryName!=null and query.surgeryName!=''">
  146. and c.surgery_name like concat('%',#{query.surgeryName},'%')
  147. </if>
  148. <if test="query.patientName!=null and query.patientName!=''">
  149. and c.patient_name like concat('%',#{query.patientName},'%')
  150. </if>
  151. <if test="query.ward != null and query.ward.size > 0">
  152. and c.ward in
  153. <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
  154. #{w, jdbcType=VARCHAR}
  155. </foreach>
  156. </if>
  157. <if test="query.bedNo!=null and query.bedNo!=''">
  158. and bed_no like concat('%',#{query.bedNo},'%')
  159. </if>
  160. <if test="query.timeRange != null and query.timeRange.size >0">
  161. and c.monitor_start_time &gt; #{query.timeRange[0]} and c.monitor_start_time &lt; #{query.timeRange[1]}
  162. </if>
  163. <if test="query.patientCode!=null and query.patientCode!=''">
  164. and c.patient_code like concat('%',#{query.patientCode},'%')
  165. </if>
  166. </where>
  167. <if test="(query.orderByDesc!=null and query.orderByDesc.size > 0 ) or (query.orderByAsc!=null and query.orderByAsc.size > 0)">
  168. order by
  169. </if>
  170. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  171. <foreach item="descItem" index="index" collection="query.orderByDesc" open="" separator="," close="">
  172. ${descItem} desc
  173. </foreach>
  174. </if>
  175. <if test="query.orderByAsc!=null and query.orderByAsc.size > 0">
  176. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  177. ,
  178. </if>
  179. <foreach item="ascItem" index="index" collection="query.orderByAsc" open="" separator="," close="">
  180. ${ascItem} asc
  181. </foreach>
  182. </if>
  183. </select>
  184. <select id="latestQueryPage" resultMap="queryResult" parameterType="com.nb.web.service.bus.service.dto.ClinicQuery">
  185. select
  186. c.id as clinic_id,
  187. p.code as patient_code,
  188. c.patient_name as patient_name,
  189. c.ward as ward,
  190. c.bed_no as bed_no,
  191. c.`surgery_name` as surgery_name,
  192. c.surgery_doctor as surgery_doctor,
  193. c.ana_doctor as ana_doctor,
  194. c.finished as finished,
  195. c.start_time as clinic_start_time,
  196. c.monitor_start_time as monitor_start_time,
  197. c.end_time as monitor_end_time,
  198. i.infusion_count as infusion_count,
  199. eval.eval_count as eval_count
  200. from
  201. (select * from bus_patient
  202. <where>
  203. <if test="query.patientCode!=null">
  204. and code like concat('%',#{query.patientCode},'%')
  205. </if>
  206. </where>
  207. )as p
  208. left join
  209. (select * from bus_clinic
  210. <where>
  211. <if test="query.monitorType!=null">
  212. and monitor_type=#{query.monitorType}
  213. </if>
  214. <if test="query.finished!=null">
  215. and finished=#{query.finished}
  216. </if>
  217. <if test="query.surgeryName!=null">
  218. and surgery_name like concat('%',#{query.surgeryName},'%')
  219. </if>
  220. <if test="query.patientName!=null">
  221. and patient_name like concat('%',#{query.patientName},'%')
  222. </if>
  223. <if test="query.ward != null and query.ward.size > 0">
  224. and ward in
  225. <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
  226. #{w, jdbcType=VARCHAR}
  227. </foreach>
  228. </if>
  229. <if test="query.bedNo!=null">
  230. and bed_no like concat('%',#{query.bedNo},'%')
  231. </if>
  232. <if test="query.timeRange != null and query.timeRange.size >0">
  233. and monitor_start_time &gt; #{query.timeRange[0]} and monitor_start_time &lt; #{query.timeRange[1]}
  234. </if>
  235. </where>
  236. ) as c on p.clinic_id=c.id
  237. left join (select clinic_id,count(1) as infusion_count from bus_infusion_history GROUP BY clinic_id) as i on i.clinic_id=c.id
  238. left join (select clinic_id,count(1) as eval_count from bus_evaluation GROUP BY clinic_id) as eval on eval.clinic_id=c.id
  239. <if test="(query.orderByDesc!=null and query.orderByDesc.size > 0 ) or (query.orderByAsc!=null and query.orderByAsc.size > 0)">
  240. order by
  241. </if>
  242. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  243. <foreach item="descItem" index="index" collection="query.orderByDesc" open="" separator="," close="">
  244. ${descItem} desc
  245. </foreach>
  246. </if>
  247. <if test="query.orderByAsc!=null and query.orderByAsc.size > 0">
  248. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  249. ,
  250. </if>
  251. <foreach item="ascItem" index="index" collection="query.orderByAsc" open="" separator="," close="">
  252. ${ascItem} asc
  253. </foreach>
  254. </if>
  255. </select>
  256. <resultMap id="stdLiquidResult" type="com.nb.web.service.bus.controller.vo.BusLiquidListVO">
  257. <result property="clinicId" column="clinic_id"/>
  258. <result property="clinicName" column="clinic_name"/>
  259. <result property="patientId" column="patient_id"/>
  260. <result property="patientCode" column="patient_code"/>
  261. <result property="patientName" column="patient_name"/>
  262. <result property="ward" column="ward"/>
  263. <result property="bedNo" column="bed_no"/>
  264. <result property="deviceId" column="device_id"/>
  265. <result property="clinicStartTime" column="clinic_start_time"/>
  266. <result property="undoTime" column="undo_time"/>
  267. <result property="formula" column="formula" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
  268. <result property="totalDose" column="total_dose"/>
  269. <result property="remainDose" column="remain_dose"/>
  270. <result property="liquidExecutor" column="liquid_executor"/>
  271. <result property="liquidChecker" column="liquid_checker"/>
  272. <result property="liquidRemark" column="liquid_remark"/>
  273. <result property="liquidTime" column="liquid_time"/>
  274. <result property="liquidMethod" column="liquid_method"/>
  275. </resultMap>
  276. <select id="selectLiquidPage" resultMap="stdLiquidResult">
  277. select
  278. c.id as clinic_id,
  279. c.patient_id as patient_id,
  280. c.patient_code as patient_code,
  281. c.patient_name as patient_name,
  282. c.ward as ward,
  283. CASE
  284. WHEN c.manual_bedno IS NOT NULL AND c.manual_bedno != '' THEN c.manual_bedno
  285. ELSE c.bed_no
  286. END as bed_no,
  287. c.surgery_name as clinic_name,
  288. i.device_id as device_id,
  289. c.monitor_start_time as clinic_start_time,
  290. i.undo_time as undo_time,
  291. c.formula as formula,
  292. i.total_dose as total_dose,
  293. i.remain_dose as remain_dose,
  294. c.liquid_executor as liquid_executor,
  295. c.liquid_checker as liquid_checker,
  296. c.liquid_remark as liquid_remark,
  297. c.liquid_time as liquid_time,
  298. c.liquid_method as liquid_method
  299. from bus_clinic as c
  300. join bus_patient as p on c.patient_id = p.id
  301. join bus_infusion_history as i on p.infusion_id = i.id
  302. <where>
  303. c.finished = 1
  304. <if test="query.undoTime != null and query.undoTime.size ==1">
  305. and undo_time &gt; #{query.undoTime[0]}
  306. </if>
  307. <if test="query.undoTime != null and query.undoTime.size > 1">
  308. and undo_time &gt; #{query.undoTime[0]} and c.undo_time &lt; #{query.undoTime[1]}
  309. </if>
  310. <if test="query.patientCode!=null and query.patientCode!=''">
  311. and c.patient_code like concat('%',#{query.patientCode},'%')
  312. </if>
  313. <if test="query.bedNo!=null and query.bedNo!=''">
  314. and bed_no like concat('%',#{query.bedNo},'%')
  315. </if>
  316. <if test="query.wards != null and query.wards.size > 0">
  317. and c.ward in
  318. <foreach item="w" index="index" collection="query.wards" open="(" separator="," close=")">
  319. #{w, jdbcType=VARCHAR}
  320. </foreach>
  321. </if>
  322. <if test="query.patientName!=null and query.patientName!=''">
  323. and patient_name like concat('%',#{query.patientName},'%')
  324. </if>
  325. <if test="query.surgeryName!=null and query.surgeryName!=''">
  326. and c.surgery_name like concat('%',#{query.surgeryName},'%')
  327. </if>
  328. <if test="query.liquidType!=null and query.liquidType == false">
  329. and liquid_checker is null
  330. </if>
  331. <if test="query.liquidType!=null and query.liquidType == true">
  332. and liquid_checker is not null
  333. </if>
  334. </where>
  335. order by undo_time desc
  336. </select>
  337. <select id="selectLiquidByIds" resultMap="stdLiquidResult">
  338. select
  339. c.id as clinic_id,
  340. c.patient_id as patient_id,
  341. c.patient_code as patient_code,
  342. c.patient_name as patient_name,
  343. c.ward as ward,
  344. CASE
  345. WHEN c.manual_bedno IS NOT NULL AND c.manual_bedno != '' THEN c.manual_bedno
  346. ELSE c.bed_no
  347. END as bed_no,
  348. c.surgery_name as clinic_name,
  349. i.device_id as device_id,
  350. c.monitor_start_time as clinic_start_time,
  351. i.undo_time as undo_time,
  352. c.formula as formula,
  353. i.total_dose as total_dose,
  354. i.remain_dose as remain_dose,
  355. c.liquid_executor as liquid_executor,
  356. c.liquid_checker as liquid_checker,
  357. c.liquid_remark as liquid_remark,
  358. c.liquid_time as liquid_time
  359. from bus_clinic as c
  360. left join bus_patient as p on c.patient_id = p.id
  361. left join bus_infusion_history as i on p.infusion_id = i.id
  362. <where>
  363. and c.id in
  364. <foreach item="w" index="index" collection="ids" open="(" separator="," close=")">
  365. #{w, jdbcType=VARCHAR}
  366. </foreach>
  367. </where>
  368. </select>
  369. </mapper>