,case when emr_fault_detail.archive_detail_id is not null then '是' else '否' end isFault,m.print_flag as printNum
m.is_scanning,m.bed_number,ao.C5 is_sign,case when emr_fault_detail.archive_detail_id is not null then '是' else '否' end isFault,m.print_flag as printNum
from archive_master m
left join (select distinct archive_detail_id from emr_fault_detail where back_flag in ('6','5')) emr_fault_detail
on emr_fault_detail.archive_detail_id = m.ID
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag is not null GROUP BY archive_detail_id) s
on m.id=s.archive_detail_id
LEFT JOIN (select distinct masterID,C5 FROM archive_other where sysFlag = '1') ao
on m.id=ao.masterID
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('2','6') GROUP BY archive_detail_id) sNurse
on m.id=sNurse.archive_detail_id
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('1','5') GROUP BY archive_detail_id) sDoctor
on m.id=sDoctor.archive_detail_id
where 1=1 and ArchiveState in('初审') and m.Is_Valid!=1
and patindex('%B%',m.inp_no) = 0 and inp_no not like 'LG%'
<iftest="isFault != null and isFault != ''">
@ -563,14 +556,6 @@
<iftest="printNum !=null and printNum !=''">
AND m.print_flag=#{printNum}
</if>
<!-- <if test="printNum != null and printNum != ''">-->
<!-- <choose>-->
<!-- <when test="printNum == 1">-->
<!-- and printTable.MasterID is not null-->
<!-- </when>-->
<!-- <otherwise>and printTable.MasterID is null</otherwise>-->
<!-- </choose>-->
<!-- </if>-->
<iftest="inpNo != null and inpNo != ''">
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
</if>
@ -628,7 +613,6 @@
and m.admission_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
<iftest="checkDoctor != null">
and m.check_doctor = #{checkDoctor,jdbcType=NVARCHAR}