|
|
@@ -3,30 +3,29 @@
|
|
|
<mapper namespace="cn.tr.module.phototherapy.common.repository.BusClinicRepository">
|
|
|
|
|
|
<select id="selectPatientTherapyDetailById" resultType="cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO">
|
|
|
- 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,
|
|
|
- COUNT(DISTINCT DATE(r.therapy_start_time)) as therapy_count,
|
|
|
- COALESCE(MAX(r_today.therapy_status), 0) as therapy_status,
|
|
|
- tp.create_time as startTime,
|
|
|
- tp.phase_type,
|
|
|
- tp.phase_freq,
|
|
|
- tp.phase_duration_min,
|
|
|
- tp.plan_doctor,
|
|
|
- c.device_id,
|
|
|
- c.bind_start_time
|
|
|
+ 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,
|
|
|
+ COUNT(DISTINCT DATE (r.therapy_start_time)) as therapy_count,
|
|
|
+ COALESCE(MAX(r_today.therapy_status), 0) as therapy_status,
|
|
|
+ tp.create_time as startTime,
|
|
|
+ tp.phase_type,
|
|
|
+ tp.phase_freq,
|
|
|
+ tp.phase_duration_min,
|
|
|
+ tp.plan_doctor,
|
|
|
+ c.device_id,
|
|
|
+ c.bind_start_time
|
|
|
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.id = r.clinic_id AND r.is_delete = 0
|
|
|
LEFT JOIN bus_therapy_record r_today ON c.id = r_today.clinic_id
|
|
|
AND r_today.is_delete = 0
|
|
|
- AND DATE(r_today.therapy_start_time) = DATE(NOW())
|
|
|
+ AND DATE (r_today.therapy_start_time) = DATE (NOW())
|
|
|
WHERE c.patient_unique_id = #{patientUniqueId}
|
|
|
AND c.is_delete = 0
|
|
|
GROUP BY
|
|
|
@@ -35,4 +34,69 @@
|
|
|
tp.create_time, tp.phase_type, tp.phase_freq,
|
|
|
tp.phase_duration_min, tp.plan_doctor, c.device_id, c.bind_start_time
|
|
|
</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,
|
|
|
+ CONCAT(
|
|
|
+ COALESCE(btp.phase_freq, ''),
|
|
|
+ ':每次',
|
|
|
+ COALESCE(CAST(btp.phase_duration_min AS TEXT), ''),
|
|
|
+ 'min'
|
|
|
+ ) as therapyPlanDesc,
|
|
|
+ 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>
|