8 changed files with 176 additions and 188 deletions
@ -0,0 +1,35 @@ |
|||||
|
package com.ccsens.carbasics.bean.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/8/31 11:25 |
||||
|
*/ |
||||
|
public class FirstAidLogVo { |
||||
|
|
||||
|
@ApiModel("参与者") |
||||
|
@Data |
||||
|
public static class JoinMember{ |
||||
|
@ApiModelProperty("急救ID") |
||||
|
private Long firstAidId; |
||||
|
@ApiModelProperty("参与者信息") |
||||
|
private List<Member> doctors; |
||||
|
} |
||||
|
|
||||
|
@ApiModel("参与者-成员") |
||||
|
@Data |
||||
|
public static class Member{ |
||||
|
@ApiModelProperty("日志ID") |
||||
|
private Long id; |
||||
|
@ApiModelProperty("角色 0:分诊护士 1:神内医生 2:神外医生") |
||||
|
private byte role; |
||||
|
@ApiModelProperty("医生名字") |
||||
|
private String name; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.ccsens.carbasics.persist.dao; |
||||
|
|
||||
|
import com.ccsens.carbasics.bean.vo.FirstAidLogVo; |
||||
|
import com.ccsens.carbasics.persist.mapper.FirstAidLogMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: whj |
||||
|
* @time: 2021/8/31 11:32 |
||||
|
*/ |
||||
|
public interface FirstAidLogDao extends FirstAidLogMapper { |
||||
|
|
||||
|
/** |
||||
|
* 查询参与急救的医生\护士信息 |
||||
|
* @param firstAidIds 急救列表 |
||||
|
* @return 医生信息 |
||||
|
*/ |
||||
|
List<FirstAidLogVo.JoinMember> queryMember(@Param("firstAidIds") List<Long> firstAidIds); |
||||
|
} |
||||
@ -1,132 +1,43 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.ccsens.carbasics.persist.dao.FirstAidDao"> |
<mapper namespace="com.ccsens.carbasics.persist.dao.FirstAidDao"> |
||||
<select id="getUserIdById" resultType="Long"> |
|
||||
SELECT |
|
||||
m.user_id |
|
||||
FROM |
|
||||
t_qcp_first_aid a, |
|
||||
t_pro_member m |
|
||||
WHERE |
|
||||
a.project_id = m.project_id |
|
||||
AND a.id = #{aidId} |
|
||||
AND a.rec_status = 0 |
|
||||
AND m.rec_status = 0 |
|
||||
</select> |
|
||||
<select id="queryQuality" resultType="com.ccsens.carbasics.bean.vo.StatisticalVo$Quality"> |
|
||||
select |
|
||||
|
|
||||
|
<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 |
||||
|
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> |
<choose> |
||||
<when test="param.type == 0"> |
<when test="param.type == 0"> |
||||
DATE_FORMAT(a.created_at,'%Y-%m') as date, |
and m.create_user_id = #{userId} |
||||
|
</when> |
||||
|
<when test="param.type == 1"> |
||||
|
and m.record_user_id in (1000, 0) |
||||
</when> |
</when> |
||||
<otherwise> |
|
||||
concat(DATE_FORMAT(a.created_at,'%Y-'), week(a.created_at)) as date, |
|
||||
</otherwise> |
|
||||
</choose> |
</choose> |
||||
count(a.id) as total, |
left join t_qcp_first_aid_record r |
||||
count(r.id) as rongshuan, |
on a.id = r.first_aid_id |
||||
max(r.answer - a.arrive_hospital_time)/60000 as max, |
and r.question_code = 'CYQK-CYSJ' and r.rec_status = 0 |
||||
min(r.answer - a.arrive_hospital_time)/60000 as min, |
left join t_qcp_first_aid_record r1 on a.id = r1.first_aid_id and r1.rec_status = 0 |
||||
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} |
|
||||
</if> |
|
||||
<choose> |
<choose> |
||||
<when test="param.type == 0"> |
<when test="param.firstAidType == 0">and r1.question_code='JBXX-FBSJ'</when> |
||||
and DATE_FORMAT(a.created_at,'%Y-%m') = FROM_UNIXTIME(r.answer/1000,'%Y-%m') |
<when test="param.firstAidType == 1">and r1.question_code='CYQK-CYSJ'</when> |
||||
GROUP BY DATE_FORMAT(a.created_at,'%Y-%m') |
|
||||
</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> |
</choose> |
||||
|
left join t_qcp_first_aid_record r2 on a.id = r2.first_aid_id and r2.rec_status = 0 |
||||
</select> |
|
||||
<select id="getMedian" resultType="java.math.BigDecimal"> |
|
||||
SELECT AVG(dd.val) as median_val |
|
||||
FROM ( |
|
||||
SELECT d.val, @rownum:=@rownum+1 as `row_number`, @total_rows:=@rownum |
|
||||
FROM |
|
||||
(select r.answer/60000 as val from t_qcp_first_aid a, t_qcp_first_aid_record r |
|
||||
where a.id = r.first_aid_id and r.question_code = 'JMRSSJ' |
|
||||
<choose> |
<choose> |
||||
<when test="type == 0">and FROM_UNIXTIME(r.answer/1000,'%Y-%m') = #{date} </when> |
<when test="param.firstAidType == 0">and r2.question_code='JBXX-DYSJ'</when> |
||||
<when test="type == 1">and concat(DATE_FORMAT(a.created_at,'%Y-'), week(a.created_at)) = #{date} </when> |
<when test="param.firstAidType == 1">and r2.question_code='CYQK-LYFS'</when> |
||||
<when test="type == 2">and FROM_UNIXTIME(r.answer/1000,'%Y-%m-%d') = #{date} </when> |
|
||||
</choose> |
</choose> |
||||
|
where |
||||
) d, |
<choose> |
||||
(SELECT @rownum:=0) r |
<when test="param.firstAidType == 0">r.id is null</when> |
||||
WHERE d.val is NOT NULL |
<when test="param.firstAidType == 1"> r.id is not null</when> |
||||
ORDER BY d.val |
<otherwise>r.id is null</otherwise> |
||||
) as dd |
</choose> |
||||
WHERE dd.row_number IN ( FLOOR((@total_rows+1)/2), FLOOR((@total_rows+2)/2) ); |
<if test="param.name != null and param.name != ''"> |
||||
</select> |
and a.name like concat('%', #{param.name}, '%') |
||||
<select id="queryThrombolyticDay" resultType="java.lang.String"> |
</if> |
||||
select distinct FROM_UNIXTIME(r.answer/1000,'%Y-%m-%d') as day |
|
||||
from t_qcp_first_aid a, t_qcp_first_aid_record r, t_qcp_patient p |
|
||||
where a.id = r.first_aid_id and a.patient_id = p.id and p.hospital_id = #{hospitalId} |
|
||||
and r.question_code = 'JMRSSJ' and a.rec_status = 0 and p.rec_status = 0 and r.rec_status = 0 |
|
||||
</select> |
|
||||
|
|
||||
<select id="getIdByProjectId" resultType="java.lang.Long"> |
|
||||
SELECT |
|
||||
id |
|
||||
FROM |
|
||||
t_qcp_first_aid AS a |
|
||||
WHERE |
|
||||
rec_status = 0 |
|
||||
AND project_id = #{projectId} |
|
||||
LIMIT 1 |
|
||||
</select> |
|
||||
<select id="getPatientName" resultType="java.lang.String"> |
|
||||
SELECT |
|
||||
p.NAME |
|
||||
FROM |
|
||||
t_qcp_first_aid a, |
|
||||
t_qcp_patient p |
|
||||
WHERE |
|
||||
a.patient_id = p.id |
|
||||
AND a.id = #{id} |
|
||||
AND a.rec_status = 0 |
|
||||
AND p.rec_status = 0 |
|
||||
</select> |
|
||||
<select id="selResult" resultType="java.lang.Integer"> |
|
||||
select |
|
||||
if(tfa.num is NULL,0,tfa.num) as num |
|
||||
FROM |
|
||||
(SELECT |
|
||||
concat( #{year}, `name` ) AS `name` |
|
||||
FROM |
|
||||
t_statistics_month ) tsm |
|
||||
LEFT JOIN ( |
|
||||
SELECT |
|
||||
tfa.da, |
|
||||
count( tfa.da ) AS num |
|
||||
FROM |
|
||||
( |
|
||||
SELECT |
|
||||
FROM_UNIXTIME( a.time / 1000, '%Y-%m' ) AS da |
|
||||
FROM |
|
||||
`t_qcp_first_aid` a LEFT JOIN t_qcp_patient p on a.patient_id = p.id and p.rec_status = 0 |
|
||||
WHERE |
|
||||
a.rec_status = 0 |
|
||||
AND p.hospital_id = #{hospitalId} |
|
||||
AND FROM_UNIXTIME( time / 1000, '%Y' ) = #{year} |
|
||||
) tfa |
|
||||
GROUP BY |
|
||||
tfa.da |
|
||||
ORDER BY |
|
||||
tfa.da |
|
||||
) tfa on tsm.`name`=tfa.`da` |
|
||||
</select> |
</select> |
||||
</mapper> |
</mapper> |
||||
|
|||||
@ -0,0 +1,35 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.ccsens.carbasics.persist.dao.FirstAidLogDao"> |
||||
|
|
||||
|
<resultMap id="memberMap" type="com.ccsens.carbasics.bean.vo.FirstAidLogVo$JoinMember"> |
||||
|
<id column="first_aid_id" property="firstAidId"/> |
||||
|
<collection property="doctors" ofType="com.ccsens.carbasics.bean.vo.FirstAidLogVo$Member"> |
||||
|
<id column="id" property="id"/> |
||||
|
<result column="role" property="role"/> |
||||
|
<result column="name" property="name"/> |
||||
|
</collection> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
<select id="queryMember" resultMap="memberMap"> |
||||
|
SELECT |
||||
|
l.id, |
||||
|
l.first_aid_id, |
||||
|
l.operation_role as role, |
||||
|
m.name |
||||
|
FROM |
||||
|
t_qcp_first_aid_log l, |
||||
|
t_organization_member m |
||||
|
WHERE |
||||
|
l.operation_user_id = m.user_id |
||||
|
AND l.operation_type IN ( 0, 7 ) |
||||
|
AND l.operation_role IN ( 0, 1, 2 ) |
||||
|
AND l.first_aid_id IN |
||||
|
<foreach collection="firstAidIds" item="id" open="(" close=")" separator=","> |
||||
|
#{id} |
||||
|
</foreach> |
||||
|
AND l.rec_status = 0 |
||||
|
AND m.rec_status = 0 |
||||
|
</select> |
||||
|
</mapper> |
||||
Loading…
Reference in new issue