-
Notifications
You must be signed in to change notification settings - Fork 0
QA Episode level care day table
clancyjane edited this page Oct 13, 2014
·
5 revisions
select fiscal_yr,sum(care_days) care_days
from base.episode_care_days eps
where eps.age_yrs_exit=-99 and eps.age_yrs_removal=-99 and eps.cd_race=0 and eps.county_cd=0 and eps.exclude_7day=0 and eps.exclude_nondcfs=0
group by fiscal_yr
order by fiscal_yr asc
select sum(datediff(dd,IIF(removal_dt<=fy_start_date
,fy_start_date
,removal_dt)
,IIF(iif([18bday]<=discharge_dt and [18bday] <= cutoff_date
,[18bday]
,discharge_dt)<=fy_stop_date,iif([18bday]<=discharge_dt and [18bday] <= cutoff_date,[18bday],discharge_dt),fy_stop_date) ))
from base.rptPlacement plc
,ref_last_dw_transfer
,(select STATE_FISCAL_YYYY sfy,min(calendar_date) fy_start_date,max(calendar_date) fy_stop_date from CALENDAR_DIM group by state_fiscal_yyyy) cd
where cd.sfy=2011 and removal_dt<=fy_stop_date
and iif([18bday]<=discharge_dt and [18bday] < =cutoff_date,[18bday],discharge_dt)>=fy_start_date
and age_at_removal_mos< (18*12) and removal_dt<iif([18bday]<=discharge_dt and [18bday] < =cutoff_date,[18bday],discharge_dt)