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.
300 lines
12 KiB
300 lines
12 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.QuestionDao">
|
|
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.Question">
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
<result column="question" jdbcType="VARCHAR" property="question" />
|
|
<result column="code" jdbcType="VARCHAR" property="code" />
|
|
<result column="sort" jdbcType="INTEGER" property="sort" />
|
|
<result column="units" jdbcType="VARCHAR" property="units" />
|
|
<result column="type" jdbcType="TINYINT" property="type" />
|
|
<result column="relevance_option_id" jdbcType="BIGINT" property="relevanceOptionId" />
|
|
<result column="search_criteria" jdbcType="TINYINT" property="searchCriteria" />
|
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
|
<result column="operator" jdbcType="BIGINT" property="operator" />
|
|
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
|
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
|
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
|
|
</resultMap>
|
|
<insert id="insertBatch">
|
|
replace into t_question (id, question, code,
|
|
sort, units, type,
|
|
relevance_option_id, search_criteria, remark)
|
|
values
|
|
<foreach collection="list" item="question" separator=",">
|
|
(#{question.id,jdbcType=BIGINT}, #{question.question,jdbcType=VARCHAR}, #{question.code,jdbcType=VARCHAR},
|
|
#{question.sort,jdbcType=INTEGER}, #{question.units,jdbcType=VARCHAR}, #{question.type,jdbcType=TINYINT},
|
|
#{question.relevanceOptionId,jdbcType=BIGINT}, #{question.searchCriteria,jdbcType=TINYINT}, #{question.remark,jdbcType=VARCHAR})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<resultMap id="queryQuestionByCode" type="com.ccsens.tcm.bean.vo.QuestionVo$CodeQuestionVo">
|
|
<id column="qid" jdbcType="BIGINT" property="id" />
|
|
<result column="qquestion" jdbcType="VARCHAR" property="question" />
|
|
<result column="qcode" jdbcType="VARCHAR" property="code" />
|
|
<result column="qsort" jdbcType="INTEGER" property="sort" />
|
|
<result column="qunits" jdbcType="VARCHAR" property="units" />
|
|
<result column="qtype" jdbcType="TINYINT" property="type" />
|
|
<result column="qrelevance_option_id" jdbcType="BIGINT" property="relevanceOptionId" />
|
|
<result column="qsearch_criteria" jdbcType="TINYINT" property="searchCriteria" />
|
|
<result column="qremark" jdbcType="VARCHAR" property="remark" />
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$QuestionOptionVo">
|
|
<id column="oid" jdbcType="BIGINT" property="id" />
|
|
<result column="oquestion_id" jdbcType="BIGINT" property="questionId" />
|
|
<result column="osort" jdbcType="INTEGER" property="sort" />
|
|
<result column="oshow_value" jdbcType="VARCHAR" property="showValue" />
|
|
<result column="osubmit_value" jdbcType="VARCHAR" property="submitValue" />
|
|
<result column="oafter_operation" jdbcType="TINYINT" property="afterOperation" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<select id="queryQuestionByCode" resultMap="queryQuestionByCode">
|
|
SELECT
|
|
q.id as qid,
|
|
q.question as qquestion,
|
|
q.`code` as qcode,
|
|
q.sort as qsort,
|
|
q.units as qunits,
|
|
q.type as qtype,
|
|
q.relevance_option_id as qrelevance_option_id,
|
|
q.search_criteria as qsearch_criteria,
|
|
q.remark as qremark,
|
|
o.id as oid,
|
|
o.question_id as oquestion_id,
|
|
o.sort as osort,
|
|
o.show_value as oshow_value,
|
|
o.submit_value as osubmit_value,
|
|
o.after_operation as oafter_operation
|
|
FROM
|
|
t_question q
|
|
LEFT JOIN t_question_option o on q.id = o.question_id and o.rec_status = 0
|
|
WHERE
|
|
q.relevance_option_id = 0
|
|
and q.rec_status = 0
|
|
and q.`code` = #{code}
|
|
</select>
|
|
|
|
<select id="queryQuestionByOption" resultMap="queryQuestionByCode">
|
|
SELECT
|
|
q.id as qid,
|
|
q.question as qquestion,
|
|
q.`code` as qcode,
|
|
q.sort as qsort,
|
|
q.units as qunits,
|
|
q.type as qtype,
|
|
q.relevance_option_id as qrelevance_option_id,
|
|
q.search_criteria as qsearch_criteria,
|
|
q.remark as qremark,
|
|
o.id as oid,
|
|
o.question_id as oquestion_id,
|
|
o.sort as osort,
|
|
o.show_value as oshow_value,
|
|
o.submit_value as osubmit_value,
|
|
o.after_operation as oafter_operation
|
|
FROM
|
|
t_question q
|
|
LEFT JOIN t_question_option o on q.id = o.question_id and o.rec_status = 0
|
|
WHERE
|
|
q.rec_status = 0
|
|
and q.relevance_option_id = #{optionId}
|
|
</select>
|
|
|
|
<resultMap id="getQuestionByCodeAndPatientId" type="com.ccsens.tcm.bean.vo.QuestionVo$PatientQuestion">
|
|
<id column="qid" jdbcType="BIGINT" property="id" />
|
|
<result column="qquestion" jdbcType="VARCHAR" property="question" />
|
|
<result column="qsort" jdbcType="INTEGER" property="sort" />
|
|
<result column="qunits" jdbcType="VARCHAR" property="units" />
|
|
<result column="qtype" jdbcType="TINYINT" property="type" />
|
|
<result column="qremark" jdbcType="VARCHAR" property="remark" />
|
|
<result column="recordId" jdbcType="VARCHAR" property="recordId" />
|
|
<result column="answer" jdbcType="VARCHAR" property="answer" />
|
|
<result column="explains" jdbcType="VARCHAR" property="explains" />
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$PatientOption">
|
|
<id column="oid" jdbcType="BIGINT" property="id" />
|
|
<result column="osort" jdbcType="INTEGER" property="sort" />
|
|
<result column="oshow_value" jdbcType="VARCHAR" property="showValue" />
|
|
<result column="osubmit_value" jdbcType="VARCHAR" property="submitValue" />
|
|
<result column="oafter_operation" jdbcType="TINYINT" property="afterOperation" />
|
|
<result column="choose" jdbcType="TINYINT" property="choose" />
|
|
<result column="otherInformation" jdbcType="VARCHAR" property="otherInformation" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
|
|
<select id="getQuestionByCodeAndPatientId" resultMap="getQuestionByCodeAndPatientId">
|
|
SELECT
|
|
*,
|
|
tpr.contents AS explains
|
|
FROM
|
|
(
|
|
SELECT
|
|
q.id as qid,
|
|
q.question as qquestion,
|
|
q.sort as qsort,
|
|
q.units as qunits,
|
|
q.type as qtype,
|
|
q.remark as qremark,
|
|
o.id as oid,
|
|
o.sort as osort,
|
|
o.show_value as oshow_value,
|
|
o.submit_value as osubmit_value,
|
|
o.after_operation as oafter_operation,
|
|
IF (q.type > 2 AND q.type < 13 AND q.type != 6,
|
|
IF ((o.submit_value = r.contents) or(r.contents_type = 1 AND SUBSTRING_INDEX( r.contents, ':', 1 ) = o.submit_value), TRUE, FALSE ),
|
|
NULL
|
|
) AS choose,
|
|
r.patient_id,
|
|
r.id as recordId,
|
|
if(r.collect_time is null, 0,r.collect_time) as collect_time,
|
|
r.contents as answer,
|
|
|
|
if(r.contents_type = 1 and SUBSTRING_INDEX(r.contents,':',1) = o.submit_value,
|
|
SUBSTRING(r.contents,char_length(o.submit_value)+2),null
|
|
) as otherInformation
|
|
FROM
|
|
t_question q
|
|
LEFT JOIN t_question_option o on q.id = o.question_id and o.rec_status = 0
|
|
LEFT JOIN t_patient_record r on r.test_questions_id = q.id and r.rec_status = 0 and r.patient_id = #{patientId}
|
|
<if test="nums != null">
|
|
and collect_time = #{nums}
|
|
</if>
|
|
WHERE
|
|
q.relevance_option_id = 0
|
|
and q.rec_status = 0
|
|
and q.`code` = #{code}
|
|
|
|
) qq,
|
|
t_patient_record tpr
|
|
where
|
|
tpr.test_questions_id = qq.qid
|
|
AND tpr.contents_type = 2
|
|
AND tpr.patient_id = #{patientId}
|
|
AND tpr.collect_time = #{nums}
|
|
AND tpr.rec_status = 0
|
|
ORDER BY qq.qsort,qq.osort,qq.choose DESC,-qq.otherInformation DESC
|
|
</select>
|
|
|
|
<resultMap id="getQuestionByOptionId" type="com.ccsens.tcm.bean.vo.QuestionVo$PatientQuestion">
|
|
<id column="qid" jdbcType="BIGINT" property="id" />
|
|
<result column="qquestion" jdbcType="VARCHAR" property="question" />
|
|
<result column="qsort" jdbcType="INTEGER" property="sort" />
|
|
<result column="qunits" jdbcType="VARCHAR" property="units" />
|
|
<result column="qtype" jdbcType="TINYINT" property="type" />
|
|
<result column="qremark" jdbcType="VARCHAR" property="remark" />
|
|
<result column="recordId" jdbcType="VARCHAR" property="recordId" />
|
|
<result column="answer" jdbcType="VARCHAR" property="answer" />
|
|
<result column="explains" jdbcType="VARCHAR" property="explains" />
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$PatientOption">
|
|
<id column="oid" jdbcType="BIGINT" property="id" />
|
|
<result column="osort" jdbcType="INTEGER" property="sort" />
|
|
<result column="oshow_value" jdbcType="VARCHAR" property="showValue" />
|
|
<result column="osubmit_value" jdbcType="VARCHAR" property="submitValue" />
|
|
<result column="oafter_operation" jdbcType="TINYINT" property="afterOperation" />
|
|
<result column="choose" jdbcType="TINYINT" property="choose" />
|
|
<result column="otherInformation" jdbcType="VARCHAR" property="otherInformation" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<select id="getQuestionByOptionId" resultMap="getQuestionByOptionId">
|
|
SELECT
|
|
*
|
|
FROM
|
|
(
|
|
SELECT
|
|
q.id as qid,
|
|
q.question as qquestion,
|
|
q.sort as qsort,
|
|
q.units as qunits,
|
|
q.type as qtype,
|
|
q.remark as qremark,
|
|
o.id as oid,
|
|
o.sort as osort,
|
|
o.show_value as oshow_value,
|
|
o.submit_value as osubmit_value,
|
|
o.after_operation as oafter_operation,
|
|
if(q.type > 2 and q.type < 13 and q.type != 6,
|
|
IF ((o.submit_value = r.contents) or(r.contents_type = 1 AND SUBSTRING_INDEX( r.contents, ':', 1 ) = o.submit_value), TRUE, FALSE ),
|
|
null) as choose,
|
|
r.patient_id,
|
|
r.id as recordId,
|
|
r.contents as answer,
|
|
if(r.contents_type = 2,r.contents,null) as explains,
|
|
|
|
if(r.contents_type = 1 and SUBSTRING_INDEX(r.contents,':',1) = o.submit_value,
|
|
SUBSTRING(r.contents,char_length(o.submit_value)+2),null
|
|
) as otherInformation
|
|
FROM
|
|
t_question q
|
|
LEFT JOIN t_question_option o on q.id = o.question_id and o.rec_status = 0
|
|
LEFT JOIN t_patient_record r on r.test_questions_id = q.id and r.rec_status = 0 and r.patient_id = #{patientId}
|
|
<if test="nums != null">
|
|
and collect_time = #{nums}
|
|
</if>
|
|
WHERE
|
|
q.rec_status = 0
|
|
and q.relevance_option_id = #{optionId}
|
|
)a
|
|
ORDER BY a.qsort,a.osort,a.choose DESC,-a.otherInformation DESC
|
|
</select>
|
|
<resultMap id="queryQuestionMap" type="com.ccsens.tcm.bean.vo.QuestionVo$subjectLists">
|
|
<id column="id" property="id"/>
|
|
<result column="code" property="code"/>
|
|
<result column="name" property="name"/>
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$subjectLists">
|
|
<id column="id1" property="id"/>
|
|
<result column="code1" property="code"/>
|
|
<result column="name1" property="name"/>
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$subjectLists">
|
|
<id property="id" column="id2"/>
|
|
<result property="name" column="question"/>
|
|
</collection>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="queryQuestion" resultMap="queryQuestionMap">
|
|
SELECT
|
|
trc.id,
|
|
trc.`code`,
|
|
trc.`name`,
|
|
trc1.id AS id1,
|
|
trc1.`code` AS code1,
|
|
trc1.`name` AS name1,
|
|
tq.id AS id2,
|
|
tq.question
|
|
FROM
|
|
t_report_code trc
|
|
LEFT JOIN t_report_code trc1 ON trc1.parent_code = trc.CODE
|
|
AND trc1.LEVEL = 2
|
|
AND trc1.rec_status = 0
|
|
LEFT JOIN t_question tq ON tq.CODE = trc1.CODE
|
|
AND tq.rec_status = 0
|
|
WHERE
|
|
trc.LEVEL = 1
|
|
AND trc.rec_status =0
|
|
order by trc.sort,trc1.sort,tq.sort
|
|
</select>
|
|
<resultMap id="queryQuestion1Map" type="com.ccsens.tcm.bean.vo.QuestionVo$subjectLists">
|
|
<id column="id" property="id"/>
|
|
<result column="code" property="code"/>
|
|
<result column="name" property="name"/>
|
|
<collection property="optionVos" ofType="com.ccsens.tcm.bean.vo.QuestionVo$subjectLists">
|
|
<id property="id" column="id2"/>
|
|
<result column="question" property="name"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="queryQuestion1" resultMap="queryQuestion1Map">
|
|
select trc.id,
|
|
trc.`code`,
|
|
trc.`name`,
|
|
tq.id AS id2,
|
|
tq.question
|
|
FROM
|
|
t_report_code trc, t_question tq
|
|
WHERE
|
|
trc.LEVEL = 1
|
|
AND trc.rec_status =0
|
|
and tq.CODE = trc.CODE
|
|
AND tq.rec_status = 0
|
|
order by trc.sort,tq.sort
|
|
</select>
|
|
|
|
</mapper>
|