@ -4,49 +4,46 @@
<select id= "querySelf" resultType= "com.ccsens.carbasics.bean.vo.PatientVo$QueryPatientList" >
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
(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
<choose >
<when test= "param.type == 0" >
and m.create_user_id = #{userId}
</when>
<when test= "param.type == 1" >
and m.record_user_id in (1000, 0)
</when>
<when test= "param.firstAidType == 0" > and r1.question_code='JBXX-FBSJ'</when>
<when test= "param.firstAidType == 1" > and r1.question_code='CYQK-CYSJ'</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
<if test= "param.startTime != null and param.startTime != 0" >
and unix_timestamp(a.created_at)*1000 > = #{param.startTime}
</if >
<if test= "param.endTime != null and param.endTime != 0 " >
and unix_timestamp(a.created_at)*1000 < = #{param.endTime}
left join t_qcp_first_aid_record r2 on a.id = r2.first_aid_id and r2.rec_status = 0
<choose >
<when test= "param.firstAidType == 0" > and r2.question_code='JBXX-DYSJ'</when>
<when test= "param.firstAidType == 1" > and r2.question_code='CYQK-LYFS'</when>
</choose>
left join t_qcp_first_aid_record r3 on a.id = r3.first_aid_id and r3.question_code='CJBL-YSBL' and r3.rec_status = 0
where
<choose >
<when test= "param.firstAidType == 0" > r.id is null</when>
<when test= "param.firstAidType == 1" > r.id is not null</when >
<otherwise > r.id is null</otherwise>
</choose >
<if test= "param.name != null and param.name != '' " >
and a.name like concat('%', #{param.name}, '%')
</if>
<choose >
<when test= "param.type == 0" >
and DATE_FORMAT(a.created_at,'%Y-%m') = FROM_UNIXTIME(r.answer/1000,'%Y-%m')
GROUP BY DATE_FORMAT(a.created_at,'%Y-%m')
and m.create_user_id = #{userId}
</when>
<when test= "param.type == 1" >
and m.record_user_id in (#{userId}, 0)
</when>
<otherwise >
and concat(DATE_FORMAT(a.created_at,'%Y-'), week(a.created_at)) = concat(DATE_FORMAT(from_unixtime(r.answer/1000),'%Y-'), week(from_unixtime(r.answer/1000)))
GROUP BY DATE_FORMAT(a.created_at,'%Y-%m')
</otherwise>
</choose>
</select>
<select id= "getIdByProjectId" resultType= "com.ccsens.carbasics.bean.po.FirstAid" >
SELECT
*