|
|
@ -1,50 +1,50 @@ |
|
|
|
<?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> |
|
|
|
<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 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 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 |
|
|
@ -56,13 +56,13 @@ |
|
|
|
GROUP BY t1.code |
|
|
|
order by t1.type,t1.sort |
|
|
|
</select> |
|
|
|
<select id="queryNPIScore" resultType="java.util.Map"> |
|
|
|
<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 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 , |
|
|
@ -73,75 +73,149 @@ |
|
|
|
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"> |
|
|
|
<select id="ignoreComplete"> |
|
|
|
update t_ht_patient_report set complete_status = 2 , show_status = 0 |
|
|
|
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} |
|
|
|
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 |
|
|
|
and is_del = 0 |
|
|
|
</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="patientId != null"> |
|
|
|
and patient_id = #{patientId, jdbcType=BIGINT} |
|
|
|
<if test="pasi != null"> |
|
|
|
and r.pasi = #{pasi} |
|
|
|
</if> |
|
|
|
and show_status = 1 |
|
|
|
and is_del = 0 |
|
|
|
</where> |
|
|
|
order by create_time desc |
|
|
|
<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="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 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 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> |
|
|
|
<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> |
|
|
|
|
|
|
|
<resultMap id="queryReportAnswer" type="com.ccsens.ht.bean.vo.PatientReportVo$ReportDetailAnswer"> |
|
|
|
<id column="parentCode" property="parentCode"/> |
|
|
|
<collection property="questionList" ofType="com.ccsens.ht.bean.vo.PatientReportVo$QuestionInfo"> |
|
|
|
<id column="questionId" property="questionId"/> |
|
|
|
<result column="questionName" property="questionName"/> |
|
|
|
<result column="type" property="type"/> |
|
|
|
<result column="operateType" property="operateType"/> |
|
|
|
<result column="otherValue" property="otherValue"/> |
|
|
|
<collection property="answers" ofType="com.ccsens.ht.bean.vo.PatientReportVo$Answer"> |
|
|
|
<id column="optionName" property="optionName"/> |
|
|
|
<result column="answer" property="answer"/> |
|
|
|
</collection> |
|
|
|
</collection> |
|
|
|
</resultMap> |
|
|
|
<select id="queryReportAnswer" resultMap="queryReportAnswer"> |
|
|
|
|
|
|
|
SELECT |
|
|
|
a.parentCode, |
|
|
|
a.questionId, |
|
|
|
a.questionName, |
|
|
|
a.type, |
|
|
|
a.operateType, |
|
|
|
a.optionName, |
|
|
|
t.answer, |
|
|
|
r.record_value as otherValue |
|
|
|
FROM |
|
|
|
( |
|
|
|
SELECT |
|
|
|
q.id as questionId, |
|
|
|
q.parent_code, |
|
|
|
r.`name` as parentCode, |
|
|
|
q.question as questionName, |
|
|
|
q.type as type, |
|
|
|
q.operate_type as operateType |
|
|
|
,o.`name` as optionName |
|
|
|
,o.id as optionId |
|
|
|
,o.sort |
|
|
|
FROM |
|
|
|
t_ht_question q |
|
|
|
LEFT JOIN t_ht_report r on q.parent_code = r.`code` |
|
|
|
LEFT JOIN t_ht_question_option o on q.id = o.question_id |
|
|
|
WHERE |
|
|
|
q.evaluation_code = #{evaluationCode} |
|
|
|
and q.is_del = 0 |
|
|
|
and r.is_del = 0 |
|
|
|
and o.is_del = 0 |
|
|
|
GROUP BY q.id ,o.`name` |
|
|
|
) a |
|
|
|
LEFT JOIN |
|
|
|
( |
|
|
|
SELECT * FROM t_ht_patient_question_record WHERE patient_report_id = #{id} and is_del = 0 |
|
|
|
)r on r.question_id = a.questionId |
|
|
|
LEFT JOIN |
|
|
|
( |
|
|
|
SELECT |
|
|
|
s.id, |
|
|
|
s.question_id, |
|
|
|
o.id as optionId, |
|
|
|
o.`name` as optionName, |
|
|
|
if(o.type = 'hidden',s.score,o.display) as answer |
|
|
|
FROM |
|
|
|
t_ht_patient_score s |
|
|
|
LEFT JOIN t_ht_question_option o |
|
|
|
on s.option_id = o.id |
|
|
|
WHERE |
|
|
|
s.patient_report_id = #{id} |
|
|
|
and s.is_del = 0 |
|
|
|
and o.is_del = 0 |
|
|
|
) t |
|
|
|
on a.optionName = t.optionName |
|
|
|
and a.questionId = t.question_id |
|
|
|
ORDER BY a.questionId ,a.sort |
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
</mapper> |