Skip to content

Commit e0edc76

Browse files
committed
revised source for ssd_person.pers_ethnicity to fit DfE returns from Child_Social.DIM_LOOKUP_DFE_ETHNIC.NAT_ID
1 parent 9d86ce4 commit e0edc76

File tree

1 file changed

+15
-11
lines changed
  • deployment_extracts/systemc/live/ssd_deployment_proc_files/procs

1 file changed

+15
-11
lines changed

deployment_extracts/systemc/live/ssd_deployment_proc_files/procs/ssd_person.sql

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ BEGIN
5151

5252

5353

54-
/* START - Temp Hard drop and recreate due to d2i structure changes */
55-
IF OBJECT_ID(N'ssd_person', N'U') IS NOT NULL
56-
DROP TABLE ssd_person;
57-
58-
/* END - remove this tmp block once SSD has run once for v1.3.5+! */
54+
-- /* START - Temp Hard drop and recreate due to d2i structure changes */
55+
-- IF OBJECT_ID(N'ssd_person', N'U') IS NOT NULL
56+
-- DROP TABLE ssd_person;
57+
-- GO
58+
-- /* END - remove this tmp block once SSD has run once for v1.3.5+! */
5959

6060
IF OBJECT_ID('tempdb..#ssd_person') IS NOT NULL DROP TABLE #ssd_person;
6161

@@ -76,7 +76,7 @@ BEGIN
7676
pers_sex NVARCHAR(20), -- metadata={"item_ref":"PERS002A", "item_status":"P", "info":"If -additional- status to Gender is held, otherwise duplicate pers_gender"}
7777
pers_gender NVARCHAR(10), -- metadata={"item_ref":"PERS003A", "item_status":"R", "expected_data":["unknown",NULL,"F","U","M","I"]}
7878
pers_ethnicity NVARCHAR(48), -- metadata={"item_ref":"PERS004A", "expected_data":[NULL, tbc]}
79-
pers_dob DATETIME, -- metadata={"item_ref":"PERS005A"}
79+
pers_dob DATETIME, -- metadata={"item_ref":"PERS005A", "info": "SSD dat values render as 2024-12-10 00:00:00.000"}
8080
pers_single_unique_id NVARCHAR(48), -- metadata={"item_ref":"PERS013A", "item_status":"P", "info":"Populate from NHS number if available"}
8181
pers_upn_unknown NVARCHAR(6), -- metadata={"item_ref":"PERS007A", "info":"SEN2 guidance suggests size(4)", "expected_data":["UN1-10"]}
8282
pers_send_flag NCHAR(5), -- metadata={"item_ref":"PERS008A", "item_status":"P"}
@@ -127,15 +127,14 @@ SELECT
127127
p.FORENAME,
128128
p.SURNAME,
129129
p.GENDER_MAIN_CODE AS pers_sex, -- Sex/Gender as used in stat-returns
130-
p.GENDER_MAIN_CODE, -- Placeholder for those LAs that store sex and gender independently
131-
p.ETHNICITY_MAIN_CODE, -- [REVIEW] LEFT(p.ETHNICITY_MAIN_CODE, 4)
130+
p.GENDER_MAIN_CODE, -- Placeholder for those LAs that store sex and gender independently
131+
dlde.NAT_ID, -- COV change to align with national ID was LEFT(p.ETHNICITY_MAIN_CODE, 4) [REVIEW]
132132
CASE WHEN (p.DOB_ESTIMATED) = 'N'
133133
THEN p.BIRTH_DTTM -- Set to BIRTH_DTTM when DOB_ESTIMATED = 'N'
134134
ELSE NULL -- or NULL
135135
END,
136136
NULL AS pers_single_unique_id, -- Set to NULL as default(dev) / or set to NHS num / or set to Single Unique Identifier(SUI)
137-
-- COALESCE(f903.NO_UPN_CODE, 'SSD_PH') AS NO_UPN_CODE, -- Use NO_UPN_CODE from f903 or 'SSD_PH' as placeholder
138-
f903.NO_UPN_CODE AS pers_upn_unknown,
137+
f903.NO_UPN_CODE AS pers_upn_unknown, -- Source of upn_unknown likely to vary between LAs [REVIEW]
139138
p.EHM_SEN_FLAG,
140139
CASE WHEN (p.DOB_ESTIMATED) = 'Y'
141140
THEN p.BIRTH_DTTM -- Set to BIRTH_DTTM when DOB_ESTIMATED = 'Y'
@@ -168,10 +167,15 @@ LEFT JOIN (
168167
ON
169168
p.DIM_PERSON_ID = f903.dim_person_id
170169

170+
LEFT JOIN
171+
-- align with national ID
172+
HDM.Child_Social.DIM_LOOKUP_DFE_ETHNIC dlde
173+
ON p.ETHNICITY_MAIN_CODE = dlde.MAIN_CODE
174+
171175
WHERE
172176
/* EXCLUSIONS */
173177

174-
-- p.DIM_PERSON_ID IN (1, 2, 3) AND -- -- hard filter on CMS person ids for LA reduced cohort testing
178+
-- p.DIM_PERSON_ID IN (1, 2, 3) AND -- -- hard filter on CMS person ids for LA reduced tiny cohort testing
175179

176180
p.DIM_PERSON_ID IS NOT NULL
177181
AND p.DIM_PERSON_ID <> -1

0 commit comments

Comments
 (0)