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_method" property="liquidMethod"/>
  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_method as liquid_method,
  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. <where>
  134. p.infusion_id is not null
  135. <if test="query.liquid!=null and query.liquid == true">
  136. and c.finished= 1
  137. </if>
  138. <if test="query.monitorType!=null and query.monitorType!=''">
  139. and c.monitor_type=#{query.monitorType}
  140. </if>
  141. <if test="query.finished!=null">
  142. and c.finished=#{query.finished}
  143. </if>
  144. <if test="query.surgeryName!=null and query.surgeryName!=''">
  145. and c.surgery_name like concat('%',#{query.surgeryName},'%')
  146. </if>
  147. <if test="query.patientName!=null and query.patientName!=''">
  148. and c.patient_name like concat('%',#{query.patientName},'%')
  149. </if>
  150. <if test="query.ward != null and query.ward.size > 0">
  151. and c.ward in
  152. <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
  153. #{w, jdbcType=VARCHAR}
  154. </foreach>
  155. </if>
  156. <if test="query.bedNo!=null and query.bedNo!=''">
  157. and bed_no like concat('%',#{query.bedNo},'%')
  158. </if>
  159. <if test="query.timeRange != null and query.timeRange.size >0">
  160. and c.monitor_start_time &gt; #{query.timeRange[0]} and c.monitor_start_time &lt; #{query.timeRange[1]}
  161. </if>
  162. <if test="query.patientCode!=null and query.patientCode!=''">
  163. and c.patient_code like concat('%',#{query.patientCode},'%')
  164. </if>
  165. </where>
  166. <if test="(query.orderByDesc!=null and query.orderByDesc.size > 0 ) or (query.orderByAsc!=null and query.orderByAsc.size > 0)">
  167. order by
  168. </if>
  169. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  170. <foreach item="descItem" index="index" collection="query.orderByDesc" open="" separator="," close="">
  171. ${descItem} desc
  172. </foreach>
  173. </if>
  174. <if test="query.orderByAsc!=null and query.orderByAsc.size > 0">
  175. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  176. ,
  177. </if>
  178. <foreach item="ascItem" index="index" collection="query.orderByAsc" open="" separator="," close="">
  179. ${ascItem} asc
  180. </foreach>
  181. </if>
  182. </select>
  183. <select id="latestQueryPage" resultMap="queryResult" parameterType="com.nb.web.service.bus.service.dto.ClinicQuery">
  184. select
  185. c.id as clinic_id,
  186. p.code as patient_code,
  187. c.patient_name as patient_name,
  188. c.ward as ward,
  189. c.bed_no as bed_no,
  190. c.`surgery_name` as surgery_name,
  191. c.surgery_doctor as surgery_doctor,
  192. c.ana_doctor as ana_doctor,
  193. c.finished as finished,
  194. c.start_time as clinic_start_time,
  195. c.monitor_start_time as monitor_start_time,
  196. c.end_time as monitor_end_time,
  197. i.infusion_count as infusion_count,
  198. eval.eval_count as eval_count
  199. from
  200. (select * from bus_patient
  201. <where>
  202. <if test="query.patientCode!=null">
  203. and code like concat('%',#{query.patientCode},'%')
  204. </if>
  205. </where>
  206. )as p
  207. left join
  208. (select * from bus_clinic
  209. <where>
  210. <if test="query.monitorType!=null">
  211. and monitor_type=#{query.monitorType}
  212. </if>
  213. <if test="query.finished!=null">
  214. and finished=#{query.finished}
  215. </if>
  216. <if test="query.surgeryName!=null">
  217. and surgery_name like concat('%',#{query.surgeryName},'%')
  218. </if>
  219. <if test="query.patientName!=null">
  220. and patient_name like concat('%',#{query.patientName},'%')
  221. </if>
  222. <if test="query.ward != null and query.ward.size > 0">
  223. and ward in
  224. <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
  225. #{w, jdbcType=VARCHAR}
  226. </foreach>
  227. </if>
  228. <if test="query.bedNo!=null">
  229. and bed_no like concat('%',#{query.bedNo},'%')
  230. </if>
  231. <if test="query.timeRange != null and query.timeRange.size >0">
  232. and monitor_start_time &gt; #{query.timeRange[0]} and monitor_start_time &lt; #{query.timeRange[1]}
  233. </if>
  234. </where>
  235. ) as c on p.clinic_id=c.id
  236. 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
  237. 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
  238. <if test="(query.orderByDesc!=null and query.orderByDesc.size > 0 ) or (query.orderByAsc!=null and query.orderByAsc.size > 0)">
  239. order by
  240. </if>
  241. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  242. <foreach item="descItem" index="index" collection="query.orderByDesc" open="" separator="," close="">
  243. ${descItem} desc
  244. </foreach>
  245. </if>
  246. <if test="query.orderByAsc!=null and query.orderByAsc.size > 0">
  247. <if test="query.orderByDesc!=null and query.orderByDesc.size > 0">
  248. ,
  249. </if>
  250. <foreach item="ascItem" index="index" collection="query.orderByAsc" open="" separator="," close="">
  251. ${ascItem} asc
  252. </foreach>
  253. </if>
  254. </select>
  255. <resultMap id="stdLiquidResult" type="com.nb.web.service.bus.controller.vo.BusLiquidListVO">
  256. <result property="clinicId" column="clinic_id"/>
  257. <result property="clinicName" column="clinic_name"/>
  258. <result property="patientId" column="patient_id"/>
  259. <result property="patientCode" column="patient_code"/>
  260. <result property="patientName" column="patient_name"/>
  261. <result property="ward" column="ward"/>
  262. <result property="bedNo" column="bed_no"/>
  263. <result property="deviceId" column="device_id"/>
  264. <result property="clinicStartTime" column="clinic_start_time"/>
  265. <result property="undoTime" column="undo_time"/>
  266. <result property="formula" column="formula" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
  267. <result property="totalDose" column="total_dose"/>
  268. <result property="remainDose" column="remain_dose"/>
  269. <result property="liquidExecutor" column="liquid_executor"/>
  270. <result property="liquidChecker" column="liquid_checker"/>
  271. <result property="liquidRemark" column="liquid_remark"/>
  272. <result property="liquidTime" column="liquid_time"/>
  273. <result property="liquidMethod" column="liquid_method"/>
  274. </resultMap>
  275. <select id="selectLiquidPage" resultMap="stdLiquidResult">
  276. select
  277. c.id as clinic_id,
  278. c.patient_id as patient_id,
  279. c.patient_code as patient_code,
  280. c.patient_name as patient_name,
  281. c.ward as ward,
  282. CASE
  283. WHEN c.manual_bedno IS NOT NULL AND c.manual_bedno != '' THEN c.manual_bedno
  284. ELSE c.bed_no
  285. END as bed_no,
  286. c.surgery_name as clinic_name,
  287. i.device_id as device_id,
  288. c.monitor_start_time as clinic_start_time,
  289. i.undo_time as undo_time,
  290. c.formula as formula,
  291. i.total_dose as total_dose,
  292. i.remain_dose as remain_dose,
  293. c.liquid_executor as liquid_executor,
  294. c.liquid_checker as liquid_checker,
  295. c.liquid_remark as liquid_remark,
  296. c.liquid_time as liquid_time,
  297. c.liquid_method as liquid_method
  298. from bus_clinic as c
  299. join bus_patient as p on c.patient_id = p.id
  300. join bus_infusion_history as i on p.infusion_id = i.id
  301. <where>
  302. c.finished = 1
  303. <if test="query.undoTime != null and query.undoTime.size ==1">
  304. and undo_time &gt; #{query.undoTime[0]}
  305. </if>
  306. <if test="query.undoTime != null and query.undoTime.size > 1">
  307. and undo_time &gt; #{query.undoTime[0]} and c.undo_time &lt; #{query.undoTime[1]}
  308. </if>
  309. <if test="query.patientCode!=null and query.patientCode!=''">
  310. and c.patient_code like concat('%',#{query.patientCode},'%')
  311. </if>
  312. <if test="query.bedNo!=null and query.bedNo!=''">
  313. and bed_no like concat('%',#{query.bedNo},'%')
  314. </if>
  315. <if test="query.wards != null and query.wards.size > 0">
  316. and c.ward in
  317. <foreach item="w" index="index" collection="query.wards" open="(" separator="," close=")">
  318. #{w, jdbcType=VARCHAR}
  319. </foreach>
  320. </if>
  321. <if test="query.patientName!=null and query.patientName!=''">
  322. and patient_name like concat('%',#{query.patientName},'%')
  323. </if>
  324. <if test="query.surgeryName!=null and query.surgeryName!=''">
  325. and c.surgery_name like concat('%',#{query.surgeryName},'%')
  326. </if>
  327. <if test="query.liquidType!=null and query.liquidType == false">
  328. and liquid_checker is null
  329. </if>
  330. <if test="query.liquidType!=null and query.liquidType == true">
  331. and liquid_checker is not null
  332. </if>
  333. </where>
  334. order by clinic_start_time desc
  335. </select>
  336. <select id="selectLiquidByIds" resultMap="stdLiquidResult">
  337. select
  338. c.id as clinic_id,
  339. c.patient_id as patient_id,
  340. c.patient_code as patient_code,
  341. c.patient_name as patient_name,
  342. c.ward as ward,
  343. CASE
  344. WHEN c.manual_bedno IS NOT NULL AND c.manual_bedno != '' THEN c.manual_bedno
  345. ELSE c.bed_no
  346. END as bed_no,
  347. c.surgery_name as clinic_name,
  348. i.device_id as device_id,
  349. c.monitor_start_time as clinic_start_time,
  350. i.undo_time as undo_time,
  351. c.formula as formula,
  352. i.total_dose as total_dose,
  353. i.remain_dose as remain_dose,
  354. c.liquid_executor as liquid_executor,
  355. c.liquid_checker as liquid_checker,
  356. c.liquid_remark as liquid_remark,
  357. c.liquid_method as liquid_method,
  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>