Skip to content

Commit bc11e34

Browse files
committed
re-align with v0.2.8 2016 EligibleBySpec 0-26yrs and SpecInclusion commenting
1 parent 3b5d727 commit bc11e34

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

sql_json_query/populate_ssd_api_data_staging_2012.sql

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,23 @@ DECLARE @ea_cohort_window_end date = DATEADD(day, 1, @run_date) -- today + 1
8989

9090
;WITH
9191
EligibleBySpec AS (
92-
/* Age gate 16..25 overlaps window, plus unborn within window
93-
Known DoB, include if 16th bday <= window_end and 26th bday > window_start
94-
Unborn, include if expected_dob between window_start and window_end
92+
/* Include if:
93+
- Known DoB and age <=25 inclusive at some point during window(we key off the 26th bday)
94+
(26th birthday after window_start) and born by window_end
95+
- OR unborn (expected_dob in window)
96+
- Deceased included, no death-date filter
97+
98+
Expected cohort:
99+
children <=25 at any point between @ea_cohort_window_start and @ea_cohort_window_end (dynamic EA window, derived from 24 months back anchored to FY start)
100+
95101
*/
96102
SELECT p.pers_person_id
97103
FROM ssd_person p
98104
WHERE
99105
(
100106
p.pers_dob IS NOT NULL
101-
AND DATEADD(year, 16, p.pers_dob) <= @ea_cohort_window_end
102-
AND DATEADD(year, 26, p.pers_dob) > @ea_cohort_window_start
107+
AND p.pers_dob <= @ea_cohort_window_end
108+
AND DATEADD(year, 26, p.pers_dob) > @ea_cohort_window_start
103109
)
104110
OR
105111
(
@@ -108,12 +114,16 @@ EligibleBySpec AS (
108114
AND p.pers_expected_dob BETWEEN @ea_cohort_window_start AND @ea_cohort_window_end
109115
)
110116

111-
/* hard cohort filter,
112-
used during live pre-alpha cohort testing -> LA to add child IDs here */
113-
AND p.pers_person_id IN ('-1')
117+
118+
/* LA hard cohort filter, used during live pre-alpha cohort testing
119+
LA to add child IDs here. Remove this line|block for full cohort. */
120+
121+
--AND p.pers_person_id IN ('1', '2', '3')
122+
114123
/* end pre-alpha cohort (remove this block as required) */
115124
),
116125

126+
117127
ActiveReferral AS (
118128
/* episode overlaps window, and open at run_date
119129
overlap, referral_date <= window_end and (close_date null or close_date >= window_start)
@@ -226,10 +236,10 @@ SpecInclusion AS (
226236
SELECT person_id FROM ActiveReferral
227237
UNION SELECT person_id FROM WaitingAssessment
228238
UNION SELECT person_id FROM HasCINPlan
229-
UNION SELECT person_id FROM HasCPPlan
239+
-- UNION SELECT person_id FROM HasCPPlan
230240
UNION SELECT person_id FROM HasLAC
231241
UNION SELECT person_id FROM IsCareLeaver16to25
232-
UNION SELECT person_id FROM IsDisabled
242+
-- UNION SELECT person_id FROM IsDisabled
233243
),
234244

235245
/* ====================== Payload builder, 2012-safe ======================= */

0 commit comments

Comments
 (0)