select a.id as firstAidId, a.name, a.gender, a.age, a.data_status as dataStatus,
a.value_type as demonstrate, a.type as type, r1.answer as record1, r2.answer as record2
a.value_type as demonstrate, a.type as type, r1.answer as record1, r2.answer as record2,
a.project_id as projectId, m.record_user_id as recordUserId, r3.answer as probableCase
from
t_qcp_first_aid a
left join t_qcp_first_aid_member m
on a.id = m.first_aid_id and m.rec_status = 0
<choose>
<whentest="param.type == 0">
and m.create_user_id = #{userId}
</when>
<whentest="param.type == 1">
and m.record_user_id in (1000, 0)
</when>
</choose>
count(a.id) as total,
count(r.id) as rongshuan,
max(r.answer - a.arrive_hospital_time)/60000 as max,
min(r.answer - a.arrive_hospital_time)/60000 as min,
avg(r.answer - a.arrive_hospital_time)/60000 as avg,
count(if(r.answer - a.arrive_hospital_time <= 3600000, 1, null)) as dabiao
from t_qcp_first_aid a left join t_qcp_patient p on a.patient_id = p.id
left join t_qcp_first_aid_record r on a.id = r.first_aid_id and r.question_code = 'JMRSSJ' and r.rec_status = 0
where p.hospital_id = #{hospitalId} and a.rec_status = 0 and p.rec_status = 0
<iftest="param.startTime != null and param.startTime != 0">
and unix_timestamp(a.created_at)*1000 >= #{param.startTime}
</if>
<iftest="param.endTime != null and param.endTime != 0">
and unix_timestamp(a.created_at)*1000 <= #{param.endTime}
(select a.* from t_qcp_first_aid a, t_organization_project o where a.hospital_id = o.organization_id and o.project_id = #{param.projectId} and a.rec_status = 0 and o.rec_status = 0 )a
left join t_qcp_first_aid_member m
on a.id = m.first_aid_id and m.rec_status = 0
left join t_qcp_first_aid_record r
on a.id = r.first_aid_id
and r.question_code = 'CYQK-CYSJ' and r.rec_status = 0
left join t_qcp_first_aid_record r1 on a.id = r1.first_aid_id and r1.rec_status = 0