|
|
@ -4,24 +4,29 @@ |
|
|
|
|
|
|
|
<select id="getOrganization" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Basic"> |
|
|
|
SELECT |
|
|
|
t1.organization_id |
|
|
|
t1.organization_id as organizationId, |
|
|
|
t2.code as role |
|
|
|
FROM |
|
|
|
( SELECT organization_id FROM t_organization_project WHERE project_id = #{projectId} AND rec_status = 0 ) t1, |
|
|
|
( |
|
|
|
SELECT |
|
|
|
d.organization_id |
|
|
|
d.organization_id, |
|
|
|
p.code |
|
|
|
FROM |
|
|
|
t_organization_member m, |
|
|
|
t_organization_department d |
|
|
|
t_organization_department d, |
|
|
|
t_organization_position p |
|
|
|
WHERE |
|
|
|
m.department_id = d.id |
|
|
|
AND m.position_id = p.id |
|
|
|
AND m.user_id = #{userId} |
|
|
|
AND m.rec_status = 0 |
|
|
|
AND d.rec_status = 0 |
|
|
|
limit 1 |
|
|
|
AND p.rec_status = 0 |
|
|
|
) t2 |
|
|
|
WHERE |
|
|
|
t1.organization_id = t2.organization_id |
|
|
|
limit 1 |
|
|
|
</select> |
|
|
|
<select id="getByProjectId" resultType="com.ccsens.carbasics.bean.po.Organization"> |
|
|
|
SELECT |
|
|
@ -82,7 +87,7 @@ |
|
|
|
AND o.rec_status = 0 |
|
|
|
LIMIT 1 |
|
|
|
</select> |
|
|
|
<select id="rankByTimeWindowPatient" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"> |
|
|
|
<select id="rankByType" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"> |
|
|
|
select rank.*, @rank := @rank + 1 as rank from ( |
|
|
|
select h.id, h.name, ifNULL(t.total, 0) as value from |
|
|
|
( |
|
|
@ -131,21 +136,58 @@ |
|
|
|
</choose> |
|
|
|
) h |
|
|
|
left join ( |
|
|
|
select a.hospital_id, count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBSJ' |
|
|
|
and a.id = r2.first_aid_id and r1.question_code = 'JBXX-DYSJ' |
|
|
|
and r2.answer + 0 >= 0 and r2.answer + 0 <= 0 |
|
|
|
and r2.answer - r1.answer > 6 * 60 * 60 * 1000 |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
<choose> |
|
|
|
<when test="type == 0"> |
|
|
|
select a.hospital_id, count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBSJ' |
|
|
|
and a.id = r2.first_aid_id and r1.question_code = 'JBXX-DYSJ' |
|
|
|
and r2.answer - r1.answer > 6 * 60 * 60 * 1000 |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
</when> |
|
|
|
<when test="type == 1"> |
|
|
|
select a.hospital_id, count(r2.id) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 |
|
|
|
where a.id = r1.first_aid_id |
|
|
|
and r1.question_code = 'ZLFA-JMRS' and r1.answer = '是' |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
</when> |
|
|
|
<when test="type == 2"> |
|
|
|
select t1.hospital_id, round(t2.part * 100 / t1.total, 2) as total from |
|
|
|
(select |
|
|
|
a.hospital_id, |
|
|
|
count(*) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JBXX-FBSJ' |
|
|
|
and a.id = r2.first_aid_id and r1.question_code = 'JBXX-DYSJ' |
|
|
|
and r2.answer - r1.answer < 6 * 60 * 60 * 1000 |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
) t1, |
|
|
|
(select |
|
|
|
a.hospital_id, count(a.id) as part from t_qcp_first_aid a, t_qcp_first_aid_record r1 |
|
|
|
where a.id = r1.first_aid_id |
|
|
|
and r1.question_code = 'ZLFA-JMRS' and r1.answer = '是' |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
)t2 |
|
|
|
where t1.hospital_id = t2.hospital_id |
|
|
|
</when> |
|
|
|
<when test="type == 4"> |
|
|
|
select a.hospital_id, count(a.id) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1 |
|
|
|
where a.id = r1.first_aid_id |
|
|
|
and r1.question_code = 'RYPG-ZDJG' and r1.answer = '出血性脑卒中' |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 |
|
|
|
</when> |
|
|
|
</choose> |
|
|
|
|
|
|
|
) t on t.hospital_id = h.id |
|
|
|
) rank, (SELECT @rank:= 0) b |
|
|
|
order by value |
|
|
|
</select> |
|
|
|
<select id="rankByThrombosis" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"> |
|
|
|
|
|
|
|
<select id="rankByDntMedian" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"> |
|
|
|
select rank.*, @rank := @rank + 1 as rank from ( |
|
|
|
select h.id, h.name, ifNULL(t.total, 0) as value from |
|
|
|
( |
|
|
|
select h.id, h.name, ifNULL(t.total, 0) as value from ( |
|
|
|
<choose> |
|
|
|
<when test="areaId == null or areaId == 0"> |
|
|
|
SELECT |
|
|
@ -191,18 +233,36 @@ |
|
|
|
</choose> |
|
|
|
) h |
|
|
|
left join ( |
|
|
|
select a.hospital_id, count(r2.id) as total from t_qcp_first_aid a, t_qcp_first_aid_record r1, t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and a.id = r2.first_aid_id |
|
|
|
and r1.question_code = #{questionCode} and r1.answer = #{answer} |
|
|
|
and r2.question_code = #{timeCode} and r2.answer + 0 >=#{startTime} and r2.answer + 0 <=#{endTime} |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 |
|
|
|
select t1.hospital_id, avg(t1.val) as total from |
|
|
|
(select hospital_id, val, @team, |
|
|
|
case @team when hospital_id then @rk := @rk+1 else @rk := 1 end rk, |
|
|
|
@team := hospital_id |
|
|
|
from |
|
|
|
(select |
|
|
|
a.hospital_id, |
|
|
|
ROUND((r1.answer - r2.answer)/60000, 2) as val |
|
|
|
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JMRSSJ' |
|
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ' |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0 |
|
|
|
) d, |
|
|
|
(select @rk := 0, @team := '') t |
|
|
|
order by hospital_id, val) t1 |
|
|
|
left join ( |
|
|
|
select |
|
|
|
a.hospital_id, |
|
|
|
count(*) as cnt |
|
|
|
from t_qcp_first_aid a, t_qcp_first_aid_record r1 , t_qcp_first_aid_record r2 |
|
|
|
where a.id = r1.first_aid_id and r1.question_code = 'JMRSSJ' |
|
|
|
and a.id = r2.first_aid_id and r2.question_code = 'JBXX-DYSJ' |
|
|
|
and a.rec_status = 0 and r1.rec_status = 0 and r2.rec_status = 0 |
|
|
|
group by a.hospital_id |
|
|
|
) t on t.hospital_id = h.id |
|
|
|
) t2 on t1.hospital_id = t2.hospital_id |
|
|
|
where t1.rk IN (t2.cnt + 0.5, t2.cnt, t2.cnt + 1) |
|
|
|
group by t1.hospital_id |
|
|
|
) t on t.hospital_id = h.id |
|
|
|
) rank, (SELECT @rank:= 0) b |
|
|
|
order by value |
|
|
|
</select> |
|
|
|
<select id="rankByThrombosisRate" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"></select> |
|
|
|
<select id="rankByDntMedian" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"></select> |
|
|
|
<select id="rankByIch" resultType="com.ccsens.carbasics.bean.vo.OrganizationVo$Rank"></select> |
|
|
|
|
|
|
|
</mapper> |
|
|
|