BusClinicRepository.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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="cn.tr.module.phototherapy.common.repository.BusClinicRepository">
  4. <select id="selectPatientTherapyDetailById" resultType="cn.tr.module.phototherapy.common.dto.PatientTherapyDetailDTO">
  5. SELECT c.patient_name,
  6. c.patient_age,
  7. c.patient_gender,
  8. c.patient_unique_id,
  9. c.patient_phone,
  10. c.patient_address,
  11. c.last_treatment_time,
  12. c.group_type,
  13. c.is_current_bind as isCurrentBind,
  14. COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
  15. COALESCE(MAX(r_today.therapy_status), 0) as therapy_status,
  16. tp.phase_start_time as phaseStartTime,
  17. tp.phase_type as phaseType,
  18. tp.phase_freq as phaseFreq,
  19. tp.phase_duration_min as phaseDurationMin ,
  20. tp.plan_doctor as planDoctor,
  21. c.device_id as deviceId,
  22. c.bind_start_time as bindStartTime,
  23. tp.plan_status as therapyPlanStatus,
  24. da.device_alarm as deviceAlarm
  25. FROM bus_clinic c
  26. LEFT JOIN bus_therapy_plan tp ON c.therapy_plan_id = tp.id
  27. LEFT JOIN bus_therapy_record r ON c.patient_unique_id = r.patient_unique_id AND r.is_delete = 0
  28. LEFT JOIN bus_therapy_record r_today ON c.patient_unique_id = r_today.patient_unique_id
  29. AND r_today.is_delete = 0
  30. AND DATE (r_today.therapy_start_time) = DATE (NOW())
  31. LEFT JOIN bus_device_alarm da ON da.device_id = c.device_id
  32. WHERE c.patient_unique_id = #{patientUniqueId}
  33. AND c.is_delete = 0
  34. GROUP BY
  35. c.patient_name, c.patient_age, c.patient_gender, c.patient_unique_id,
  36. c.patient_phone, c.patient_address, c.last_treatment_time, c.group_type,c.is_current_bind,
  37. tp.phase_start_time, tp.phase_type, tp.phase_freq,
  38. tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time,tp.plan_status,da.device_alarm
  39. </select>
  40. <select id="selectPatientLists" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO"
  41. parameterType="cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO">
  42. select bc.patient_unique_id,
  43. bc.patient_name,
  44. bc.patient_age,
  45. bc.patient_gender,
  46. bc.patient_phone,
  47. bc.last_treatment_time,
  48. bc.bind_start_time,
  49. bc.group_type,
  50. bc.is_current_bind,
  51. bc.last_treatment_time,
  52. bc.is_current_bind,
  53. btp.phase_type,
  54. btp.phase_target_times,
  55. btp.phase_freq,
  56. btp.phase_duration_min,
  57. btp.plan_status,
  58. bd.device_id,
  59. bda.device_alarm
  60. from bus_clinic bc
  61. LEFT JOIN bus_therapy_plan btp ON bc.patient_unique_id = btp.patient_unique_id
  62. LEFT JOIN bus_device bd ON bc.patient_unique_id = bd.patient_unique_id
  63. LEFT JOIN bus_device_alarm bda on bda.device_id = bd.device_id
  64. <where>
  65. <if test="query.patientName != null">
  66. and patient_name = #{query.patientName}
  67. </if>
  68. <if test="query.patientGender != null">
  69. and patient_gender = #{query.patientGender}
  70. </if>
  71. <if test="query.planStatus != null">
  72. and plan_status = #{query.planStatus}
  73. </if>
  74. <if test="query.isCurrentBind != null">
  75. and is_current_bind = #{query.isCurrentBind}
  76. </if>
  77. <if test="query.groupType != null">
  78. and group_type = #{query.groupType}
  79. </if>
  80. <if test="query.deviceAlarm != null">
  81. and device_alarm = #{query.deviceAlarm}
  82. </if>
  83. <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >0">
  84. and last_treatment_time &gt;= #{query.lastTreatmentTime[0]}
  85. </if>
  86. <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >1">
  87. and last_treatment_time &lt;= #{query.lastTreatmentTime[1]}
  88. </if>
  89. <if test="query.patientAge != null and query.patientAge.size() > 0">
  90. <if test="query.patientAge[0] != null">
  91. and bc.patient_age &gt;= #{query.patientAge[0]}
  92. </if>
  93. <if test="query.patientAge.size() > 1 and query.patientAge[1] != null">
  94. and bc.patient_age &lt;= #{query.patientAge[1]}
  95. </if>
  96. </if>
  97. </where>
  98. </select>
  99. </mapper>