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.
 
 

147 lines
6.3 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.HtQuestionDao">
<resultMap id="BaseResultMap" type="com.ccsens.ht.bean.vo.QuestionVo$Question">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="evaluationCode" jdbcType="VARCHAR" property="evaluationCode" />
<result column="parentCode" jdbcType="VARCHAR" property="parentCode" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="question" jdbcType="VARCHAR" property="question" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="recordType" jdbcType="VARCHAR" property="recordType" />
<result column="recordContent" jdbcType="VARCHAR" property="recordContent" />
<result column="operateType" jdbcType="TINYINT" property="operateType" />
<result column="recodeStarttime" jdbcType="TINYINT" property="recodeStarttime" />
<result column="timeWabei" jdbcType="TINYINT" property="timeWabei" />
<result column="allowClear" jdbcType="TINYINT" property="allowClear" />
<result column="clearTimes" jdbcType="INTEGER" property="clearTimes" />
<result column="timingLength" jdbcType="INTEGER" property="timingLength" />
<collection property="questionRecords" ofType="com.ccsens.ht.bean.vo.QuestionVo$QuestionRecord">
<id column="rid" property="id"></id>
<result column="rCalcType" property="calcType"/>
<result column="rShowTitle" property="showTitle"/>
<result column="rShowForm" property="showForm"/>
<result column="rDefaultValue" property="defaultValue"/>
<result column="rType" property="type"/>
<result column="rRemark" property="remark"/>
<collection property="answers" ofType="String">
<id column="answer"/>
</collection>
<collection property="options" ofType="com.ccsens.ht.bean.vo.QuestionVo$RecordOption">
<id column="optionId" property="id"/>
<result column="dataKey" property="dataKey"/>
<result column="dataValue" property="dataValue"/>
</collection>
</collection>
</resultMap>
<insert id="insertBatch" parameterType="java.util.List">
replace into t_ht_question (id, evaluation_code, parent_code,
sort, question, type,
record_type, record_content, relation_code, relation_id,
operate_type, recode_starttime, time_wabei,
allow_clear, clear_times, timing_length,
remark, create_time, update_time,
is_del)
values
<foreach collection="list" item="question" separator=",">
(#{question.id,jdbcType=BIGINT}, #{question.evaluationCode,jdbcType=VARCHAR}, #{question.parentCode,jdbcType=VARCHAR},
#{question.sort,jdbcType=INTEGER}, #{question.question,jdbcType=VARCHAR}, #{question.type,jdbcType=TINYINT},
#{question.recordType,jdbcType=VARCHAR}, #{question.recordContent,jdbcType=VARCHAR}, #{question.relationCode,jdbcType=VARCHAR},
<choose>
<when test="question.relationId == null">
0,
</when>
<otherwise>
#{question.relationId},
</otherwise>
</choose>
#{question.operateType,jdbcType=TINYINT}, #{question.recodeStarttime,jdbcType=TINYINT}, #{question.timeWabei,jdbcType=TINYINT},
#{question.allowClear,jdbcType=TINYINT}, #{question.clearTimes,jdbcType=INTEGER}, #{question.timingLength,jdbcType=INTEGER},
#{question.remark,jdbcType=VARCHAR}, #{question.createTime,jdbcType=TIMESTAMP}, now(), 0 )
</foreach>
</insert>
<select id="selectMaxSort" resultType="Integer">
select
max(sort)
from t_ht_question
where evaluation_code = #{code, jdbcType=VARCHAR}
</select>
<select id="queryShareAnswer" resultType="com.ccsens.ht.bean.vo.QuestionVo$ShareAnswer">
SELECT
r.relevance_id as shareAnswerId,
if(count(s.id) = 0, false,true) as showShareAnswer
FROM
t_ht_question_relevance r
LEFT JOIN
(SELECT * FROM t_ht_patient_score WHERE patient_report_id = #{patientReportId} and is_del = 0) s
on r.relevance_id = s.question_id
WHERE
r.question_id = #{questionId}
GROUP BY r.relevance_id
</select>
<select id="queryQuestionAndRecord" resultMap="BaseResultMap">
SELECT
*
FROM
(
SELECT
q.id,
q.evaluation_code AS evaluationCode,
q.parent_code AS parentCode,
q.sort,
q.question,
q.type,
q.record_type AS recordType,
q.record_content AS recordContent,
q.operate_type AS operateType,
q.recode_starttime AS recodeStarttime,
q.time_wabei AS timeWabei,
q.allow_clear AS allowClear,
q.clear_times AS clearTimes,
q.timing_length AS timingLength
FROM
t_ht_question q
WHERE
q.evaluation_code = #{code}
AND q.sort = #{num}
AND q.relation_id = 0
AND q.is_del = 0
LIMIT 1
) q
LEFT JOIN (
SELECT
r.id AS rId,
r.question_id,
r.calc_type AS rCalcType,
r.show_title AS rShowTitle,
r.show_form AS rShowForm,
r.default_value AS rDefaultValue,
r.type AS rType,
r.remark AS rRemark,
qr.answer
FROM
( SELECT * FROM t_ht_question_record WHERE record_type = 1 AND is_del = 0 ) r
LEFT JOIN ( SELECT * FROM t_ht_patient_report_record_desc WHERE
<choose>
<when test="patientReportId != null and patientReportId != 0">
patient_report_id = #{patientReportId} AND is_del = 0
</when>
<otherwise>
1=2
</otherwise>
</choose>
) qr ON r.id = qr.record_id
ORDER BY
r.question_id,
r.sort
) r ON q.id = r.question_id
left join
(select id as optionId,
data_key as dataKey,
data_value as dataValue,
question_record_id from t_ht_question_record_option where is_del = 0) o
on r.rId = o.question_record_id
</select>
</mapper>