You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
437 lines
19 KiB
437 lines
19 KiB
<?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.tcm.persist.dao.PatientDao">
|
|
|
|
<select id="selConRec" resultType="com.ccsens.tcm.bean.vo.ConRecVo$SelConRecVo">
|
|
SELECT
|
|
tcr.id,
|
|
tcr.start_time AS startTime,
|
|
tcr.end_time AS endTime,
|
|
place,
|
|
`host`,
|
|
participants,
|
|
tcr.discussion_content AS discussionContent,
|
|
tcr.meeting_minutes AS meetingMinutes
|
|
FROM
|
|
t_conference_records tcr
|
|
WHERE
|
|
tcr.rec_status=0
|
|
<if test="id != null and id!=0 ">
|
|
and id = #{param.id}
|
|
</if>
|
|
<if test="id == null">
|
|
<if test="startTime != null ">
|
|
and tcr.start_time > #{param.startTime}
|
|
</if>
|
|
<if test="endTime != null ">
|
|
and tcr.end_time < #{param.endTime}
|
|
</if>
|
|
<if test="place != null and place != ''">
|
|
and tcr.place like concat('%',#{place, jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="host != null and host != ''">
|
|
and tcr.host like concat('%',#{host, jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="discussionContent != null and discussionContent != ''">
|
|
and tcr.discussion_content like concat('%',#{discussionContent},'%')
|
|
</if>
|
|
</if>
|
|
</select>
|
|
<select id="selPatientMesList" resultType="com.ccsens.tcm.bean.vo.PatientVo$SelPatient">
|
|
SELECT
|
|
tpi.id,
|
|
tpi.hospitalization,
|
|
tpi.inpatient_id AS inpatientId,
|
|
tpi.input_status AS inputStatus,
|
|
tpi.hospital_id AS hospitalId,
|
|
th.name as hosName,
|
|
ti.name,
|
|
ti.collection_num as collectionNum
|
|
FROM
|
|
t_patient_information tpi left join t_inpatient ti on ti.rec_status=0 and ti.id=tpi.inpatient_id
|
|
left join t_hospital th on th.rec_status=0 and th.id=tpi.hospital_id
|
|
WHERE
|
|
tpi.rec_status = 0
|
|
<if test="hospitalId!=null and hospitalId !=0 ">
|
|
and tpi.hospital_id=#{hospitalId}
|
|
</if>
|
|
<if test="hospitalization!=null and hospitalization!=''">
|
|
and tpi.hospitalization like concat('%',#{hospitalization},'%')
|
|
</if>
|
|
<if test="inpatientId !=null and inpatientId!=0">
|
|
and tpi.inpatient_id=#{inpatientId}
|
|
</if>
|
|
<if test="inputStatus !=null">
|
|
and tpi.input_status=#{inputStatus}
|
|
</if>
|
|
<if test="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 )">
|
|
and tpi.id IN (
|
|
SELECT DISTINCT
|
|
( t.patient_id )
|
|
FROM
|
|
(
|
|
<trim suffixOverrides="INTERSECT">
|
|
<if test="conditionList!=null and conditionList.size()!=0 ">
|
|
<foreach collection="conditionList" item="item">
|
|
SELECT
|
|
tpr.patient_id
|
|
FROM
|
|
t_patient_record tpr
|
|
WHERE
|
|
tpr.rec_status = 0
|
|
and tpr.contents_type = 0
|
|
AND tpr.test_questions_id = #{item.testQuestionsId}
|
|
<if test="item.contents!=null and item.contents!=''">
|
|
AND tpr.contents LIKE concat('%',#{item.contents},'%')
|
|
</if>
|
|
INTERSECT
|
|
</foreach>
|
|
</if>
|
|
<if test="conditionListDate != null and conditionListDate.size() !=0 ">
|
|
<foreach collection="conditionListDate" item="item1">
|
|
SELECT
|
|
tpr.patient_id
|
|
FROM
|
|
t_patient_record tpr
|
|
WHERE
|
|
tpr.rec_status = 0
|
|
and tpr.contents_type = 0
|
|
AND tpr.test_questions_id = #{item1.testQuestionsId}
|
|
<if test="item1.startTime!=null and item1.startTime!=''">
|
|
AND tpr.contents > #{item1.startTime}
|
|
</if>
|
|
<if test="item1.endTime!=null and item1.endTime!=''">
|
|
AND tpr.contents < #{item1.endTime}
|
|
</if>
|
|
INTERSECT
|
|
</foreach>
|
|
</if>
|
|
</trim>
|
|
) t
|
|
)
|
|
</if>
|
|
</select>
|
|
<select id="selPatientInformationList" resultType="com.ccsens.tcm.bean.vo.PatientVo$SelPatient">
|
|
SELECT
|
|
tpi.id,
|
|
tpi.hospitalization,
|
|
tpi.inpatient_id AS inpatientId,
|
|
tpi.input_status AS inputStatus,
|
|
tpi.hospital_id AS hospitalId,
|
|
ti.name,
|
|
ti.collection_num as collectionNum
|
|
FROM
|
|
t_patient_information tpi left join t_inpatient ti on ti.rec_status=0 and ti.id=tpi.inpatient_id
|
|
WHERE
|
|
tpi.rec_status =0
|
|
<if test="id != null and id!=0">
|
|
and tpi.id=#{id}
|
|
</if>
|
|
<if test="id == null">
|
|
<if test="hospitalization!=null and hospitalization!='' ">
|
|
and tpi.hospitalization=#{hospitalization}
|
|
</if>
|
|
<if test="inpatientId!=null and inpatientId!=0 ">
|
|
and tpi.inpatient_id= #{inpatientId}
|
|
</if>
|
|
<if test="inputStatus!=null and inputStatus!=0 ">
|
|
and tpi.input_status= #{inputStatus}
|
|
</if>
|
|
</if>
|
|
</select>
|
|
<select id="countCase" resultType="com.ccsens.tcm.bean.vo.StatisticVo$Shuliang">
|
|
select DATE_FORMAT(tpi.update_at,'%Y-%d-%m') as shijian,count(*) as nums from t_patient_information tpi
|
|
where tpi.rec_status=0
|
|
<if test="param.userId!=null and param.userId!=0 ">
|
|
and tpi.user_id=#{param.userId}
|
|
</if>
|
|
<if test="param.hospitalId!=null and param.hospitalId!=0 ">
|
|
and tpi.hospital_id=#{param.hospitalId}
|
|
</if>
|
|
<if test="inputStatus!=null and inputStatus!=0 ">
|
|
and tpi.input_status=#{inputStatus}
|
|
</if>
|
|
<if test="param.startDate!=null">
|
|
and tpi.update_at > #{param.startDate}
|
|
</if>
|
|
<if test="param.endDate!=null">
|
|
and tpi.update_at < #{param.endDate}
|
|
</if>
|
|
GROUP BY shijian
|
|
</select>
|
|
<select id="countAnalysis" resultType="com.ccsens.tcm.bean.vo.StatisticVo$SelGroupList">
|
|
<if test="testQuestionsId!=null and testQuestionsId!=0">
|
|
|
|
select tpr.contents as content,ti.name,
|
|
count(distinct tpr.patient_id) as nums
|
|
from t_patient_information tpi
|
|
left join t_patient_record tpr on tpi.id=tpr.patient_id and tpr.rec_status=0 and tpr.contents_type =0
|
|
left join t_inpatient ti on ti.id=tpi.inpatient_id and ti.rec_status = 0
|
|
where tpi.rec_status=0
|
|
|
|
<if test="testQuestionsId!=null and testQuestionsId!=0">
|
|
and tpr.test_questions_id=#{testQuestionsId}
|
|
</if>
|
|
</if>
|
|
<if test="testQuestionsId==null or testQuestionsId==0">
|
|
SELECT
|
|
'总人数' as content,
|
|
ti.name,
|
|
count( * ) AS nums
|
|
FROM
|
|
t_patient_information tpi
|
|
left join t_inpatient ti on ti.id=tpi.inpatient_id and ti.rec_status = 0
|
|
WHERE
|
|
tpi.rec_status = 0
|
|
</if>
|
|
and tpi.id in (
|
|
SELECT
|
|
tpi.id
|
|
FROM
|
|
t_patient_information tpi left join t_inpatient ti on ti.rec_status=0 and ti.id=tpi.inpatient_id
|
|
WHERE
|
|
tpi.rec_status = 0
|
|
<if test="hospitalId!=null and hospitalId !=0 ">
|
|
and tpi.hospital_id=#{hospitalId}
|
|
</if>
|
|
<if test="hospitalization!=null and hospitalization!=''">
|
|
and tpi.hospitalization like concat('%',#{hospitalization},'%')
|
|
</if>
|
|
<if test="inpatientId !=null and inpatientId!=0">
|
|
and tpi.inpatient_id=#{inpatientId}
|
|
</if>
|
|
<if test="inputStatus !=null">
|
|
and tpi.input_status=#{inputStatus}
|
|
</if>
|
|
<if test="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 )">
|
|
and tpi.id IN (
|
|
SELECT DISTINCT
|
|
( t.patient_id )
|
|
FROM
|
|
(
|
|
<trim suffixOverrides="INTERSECT">
|
|
<if test="conditionList!=null and conditionList.size()!=0 ">
|
|
<foreach collection="conditionList" item="item">
|
|
SELECT
|
|
tpr.patient_id
|
|
FROM
|
|
t_patient_record tpr
|
|
WHERE
|
|
tpr.rec_status = 0
|
|
AND tpr.test_questions_id = #{item.testQuestionsId}
|
|
and tpr.contents_type =0
|
|
<if test="item.contents!=null and item.contents!=''">
|
|
AND tpr.contents LIKE concat('%',#{item.contents},'%')
|
|
</if>
|
|
INTERSECT
|
|
</foreach>
|
|
</if>
|
|
<if test="conditionListDate != null and conditionListDate.size() !=0 ">
|
|
<foreach collection="conditionListDate" item="item1">
|
|
SELECT
|
|
tpr.patient_id
|
|
FROM
|
|
t_patient_record tpr
|
|
WHERE
|
|
tpr.rec_status = 0
|
|
AND tpr.test_questions_id = #{item1.testQuestionsId}
|
|
and tpr.contents_type = 0
|
|
<if test="item1.startTime!=null and item1.startTime!=''">
|
|
AND tpr.contents > #{item1.startTime}
|
|
</if>
|
|
<if test="item1.endTime!=null and item1.endTime!=''">
|
|
AND tpr.contents < #{item1.endTime}
|
|
</if>
|
|
INTERSECT
|
|
</foreach>
|
|
</if>
|
|
</trim>
|
|
) t
|
|
)
|
|
</if>
|
|
)
|
|
<if test="testQuestionsId != null and testQuestionsId!=0">
|
|
group by content
|
|
</if>
|
|
</select>
|
|
<select id="statisticsComplete" resultType="com.ccsens.tcm.bean.vo.StatisticVo$StatisticsComplete">
|
|
SELECT
|
|
MAX(CASE t.input_status WHEN 0 THEN nums ELSE 0 END ) unfinished,
|
|
MAX(CASE t.input_status WHEN 1 THEN nums ELSE 0 END ) underway,
|
|
MAX(CASE t.input_status WHEN 2 THEN nums ELSE 0 END ) completed,
|
|
MAX(CASE t.input_status WHEN 3 THEN nums ELSE 0 END ) overtime,
|
|
MAX(CASE t.input_status WHEN 4 THEN nums ELSE 0 END ) discarded
|
|
FROM(
|
|
SELECT
|
|
input_status,
|
|
count(*) as nums
|
|
FROM
|
|
t_patient_information
|
|
WHERE
|
|
rec_status = 0
|
|
<if test="hospitalId != null and hospitalId != 0">
|
|
and hospital_id = #{hospitalId}
|
|
</if>
|
|
<if test="userId != null and userId != 0">
|
|
and user_id = #{userId}
|
|
</if>
|
|
GROUP BY
|
|
input_status
|
|
) t
|
|
</select>
|
|
<select id="completeHospital" resultType="com.ccsens.tcm.bean.vo.StatisticVo$CompleteHospital">
|
|
SELECT
|
|
t.hospital_id as hospitalId,
|
|
t.`name` as hospitalName,
|
|
MAX(CASE t.input_status WHEN 0 THEN nums ELSE 0 END ) unfinished,
|
|
MAX(CASE t.input_status WHEN 1 THEN nums ELSE 0 END ) underway,
|
|
MAX(CASE t.input_status WHEN 2 THEN nums ELSE 0 END ) completed,
|
|
MAX(CASE t.input_status WHEN 3 THEN nums ELSE 0 END ) overtime,
|
|
MAX(CASE t.input_status WHEN 4 THEN nums ELSE 0 END ) discarded
|
|
FROM(
|
|
SELECT
|
|
i.hospital_id,
|
|
h.`name`,
|
|
i.input_status,
|
|
count(*) as nums
|
|
FROM
|
|
t_patient_information i
|
|
LEFT JOIN t_hospital h on i.hospital_id = h.id
|
|
WHERE
|
|
i.rec_status = 0
|
|
and h.rec_status = 0
|
|
GROUP BY
|
|
hospital_id,
|
|
input_status
|
|
) t
|
|
GROUP BY
|
|
t.hospital_id
|
|
</select>
|
|
<select id="completeDoctor" resultType="com.ccsens.tcm.bean.vo.StatisticVo$CompleteDoctor">
|
|
SELECT
|
|
t.user_id as doctorId,
|
|
t.`name` as doctorName,
|
|
MAX(CASE t.input_status WHEN 0 THEN nums ELSE 0 END ) unfinished,
|
|
MAX(CASE t.input_status WHEN 1 THEN nums ELSE 0 END ) underway,
|
|
MAX(CASE t.input_status WHEN 2 THEN nums ELSE 0 END ) completed,
|
|
MAX(CASE t.input_status WHEN 3 THEN nums ELSE 0 END ) overtime,
|
|
MAX(CASE t.input_status WHEN 4 THEN nums ELSE 0 END ) discarded
|
|
FROM(
|
|
SELECT
|
|
i.user_id,
|
|
d.`name`,
|
|
i.input_status,
|
|
count(*) as nums
|
|
FROM
|
|
t_patient_information i
|
|
LEFT JOIN t_doctor d on i.user_id = d.user_id
|
|
WHERE
|
|
i.rec_status = 0
|
|
and d.rec_status = 0
|
|
and i.hospital_id = #{hospitalId}
|
|
GROUP BY
|
|
i.user_id,
|
|
i.input_status
|
|
) t
|
|
GROUP BY
|
|
t.user_id
|
|
</select>
|
|
<select id="selBiologicalSamples" resultType="com.ccsens.tcm.bean.vo.BiologicalSamplesVo$selBiolog">
|
|
select th.name,tbs.sample_type as sampleType, tpi.hospitalization,tbs.collect_time as collectTime
|
|
from t_biological_samples tbs
|
|
left join t_patient_information tpi on tpi.id=tbs.patient_information_id and tpi.rec_status=0
|
|
left join t_hospital th on th.id=tpi.hospital_id and th.rec_status=0
|
|
where tbs.rec_status=0
|
|
<if test="hospitalId!=null">
|
|
and th.id=#{hospitalId}
|
|
</if>
|
|
<if test="sampleType!=null">
|
|
and tbs.sample_type=#{sampleType}
|
|
</if>
|
|
<if test="hospitalization!=null and hospitalization!=''">
|
|
and tpi.hospitalization like concat('%',#{hospitalization},'%')
|
|
</if>
|
|
<if test="collectTime!=null">
|
|
and tbs.collect_time=#{collectTime}
|
|
</if>
|
|
</select>
|
|
<select id="selAllYBS" resultType="com.ccsens.tcm.bean.vo.BiologicalSamplesVo$SelBiologNums">
|
|
select th.id,th.name,count(*) as nums from t_biological_samples tbs
|
|
left join t_patient_information tpi on tpi.id = tbs.patient_information_id and tpi.rec_status=0
|
|
left join t_hospital th on th.id=tpi.hospital_id and th.rec_status=0
|
|
where tbs.rec_status=0
|
|
group by th.id
|
|
</select>
|
|
<select id="adjacentTasks" resultType="com.ccsens.tcm.bean.vo.StatisticVo$RecentAnalysisVO">
|
|
select
|
|
tpr.id,
|
|
(
|
|
CASE
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 11 AND DATEDIFF( now( ), tpr.contents ) <= 17 ) THEN
|
|
DATE_FORMAT( FROM_UNIXTIME( UNIX_TIMESTAMP( tpr.contents ) + 14 * 24 * 60 * 60 ), '%Y-%m-%d' )
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 87 AND DATEDIFF( now( ), tpr.contents ) <= 93 ) THEN
|
|
DATE_FORMAT( FROM_UNIXTIME( UNIX_TIMESTAMP( tpr.contents ) + 90 * 24 * 60 * 60 ), '%Y-%m-%d' )
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 177 AND DATEDIFF( now( ), tpr.contents ) <= 183 ) THEN
|
|
DATE_FORMAT( FROM_UNIXTIME( UNIX_TIMESTAMP( tpr.contents ) + 180 * 24 * 60 * 60 ), '%Y-%m-%d' )
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 362 AND DATEDIFF( now( ), tpr.contents ) <= 368 ) THEN
|
|
DATE_FORMAT( FROM_UNIXTIME( UNIX_TIMESTAMP( tpr.contents ) + 365 * 24 * 60 * 60 ), '%Y-%m-%d' )
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 0 AND DATEDIFF( now( ), tpr.contents ) <= 3 ) THEN
|
|
DATE_FORMAT( FROM_UNIXTIME( UNIX_TIMESTAMP( tpr.contents ) + 1 * 24 * 60 * 60 ), '%Y-%m-%d' )
|
|
END
|
|
) as shijian,tpi.hospitalization,(
|
|
CASE
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 11 AND DATEDIFF( now( ), tpr.contents ) <= 17 ) THEN
|
|
'14天数据搜集'
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 87 AND DATEDIFF( now( ), tpr.contents ) <= 93 ) THEN
|
|
'90天数据搜集'
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 177 AND DATEDIFF( now( ), tpr.contents ) <= 183 ) THEN
|
|
'180天随访'
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 362 AND DATEDIFF( now( ), tpr.contents ) <= 368 ) THEN
|
|
'360天随访'
|
|
WHEN ( DATEDIFF( now( ), tpr.contents ) >= 0 AND DATEDIFF( now( ), tpr.contents ) <= 3 ) THEN
|
|
'第一次数据收集'
|
|
END
|
|
) as task from t_patient_record tpr
|
|
left join t_patient_information tpi on tpi.id=tpr.patient_id and tpi.rec_status=0
|
|
where tpr.rec_status=0
|
|
and tpr.test_questions_id=#{param.testQuestionsId}
|
|
and (
|
|
( DATEDIFF( now( ), tpr.contents ) >= 11 AND DATEDIFF( now( ), tpr.contents ) <= 17 )
|
|
OR ( DATEDIFF( now( ), tpr.contents ) >= 87 AND DATEDIFF( now( ), tpr.contents ) <= 93 )
|
|
OR ( DATEDIFF( now( ), tpr.contents ) >= 177 AND DATEDIFF( now( ), tpr.contents ) <= 183 )
|
|
OR ( DATEDIFF( now( ), tpr.contents ) >= 362 AND DATEDIFF( now( ), tpr.contents ) <= 368 )
|
|
OR ( DATEDIFF( now( ), tpr.contents ) >= 0 AND DATEDIFF( now( ), tpr.contents ) <= 3 )
|
|
)
|
|
and tpr.user_id=#{userId}
|
|
</select>
|
|
<resultMap id="selPatientProgress1" type="com.ccsens.tcm.bean.vo.StatisticVo$PatientProgressVo">
|
|
<id property="id" column="id" />
|
|
<result property="hospitalization" column="hospitalization" />
|
|
<collection property="collectTime" ofType="java.lang.Integer">
|
|
<result column="collectTime"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="selPatientProgress" resultMap="selPatientProgress1">
|
|
SELECT
|
|
tpi.id,
|
|
tpi.hospitalization,
|
|
tpr.collect_time collectTime
|
|
FROM
|
|
t_patient_record tpr
|
|
, t_patient_information tpi
|
|
WHERE
|
|
tpr.rec_status = 0
|
|
and tpi.rec_status = 0
|
|
AND tpi.id = tpr.patient_id
|
|
AND tpi.input_status IN ( 0, 1, 3 )
|
|
AND tpr.user_id = #{userId}
|
|
AND tpr.created_at > DATE_SUB( now( ), INTERVAL 1 YEAR )
|
|
GROUP BY
|
|
tpr.patient_id,tpr.collect_time
|
|
</select>
|
|
<select id="stringLists" resultType="java.lang.String">
|
|
select distinct tpr.contents from t_patient_record tpr
|
|
where tpr.rec_status=0
|
|
and tpr.test_questions_id=#{testQuestionsId}
|
|
</select>
|
|
</mapper>
|