<iftest="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 )">
<iftest="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 ) or (reportParams != null and reportParams.size() != 0)">
and tpi.id IN (
and tpi.id IN (
SELECT DISTINCT
SELECT DISTINCT
( t.patient_id )
( t.patient_id )
@ -106,6 +106,37 @@
INTERSECT
INTERSECT
</foreach>
</foreach>
</if>
</if>
<iftest="reportParams != null and reportParams.size() != 0">
<foreachcollection="reportParams"item="item">
<iftest="item.code != null and item.code != '' and (item.start != null or item.end != null)">
SELECT
r.patient_id
FROM
question.t_ht_patient_score s,
question.t_ht_question q,
question.t_ht_patient_report r
WHERE
s.question_id = q.id
AND s.patient_report_id = r.id
AND s.question_parent_code = #{item.code}
AND s.type IN ( 0, 2 )
AND s.is_del = 0
AND q.is_del = 0
GROUP BY
patient_report_id
HAVING
<trimsuffixOverrides="AND">
<iftest="item.start != null">
sum( score ) >= #{item.start} AND
</if>
<iftest="item.end != null">
sum( score ) <= #{item.end} AND
</if>
</trim>
INTERSECT
</if>
</foreach>
</if>
</trim>
</trim>
) t
) t
)
)
@ -195,7 +226,7 @@
<iftest="inputStatus !=null">
<iftest="inputStatus !=null">
and tpi.input_status=#{inputStatus}
and tpi.input_status=#{inputStatus}
</if>
</if>
<iftest="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 )">
<iftest="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 ) or (reportParams != null and reportParams.size() != 0)">
and tpi.id IN (
and tpi.id IN (
SELECT DISTINCT
SELECT DISTINCT
( t.patient_id )
( t.patient_id )
@ -237,6 +268,37 @@
INTERSECT
INTERSECT
</foreach>
</foreach>
</if>
</if>
<iftest="reportParams != null and reportParams.size() != 0">
<foreachcollection="reportParams"item="item">
<iftest="item.code != null and item.code != '' and (item.start != null or item.end != null)">