|
|
@ -82,4 +82,127 @@ |
|
|
|
AND o.rec_status = 0 |
|
|
|
LIMIT 1 |
|
|
|
</select> |
|
|
|
<select id="rankByTimeWindowPatient" 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 |
|
|
|
( |
|
|
|
<choose> |
|
|
|
<when test="areaId == null or areaId == 0"> |
|
|
|
SELECT |
|
|
|
t1.id, |
|
|
|
t1.organization_type as organizationType, |
|
|
|
t1.CODE, |
|
|
|
t1.NAME, |
|
|
|
t1.short_name AS shortName, |
|
|
|
t1.introduce, |
|
|
|
t1.LEVEL |
|
|
|
from t_organization |
|
|
|
WHERE |
|
|
|
organizationType = 3 |
|
|
|
<if test="level != null"> |
|
|
|
AND level = 3 |
|
|
|
</if> |
|
|
|
</when> |
|
|
|
<otherwise> |
|
|
|
SELECT |
|
|
|
* |
|
|
|
FROM |
|
|
|
( |
|
|
|
SELECT |
|
|
|
t1.id, |
|
|
|
t1.organization_type as organizationType, |
|
|
|
t1.CODE, |
|
|
|
t1.NAME, |
|
|
|
t1.short_name AS shortName, |
|
|
|
t1.introduce, |
|
|
|
t1.LEVEL, |
|
|
|
IF( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild |
|
|
|
FROM |
|
|
|
( SELECT t.*, p.parent_id FROM t_organization t, t_organization_parent p WHERE t.id = p.organization_id ORDER BY parent_id, id ) t1, |
|
|
|
( SELECT @pids := 2 ) t2 |
|
|
|
) t3 |
|
|
|
WHERE |
|
|
|
ischild != 0 |
|
|
|
<if test="level != null"> |
|
|
|
AND level = 3 |
|
|
|
</if> |
|
|
|
AND organizationType = 3 |
|
|
|
</otherwise> |
|
|
|
</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 |
|
|
|
) 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 rank.*, @rank := @rank + 1 as rank from ( |
|
|
|
select h.id, h.name, ifNULL(t.total, 0) as value from |
|
|
|
( |
|
|
|
<choose> |
|
|
|
<when test="areaId == null or areaId == 0"> |
|
|
|
SELECT |
|
|
|
t1.id, |
|
|
|
t1.organization_type as organizationType, |
|
|
|
t1.CODE, |
|
|
|
t1.NAME, |
|
|
|
t1.short_name AS shortName, |
|
|
|
t1.introduce, |
|
|
|
t1.LEVEL |
|
|
|
from t_organization |
|
|
|
WHERE |
|
|
|
organizationType = 3 |
|
|
|
<if test="level != null"> |
|
|
|
AND level = 3 |
|
|
|
</if> |
|
|
|
</when> |
|
|
|
<otherwise> |
|
|
|
SELECT |
|
|
|
* |
|
|
|
FROM |
|
|
|
( |
|
|
|
SELECT |
|
|
|
t1.id, |
|
|
|
t1.organization_type as organizationType, |
|
|
|
t1.CODE, |
|
|
|
t1.NAME, |
|
|
|
t1.short_name AS shortName, |
|
|
|
t1.introduce, |
|
|
|
t1.LEVEL, |
|
|
|
IF( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild |
|
|
|
FROM |
|
|
|
( SELECT t.*, p.parent_id FROM t_organization t, t_organization_parent p WHERE t.id = p.organization_id ORDER BY parent_id, id ) t1, |
|
|
|
( SELECT @pids := 2 ) t2 |
|
|
|
) t3 |
|
|
|
WHERE |
|
|
|
ischild != 0 |
|
|
|
<if test="level != null"> |
|
|
|
AND level = 3 |
|
|
|
</if> |
|
|
|
AND organizationType = 3 |
|
|
|
</otherwise> |
|
|
|
</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 |
|
|
|
group by a.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> |
|
|
|