Skip to content

Commit a3b3256

Browse files
committed
refresh f.name s.name added
1 parent 0364458 commit a3b3256

14 files changed

+6769
-171
lines changed

data/objects/ssd_cla_episodes.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ nodes:
172172
\ no parent(s) available to provide for them. A child whose parent(s) decide\
173173
\ it is in the best interest for the child to be adopted would be included in\
174174
\ this category"
175-
- name: clae_cla_episode_ceased
175+
- name: clae_cla_episode_ceased_date
176176
description: Date Episode Ceased
177177
item_ref: CLAE005A
178178
type: datetime
@@ -186,8 +186,8 @@ nodes:
186186
- liquid_logic
187187
- mosaic
188188
cms_field:
189-
- liquid_logic:clae_cla_episode_ceased
190-
- mosaic:clae_cla_episode_ceased
189+
- liquid_logic:clae_cla_episode_ceased_date
190+
- mosaic:clae_cla_episode_ceased_date
191191
cms_table:
192192
- liquid_logic:ssd_cla_episodes
193193
- mosaic:ssd_cla_episodes

deployment_extracts/cmsname_dbtype_ssd_template_v1.2.2_1_20240926.sql

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -61,79 +61,65 @@ Currently in [REVIEW]
6161
**********************************************************************************************************
6262
*/
6363
-- META-ELEMENT: {"type": "config_metadata"}
64-
-- Developers pls leave blank
64+
-- Optional notes from la config file
6565

6666
-- META-ELEMENT: {"type": "dev_set_up"}
67-
-- e.g.
68-
-- GO
69-
-- SET NOCOUNT ON;
67+
GO
68+
SET NOCOUNT ON;
69+
70+
7071

7172

7273
-- META-ELEMENT: {"type": "ssd_timeframe"}
73-
-- postgress version
74-
DO $$
75-
DECLARE
76-
ssd_timeframe_years INT := 4; -- ssd extract time-frame (YRS)
77-
ssd_sub1_range_years INT := 1; -- Not in use
78-
CaseloadLastSept30th DATE;
79-
CaseloadTimeframeStartDate DATE;
80-
BEGIN
81-
-- CASELOAD count Date (Currently: September 30th)
82-
CaseloadLastSept30th := CASE
83-
WHEN CURRENT_DATE > MAKE_DATE(EXTRACT(YEAR FROM CURRENT_DATE)::INT, 9, 30)
84-
THEN MAKE_DATE(EXTRACT(YEAR FROM CURRENT_DATE)::INT, 9, 30)
85-
ELSE MAKE_DATE(EXTRACT(YEAR FROM CURRENT_DATE)::INT - 1, 9, 30)
86-
END;
87-
88-
-- Start Date for Caseload Timeframe
89-
CaseloadTimeframeStartDate := CaseloadLastSept30th - INTERVAL '6 years';
90-
91-
RAISE NOTICE 'CaseloadLastSept30th: %, CaseloadTimeframeStartDate: %', CaseloadLastSept30th, CaseloadTimeframeStartDate;
92-
END $$;
74+
DECLARE @ssd_timeframe_years INT = 6; -- ssd extract time-frame (YRS)
75+
DECLARE @ssd_sub1_range_years INT = 1;
9376

9477

95-
-- META-ELEMENT: {"type": "dbschema"}
96-
-- Postgress example for review
97-
-- Set the schema search path if needed (SSD tables created here)
98-
SET search_path TO 'ssd_development'; -- replace 'ssd_development' with the desired schema name
9978

100-
DO $$
101-
DECLARE
102-
schema_name VARCHAR(128) := 'ssd_development'; -- set schema name here OR leave empty for default behavior
103-
BEGIN
104-
RAISE NOTICE 'Schema Name: %', schema_name;
105-
END $$;
79+
-- CASELOAD count Date (Currently: September 30th)
80+
DECLARE @CaseloadLastSept30th DATE;
81+
SET @CaseloadLastSept30th = CASE
82+
WHEN CONVERT(DATE, GETDATE()) > DATEFROMPARTS(YEAR(GETDATE()), 9, 30)
83+
THEN DATEFROMPARTS(YEAR(GETDATE()), 9, 30)
84+
ELSE DATEFROMPARTS(YEAR(GETDATE()) - 1, 9, 30)
85+
END;
10686

107-
-- META-ELEMENT: {"type": "test"}
108-
DO $$
109-
DECLARE
110-
TableName VARCHAR(128) := 'table_name_placeholder'; -- replace placeholder with the actual table name
111-
BEGIN
112-
RAISE NOTICE 'Table Name: %', TableName;
113-
END $$;
11487

88+
DECLARE @CaseloadTimeframeStartDate DATE = DATEADD(YEAR, -@ssd_timeframe_years, @CaseloadLastSept30th);
89+
-- Example resultant dates into @CaseloadTimeframeStartDate
90+
-- With
91+
-- @CaseloadLastSept30th = 30th September 2023
92+
-- @CaseloadTimeframeStartDate = 30th September 2017
11593

116-
-- -- META-ELEMENT: {"type": "dbschema"}
117-
-- -- SQL Server variant for review
118-
-- -- Point to DB/TABLE_CATALOG if required (SSD tables created here)
119-
-- USE HDM_Local; -- used in logging (and seperate clean-up script(s))
120-
-- DECLARE @schema_name NVARCHAR(128) = N'ssd_development'; -- set your schema name here OR leave empty for default behaviour. Used towards ssd_extract_log
12194

122-
-- -- META-ELEMENT: {"type": "test"}
123-
-- DECLARE @TableName NVARCHAR(128) = N'table_name_placeholder'; -- Note: also/seperately use of @table_name in non-test|live elements of script.
12495

12596

97+
-- META-ELEMENT: {"type": "dbschema"}
98+
-- Point to DB/TABLE_CATALOG if required (SSD tables created here)
99+
USE HDM_Local; -- used in logging (and seperate clean-up script(s))
100+
DECLARE @schema_name NVARCHAR(128) = N'ssd_development'; -- set your schema name here OR leave empty for default behaviour. Used towards ssd_extract_log
101+
102+
ALTER USER [ESCC\RobertHa] WITH DEFAULT_SCHEMA = [ssd_development];
103+
104+
105+
-- META-ELEMENT: {"type": "test"}
106+
DECLARE @TableName NVARCHAR(128) = N'table_name_placeholder'; -- Note: also/seperately use of @table_name in non-test|live elements of script.
126107

127108
-- META-END
128109

129110

130111

112+
113+
131114
/* ********************************************************************************************************** */
132115
-- META-CONTAINER: {"type": "settings", "name": "testing"}
133116
/* Towards simplistic TEST run outputs and logging (to be removed from live v2+) */
134-
-- Devs can ignore this block.
135-
-- META-END
136117

118+
-- META-ELEMENT: {"type": "test"}
119+
DECLARE @StartTime DATETIME, @EndTime DATETIME;
120+
SET @StartTime = GETDATE(); -- Script start time
121+
122+
-- META-END
137123

138124

139125

@@ -230,7 +216,9 @@ IF OBJECT_ID('tempdb..#ssd_person') IS NOT NULL DROP TABLE #ssd_person;
230216
-- META-ELEMENT: {"type": "create_table"}
231217
CREATE TABLE ssd_development.ssd_person (
232218
pers_legacy_id NVARCHAR(48), -- metadata={"item_ref":"PERS014A"}
233-
pers_person_id NVARCHAR(48) PRIMARY KEY, -- metadata={"item_ref":"PERS001A"}
219+
pers_person_id NVARCHAR(48) PRIMARY KEY, -- metadata={"item_ref":"PERS001A"}
220+
pers_forename NVARCHAR(100), -- metadata={"item_ref":"PERS015A"}
221+
pers_surname NVARCHAR(255), -- metadata={"item_ref":"PERS016A"}
234222
pers_sex NVARCHAR(20), -- metadata={"item_ref":"PERS002A", "item_status":"P", "info":"If additional status to Gender is held, otherwise dup of pers_gender"}
235223
pers_gender NVARCHAR(10), -- metadata={"item_ref":"PERS003A", "item_status":"R", "expected_data":["unknown","NULL","F","U","M","I"]}
236224
pers_ethnicity NVARCHAR(48), -- metadata={"item_ref":"PERS004A"}
@@ -249,6 +237,8 @@ CREATE TABLE ssd_development.ssd_person (
249237
INSERT INTO ssd_development.ssd_person (
250238
pers_legacy_id,
251239
pers_person_id,
240+
pers_forename,
241+
pers_surname,
252242
pers_sex, -- sex and gender currently extracted as one
253243
pers_gender, --
254244
pers_ethnicity,
@@ -304,7 +294,7 @@ INSERT INTO ssd_development.ssd_person (
304294
-- WHERE
305295
-- p.DIM_PERSON_ID IS NOT NULL
306296
-- AND p.DIM_PERSON_ID <> -1
307-
-- -- AND YEAR(p.BIRTH_DTTM) != 1900
297+
-- -- AND YEAR(p.BIRTH_DTTM) != 1900 -- #DtoI-1814
308298
-- AND (p.IS_CLIENT = 'Y'
309299
-- OR (
310300
-- EXISTS (
@@ -338,7 +328,7 @@ INSERT INTO ssd_development.ssd_person (
338328
-- WHERE (fi.DIM_PERSON_ID = p.DIM_PERSON_ID
339329
-- AND (fi.DIM_LOOKUP_INVOLVEMENT_TYPE_CODE NOT LIKE 'KA%' --Key Agencies (External)
340330
-- OR fi.DIM_LOOKUP_INVOLVEMENT_TYPE_CODE IS NOT NULL OR fi.IS_ALLOCATED_CW_FLAG = 'Y')
341-
-- AND START_DTTM > '2009-12-04 00:54:49.947' -- was trying to cut off from 2010 but when I changed the date it threw up an erro
331+
-- -- AND START_DTTM > '2009-12-04 00:54:49.947' -- #DtoI-1830 care leavers who were aged 22-25 and may not have had Allocated Case Worker relationship for years+.
342332
-- AND DIM_WORKER_ID <> '-1'
343333
-- AND (fi.END_DTTM IS NULL OR fi.END_DTTM > GETDATE()))
344334
-- )
@@ -349,6 +339,7 @@ INSERT INTO ssd_development.ssd_person (
349339

350340

351341

342+
352343
-- META-ELEMENT: {"type": "create_fk"}
353344
-- Not required
354345

@@ -1933,7 +1924,7 @@ CREATE TABLE ssd_development.ssd_cla_episodes (
19331924
clae_cla_episode_start_date DATETIME, -- metadata={"item_ref":"CLAE003A"}
19341925
clae_cla_episode_start_reason NVARCHAR(100), -- metadata={"item_ref":"CLAE004A"}
19351926
clae_cla_primary_need_code NVARCHAR(3), -- metadata={"item_ref":"CLAE009A", "info":"Expecting codes N0-N9"}
1936-
clae_cla_episode_ceased DATETIME, -- metadata={"item_ref":"CLAE005A"}
1927+
clae_cla_episode_ceased_date DATETIME, -- metadata={"item_ref":"CLAE005A"}
19371928
clae_cla_episode_ceased_reason NVARCHAR(255), -- metadata={"item_ref":"CLAE006A"}
19381929
clae_cla_id NVARCHAR(48), -- metadata={"item_ref":"CLAE010A"}
19391930
clae_referral_id NVARCHAR(48), -- metadata={"item_ref":"CLAE011A"}

0 commit comments

Comments
 (0)