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.
345 lines
14 KiB
345 lines
14 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,
|
|
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="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}
|
|
<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}
|
|
<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="java.lang.Integer">
|
|
select 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>
|
|
</select>
|
|
<select id="countAnalysis" resultType="com.ccsens.tcm.bean.vo.StatisticVo$SelGroupList">
|
|
<if test="testQuestionsId!=null and testQuestionsId!=0">
|
|
|
|
select if(locate('其他',tpr.contents),'其他',tpr.contents) as content,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
|
|
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,
|
|
count( * ) AS nums
|
|
FROM
|
|
t_patient_information tpi
|
|
|
|
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}
|
|
<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}
|
|
<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>
|
|
</mapper>
|