|
|
@@ -120,35 +120,60 @@
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="selectRepeatDevice" resultMap="repeatDeviceResult">
|
|
|
+<!-- SELECT-->
|
|
|
+<!-- p.id as patient_id,-->
|
|
|
+<!-- p.code as code,-->
|
|
|
+<!-- p.infusion_id as master_infusion_id,-->
|
|
|
+<!-- c.patient_gender as gender,-->
|
|
|
+<!-- c.`patient_name` as name,-->
|
|
|
+<!-- c.patient_age as age,-->
|
|
|
+<!-- c.ward,-->
|
|
|
+<!-- COALESCE(c.manual_bedno, c.bed_no) as bed_no,-->
|
|
|
+<!-- c.id as clinic_id,-->
|
|
|
+<!-- c.`surgery_name` as clinic_name,-->
|
|
|
+<!-- i.device_id as device_id,-->
|
|
|
+<!-- i.id as infusion_id,-->
|
|
|
+<!-- d.alias as device_alias,-->
|
|
|
+<!-- i.run_state as device_run_state,-->
|
|
|
+<!-- i.alarm as device_alarm,-->
|
|
|
+<!-- i.start_time as infusion_start_time-->
|
|
|
+<!-- FROM (SELECT `name`,gender,infusion_id,CODE,id FROM bus_patient-->
|
|
|
+<!-- <where>-->
|
|
|
+<!-- bus_patient.`alarm`=1-->
|
|
|
+<!-- <if test="tenantId != null and tenantId != ''">-->
|
|
|
+<!-- and tenant_id=#{tenantId}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- </where>-->
|
|
|
+<!-- ) AS p-->
|
|
|
+<!-- join (select * from bus_infusion_history where is_undo=0 and finished=0) as i on i.patient_id=p.id-->
|
|
|
+<!-- join (select device_id,alias from bus_device) as d on d.device_id=i.device_id-->
|
|
|
+<!-- join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id-->
|
|
|
SELECT
|
|
|
- p.id as patient_id,
|
|
|
- p.code as code,
|
|
|
- p.infusion_id as master_infusion_id,
|
|
|
- c.patient_gender as gender,
|
|
|
- c.`patient_name` as name,
|
|
|
- c.patient_age as age,
|
|
|
+ p.id AS patient_id,
|
|
|
+ p.code AS code,
|
|
|
+ p.infusion_id AS master_infusion_id,
|
|
|
+ c.patient_gender AS gender,
|
|
|
+ c.`patient_name` AS name,
|
|
|
+ c.patient_age AS age,
|
|
|
c.ward,
|
|
|
- COALESCE(c.manual_bedno, c.bed_no) as bed_no,
|
|
|
- c.id as clinic_id,
|
|
|
- c.`surgery_name` as clinic_name,
|
|
|
- i.device_id as device_id,
|
|
|
- i.id as infusion_id,
|
|
|
- d.alias as device_alias,
|
|
|
- i.run_state as device_run_state,
|
|
|
- i.alarm as device_alarm,
|
|
|
- i.start_time as infusion_start_time
|
|
|
- FROM (SELECT `name`,gender,infusion_id,CODE,id FROM bus_patient
|
|
|
+ COALESCE(c.manual_bedno, c.bed_no) AS bed_no,
|
|
|
+ c.id AS clinic_id,
|
|
|
+ c.`surgery_name` AS clinic_name,
|
|
|
+ i.device_id AS device_id,
|
|
|
+ i.id AS infusion_id,
|
|
|
+ (SELECT alias FROM bus_device WHERE device_id = i.device_id) AS device_alias, -- 子查询获取alias
|
|
|
+ i.run_state AS device_run_state,
|
|
|
+ i.alarm AS device_alarm,
|
|
|
+ i.start_time AS infusion_start_time
|
|
|
+ FROM (SELECT `name`, gender, infusion_id, CODE, id FROM bus_patient
|
|
|
<where>
|
|
|
bus_patient.`alarm`=1
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
and tenant_id=#{tenantId}
|
|
|
</if>
|
|
|
- </where>
|
|
|
- ) AS p
|
|
|
- join (select * from bus_infusion_history where is_undo=0 and finished=0) as i on i.patient_id=p.id
|
|
|
- join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
|
|
|
- join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id
|
|
|
-
|
|
|
+ </where>) AS p
|
|
|
+ JOIN (SELECT * FROM bus_infusion_history WHERE is_undo = 0 AND finished = 0) AS i ON i.patient_id = p.id
|
|
|
+ JOIN (SELECT * FROM bus_clinic WHERE finished = 0 AND monitor_type = 1) AS c ON c.`patient_id` = p.id;
|
|
|
</select>
|
|
|
|
|
|
<select id="selectNoneDevice" resultMap="deviceNone">
|