优化两个统计查询:过滤留观记录

master
hujl 4 years ago
parent 6aa1e4e631
commit 0d69a27314

@ -971,7 +971,7 @@
and CONVERT(VARCHAR(10),discharge_date_time,120) <= #{endDateTo,jdbcType=NCHAR}
</when>
</choose>
AND Is_Valid != 1 THEN 1 ELSE 0 END) as checkDoctor,
AND Is_Valid != 1 and patindex('%B%',inp_no) = 0 and inp_no not like 'LG%' THEN 1 ELSE 0 END) as checkDoctor,
SUM(CASE WHEN ArchiveState is not null and ArchiveState!='' and ArchiveState IN ('归档中','提交','主任退回','复审退回')
<choose>
<when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''">
@ -984,8 +984,8 @@
and CONVERT(VARCHAR(10),discharge_date_time,120) &lt;= #{endDateTo,jdbcType=NCHAR}
</when>
</choose>
AND Is_Valid != 1 THEN 1 ELSE 0 END) as lockinfo,
SUM(CASE WHEN ArchiveState is not null and ArchiveState not IN ('已封存','归档中','提交','主任退回','复审退回','')
AND Is_Valid != 1 and patindex('%B%',inp_no) = 0 and inp_no not like 'LG%' THEN 1 ELSE 0 END) as lockinfo,
SUM(CASE WHEN ArchiveState is not null and ArchiveState not IN ('已封存','归档中','提交','主任退回','复审退回','','作废')
<choose>
<when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''">
and CONVERT(VARCHAR(10),discharge_date_time,120) between CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120) and #{endDateTo,jdbcType=NCHAR}
@ -997,8 +997,8 @@
and CONVERT(VARCHAR(10),discharge_date_time,120) &lt;= #{endDateTo,jdbcType=NCHAR}
</when>
</choose>
AND Is_Valid != 1 THEN 1 ELSE 0 END) as inpNo,
SUM(CASE WHEN ArchiveState is not null and ArchiveState not IN ('已封存','归档中','提交','主任退回','复审退回','')
AND Is_Valid != 1 and patindex('%B%',inp_no) = 0 and inp_no not like 'LG%' THEN 1 ELSE 0 END) as inpNo,
SUM(CASE WHEN ArchiveState is not null and ArchiveState not IN ('已封存','归档中','提交','主任退回','复审退回','','作废')
<choose>
<when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''">
and CONVERT(VARCHAR(10),discharge_date_time,120) between CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120) and #{endDateTo,jdbcType=NCHAR}
@ -1010,7 +1010,7 @@
and CONVERT(VARCHAR(10),discharge_date_time,120) &lt;= #{endDateTo,jdbcType=NCHAR}
</when>
</choose>
AND Is_Valid != 1
AND Is_Valid != 1 and patindex('%B%',inp_no) = 0 and inp_no not like 'LG%'
<if test="remark!= null and remark!= ''">
and CEILING(DATEDIFF(hour,discharge_date_time,GETDATE())/24.00)>#{remark,jdbcType=NCHAR}
</if>
@ -1049,7 +1049,7 @@
select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where typeCode='dept_code' )
) E
ON U.dept_name=E.code
<where> 1=1 and U.ArchiveState in('归档中','提交','主任退回','复审退回') AND U.Is_Valid != 1
<where> 1=1 and U.ArchiveState in('归档中','提交','主任退回','复审退回') AND U.Is_Valid != 1 and patindex('%B%',inp_no) = 0 and inp_no not like 'LG%'
<if test="remark!= null and remark!= ''">
and CEILING(DATEDIFF(hour,U.discharge_date_time,GETDATE())/24.00)>#{remark,jdbcType=NCHAR}
</if>

Loading…
Cancel
Save