| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.tr.module.phototherapy.common.repository.BusClinicRepository">
- <select id="selectPatientTherapyDetailById" resultType="cn.tr.module.phototherapy.common.dto.PatientTherapyDetailDTO">
- SELECT c.patient_name,
- c.patient_age,
- c.patient_gender,
- c.patient_unique_id,
- c.patient_phone,
- c.patient_address,
- c.last_treatment_time,
- c.group_type,
- c.is_current_bind as isCurrentBind,
- COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
- COALESCE(MAX(r_today.therapy_status), 0) as therapy_status,
- tp.phase_start_time as phaseStartTime,
- tp.phase_type as phaseType,
- tp.phase_freq as phaseFreq,
- tp.phase_duration_min as phaseDurationMin ,
- tp.plan_doctor as planDoctor,
- c.device_id as deviceId,
- c.bind_start_time as bindStartTime,
- tp.plan_status as therapyPlanStatus,
- da.device_alarm as deviceAlarm
- FROM bus_clinic c
- LEFT JOIN bus_therapy_plan tp ON c.therapy_plan_id = tp.id
- LEFT JOIN bus_therapy_record r ON c.patient_unique_id = r.patient_unique_id AND r.is_delete = 0
- LEFT JOIN bus_therapy_record r_today ON c.patient_unique_id = r_today.patient_unique_id
- AND r_today.is_delete = 0
- AND DATE (r_today.therapy_start_time) = DATE (NOW())
- LEFT JOIN bus_device_alarm da ON da.device_id = c.device_id
- WHERE c.patient_unique_id = #{patientUniqueId}
- AND c.is_delete = 0
- GROUP BY
- c.patient_name, c.patient_age, c.patient_gender, c.patient_unique_id,
- c.patient_phone, c.patient_address, c.last_treatment_time, c.group_type,c.is_current_bind,
- tp.phase_start_time, tp.phase_type, tp.phase_freq,
- tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time,tp.plan_status,da.device_alarm
- </select>
- <select id="selectPatientLists" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyRecordVO"
- parameterType="cn.tr.module.phototherapy.common.dto.BusPatientListQueryDTO">
- select bc.patient_unique_id,
- bc.patient_name,
- bc.patient_age,
- bc.patient_gender,
- bc.patient_phone,
- bc.last_treatment_time,
- bc.bind_start_time,
- bc.group_type,
- bc.is_current_bind,
- bc.last_treatment_time,
- bc.is_current_bind,
- btp.phase_type,
- btp.phase_target_times,
- btp.phase_freq,
- btp.phase_duration_min,
- btp.plan_status,
- bd.device_id,
- bda.device_alarm
- from bus_clinic bc
- LEFT JOIN bus_therapy_plan btp ON bc.patient_unique_id = btp.patient_unique_id
- LEFT JOIN bus_device bd ON bc.patient_unique_id = bd.patient_unique_id
- LEFT JOIN bus_device_alarm bda on bda.device_id = bd.device_id
- <where>
- <if test="query.patientName != null">
- and patient_name = #{query.patientName}
- </if>
- <if test="query.patientGender != null">
- and patient_gender = #{query.patientGender}
- </if>
- <if test="query.planStatus != null">
- and plan_status = #{query.planStatus}
- </if>
- <if test="query.isCurrentBind != null">
- and is_current_bind = #{query.isCurrentBind}
- </if>
- <if test="query.groupType != null">
- and group_type = #{query.groupType}
- </if>
- <if test="query.deviceAlarm != null">
- and device_alarm = #{query.deviceAlarm}
- </if>
- <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >0">
- and last_treatment_time >= #{query.lastTreatmentTime[0]}
- </if>
- <if test="query.lastTreatmentTime != null and query.lastTreatmentTime.size() >1">
- and last_treatment_time <= #{query.lastTreatmentTime[1]}
- </if>
- <if test="query.patientAge != null and query.patientAge.size() > 0">
- <if test="query.patientAge[0] != null">
- and bc.patient_age >= #{query.patientAge[0]}
- </if>
- <if test="query.patientAge.size() > 1 and query.patientAge[1] != null">
- and bc.patient_age <= #{query.patientAge[1]}
- </if>
- </if>
- </where>
- </select>
- </mapper>
|