BusPatientMapper.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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.BusPatientMapper">
  4. <resultMap id="repeatDeviceResult" type="com.nb.web.service.bus.entity.PatientDeviceRepeatDomain">
  5. <result column="patient_id" property="patientId"/>
  6. <result column="name" property="name"/>
  7. <result column="gender" property="gender"/>
  8. <result column="code" property="code"/>
  9. <result column="age" property="age"/>
  10. <result column="ward" property="ward"/>
  11. <result column="bed_no" property="bedNo"/>
  12. <result column="clinic_name" property="clinicName"/>
  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="infusion_id" property="infusionId"/>
  20. <result column="master_infusion_id" property="masterInfusionId"/>
  21. </resultMap>
  22. <resultMap id="monitorResult" type="com.nb.web.api.feign.result.PatientMonitorResult">
  23. <result column="patient_name" property="patientName"/>
  24. <result column="patient_code" property="patientCode"/>
  25. <result column="patient_age" property="patientAge"/>
  26. <result column="gender" property="gender"/>
  27. <result column="infusion_id" property="infusionId"/>
  28. <result column="patient_alarm" property="patientAlarm"/>
  29. <result column="classification" property="classification"/>
  30. <result column="data_num" property="dataNum"/>
  31. <result column="device_id" property="deviceId"/>
  32. <result column="device_alias" property="deviceAlias"/>
  33. <result column="clinic_id" property="clinicId"/>
  34. <result column="patient_gender" property="gender"/>
  35. <result column="infusion_finished" property="infusionFinished"/>
  36. <result column="ward" property="ward"/>
  37. <result column="bed_no" property="bedNo"/>
  38. <result column="total_dose" property="totalDose"/>
  39. <result column="first_dose" property="firstDose"/>
  40. <result column="remain_dose" property="remainDose"/>
  41. <result column="input_dose" property="inputDose"/>
  42. <result column="append_dose" property="appendDose"/>
  43. <result column="append_lock_time" property="appendLockTime"/>
  44. <result column="max_dose" property="maxDose"/>
  45. <result column="last_upload_time" property="lastUploadTime"/>
  46. <result column="product_no" property="productNo"/>
  47. <!--<result column="self_control_count" property="selfControlCount"/>-->
  48. <result column="self_control_lock_time" property="selfControlLockTime"/>
  49. <result column="pca_valid_count" property="pcaValidCount"/>
  50. <result column="pca_invalid_count" property="pcaInvalidCount"/>
  51. <result column="pca_total_count" property="pcaTotalCount"/>
  52. <result column="continue_dose" property="continueDose"/>
  53. <result column="pulse_dose" property="pulseDose"/>
  54. <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
  55. <result column="pulse_lock_time" property="pulseLockTime"/>
  56. <result column="flow_up_cycle" property="flowUpCycle"/>
  57. <result column="flow_down_cycle" property="flowDownCycle"/>
  58. <result column="flow_count" property="flowCount"/>
  59. <result column="flow_up_limit" property="flowUpLimit"/>
  60. <result column="flow_down_limit" property="flowDownLimit"/>
  61. <result column="flow_adjust_rate" property="flowAdjustRate"/>
  62. <result column="run_state" property="deviceRunState"/>
  63. <result column="electric_quantity" property="electricQuantity"/>
  64. <result column="warn_flow" property="warnFlow"/>
  65. <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
  66. <result column="warn_low_battery" property="warnLowBattery"/>
  67. <result column="warn_will_finished" property="warnWillFinished"/>
  68. <result column="device_alarm" property="deviceAlarm"/>
  69. <result column="infusion_start_time" property="infusionStartTime"/>
  70. <result column="remark" property="remark"/>
  71. <result column="device_type" property="deviceType"/>
  72. <result column="anal_type" property="analType"/>
  73. <result column="ana_doctor" property="anaDoctor"/>
  74. <result column="ana_type" property="anaType"/>
  75. <result column="surgery_doctor" property="surgeryDoctor"/>
  76. <result column="surgery_name" property="surgeryName"/>
  77. <result column="finished" property="clinicFinished"/>
  78. <result column="monitor_end_time" property="monitorEndTime"/>
  79. <result column="monitor_start_time" property="monitorStartTime"/>
  80. <result column="eval_time" property="evalTime"/>
  81. <result column="patient_id" property="patientId"/>
  82. <result column="manage_type" property="manageType"/>
  83. <result column="block1" property="block1"/>
  84. <result column="block2" property="block2"/>
  85. <result column="block_status" property="blockStatus"/>
  86. </resultMap>
  87. <resultMap id="deviceNone" type="com.nb.web.service.bus.service.dto.PatientDeviceNoneResult">
  88. <result column="patient_id" property="patientId"/>
  89. <result column="clinic_id" property="clinicId"/>
  90. <result column="name" property="name"/>
  91. <result column="gender" property="gender"/>
  92. <result column="code" property="code"/>
  93. <result column="age" property="age"/>
  94. <result column="ward" property="ward"/>
  95. <result column="bed_no" property="bedNo"/>
  96. <result column="surgery_name" property="surgeryName"/>
  97. <result column="weight" property="weight"/>
  98. <result column="height" property="height"/>
  99. <result column="ana_doctor" property="anaDoctor"/>
  100. <result column="ana_type" property="anaType"/>
  101. <result column="anal_type" property="analType"/>
  102. <result column="surgery_doctor" property="surgeryDoctor"/>
  103. <result column="asa" property="asa"/>
  104. <result column="formula" property="formula" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
  105. <result column="finished" property="finished"/>
  106. <result column="config_person" property="configPerson"/>
  107. </resultMap>
  108. <resultMap id="contactMap" type="com.nb.web.api.feign.result.ContactPatientResult">
  109. <result column="patient_id" property="patientId"/>
  110. <result column="patient_name" property="patientName"/>
  111. <result column="sex" property="patientSex"/>
  112. <result column="patient_code" property="patientCode"/>
  113. <result column="patient_age" property="patientAge"/>
  114. </resultMap>
  115. <select id="selectRepeatDevice" resultMap="repeatDeviceResult">
  116. SELECT
  117. p.id as patient_id,
  118. p.code as code,
  119. p.infusion_id as master_infusion_id,
  120. c.patient_gender as gender,
  121. c.`patient_name` as name,
  122. c.patient_age as age,
  123. c.ward,
  124. c.bed_no,
  125. c.id as clinic_id,
  126. c.`surgery_name` as clinic_name,
  127. i.device_id as device_id,
  128. i.id as infusion_id,
  129. d.alias as device_alias,
  130. i.run_state as device_run_state,
  131. i.alarm as device_alarm,
  132. i.start_time as infusion_start_time
  133. FROM (SELECT `name`,gender,infusion_id,CODE,id FROM bus_patient
  134. <where>
  135. bus_patient.`alarm`=1
  136. <if test="tenantId != null and tenantId != ''">
  137. and tenant_id=#{tenantId}
  138. </if>
  139. </where>
  140. ) AS p
  141. join (select * from bus_infusion_history where is_undo=0 and finished=0) as i on i.patient_id=p.id
  142. join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
  143. join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id
  144. </select>
  145. <select id="selectNoneDevice" resultMap="deviceNone">
  146. SELECT
  147. p.id as patient_id,
  148. p.code as code,
  149. c.id as clinic_id,
  150. c.patient_gender as gender,
  151. c.`patient_name` as name,
  152. c.patient_age as age,
  153. c.ward as ward,
  154. c.bed_no as bed_no,
  155. c.`surgery_name` as surgery_name,
  156. c.weight as weight,
  157. c.height as height,
  158. c.ana_doctor as ana_doctor,
  159. c.ana_type as ana_type,
  160. c.anal_type as anal_type,
  161. c.surgery_doctor as surgery_doctor,
  162. c.asa as asa,
  163. c.formula as formula,
  164. c.finished as finished,
  165. c.monitor_start_time as monitor_start_time,
  166. c.config_person as config_person
  167. FROM (SELECT `name`,gender,CODE,tenant_id,id FROM bus_patient WHERE bus_patient.`alarm`=2 ) AS p
  168. join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id
  169. <where>
  170. <if test="tenantId != null and tenantId != ''">
  171. and p.tenant_id=#{tenantId}
  172. </if>
  173. </where>
  174. order by c.monitor_start_time desc;
  175. </select>
  176. <select id="selectMonitor" resultMap="monitorResult" parameterType="com.nb.web.api.feign.query.PatientMonitorQuery">
  177. select
  178. p.id as patient_id,
  179. p.code as patient_code,
  180. p.alarm as patient_alarm,
  181. i.id as infusion_id,
  182. i.device_id as device_id,
  183. i.clinic_id as clinic_id,
  184. i.classification as classification,
  185. i.data_number as data_num,
  186. i.total_dose as total_dose,
  187. i.first_dose as first_dose,
  188. i.remain_dose as remain_dose,
  189. i.input_dose as input_dose,
  190. i.append_dose as append_dose,
  191. i.append_lock_time as append_lock_time,
  192. i.max_dose as max_dose,
  193. i.finished as infusion_finished,
  194. i.electric_quantity as electric_quantity,
  195. i.warn_flow as warn_flow,
  196. i.self_control_count as self_control_count,
  197. i.self_control_lock_time as self_control_lock_time,
  198. i.pca_valid_count as pca_valid_count,
  199. i.pca_invalid_count as pca_invalid_count,
  200. i.pca_total_count as pca_total_count,
  201. i.continue_dose as continue_dose,
  202. i.pulse_dose as pulse_dose,
  203. i.pulse_lock_time as pulse_lock_time,
  204. i.pulse_first_lock_time as pulse_first_lock_time,
  205. i.flow_up_cycle as flow_up_cycle,
  206. i.flow_down_cycle as flow_down_cycle,
  207. i.flow_count as flow_count,
  208. i.flow_up_limit as flow_up_limit,
  209. i.flow_down_limit as flow_down_limit,
  210. i.flow_adjust_rate as flow_adjust_rate,
  211. i.run_state as run_state,
  212. i.warn_will_finished as warn_will_finished,
  213. i.warn_analgesic_poor as warn_analgesic_poor,
  214. i.warn_low_battery as warn_low_battery,
  215. i.alarm as device_alarm,
  216. i.data_number as data_number,
  217. i.start_time as infusion_start_time,
  218. i.remark as remark,
  219. i.type as device_type,
  220. i.last_upload_time as last_upload_time,
  221. i.block1 as block1,
  222. i.block2 as block2,
  223. i.block_status as block_status,
  224. <!--d.alias as device_alias,-->
  225. <!--d.product_no as product_no ,-->
  226. c.patient_gender as patient_gender,
  227. c.`patient_name` as patient_name,
  228. c.finished as finished,
  229. c.monitor_start_time as monitor_start_time,
  230. c.end_time as monitor_end_time,
  231. c.ana_doctor as ana_doctor,
  232. c.patient_age as patient_age,
  233. c.ana_type as ana_type,
  234. c.anal_type as anal_type,
  235. c.surgery_doctor as surgery_doctor,
  236. c.surgery_name as surgery_name,
  237. c.ward as ward,
  238. c.bed_no as bed_no,
  239. c.eval_time as eval_time,
  240. c.manage_type as manage_type
  241. from
  242. (select * from bus_patient
  243. <where>
  244. <if test="query.tenantId!=null">
  245. and tenant_id=#{query.tenantId}
  246. </if>
  247. </where>
  248. )
  249. as p
  250. join
  251. (select * from bus_infusion_history
  252. <where>
  253. is_undo='0'
  254. <if test="query.infusionFinished != null and query.andFinished == true ">
  255. and finished=#{query.infusionFinished}
  256. </if>
  257. <if test="query.types != null and query.types.size > 0">
  258. and type in
  259. <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
  260. #{type, jdbcType=VARCHAR}
  261. </foreach>
  262. </if>
  263. <if test="query.tenantId!=null">
  264. and tenant_id=#{query.tenantId}
  265. </if>
  266. <choose>
  267. <when test="query.deviceStatus != null and query.deviceStatus.size > 0">
  268. and (
  269. run_state in
  270. <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator=","
  271. close=")">
  272. #{status, jdbcType=VARCHAR}
  273. </foreach>
  274. <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
  275. or alarm in
  276. <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator=","
  277. close=")">
  278. #{alarm, jdbcType=VARCHAR}
  279. </foreach>
  280. </if>
  281. <if test="query.infusionFinished != null and query.andFinished == false ">
  282. or finished=#{query.infusionFinished}
  283. </if>
  284. )
  285. </when>
  286. <otherwise>
  287. <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
  288. and alarm in
  289. <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
  290. #{alarm, jdbcType=VARCHAR}
  291. </foreach>
  292. </if>
  293. </otherwise>
  294. </choose>
  295. <choose>
  296. <when test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or query.warnLowBattery != false">
  297. and (
  298. <choose>
  299. <when test="query.warnWillFinished != false">warn_will_finished=1</when>
  300. <otherwise>0=1</otherwise>
  301. </choose>
  302. <if test="query.warnAnalgesicPoor != false">or warn_analgesic_poor=1 </if>
  303. <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
  304. <if test="query.warnFlow !=null and query.warnFlow.size > 0 ">
  305. or warn_flow in
  306. <foreach item="wf" index="index" collection="query.warnFlow" open="(" separator="," close=")">
  307. #{wf, jdbcType=VARCHAR}
  308. </foreach>
  309. </if>
  310. )
  311. </when>
  312. <otherwise>
  313. <if test="query.warnFlow !=null and query.warnFlow.size > 0 ">
  314. and warn_flow in
  315. <foreach item="wf" index="index" collection="query.warnFlow" open="(" separator="," close=")">
  316. #{wf, jdbcType=VARCHAR}
  317. </foreach>
  318. </if>
  319. </otherwise>
  320. </choose>
  321. </where>
  322. ) as i on p.infusion_id=i.id
  323. <!--left join-->
  324. <!--(select device_id,alias,product_no-->
  325. <!--from bus_device-->
  326. <!--<where>-->
  327. <!--<if test="query.tenantId!=null">-->
  328. <!--and tenant_id=#{query.tenantId}-->
  329. <!--</if>-->
  330. <!--</where>-->
  331. <!--) as d on d.device_id=i.device_id-->
  332. join (select * from bus_clinic
  333. <where>
  334. finished=0
  335. <if test="query.wards != null and query.wards.size > 0">
  336. and ward in
  337. <foreach item="ward" index="index" collection="query.wards" open="(" separator="," close=")">
  338. #{ward, jdbcType=VARCHAR}
  339. </foreach>
  340. </if>
  341. <if test="query.timeRange != null and query.timeRange.size >0">
  342. and monitor_start_time &gt;= #{query.timeRange[0]} and monitor_start_time &lt;= #{query.timeRange[1]}
  343. </if>
  344. <if test="query.tenantId!=null">
  345. and tenant_id=#{query.tenantId}
  346. </if>
  347. <if test="query.manageType!=null">
  348. and manage_type=#{query.manageType}
  349. </if>
  350. </where>
  351. ) c on p.clinic_id=c.id
  352. <!--<if test="query.bedNo!=null || query.name!=null || query.code!=null || query.anaDoctor!=null || query.surgeName!=null ||query.gender!=null ||query.anaType!=null || query.deviceId != null || query.productNo!=null">-->
  353. <!--<where>-->
  354. <!--(1=0-->
  355. <!--<if test="query.bedNo!=null">-->
  356. <!--or c.bed_no LIKE concat('%', #{query.bedNo}, '%')-->
  357. <!--</if>-->
  358. <!--<if test="query.name!=null">-->
  359. <!--or c.`patient_name` LIKE concat('%', #{query.name}, '%')-->
  360. <!--</if>-->
  361. <!--<if test="query.code!=null">-->
  362. <!--or p.`code` LIKE concat('%', #{query.code}, '%')-->
  363. <!--</if>-->
  364. <!--<if test="query.anaDoctor!=null">-->
  365. <!--or c.`ana_doctor` like concat('%', #{query.anaDoctor}, '%')-->
  366. <!--</if>-->
  367. <!--<if test="query.surgeName!=null">-->
  368. <!--or c.`surgery_name` like concat('%',#{query.surgeName}, '%')-->
  369. <!--</if>-->
  370. <!--<if test="query.gender!=null">-->
  371. <!--or c.patient_gender LIKE concat('%', #{query.gender}, '%')-->
  372. <!--</if>-->
  373. <!--<if test="query.anaType!=null">-->
  374. <!--or c.ana_type LIKE concat('%', #{query.anaType}, '%')-->
  375. <!--</if>)-->
  376. <!--&lt;!&ndash;<if test="query.deviceId!=null">&ndash;&gt;-->
  377. <!--&lt;!&ndash;or i.device_id like concat('%', #{query.deviceId}, '%')&ndash;&gt;-->
  378. <!--&lt;!&ndash;</if>&ndash;&gt;-->
  379. <!--&lt;!&ndash;<if test="query.deviceAlias!=null">&ndash;&gt;-->
  380. <!--&lt;!&ndash;or d.alias like concat('%', #{query.deviceAlias}, '%')&ndash;&gt;-->
  381. <!--&lt;!&ndash;</if>&ndash;&gt;-->
  382. <!--</where>-->
  383. <!--</if>-->
  384. order by c.monitor_start_time desc
  385. </select>
  386. <select id="findByPatientId" resultMap="monitorResult">
  387. select
  388. p.id as patient_id,
  389. p.`code` as patient_code,
  390. p.alarm as patient_alarm,
  391. i.id as infusion_id,
  392. i.device_id as device_id,
  393. i.clinic_id as clinic_id,
  394. i.classification as classification,
  395. i.data_number as data_num,
  396. i.total_dose as total_dose,
  397. i.first_dose as first_dose,
  398. i.remain_dose as remain_dose,
  399. i.input_dose as input_dose,
  400. i.append_dose as append_dose,
  401. i.append_lock_time as append_lock_time,
  402. i.max_dose as max_dose,
  403. i.finished as infusion_finished,
  404. i.electric_quantity as electric_quantity,
  405. i.warn_flow as warn_flow,
  406. i.self_control_count as self_control_count,
  407. i.self_control_lock_time as self_control_lock_time,
  408. i.pca_valid_count as pca_valid_count,
  409. i.pca_invalid_count as pca_invalid_count,
  410. i.pca_total_count as pca_total_count,
  411. i.continue_dose as continue_dose,
  412. i.pulse_dose as pulse_dose,
  413. i.pulse_lock_time as pulse_lock_time,
  414. i.pulse_first_lock_time as pulse_first_lock_time,
  415. i.flow_up_cycle as flow_up_cycle,
  416. i.flow_down_cycle as flow_down_cycle,
  417. i.flow_count as flow_count,
  418. i.flow_up_limit as flow_up_limit,
  419. i.flow_down_limit as flow_down_limit,
  420. i.flow_adjust_rate as flow_adjust_rate,
  421. i.run_state as run_state,
  422. i.last_upload_time as last_upload_time,
  423. i.warn_will_finished as warn_will_finished,
  424. i.warn_analgesic_poor as warn_analgesic_poor,
  425. i.warn_low_battery as warn_low_battery,
  426. i.alarm as device_alarm,
  427. i.start_time as infusion_start_time,
  428. i.remark as remark,
  429. i.type as device_type,
  430. d.alias as device_alias,
  431. d.product_no as product_no ,
  432. c.patient_gender as patient_gender,
  433. c.`patient_name` as patient_name,
  434. c.finished as finished,
  435. c.monitor_start_time as monitor_start_time,
  436. c.end_time as monitor_end_time,
  437. c.ana_doctor as ana_doctor,
  438. c.patient_age as patient_age,
  439. c.ana_type as ana_type,
  440. c.anal_type as anal_type,
  441. c.surgery_doctor as surgery_doctor,
  442. c.surgery_name as surgery_name,
  443. c.ward as ward,
  444. c.bed_no as bed_no,
  445. c.eval_time as eval_time
  446. from
  447. (select * from bus_patient
  448. <where>
  449. <if test="tenantId!=null">
  450. and tenant_id=#{tenantId}
  451. </if>
  452. <if test="patientId!=null">
  453. and id=#{patientId}
  454. </if>
  455. </where>
  456. )
  457. as p
  458. left join
  459. bus_infusion_history as i on p.infusion_id=i.id
  460. left join (select device_id,alias,product_no from bus_device) as d on d.device_id=i.device_id
  461. left join (select * from bus_clinic where monitor_type=1) c on p.clinic_id=c.id
  462. limit 1
  463. </select>
  464. <select id="selectAlarmCount" resultType="long">
  465. select count(1) from (select * from bus_patient
  466. <where>
  467. <if test="tenantId!=null">
  468. and tenant_id=#{tenantId}
  469. </if>
  470. </where>
  471. ) as p
  472. join (select * from bus_clinic
  473. <where>
  474. finished=0
  475. and monitor_type=1
  476. <if test="tenantId!=null">
  477. and tenant_id=#{tenantId}
  478. </if>
  479. </where>
  480. ) as c on p.id=c.patient_id
  481. <where>
  482. <if test="alarmValue!=null">
  483. and p.alarm=#{alarmValue}
  484. </if>
  485. </where>
  486. </select>
  487. <select id="monitorTotalCount" resultType="long">
  488. select count(1) from (select * from bus_patient where tenant_id=#{tenantId}) as p JOIN (select * from bus_clinic where finished=0 and tenant_id=#{tenantId}) as c on p.clinic_id=c.id
  489. </select>
  490. <resultMap id="doctorMonitorResult" type="com.nb.web.api.feign.result.DoctorPatientMonitorResult">
  491. <result column="patient_id" property="patientId"/>
  492. <result column="patient_name" property="patientName"/>
  493. <result column="patient_code" property="patientCode"/>
  494. <result column="patient_age" property="patientAge"/>
  495. <result column="gender" property="gender"/>
  496. <result column="patient_alarm" property="patientAlarm"/>
  497. <result column="device_id" property="deviceId"/>
  498. <result column="device_alias" property="deviceAlias"/>
  499. <result column="clinic_id" property="clinicId"/>
  500. <result column="patient_gender" property="gender"/>
  501. <result column="ward" property="ward"/>
  502. <result column="bed_no" property="bedNo"/>
  503. <result column="total_dose" property="totalDose"/>
  504. <result column="first_dose" property="firstDose"/>
  505. <result column="electric_quantity" property="electricQuantity"/>
  506. <result column="remain_dose" property="remainDose"/>
  507. <result column="input_dose" property="inputDose"/>
  508. <result column="append_dose" property="appendDose"/>
  509. <result column="append_lock_time" property="appendLockTime"/>
  510. <result column="max_dose" property="maxDose"/>
  511. <result column="self_control_lock_time" property="selfControlLockTime"/>
  512. <result column="pca_valid_count" property="pcaValidCount"/>
  513. <result column="pca_invalid_count" property="pcaInvalidCount"/>
  514. <result column="pca_total_count" property="pcaTotalCount"/>
  515. <result column="continue_dose" property="continueDose"/>
  516. <result column="pulse_dose" property="pulseDose"/>
  517. <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
  518. <result column="pulse_lock_time" property="pulseLockTime"/>
  519. <result column="flow_up_cycle" property="flowUpCycle"/>
  520. <result column="flow_down_cycle" property="flowDownCycle"/>
  521. <result column="flow_count" property="flowCount"/>
  522. <result column="flow_up_limit" property="flowUpLimit"/>
  523. <result column="flow_down_limit" property="flowDownLimit"/>
  524. <result column="flow_adjust_rate" property="flowAdjustRate"/>
  525. <result column="device_run_state" property="deviceRunState"/>
  526. <result column="device_alarm" property="deviceAlarm"/>
  527. <result column="infusion_start_time" property="infusionStartTime"/>
  528. <result column="device_type" property="deviceType"/>
  529. <result column="eval_time" property="evalTime"/>
  530. <result column="warn_flow" property="warnFlow"/>
  531. <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
  532. <result column="warn_low_battery" property="warnLowBattery"/>
  533. <result column="warn_will_finished" property="warnWillFinished"/>
  534. <result column="manage_type" property="manageType"/>
  535. <result column="assist_id" property="assistId"/>
  536. <result column="assist_nickname" property="assistNickname"/>
  537. <result column="abnormal" property="abnormal"/>
  538. </resultMap>
  539. <select id="doctorSelectPatientList" resultMap="doctorMonitorResult">
  540. SELECT
  541. <!-- 患者基础信息 -->
  542. c.patient_id AS patient_id,
  543. c.patient_code AS patient_code,
  544. c.patient_age AS patient_age, <!-- 补充:假设 patient_age 对应实体类中的年龄字段(result 中有 patient_age) -->
  545. c.patient_gender AS gender, <!-- 注意:patient_gender 映射到实体类的 gender 属性(可能存在冗余,需确认表结构) -->
  546. <!-- 临床信息 -->
  547. c.patient_name AS patient_name,
  548. c.ward AS ward,
  549. c.bed_no AS bed_no,
  550. c.ana_doctor AS ana_doctor,
  551. c.surgery_name AS surge_name,
  552. c.ana_type AS ana_type,
  553. c.eval_time AS eval_time, <!-- 评价时间 -->
  554. c.manage_type AS manage_type,
  555. c.abnormal as abnormal,
  556. <!-- 设备与输注信息 -->
  557. i.device_id AS device_id,
  558. d.alias AS device_alias, <!-- 假设来自设备表,若未关联需调整 -->
  559. i.clinic_id AS clinic_id,
  560. i.total_dose AS total_dose,
  561. i.first_dose AS first_dose,
  562. i.remain_dose AS remain_dose,
  563. i.input_dose AS input_dose,
  564. i.append_dose AS append_dose,
  565. i.append_lock_time AS append_lock_time,
  566. i.max_dose AS max_dose,
  567. i.self_control_lock_time AS self_control_lock_time,
  568. i.pca_valid_count AS pca_valid_count,
  569. i.pca_invalid_count AS pca_invalid_count,
  570. i.pca_total_count AS pca_total_count,
  571. i.continue_dose AS continue_dose,
  572. i.pulse_dose AS pulse_dose,
  573. i.pulse_first_lock_time AS pulse_first_lock_time,
  574. i.pulse_lock_time AS pulse_lock_time,
  575. i.flow_up_cycle AS flow_up_cycle,
  576. i.flow_down_cycle AS flow_down_cycle,
  577. i.flow_count AS flow_count,
  578. i.flow_up_limit AS flow_up_limit,
  579. i.flow_down_limit AS flow_down_limit,
  580. i.flow_adjust_rate AS flow_adjust_rate,
  581. i.run_state AS device_run_state,
  582. i.alarm AS device_alarm,
  583. i.electric_quantity as electric_quantity,
  584. i.start_time AS infusion_start_time,
  585. i.type AS device_type,
  586. i.warn_flow AS warn_flow,
  587. i.warn_analgesic_poor AS warn_analgesic_poor,
  588. i.warn_low_battery AS warn_low_battery,
  589. <if test="query.consult != null and query.consult == true">
  590. aub.assist_id as assist_id,
  591. aub.assist_nickname as assist_nickname,
  592. </if>
  593. i.warn_will_finished AS warn_will_finished
  594. FROM
  595. bus_patient p
  596. JOIN bus_clinic c ON p.clinic_id = c.id <!-- 患者与临床信息关联 -->
  597. JOIN bus_infusion_history i ON p.infusion_id = i.id <!-- 患者与输注记录关联 -->
  598. <!-- 设备表左连接(若 device_alias 来自设备表) -->
  599. LEFT JOIN bus_device d ON i.device_id = d.id
  600. <if test="query.consult != null and query.consult == true">
  601. LEFT JOIN (select * from assistant_user_bind where status = '1' and doctor_id = #{query.userId}) aub on aub.patient_id = p.id
  602. </if>
  603. <where>
  604. i.is_undo='0' and c.finished=0 and p.tenant_id = #{query.tenantId}
  605. <!-- 患者基础条件 -->
  606. <if test="query.patientCode != null">
  607. AND p.code LIKE CONCAT('%', #{query.patientCode}, '%')
  608. </if>
  609. <if test="query.patientName != null">
  610. AND c.patient_name LIKE CONCAT('%', #{query.patientName}, '%')
  611. </if>
  612. <!--todo-->
  613. <if test="query.abnormal != null">
  614. AND c.abnormal = #{query.abnormal}
  615. </if>
  616. <!-- 临床与病区条件 -->
  617. <if test="query.wards != null and query.wards.size > 0">
  618. AND c.ward IN
  619. <foreach item="ward" collection="query.wards" open="(" separator="," close=")">
  620. #{ward}
  621. </foreach>
  622. </if>
  623. <if test="query.bedNo != null">
  624. AND c.bed_no LIKE CONCAT('%', #{query.bedNo}, '%')
  625. </if>
  626. <if test="query.anaDoctor != null">
  627. AND c.ana_doctor LIKE CONCAT('%', #{query.anaDoctor}, '%')
  628. </if>
  629. <if test="query.surgeName != null">
  630. AND c.surgery_name LIKE CONCAT('%', #{query.surgeName}, '%')
  631. </if>
  632. <if test="query.anaType != null">
  633. AND c.ana_type LIKE CONCAT('%', #{query.anaType}, '%')
  634. </if>
  635. <!-- 设备与输注条件 -->
  636. <if test="query.types != null and query.types.size > 0">
  637. AND i.type IN
  638. <foreach item="type" collection="query.types" open="(" separator="," close=")">
  639. #{type}
  640. </foreach>
  641. </if>
  642. <if test="query.deviceStatus != null and query.deviceStatus.size > 0">
  643. AND i.run_state IN
  644. <foreach item="status" collection="query.deviceStatus" open="(" separator="," close=")">
  645. #{status}
  646. </foreach>
  647. </if>
  648. <!-- 无报警 -->
  649. <if test="query.alarm != null and query.alarm == false">
  650. AND i.alarm = 0
  651. </if>
  652. <!-- 有报警 -->
  653. <if test="query.alarm != null and query.alarm == true">
  654. AND i.alarm != 0
  655. </if>
  656. <!--无提醒-->
  657. <if test="query.warn != null and query.warn == false">
  658. AND (i.warn_flow is null and i.warn_low_battery = 0 and i.warn_will_finished =0 and i.warn_analgesic_poor=0)
  659. </if>
  660. <!--有提醒-->
  661. <if test="query.warn != null and query.warn == true">
  662. AND (i.warn_flow = 1 or i.warn_low_battery = 1 or i.warn_will_finished=1 or i.warn_analgesic_poor=1)
  663. </if>
  664. <if test="query.timeRange != null and query.timeRange.size == 1">
  665. AND c.monitor_start_time &gt;= #{query.timeRange[0]}
  666. </if>
  667. <!-- 时间区间查询 -->
  668. <if test="query.timeRange != null and query.timeRange.size > 1">
  669. AND c.monitor_start_time &lt;= #{query.timeRange[1]}
  670. </if>
  671. <!-- 已评价 -->
  672. <if test="query.evaluate != null and query.evaluate == 1">
  673. and c.eval_time is not null
  674. </if>
  675. <!-- 待评价 -->
  676. <if test="query.evaluate != null and query.evaluate == 2">
  677. and c.eval_time is not null and DATE_ADD(c.eval_time,INTERVAL #{query.interval} MINUTE) &gt; NOW()
  678. </if>
  679. <!-- 未评价 -->
  680. <if test="query.evaluate != null and query.evaluate == 3">
  681. AND c.eval_time is null
  682. </if>
  683. <!-- 管理类型 -->
  684. <if test="query.manageType != null">
  685. AND c.manage_type = #{query.manageType}
  686. </if>
  687. </where>
  688. <!-- 排序逻辑 -->
  689. <if test="query.orderType == 0">
  690. order by i.start_time DESC <!-- 默认按输注开始时间倒序 -->
  691. </if>
  692. <if test="query.orderType == 1">
  693. order by c.bed_no ASC <!-- 按病区和床号升序 -->
  694. </if>
  695. </select>
  696. </mapper>