BusClinicMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.BusClinicMapper">
  4. <resultMap id="stats" type="com.coffee.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="invalid_count" property="inValidCount"/>
  10. <result column="upload_time" property="uploadTime"/>
  11. </resultMap>
  12. <resultMap id="queryResult" type="com.coffee.bus.service.dto.ClinicResult">
  13. <result column="clinic_id" property="clinicId"/>
  14. <result column="patient_code" property="patientCode"/>
  15. <result column="patient_name" property="patientName"/>
  16. <result column="ward" property="ward"/>
  17. <result column="bed_no" property="bedNo"/>
  18. <result column="surgery_name" property="surgeryName"/>
  19. <result column="surgery_doctor" property="surgeryDoctor"/>
  20. <result column="ana_doctor" property="anaDoctor"/>
  21. <result column="monitor_type" property="monitorType"/>
  22. <result column="finished" property="finished"/>
  23. <result column="clinic_start_time" property="clinicStartTime"/>
  24. <result column="monitor_start_time" property="monitorStartTime"/>
  25. <result column="monitor_end_time" property="monitorEndTime"/>
  26. <result column="monitor_alarm" property="monitorAlarm"/>
  27. <result column="infusion_count" property="infusionCount"/>
  28. <result column="eval_count" property="evalCount"/>
  29. </resultMap>
  30. <select id="stats" resultMap="stats">
  31. SELECT
  32. <if test="query.continueDose!=false">
  33. h.continue_dose as continue_dose,
  34. </if>
  35. <if test="query.appendDose!=false">
  36. h.append_dose as append_dose,
  37. </if>
  38. <if test="query.inputDose!=false">
  39. h.input_dose as input_dose,
  40. </if>
  41. <if test="query.validCount!=false">
  42. h.pca_valid_count as valid_count,
  43. </if>
  44. <if test="query.inValidCount!=false">
  45. h.pca_invalid_count as invalid_count,
  46. </if>
  47. h.upload_time
  48. FROM
  49. (select id from bus_infusion_history
  50. <where>
  51. <if test="query.clinicId!=null">
  52. and clinic_id = #{query.clinicId}
  53. </if>
  54. <if test="query.infusionId!=null">
  55. and id = #{query.infusionId}
  56. </if>
  57. <if test="query.deviceId!=null">
  58. and device_id = #{query.deviceId}
  59. </if>
  60. </where>)
  61. as i
  62. left JOIN (select * from bus_device_history
  63. <where>
  64. <if test="query.infusionModifyIds != null and query.infusionModifyIds.size > 0">
  65. and infusion_modify_id in
  66. <foreach item="infusionModifyId" index="index" collection="query.infusionModifyIds" open="(" separator="," close=")">
  67. #{infusionModifyId, jdbcType=VARCHAR}
  68. </foreach>
  69. </if>
  70. </where>
  71. ) as h on h.infusion_id=i.id
  72. order by h.upload_time asc
  73. </select>
  74. <select id="pageQuery" resultMap="queryResult" parameterType="com.coffee.bus.service.dto.ClinicQuery">
  75. select
  76. c.id as clinic_id,
  77. c.patient_code as patient_code,
  78. c.patient_name as patient_name,
  79. c.ward as ward,
  80. c.bed_no as bed_no,
  81. c.`name` as surgery_name,
  82. c.surgery_doctor as surgery_doctor,
  83. c.ana_doctor as ana_doctor,
  84. c.monitor_type as monitor_type,
  85. c.finished as finished,
  86. c.start_time as clinic_start_time,
  87. c.monitor_start_time as monitor_start_time,
  88. c.end_time as monitor_end_time,
  89. i.infusion_count as infusion_count,
  90. eval.eval_count as eval_count
  91. from (select * from bus_clinic
  92. <where>
  93. <if test="query.monitorType!=null">
  94. and monitor_type=#{query.monitorType}
  95. </if>
  96. <if test="query.surgeryName!=null">
  97. and name like concat('%',#{query.surgeryName},'%')
  98. </if>
  99. <if test="query.patientName!=null">
  100. and patient_name like concat('%',#{query.patientName},'%')
  101. </if>
  102. <if test="query.patientCode!=null">
  103. and patient_code like concat('%',#{query.patientCode},'%')
  104. </if>
  105. <if test="query.ward!=null">
  106. and ward=#{query.ward}
  107. </if>
  108. <if test="query.bedNo!=null">
  109. and bed_no like concat('%',#{query.bedNo},'%')
  110. </if>
  111. <if test="query.timeRange != null and query.timeRange.size >0">
  112. and monitor_start_time &gt; #{query.timeRange[0]} and monitor_start_time &lt; #{query.timeRange[1]}
  113. </if>
  114. </where>
  115. ) as c
  116. left join bus_patient as p on c.id=p.clinic_id
  117. 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
  118. 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
  119. order by c.monitor_start_time desc
  120. </select>
  121. </mapper>