Skip to content

Commit

Permalink
Update 03_02 to 03_06 HMIS Households and Enrollments.sql
Browse files Browse the repository at this point in the history
closes #676
  • Loading branch information
MollyMcEvilley committed Oct 7, 2021
1 parent 10316be commit f03cf10
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions 03_02 to 03_06 HMIS Households and Enrollments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
LSA FY2021 Sample Code
Name: 03_02 to 03_06 HMIS Households and Enrollments.sql
Date: 08 SEP 2021
Date: 6 OCT 2021
3.2 Cohort Dates
Expand Down Expand Up @@ -93,7 +93,7 @@ select distinct hoh.HouseholdID, hoh.PersonalID, hoh.EnrollmentID
when p.ProjectType = 1 and hx.ExitDate is null
and dateadd(dd, 90, bn.LastBednight) <= rpt.ReportEnd then dateadd(dd, 1, bn.LastBednight)
when p.OperatingEndDate <= rpt.ReportEnd and hx.ExitDate is null then p.OperatingEndDate
when p.ProjectType = 13 and hoh.MoveInDate = hx.ExitDate and hx.ExitDate = rpt.ReportEnd then NULL
when p.ProjectType = 13 and hoh.MoveInDate = hx.ExitDate and hx.ExitDate = rpt.ReportEnd then NULL
when p.ProjectType = 13 and hoh.MoveInDate = hx.ExitDate then dateadd(dd, 1, hx.ExitDate)
else hx.ExitDate end
, bn.LastBednight
Expand All @@ -111,7 +111,7 @@ inner join (select hp.ProjectID, case when hp.ProjectType = 1 and hp.TrackingMe
where hp.DateDeleted is null
and hp.ContinuumProject = 1
and (hp.OperatingEndDate is null
or (hp.OperatingEndDate > hp.OperatingStartDate ))) p on p.ProjectID = hoh.ProjectID
or (hp.OperatingEndDate > hp.OperatingStartDate and hp.OperatingEndDate > '10/1/2012' ))) p on p.ProjectID = hoh.ProjectID
left outer join hmis_Exit hx on hx.EnrollmentID = hoh.EnrollmentID
and hx.ExitDate <= rpt.ReportEnd
and (hx.ExitDate <= p.OperatingEndDate or p.OperatingEndDate is null)
Expand Down Expand Up @@ -145,8 +145,8 @@ where hoh.DateDeleted is null

update hhid
set hhid.ExitDest = case
when hx.ExitDate is null or
(hx.ExitDate <> hhid.ExitDate
when hx.ExitDate is null or
(hx.ExitDate <> hhid.ExitDate
and (hhid.MoveInDate is NULL or hhid.MoveInDate <> hx.ExitDate)) then 99
when hx.Destination = 3 then 1 --PSH
when hx.Destination = 31 then 2 --PH - rent/temp subsidy
Expand Down Expand Up @@ -189,7 +189,7 @@ where hoh.DateDeleted is null
, case when hhid.EntryDate > hn.EntryDate then hhid.EntryDate else hn.EntryDate end
, case when hx.ExitDate >= hhid.ExitDate then hhid.ExitDate
when hx.ExitDate is NULL and hhid.ExitDate is not NULL then hhid.ExitDate
when hhid.LSAProjectType = 13 and hhid.MoveInDate = hx.ExitDate and hx.ExitDate = rpt.ReportEnd then NULL
when hhid.LSAProjectType = 13 and hhid.MoveInDate = hx.ExitDate and hx.ExitDate = rpt.ReportEnd then NULL
when hhid.LSAProjectType = 13 and hhid.MoveInDate = hx.ExitDate then dateadd(dd, 1, hx.ExitDate)
else hx.ExitDate end
, case when hn.DisablingCondition in (0,1) then hn.DisablingCondition
Expand Down

0 comments on commit f03cf10

Please sign in to comment.