Skip to content

Commit 5f55a14

Browse files
4.44 Exit Cohort Population Identifiers
Add join to hmis_Exit to update queries / verify that population identifiers (like HHType) are based on HoH and HH members who exited in the cohort period.
1 parent a7e73a7 commit 5f55a14

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

LSASampleCode.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,6 +3103,9 @@ set ex.HoHRace = case
31033103
from tmp_Exit ex
31043104
inner join hmis_Client c on c.PersonalID = ex.HoHID
31053105

3106+
--CHANGE 11/29/2018 add join to hmis_Exit and verify ExitDate >= CohortStart
3107+
-- in pop subquery and age sub-subquery so that population identifiers are
3108+
-- based solely on HoH and HH members who exited in the cohort period
31063109

31073110
update ex
31083111
set ex.HHVet = pop.HHVet
@@ -3131,8 +3134,11 @@ inner join (
31313134
, max(case when hn.RelationshipToHoH = 2 and age.ageStat = 0 then 1
31323135
else 0 end) as HHParent
31333136
from tmp_Exit ex
3137+
inner join tmp_CohortDates cd on cd.Cohort = ex.Cohort
31343138
inner join hmis_Enrollment hoh on hoh.EnrollmentID = ex.EnrollmentID
31353139
inner join hmis_Enrollment hn on hn.HouseholdID = hoh.HouseholdID
3140+
inner join hmis_Exit hx on hx.EnrollmentID = hn.EnrollmentID
3141+
and hx.ExitDate >= cd.CohortStart
31363142
inner join hmis_Client c on c.PersonalID = hn.PersonalID
31373143
left outer join hmis_HealthAndDV dv on hn.EnrollmentID = dv.EnrollmentID
31383144
inner join (select distinct hn.PersonalID
@@ -3152,10 +3158,15 @@ inner join (
31523158
inner join tmp_CohortDates cd on cd.Cohort = ex.Cohort
31533159
inner join hmis_Enrollment hoh on hoh.EnrollmentID = ex.EnrollmentID
31543160
inner join hmis_Enrollment hn on hn.HouseholdID = hoh.HouseholdID
3161+
inner join hmis_Exit hx on hx.EnrollmentID = hn.EnrollmentID
3162+
and hx.ExitDate >= cd.CohortStart
31553163
inner join hmis_Client c on c.PersonalID = hn.PersonalID
31563164
) age on age.PersonalID = hn.PersonalID
31573165
group by ex.EnrollmentID) pop on pop.EnrollmentID = ex.EnrollmentID
31583166

3167+
--CHANGE 11/29/2018 add join to hmis_Exit and verify ExitDate >= CohortStart
3168+
-- in adultAges subquery so that HHAdultAge is based solely on HoH and HH members
3169+
-- who exited in the cohort period
31593170
update ex
31603171
set ex.HHAdultAge = ageGroup.AgeGroup
31613172
from
@@ -3195,6 +3206,8 @@ inner join
31953206
inner join tmp_CohortDates cd on cd.Cohort = ex.Cohort
31963207
inner join hmis_Enrollment hoh on hoh.EnrollmentID = ex.EnrollmentID
31973208
inner join hmis_Enrollment hn on hn.HouseholdID = hoh.HouseholdID
3209+
inner join hmis_Exit hx on hx.EnrollmentID = hn.EnrollmentID
3210+
and hx.ExitDate >= cd.CohortStart
31983211
inner join hmis_Client c on c.PersonalID = hn.PersonalID
31993212
) adultAges
32003213
group by adultAges.HoHID, adultAges.EnrollmentID

0 commit comments

Comments
 (0)