BusPatientMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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.coffee.bus.mapper.BusPatientMapper">
  4. <resultMap id="repeatDeviceResult" type="com.coffee.bus.entity.PatientDeviceRepeatDomain">
  5. <result column="name" property="name"/>
  6. <result column="gender" property="gender"/>
  7. <result column="code" property="code"/>
  8. <result column="age" property="age"/>
  9. <result column="ward" property="ward"/>
  10. <result column="bed_no" property="bedNo"/>
  11. <result column="clinic_name" property="clinicName"/>
  12. <result column="device_running_id" property="deviceRunningId"/>
  13. <result column="device_id" property="deviceId"/>
  14. <result column="device_alias" property="deviceAlias"/>
  15. <result column="device_run_state" property="deviceRunState"/>
  16. <result column="clinic_id" property="clinicId"/>
  17. <result column="device_alarm" property="deviceAlarm" />
  18. <result column="infusion_start_time" property="infusionStartTime"/>
  19. <result column="master" property="master"/>
  20. </resultMap>
  21. <resultMap id="monitorResult" type="com.coffee.bus.service.dto.PatientMonitorResult">
  22. <result column="patient_name" property="patientName"/>
  23. <result column="patient_code" property="patientCode"/>
  24. <result column="patient_age" property="patientAge"/>
  25. <result column="gender" property="gender"/>
  26. <result column="infusion_id" property="infusionId"/>
  27. <result column="patient_alarm" property="patientAlarm"/>
  28. <result column="device_id" property="deviceId"/>
  29. <result column="device_alias" property="deviceAlias"/>
  30. <result column="clinic_id" property="clinicId"/>
  31. <result column="infusion_finished" property="infusionFinished"/>
  32. <result column="ward" property="ward"/>
  33. <result column="bed_no" property="bedNo"/>
  34. <result column="total_dose" property="totalDose"/>
  35. <result column="first_dose" property="firstDose"/>
  36. <result column="remain_dose" property="remainDose"/>
  37. <result column="input_dose" property="inputDose"/>
  38. <result column="append_dose" property="appendDose"/>
  39. <result column="append_lock_time" property="appendLockTime"/>
  40. <result column="max_dose" property="maxDose"/>
  41. <result column="self_control_count" property="selfControlCount"/>
  42. <result column="self_control_lock_time" property="selfControlLockTime"/>
  43. <result column="pca_valid_count" property="pcaValidCount"/>
  44. <result column="pca_invalid_count" property="pcaInvalidCount"/>
  45. <result column="pca_total_count" property="pcaTotalCount"/>
  46. <result column="continue_dose" property="continueDose"/>
  47. <result column="pulse_dose" property="pulseDose"/>
  48. <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
  49. <result column="pulse_lock_time" property="pulseLockTime"/>
  50. <result column="flow_up_cycle" property="flowUpCycle"/>
  51. <result column="flow_down_cycle" property="flowDownCycle"/>
  52. <result column="flow_count" property="flowCount"/>
  53. <result column="flow_up_limit" property="flowUpLimit"/>
  54. <result column="flow_down_limit" property="flowDownLimit"/>
  55. <result column="flow_adjust_rate" property="flowAdjustRate"/>
  56. <result column="run_state" property="deviceRunState"/>
  57. <result column="electric_quantity" property="electricQuantity"/>
  58. <result column="warn_flow" property="warnFlow"/>
  59. <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
  60. <result column="warn_low_battery" property="warnLowBattery"/>
  61. <result column="warn_will_finished" property="warnWillFinished"/>
  62. <result column="device_alarm" property="deviceAlarm"/>
  63. <result column="infusion_start_time" property="infusionStartTime"/>
  64. <result column="remark" property="remark"/>
  65. <result column="device_type" property="deviceType"/>
  66. <result column="anal_type" property="analType"/>
  67. <result column="ana_doctor" property="anaDoctor"/>
  68. <result column="ana_type" property="anaType"/>
  69. <result column="surgery_doctor" property="surgeryDoctor"/>
  70. <result column="surgery_name" property="surgeryName"/>
  71. <result column="finished" property="clinicFinished"/>
  72. <result column="monitor_end_time" property="monitorEndTime"/>
  73. <result column="monitor_start_time" property="monitorStartTime"/>
  74. </resultMap>
  75. <resultMap id="deviceNone" type="com.coffee.bus.service.dto.PatientDeviceNoneResult">
  76. <result column="name" property="name"/>
  77. <result column="gender" property="gender"/>
  78. <result column="code" property="code"/>
  79. <result column="age" property="age"/>
  80. <result column="ward" property="ward"/>
  81. <result column="bed_no" property="bedNo"/>
  82. <result column="clinic_name" property="clinicName"/>
  83. <result column="weight" property="weight"/>
  84. <result column="height" property="height"/>
  85. <result column="ana_doctor" property="anaDoctor"/>
  86. <result column="ana_type" property="anaType"/>
  87. <result column="anal_type" property="analType"/>
  88. <result column="surgery_doctor" property="surgeryDoctor"/>
  89. <result column="asa" property="asa"/>
  90. <result column="formula" property="formula"/>
  91. <result column="finished" property="finished"/>
  92. <result column="config_person" property="configPerson"/>
  93. </resultMap>
  94. <select id="selectRepeatDevice" resultMap="repeatDeviceResult">
  95. SELECT
  96. p.code as code,
  97. c.patient_gender as gender,
  98. c.`patient_name` as name,
  99. c.patient_age as age,
  100. c.ward,
  101. c.bed_no,
  102. c.id as clinic_id,
  103. c.`name` as clinic_name,
  104. d.id as device_running_id,
  105. d.device_id as device_id,
  106. d.alias as device_alias,
  107. d.run_state as device_run_state,
  108. d.alarm as device_alarm,
  109. d.start_time as infusion_start_time,
  110. d.master
  111. FROM (SELECT `name`,gender,CODE FROM bus_patient WHERE bus_patient.`alarm`=1) AS p
  112. left join (SELECT * from bus_device_running where monitor_type=1 ) as d on p.CODE=d.patient_code
  113. left join (SELECT * FROM bus_clinic WHERE finished=0 ) AS c ON c.`patient_code`=p.code;
  114. </select>
  115. <select id="selectNoneDevice" resultMap="deviceNone">
  116. SELECT
  117. p.code as code,
  118. c.patient_gender as gender,
  119. c.`patient_name` as name,
  120. c.patient_age as age,
  121. c.ward as ward,
  122. c.bed_no as bed_no,
  123. c.`name` as clinic_name,
  124. c.weight as weight,
  125. c.height as height,
  126. c.ana_doctor as ana_doctor,
  127. c.ana_type as ana_type,
  128. c.anal_type as anal_type,
  129. c.surgery_doctor as surgery_doctor,
  130. c.asa as asa,
  131. c.formula as formula,
  132. c.finished as finished,
  133. c.config_person as config_person
  134. FROM (SELECT `name`,gender,CODE,tenant_id FROM bus_patient WHERE bus_patient.`alarm`=2 ) AS p
  135. left join (SELECT * FROM bus_clinic WHERE finished=0 ) AS c ON c.`patient_code`=p.code;
  136. </select>
  137. <select id="selectMonitor" resultMap="monitorResult" parameterType="com.coffee.bus.service.dto.PatientMonitorQuery">
  138. select
  139. p.`code` as patient_code,
  140. p.alarm as patient_alarm,
  141. i.id as infusion_id,
  142. i.device_id as device_id,
  143. i.clinic_id as clinic_id,
  144. i.ward as ward,
  145. i.bed_no as bed_no,
  146. i.total_dose as total_dose,
  147. i.first_dose as first_dose,
  148. i.remain_dose as remain_dose,
  149. i.input_dose as input_dose,
  150. i.append_dose as append_dose,
  151. i.append_lock_time as append_lock_time,
  152. i.max_dose as max_dose,
  153. i.finished as infusion_finished,
  154. i.electric_quantity as electric_quantity,
  155. i.warn_flow as warn_flow,
  156. i.self_control_count as self_control_count,
  157. i.self_control_lock_time as self_control_lock_time,
  158. i.pca_valid_count as pca_valid_count,
  159. i.pca_invalid_count as pca_invalid_count,
  160. i.pca_total_count as pca_total_count,
  161. i.continue_dose as continue_dose,
  162. i.pulse_dose as pulse_dose,
  163. i.pulse_lock_time as pulse_lock_time,
  164. i.pulse_first_lock_time as pulse_first_lock_time,
  165. i.flow_up_cycle as flow_up_cycle,
  166. i.flow_down_cycle as flow_down_cycle,
  167. i.flow_count as flow_count,
  168. i.flow_up_limit as flow_up_limit,
  169. i.flow_down_limit as flow_down_limit,
  170. i.flow_adjust_rate as flow_adjust_rate,
  171. i.run_state as run_state,
  172. i.warn_will_finished as warn_will_finished,
  173. i.warn_analgesic_poor as warn_analgesic_poor,
  174. i.warn_low_battery as warn_low_battery,
  175. i.alarm as device_alarm,
  176. i.start_time as infusion_start_time,
  177. i.remark as remark,
  178. i.type as device_type,
  179. r.alias as device_alias,
  180. c.patient_gender as patient_gender,
  181. c.`patient_name` as patient_name,
  182. c.finished as finished,
  183. c.monitor_start_time as monitor_start_time,
  184. c.end_time as monitor_end_time,
  185. c.ana_doctor as ana_doctor,
  186. c.patient_age as patient_age,
  187. c.ana_type as ana_type,
  188. c.anal_type as anal_type,
  189. c.surgery_doctor as surgery_doctor,
  190. c.surgery_name as surgery_name
  191. from
  192. (select * from bus_patient
  193. <where>
  194. <if test="query.tenantId!=null">
  195. and tenant_id=#{query.tenantId}
  196. </if>
  197. </where>
  198. )
  199. as p
  200. join
  201. (select * from bus_infusion_history
  202. <where>
  203. is_undo='0'
  204. <if test="query.wards != null and query.wards.size > 0">
  205. and ward in
  206. <foreach item="ward" index="index" collection="query.wards" open="(" separator="," close=")">
  207. #{ward, jdbcType=VARCHAR}
  208. </foreach>
  209. </if>
  210. <if test="query.types != null and query.types.size > 0">
  211. and type in
  212. <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
  213. #{type, jdbcType=VARCHAR}
  214. </foreach>
  215. </if>
  216. <choose>
  217. <when test="query.deviceStatus != null and query.deviceStatus.size > 0">
  218. and (
  219. run_state in
  220. <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator=","
  221. close=")">
  222. #{status, jdbcType=VARCHAR}
  223. </foreach>
  224. <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
  225. or alarm in
  226. <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator=","
  227. close=")">
  228. #{alarm, jdbcType=VARCHAR}
  229. </foreach>
  230. </if>
  231. )
  232. </when>
  233. <otherwise>
  234. <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
  235. and alarm in
  236. <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
  237. #{alarm, jdbcType=VARCHAR}
  238. </foreach>
  239. </if>
  240. </otherwise>
  241. </choose>
  242. <choose>
  243. <when test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or query.warnLowBattery != false">
  244. and (
  245. <choose>
  246. <when test="query.warnWillFinished != false">warn_will_finished=1</when>
  247. <otherwise>warn_will_finished!=1</otherwise>
  248. </choose>
  249. <if test="query.warnAnalgesicPoor != false">or warn_analgesic_poor=1 </if>
  250. <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
  251. <if test="query.warnFlow !=null">
  252. or warn_flow= #{query.warnFlow}
  253. </if>
  254. )
  255. </when>
  256. <otherwise>
  257. <if test="query.warnFlow !=null">
  258. and warn_flow= #{query.warnFlow}
  259. </if>
  260. </otherwise>
  261. </choose>
  262. </where>
  263. ) as i on p.infusion_id=i.id
  264. join (select device_id,alias from bus_device_running) as r on r.device_id=i.device_id
  265. left join (select * from bus_clinic
  266. <where>
  267. <if test="query.timeRange != null and query.timeRange.size >0">
  268. and monitor_start_time &gt; #{query.timeRange[0]} and monitor_start_time &lt; #{query.timeRange[1]}
  269. </if>
  270. </where>
  271. ) c on i.clinic_id=c.id
  272. <if test="query.bedNo!=null || query.name!=null || query.code!=null || query.anaDoctor!=null || query.surgeName!=null ||query.gender!=null ||query.anaType!=null">
  273. <where>
  274. (1=0
  275. <if test="query.bedNo!=null">
  276. or i.bed_no LIKE concat('%', #{query.bedNo}, '%')
  277. </if>
  278. <if test="query.name!=null">
  279. or p.`name` LIKE concat('%', #{query.name}, '%')
  280. </if>
  281. <if test="query.code!=null">
  282. or p.`code` LIKE concat('%', #{query.code}, '%')
  283. </if>
  284. <if test="query.anaDoctor!=null">
  285. or c.`ana_doctor` like concat('%', #{query.anaDoctor}, '%')
  286. </if>
  287. <if test="query.surgeName!=null">
  288. or c.`surgery_name` like concat('%',#{query.surgeName}, '%')
  289. </if>
  290. <if test="query.gender!=null">
  291. or p.gender LIKE concat('%', #{query.gender}, '%')
  292. </if>
  293. <if test="query.anaType!=null">
  294. or c.ana_type LIKE concat('%', #{query.anaType}, '%')
  295. </if>)
  296. </where>
  297. </if>
  298. order by c.monitor_start_time desc
  299. </select>
  300. <select id="findByPatientCode" resultMap="monitorResult">
  301. select
  302. p.alarm as patient_alarm,
  303. p.`code` as patient_code,
  304. i.device_id as device_id,
  305. i.clinic_id as clinic_id,
  306. i.ward as ward,
  307. i.bed_no as bed_no,
  308. i.total_dose as total_dose,
  309. i.first_dose as first_dose,
  310. i.remain_dose as remain_dose,
  311. i.input_dose as input_dose,
  312. i.append_dose as append_dose,
  313. i.append_lock_time as append_lock_time,
  314. i.max_dose as max_dose,
  315. i.electric_quantity as electric_quantity,
  316. i.warn_flow as warn_flow,
  317. i.self_control_count as self_control_count,
  318. i.self_control_lock_time as self_control_lock_time,
  319. i.pca_valid_count as pca_valid_count,
  320. i.pca_invalid_count as pca_invalid_count,
  321. i.pca_total_count as pca_total_count,
  322. i.continue_dose as continue_dose,
  323. i.pulse_dose as pulse_dose,
  324. i.pulse_lock_time as pulse_lock_time,
  325. i.pulse_first_lock_time as pulse_first_lock_time,
  326. i.flow_up_cycle as flow_up_cycle,
  327. i.flow_down_cycle as flow_down_cycle,
  328. i.flow_count as flow_count,
  329. i.flow_up_limit as flow_up_limit,
  330. i.flow_down_limit as flow_down_limit,
  331. i.flow_adjust_rate as flow_adjust_rate,
  332. i.run_state as run_state,
  333. i.warn_will_finished as warn_will_finished,
  334. i.warn_analgesic_poor as warn_analgesic_poor,
  335. i.warn_low_battery as warn_low_battery,
  336. i.alarm as device_alarm,
  337. i.start_time as infusion_start_time,
  338. i.remark as remark,
  339. i.type as device_type,
  340. r.alias as device_alias,
  341. c.finished as finished,
  342. c.`patient_name` as patient_name,
  343. c.patient_gender as gender,
  344. c.monitor_start_time as monitor_start_time,
  345. c.end_time as monitor_end_time,
  346. c.ana_doctor as ana_doctor,
  347. c.patient_age as patient_age,
  348. c.ana_type as ana_type,
  349. c.anal_type as anal_type,
  350. c.surgery_doctor as surgery_doctor,
  351. c.surgery_name as surgery_name
  352. from
  353. (select * from bus_patient where tenant_id=#{tenantId} and code=#{patientCode} )
  354. as p
  355. join
  356. bus_infusion_history as i on p.infusion_id=i.id
  357. join (select device_id,alias from bus_device_running) as r on r.device_id=i.device_id
  358. left join bus_clinic c on i.clinic_id=c.id
  359. limit 1
  360. </select>
  361. </mapper>