select if(LOCATE('其他'),'其他',tpr.contents) as content,count(*) as nums from t_patient_information tpi left join t_patient_record tpr on tpi.id=tpr.patient_id and tpr.rec_status=0
where tpi.rec_status=0
and tpi.inpatient_id=#{aLong}
<iftest="id!=null and id!=0">
and tpr.test_questions_id=#{id}
<iftest="testQuestionsId!=null and testQuestionsId!=0">
and tpr.test_questions_id=#{testQuestionsId}
</if>
and tpi.id in (
SELECT
@ -158,12 +167,26 @@
t_patient_information tpi left join t_inpatient ti on ti.rec_status=0 and ti.id=tpi.inpatient_id
WHERE
tpi.rec_status = 0
AND tpi.id IN (
<iftest="hospitalId!=null and hospitalId !=0 ">
and tpi.hospital_id=#{hospitalId}
</if>
<iftest="hospitalization!=null and hospitalization!=''">
and tpi.hospitalization like concat('%',#{hospitalization},'%')
</if>
<iftest="inpatientId !=null and inpatientId!=0">
and tpi.inpatient_id=#{inpatientId}
</if>
<iftest="inputStatus !=null">
and tpi.input_status=#{inputStatus}
</if>
<iftest="(conditionList!=null and conditionList.size()!=0 ) or (conditionListDate != null and conditionListDate.size() !=0 )">
and tpi.id IN (
SELECT DISTINCT
( t.patient_id )
FROM
(
<trimsuffixOverrides="INTERSECT">
<iftest="conditionList!=null and conditionList.size()!=0 ">
<foreachcollection="conditionList"item="item">
SELECT
tpr.patient_id
@ -172,9 +195,13 @@
WHERE
tpr.rec_status = 0
AND tpr.test_questions_id = #{item.testQuestionsId}
<iftest="item.contents!=null and item.contents!=''">
AND tpr.contents LIKE concat('%',#{item.contents},'%')
</if>
INTERSECT
</foreach>
</if>
<iftest="conditionListDate != null and conditionListDate.size() !=0 ">