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.
146 lines
7.5 KiB
146 lines
7.5 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.ht.persist.dao.HtPatientReportDao">
|
|
<resultMap id="BaseResultMap" type="com.ccsens.ht.bean.vo.PatientReportVo$ReprotPatient">
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
|
<result column="patient_id" jdbcType="BIGINT" property="patientId" />
|
|
<result column="patient_age" jdbcType="TINYINT" property="patientAge" />
|
|
<result column="doctor_id" jdbcType="BIGINT" property="doctorId" />
|
|
<result column="doctor_name" jdbcType="VARCHAR" property="doctorName" />
|
|
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
|
|
<result column="initial_impression" jdbcType="VARCHAR" property="initialImpression" />
|
|
<result column="clinical_diagnosis" jdbcType="VARCHAR" property="clinicalDiagnosis" />
|
|
<result column="pasi" jdbcType="TINYINT" property="pasi" />
|
|
<result column="department" jdbcType="VARCHAR" property="department" />
|
|
<result column="bed_number" jdbcType="VARCHAR" property="bedNumber" />
|
|
<result column="report_time" jdbcType="BIGINT" property="reportTime" />
|
|
<result column="check_time" jdbcType="BIGINT" property="checkTime" />
|
|
<result column="url" jdbcType="VARCHAR" property="url" />
|
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
|
<result column="patient_name" jdbcType="VARCHAR" property="patientName"/>
|
|
<result column="patient_number" jdbcType="VARCHAR" property="patientNumber" />
|
|
<result column="hospital_number" jdbcType="VARCHAR" property="hospitalNumber" />
|
|
<result column="sex" jdbcType="TINYINT" property="sex" />
|
|
<result column="educational_status" jdbcType="TINYINT" property="educationalStatus" />
|
|
<result column="educational_status_unit" jdbcType="VARCHAR" property="educationalStatusUnit" />
|
|
<result column="career" jdbcType="TINYINT" property="career" />
|
|
<result column="hospital" jdbcType="VARCHAR" property="hospital" />
|
|
</resultMap>
|
|
<resultMap id="ScoreMap" type="com.ccsens.ht.bean.vo.PatientReportVo$ReportScore">
|
|
<result column="code" jdbcType="VARCHAR" property="code"/>
|
|
<result column="parent_code" jdbcType="VARCHAR" property="parentCode"/>
|
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
|
<result column="description" jdbcType="VARCHAR" property="description"/>
|
|
<result column="total_score" jdbcType="INTEGER" property="totalScore"/>
|
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
|
<result column="type" jdbcType="TINYINT" property="type"/>
|
|
<result column="score" jdbcType="INTEGER" property="score"/>
|
|
</resultMap>
|
|
|
|
<select id="queryReportResult" resultMap="BaseResultMap">
|
|
select r.*, d.name as doctor_name, p.name as patient_name, p.sex, p.educational_status, p.educational_status_unit, p.career, p.hospital_number, p.patient_number
|
|
from t_ht_patient_report r, t_ht_patient p, t_ht_doctor d
|
|
where r.patient_id = p.id and r.doctor_id = d.id and r.id = #{id, jdbcType=BIGINT}
|
|
and r.is_del = 0 and p.is_del = 0 and d.is_del = 0
|
|
</select>
|
|
<select id="queryReportScore" resultMap="ScoreMap">
|
|
select t1.code,t1.name, t1.description, t1.total_score, t1.remark,t1.type,t1.parent_code, sum(t2.score) as score
|
|
from
|
|
(select code,name, description, total_score, remark, type, parent_code, sort from t_ht_report where is_show = 1 and is_del = 0) t1
|
|
left join t_ht_patient_score t2
|
|
on t1.code = t2.question_parent_code and
|
|
(
|
|
(t2.patient_report_id = #{id, jdbcType=BIGINT} and t2.type in (0,2) and t2.is_del = 0) or t2.id is null
|
|
)
|
|
GROUP BY t1.code
|
|
order by t1.type,t1.sort
|
|
</select>
|
|
<select id="queryNPIScore" resultType="java.util.Map">
|
|
select option_name as optionName, sum(score) as score
|
|
from t_ht_patient_score
|
|
where patient_report_id = #{id, jdbcType=BIGINT} and question_parent_code = 'NPI'
|
|
and option_name in ('carer','result') and is_del = 0 group by option_name;
|
|
</select>
|
|
<select id="checkComplete" resultType="com.ccsens.ht.bean.vo.PatientReportVo$Complete">
|
|
select r.id, r.name, p.id as patientId, p.name as patientName, p.idcard as patientIdCard,
|
|
r.create_time as createTime,
|
|
concat('检测到您在', r.create_time, '为患者', p.name,'的检测报告尚未完成,是否继续?') as description ,
|
|
if(r.id = null , 0, 1) as hasUnfinished
|
|
from t_ht_patient_report r, t_ht_patient p, t_ht_doctor d
|
|
where r.patient_id = p.id and r.doctor_id = d.id
|
|
and d.user_id = #{userId, jdbcType=BIGINT} and d.audit_state = 1
|
|
and r.complete_status = 0 and d.is_del = 0 and r.is_del = 0 and p.is_del = 0
|
|
order by r.create_time desc limit 1;
|
|
</select>
|
|
<select id="ignoreComplete">
|
|
update t_ht_patient_report set complete_status = 2
|
|
where id = #{id, jdbcType=BIGINT} and complete_status = 0 and is_del = 0 and doctor_id in
|
|
(select doctor_id from t_ht_doctor where user_id = #{userId, jdbcType=BIGINT} and audit_state = 1 and is_del = 0)
|
|
</select>
|
|
<select id="queryReportName" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName">
|
|
select id, name, url, doctor_id as doctorId, 0 as authority from t_ht_patient_report
|
|
<where>
|
|
<if test="doctorId != null">
|
|
and doctor_id = #{doctorId, jdbcType=BIGINT}
|
|
</if>
|
|
<if test="patientId != null">
|
|
and patient_id = #{patientId, jdbcType=BIGINT}
|
|
</if>
|
|
and show_status = 1
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
<select id="queryAllReports" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName">
|
|
select r.id, r.name, r.url, r.doctor_id as doctorId, 1 as authority
|
|
from t_ht_patient_report r, t_ht_patient p
|
|
where r.patient_id = p.id
|
|
<if test="patientSex != null">
|
|
and p.sex = #{patientSex}
|
|
</if>
|
|
<if test="startAge != null">
|
|
and r.patient_age > #{startAge}
|
|
</if>
|
|
<if test="endAge != null">
|
|
and r.patient_age < #{endAge}
|
|
</if>
|
|
<if test="clinicalDiagnosis != null and clinicalDiagnosis != ''">
|
|
and r.clinical_diagnosis = #{clinicalDiagnosis}
|
|
</if>
|
|
<if test="pasi != null">
|
|
and r.pasi = #{pasi}
|
|
</if>
|
|
<if test="startTime != null">
|
|
and r.report_time >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and r.report_time <= #{endTime}
|
|
</if>
|
|
and r.show_status = 1
|
|
and r.is_del = 0
|
|
order by r.create_time desc
|
|
</select>
|
|
<select id="countByClinicalDiagnosis" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ClinicalDiagnosis">
|
|
select clinical_diagnosis as diagnosis, count(*) as count from t_ht_patient_report
|
|
where is_del = 0 and show_status = 1 group by diagnosis
|
|
</select>
|
|
<select id="countBySexAndAge" resultType="com.ccsens.ht.bean.vo.PatientReportVo$AgeAndSex">
|
|
select r.patient_age div 10 * 10 as ageLevel, p.sex as sex, count(*) as count from t_ht_patient_report r, t_ht_patient p
|
|
where r.patient_id = p.id and r.is_del = 0 and r.show_status = 1 group by ageLevel, sex
|
|
order by ageLevel, sex
|
|
</select>
|
|
<select id="countByDay" resultType="com.ccsens.ht.bean.vo.PatientReportVo$Day">
|
|
select FROM_UNIXTIME(report_time div 1000, '%Y-%m-%d') as dateDay, count(*) as count
|
|
from t_ht_patient_report
|
|
where is_del = 0 and show_status = 1
|
|
<if test="startTime != null">
|
|
and report_time >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
and report_time < #{endTime}
|
|
</if>
|
|
group by dateDay
|
|
</select>
|
|
|
|
|
|
</mapper>
|