@@ -3103,6 +3103,9 @@ set ex.HoHRace = case
31033103from tmp_Exit ex
31043104inner 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
31073110update ex
31083111set 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
31593170update ex
31603171set ex .HHAdultAge = ageGroup .AgeGroup
31613172from
@@ -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