LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) d
@ -266,7 +266,7 @@
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
on m.dept_name=f.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and content!='' and content is not null and back_flag is not null GROUP BY archive_detail_id) s
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
where 1=1 and ArchiveState in('归档中','提交','主任退回')
and patindex('%B%',m.inp_no) = 0
@ -380,7 +380,7 @@
on m.dept_name=f.code
left join Archive_Master_Following amf
on m.id=amf.master_id and amf.following_type=9
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and content!='' and content is not null and back_flag is not null GROUP BY archive_detail_id) s
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
where 1=1 and ArchiveState in('初审')
and patindex('%B%',m.inp_no) = 0
@ -510,7 +510,7 @@
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
on m.dept_name=f.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and content!='' and content is not null and back_flag is not null GROUP BY archive_detail_id) s
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
where 1=1
and m.ArchiveState not in('作废','已封存')
@ -633,7 +633,7 @@
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
on m.dept_name=f.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and content!='' and content is not null and back_flag is not null GROUP BY archive_detail_id) s
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
where 1=1
and patindex('%B%',m.inp_no) = 0
@ -756,7 +756,7 @@
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
on m.dept_name=f.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and content!='' and content is not null and back_flag is not null GROUP BY archive_detail_id) s
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
where 1=1 and ArchiveState in('提交','主任退回','归档中','复审退回')
SELECT deptCode, deptName,ISNULL(timeOutNum,0)timeOutNum,ISNULL(isOutNum,0)isOutNum,ISNULL(inTime,0) inTime,ISNULL(timeOutRate,'0') timeOutRate,ISNULL(inTimeRate,'0') inTimeRate FROM (select DISTINCT c.dept_name as deptCode,t8.Name as deptName,t1.isOutNum ,n1.timeOutNum,
CONVERT(decimal(8,2),n1.timeOutNum*1./t1.isOutNum) as timeOutRate,(t1.isOutNum-n1.timeOutNum) as inTime,CONVERT(decimal(8,2),(t1.isOutNum-n1.timeOutNum)*1./t1.isOutNum) as inTimeRate
from archive_master as c
]]>
left join (select dept_name,COUNT(*) AS inNum from archive_master as s where s.ArchiveState in('在院')
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t on c.dept_name= t.dept_name
left join (select dept_name,COUNT(*) AS isOutNum from archive_master as s where s.ArchiveState!='在院'
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t1 on c.dept_name= t1.dept_name
left join (
SELECT a.dept_name,ISNULL(timeOutNum, 0) timeOutNum FROM archive_master AS a LEFT JOIN (
select s.dept_name as dept_name,COUNT(*) AS timeOutNum from archive_master as s
LEFT JOIN(select master_id archive_detail_id,handle_time create_time,handle_name first_instance from (
select ROW_NUMBER() over(partition by master_id order by handle_time asc) RowNum
,Archive_Master_Following.*
from Archive_Master_Following where 1=1 and following_type ='5' ) as t1 where 1=1 and RowNum = 1
) d
on s.id=d.archive_detail_id
where s.ArchiveState!='在院'
<iftest="overdueDays != null and overdueDays != ''">
and convert(int,[dbo].[getWorkday](s.discharge_date_time,d.create_time))-convert(int,#{overdueDays,jdbcType=INTEGER})>0
</if>
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7) group by dept_name
) x ON a.dept_name = x.dept_name
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
) as n1 on c.dept_name= n1.dept_name
left join (select dept_name,COUNT(*) AS fileNum from archive_master as s where s.ArchiveState in('已归档','已认证')
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t2 on c.dept_name= t2.dept_name
left join (select dept_name,COUNT(*) AS unfileNum from archive_master as s where s.ArchiveState not in('已归档','已认证')
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t3 on c.dept_name= t3.dept_name
left join (select dept_name,COUNT(*) AS deathNum from archive_master as s where s.DISCHARGE_DISPOSITION=5
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t4 on c.dept_name= t4.dept_name
left join (select dept_name,COUNT(*) AS Num from archive_master as s where s.ArchiveState in('已归档','已认证') and datediff(d,discharge_date_time,getdate())<=2
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t5 on c.dept_name= t5.dept_name
left join (select dept_name,COUNT(*) AS Num from archive_master as s where s.ArchiveState in('已归档','已认证') and datediff(d,discharge_date_time,getdate())<=3
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t6 on c.dept_name= t6.dept_name
left join (select dept_name,COUNT(*) AS Num from archive_master as s where s.ArchiveState in('已归档','已认证') and datediff(d,discharge_date_time,getdate())<=7
and not (datepart(weekday,discharge_date_time)=1 or datepart(weekday,discharge_date_time)=7)
<choose>
<whentest="startDate != null and startDate != '' and endDate != null and endDate != ''">
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
<whentest="startDate != null and startDate != ''">
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
</when>
<whentest="endDate != null and endDate != ''">
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
group by dept_name) as t7 on c.dept_name= t7.dept_name
left join (SELECT code,Name FROM emr_dictionary ) as t8 on c.dept_name=t8.code
) v_count where 1=1
<!--<if test="deptCode != null and deptCode!=''">-->
(t2.fileNum/t1.outNum) as fileRate,(t5.Num-t4.deathNum)/(t2.fileNum-t4.deathNum) as day2Rate, (t6.Num-t4.deathNum)/(t2.fileNum-t4.deathNum) as day3Rate, (t7.Num)/(t2.fileNum) as day7Rate
@ -161,9 +351,9 @@
group by dept_name) as t7 on c.dept_name= t7.dept_name
left join (SELECT code,Name FROM emr_dictionary ) as t8 on c.dept_name=t8.code
) v_count where 1=1
<!--<if test="deptCode != null and deptCode!=''">-->