diff --git a/cms_ssd_extract_sql/mosaic/SQL_Professionals_DW.sql b/cms_ssd_extract_sql/mosaic/SQL_Professionals_DW.sql index 7937e23..c0d0c52 100644 --- a/cms_ssd_extract_sql/mosaic/SQL_Professionals_DW.sql +++ b/cms_ssd_extract_sql/mosaic/SQL_Professionals_DW.sql @@ -16,166 +16,162 @@ DECLARE @ssd_timeframe_years INT = 6, @ssd_sub1_range_years INT = 1 - IF OBJECT_ID('Tempdb..#t','u') IS NOT NULL BEGIN -DROP TABLE #t + DROP TABLE #t END CREATE TABLE #t ( -prof_table_id INT /*Information not held as a separate field as Worker ID is unique*/, -prof_professional_id INT, ---FIRST_NAMES VARCHAR(50), ---LAST_NAMES VARCHAR(50), -prof_social_worker_registration_no VARCHAR(20), -prof_agency_worker_flag VARCHAR(10) /*Field removed from SSDS*/, -prof_professional_job_title VARCHAR(100), -prof_professional_caseload INT DEFAULT 0, -prof_professional_department VARCHAR(100), -prof_full_time_equivalency DEC (10,2) /*Information not held in Mosaic; held in HR System (I-Trent)*/ + prof_table_id INT /*Information not held as a separate field as Worker ID is unique*/, + prof_staff_id INT, + --FIRST_NAMES VARCHAR(50), + --LAST_NAMES VARCHAR(50), + prof_social_worker_registration_no VARCHAR(20), + prof_agency_worker_flag VARCHAR(10) /*Field removed from SSDS*/, + prof_professional_job_title VARCHAR(100), + prof_professional_caseload INT DEFAULT 0, + prof_professional_department VARCHAR(100), + prof_full_time_equivalency DEC (10,2) /*Information not held in Mosaic; held in HR System (I-Trent)*/ ) INSERT #t ( -prof_table_id, -prof_professional_id, ---FIRST_NAMES, ---LAST_NAMES, -prof_social_worker_registration_no, -prof_agency_worker_flag, -prof_professional_job_title, -prof_professional_department, -prof_full_time_equivalency + prof_table_id, + prof_staff_id, + --FIRST_NAMES, + --LAST_NAMES, + prof_social_worker_registration_no, + prof_agency_worker_flag, + prof_professional_job_title, + prof_professional_department, + prof_full_time_equivalency ) -Select -d.prof_table_id, -d.prof_professional_id, ---d.FIRST_NAMES, ---d.LAST_NAMES, -d.prof_social_worker_registration_no, -d.prof_agency_worker_flag, -d.prof_professional_job_title, -d.prof_professional_department, -d.prof_full_time_equivalency - -from +SELECT + d.prof_table_id, + d.prof_staff_id, + --d.FIRST_NAMES, + --d.LAST_NAMES, + d.prof_social_worker_registration_no, + d.prof_agency_worker_flag, + d.prof_professional_job_title, + d.prof_professional_department, + d.prof_full_time_equivalency + +FROM ( - Select - NULL prof_table_id /*Information not held as a separate field as Worker ID is unique*/, - a.ID prof_professional_id, - a.FIRST_NAMES, - a.LAST_NAMES, - COALESCE(b.HCPCIdentifier, 'XX' + CAST(a.id as VARCHAR)) prof_social_worker_registration_no, - NULL prof_agency_worker_flag, /*Field removed from SSDS*/ - wrt.DESCRIPTION prof_professional_job_title, - org.NAME prof_professional_department, - NULL prof_full_time_equivalency, /*Information not held in Mosaic; held in HR System (I-Trent)*/ - DENSE_RANK() OVER(PARTITION BY a.ID ORDER BY COALESCE(wr.END_DATE, '99991231') DESC, wr.ID DESC) Rnk - - from Mosaic.M.WORKERS a - inner join Mosaic.M.WORKER_ROLES wr on a.ID = wr.WORKER_ID - inner join Mosaic.M.WORKER_ROLE_TYPES wrt on wr.ROLE = wrt.ROLE - inner join Mosaic.M.ORGANISATIONS org on wr.ORG_ID = org.ID - left join Returns.CSCWC.HCPC b on a.ID = b.WID - - where wrt.DESCRIPTION not like '%auth%' /*Authorisor roles which are additional to main role*/ - and wr.START_DATE <= @STARTTIME - and COALESCE(wr.END_DATE,'99991231') > @STARTTIME - - and wr.ORG_ID in - /*Get current Teams within 'Children's Social Care' in Mosaic Organisation Hierarchy*/ - ( - Select - d1.OHLevel1ID - - from - ( - Select - o1.ID OHLevel1ID, - o1.NAME OHLevel1Name, - o2.ID OHLevel2ID, - o2.NAME OHLevel2Name, - o3.ID OHLevel3ID, - o3.NAME OHLevel3Name, - o4.ID OHLevel4ID, - o4.NAME OHLevel4Name, - o5.ID OHLevel5ID, - o5.NAME OHLevel5Name, - o6.id OHLevel6ID, - o6.Name OHLevel6Name, - o7.id OHLevel7ID, - o7.Name OHLevel7Name - - from Mosaic.M.ORGANISATIONS o1 - left join Mosaic.M.ORGANISATION_STRUCTURE os1 on o1.id = os1.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o2 on os1.PARENT_ORG_ID = o2.id - left join Mosaic.M.ORGANISATION_STRUCTURE os2 on o2.id = os2.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o3 on os2.PARENT_ORG_ID = o3.id - left join Mosaic.M.ORGANISATION_STRUCTURE os3 on o3.id = os3.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o4 on os3.PARENT_ORG_ID = o4.id - left join Mosaic.M.ORGANISATION_STRUCTURE os4 on o4.id = os4.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o5 on os4.PARENT_ORG_ID = o5.id - left join Mosaic.M.ORGANISATION_STRUCTURE os5 on o5.id = os5.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o6 on os5.PARENT_ORG_ID = o6.id - left join Mosaic.M.ORGANISATION_STRUCTURE os6 on o6.id = os6.CHILD_ORG_ID - left join Mosaic.M.ORGANISATIONS o7 on os6.PARENT_ORG_ID = o7.id - - where o1.ID = 1221140 /*Children's Social Care*/ - or o2.ID = 1221140 - or o3.ID = 1221140 - or o4.ID = 1221140 - or o5.ID = 1221140 - or o6.ID = 1221140 - or o7.ID = 1221140 - ) - d1 - ) -) -d - -where d.Rnk = 1 + SELECT + NULL prof_table_id /*Information not held as a separate field as Worker ID is unique*/, + a.ID prof_staff_id, + a.FIRST_NAMES, + a.LAST_NAMES, + COALESCE(b.HCPCIdentifier, 'XX' + CAST(a.id as VARCHAR)) prof_social_worker_registration_no, + NULL prof_agency_worker_flag, /*Field removed from SSDS*/, + wrt.DESCRIPTION prof_professional_job_title, + org.NAME prof_professional_department, + NULL prof_full_time_equivalency, /*Information not held in Mosaic; held in HR System (I-Trent)*/, + DENSE_RANK() OVER(PARTITION BY a.ID ORDER BY COALESCE(wr.END_DATE, '99991231') DESC, wr.ID DESC) Rnk + + FROM Mosaic.M.WORKERS a + INNER JOIN Mosaic.M.WORKER_ROLES wr ON a.ID = wr.WORKER_ID + INNER JOIN Mosaic.M.WORKER_ROLE_TYPES wrt ON wr.ROLE = wrt.ROLE + INNER JOIN Mosaic.M.ORGANISATIONS org ON wr.ORG_ID = org.ID + LEFT JOIN Returns.CSCWC.HCPC b ON a.ID = b.WID + + WHERE wrt.DESCRIPTION NOT LIKE '%auth%' /*Authorisor roles which are additional to main role*/ + AND wr.START_DATE <= @STARTTIME + AND COALESCE(wr.END_DATE,'99991231') > @STARTTIME + + AND wr.ORG_ID IN + /*Get current Teams within 'Children's Social Care' in Mosaic Organisation Hierarchy*/ + ( + SELECT + d1.OHLevel1ID + + FROM + ( + SELECT + o1.ID OHLevel1ID, + o1.NAME OHLevel1Name, + o2.ID OHLevel2ID, + o2.NAME OHLevel2Name, + o3.ID OHLevel3ID, + o3.NAME OHLevel3Name, + o4.ID OHLevel4ID, + o4.NAME OHLevel4Name, + o5.ID OHLevel5ID, + o5.NAME OHLevel5Name, + o6.ID OHLevel6ID, + o6.Name OHLevel6Name, + o7.ID OHLevel7ID, + o7.Name OHLevel7Name + + FROM Mosaic.M.ORGANISATIONS o1 + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os1 ON o1.ID = os1.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o2 ON os1.PARENT_ORG_ID = o2.ID + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os2 ON o2.ID = os2.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o3 ON os2.PARENT_ORG_ID = o3.ID + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os3 ON o3.ID = os3.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o4 ON os3.PARENT_ORG_ID = o4.ID + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os4 ON o4.ID = os4.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o5 ON os4.PARENT_ORG_ID = o5.ID + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os5 ON o5.ID = os5.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o6 ON os5.PARENT_ORG_ID = o6.ID + LEFT JOIN Mosaic.M.ORGANISATION_STRUCTURE os6 ON o6.ID = os6.CHILD_ORG_ID + LEFT JOIN Mosaic.M.ORGANISATIONS o7 ON os6.PARENT_ORG_ID = o7.ID + + WHERE o1.ID = 1221140 /*Children's Social Care*/ + OR o2.ID = 1221140 + OR o3.ID = 1221140 + OR o4.ID = 1221140 + OR o5.ID = 1221140 + OR o6.ID = 1221140 + OR o7.ID = 1221140 + ) d1 + ) +) d + +WHERE d.Rnk = 1 /*Number of Open Cases*/ UPDATE #t SET prof_professional_caseload = d.prof_professional_caseload -from #t t -inner join +FROM #t t +INNER JOIN ( - Select - pw.WORKER_ID prof_professional_id, - COUNT(*) prof_professional_caseload + SELECT + pw.WORKER_ID prof_staff_id, + COUNT(*) prof_professional_caseload - from Mosaic.M.PEOPLE_WORKERS pw + FROM Mosaic.M.PEOPLE_WORKERS pw - where pw.START_DATE <= @STARTTIME - and COALESCE(pw.END_DATE, '99991231') > @STARTTIME - and pw.TYPE in ('ALLWKR' /*Allocated Worker*/, - 'AWAKENTEAN' /*Awaken Team*/, - 'FAMFINDSOC' /*Adoption*/, - 'FAMPLACEMENTWORK' /*Fostering*/, - 'PASSW') + WHERE pw.START_DATE <= @STARTTIME + AND COALESCE(pw.END_DATE, '99991231') > @STARTTIME + AND pw.TYPE IN ('ALLWKR' /*Allocated Worker*/, + 'AWAKENTEAN' /*Awaken Team*/, + 'FAMFINDSOC' /*Adoption*/, + 'FAMPLACEMENTWORK' /*Fostering*/, + 'PASSW') - group by pw.WORKER_ID -) -d on t.prof_professional_id = d.prof_professional_id + GROUP BY pw.WORKER_ID +) d ON t.prof_staff_id = d.prof_staff_id /*Output Data*/ -Select -t.prof_table_id, -t.prof_professional_id, ---t.FIRST_NAMES, ---t.LAST_NAMES, -t.prof_social_worker_registration_no, -t.prof_agency_worker_flag, -t.prof_professional_job_title, -t.prof_professional_caseload, -t.prof_professional_department, -t.prof_full_time_equivalency - -from #t t - -order by t.prof_professional_id \ No newline at end of file +SELECT + t.prof_table_id, + t.prof_staff_id, + --t.FIRST_NAMES, + --t.LAST_NAMES, + t.prof_social_worker_registration_no, + t.prof_agency_worker_flag, + t.prof_professional_job_title, + t.prof_professional_caseload, + t.prof_professional_department, + t.prof_full_time_equivalency + +FROM #t t + +ORDER BY t.prof_staff_id diff --git a/cms_ssd_extract_sql/mosaic/SQL_Professionals_Live.sql b/cms_ssd_extract_sql/mosaic/SQL_Professionals_Live.sql index 1012ee7..7589872 100644 --- a/cms_ssd_extract_sql/mosaic/SQL_Professionals_Live.sql +++ b/cms_ssd_extract_sql/mosaic/SQL_Professionals_Live.sql @@ -1,181 +1,142 @@ -/* -PW - Need to clarify which workers to include - e.g. Is it current workers, workers with current cases, workers appearing in other lists etc - Then add appropriate selection criteria - - Currently includes workers with current active role in a tean within 'Children Social Care' in Mosaic Organisation Hierarchy - This still picks up non-case holders (could remove workers with zero cases but this would then exclude Team Managers etc) -*/ - - -DECLARE @STARTTIME DATE = GETDATE() -DECLARE @ENDTIME DATE - - -DECLARE -@ssd_timeframe_years INT = 6, -@ssd_sub1_range_years INT = 1 - - IF OBJECT_ID('Tempdb..#t','u') IS NOT NULL BEGIN -DROP TABLE #t + DROP TABLE #t END CREATE TABLE #t ( -prof_table_id INT /*Information not held as a separate field as Worker ID is unique*/, -prof_professional_id INT, ---FIRST_NAMES VARCHAR(50), ---LAST_NAMES VARCHAR(50), -prof_social_worker_registration_no VARCHAR(20), -prof_agency_worker_flag VARCHAR(10) /*Field removed from SSDS*/, -prof_professional_job_title VARCHAR(100), -prof_professional_caseload INT DEFAULT 0, -prof_professional_department VARCHAR(100), -prof_full_time_equivalency DEC (10,2) /*Information not held in Mosaic; held in HR System (I-Trent)*/ + prof_table_id INT /*Information not held as a separate field as Worker ID is unique*/, -- [REVIEW] Change to prof_profesional_id? + prof_staff_id INT, + --FIRST_NAMES VARCHAR(50), + --LAST_NAMES VARCHAR(50), + prof_social_worker_registration_no VARCHAR(20), + prof_agency_worker_flag VARCHAR(10) /*Field removed from SSDS*/, + prof_professional_job_title VARCHAR(100), + prof_professional_caseload INT DEFAULT 0, + prof_professional_department VARCHAR(100), + prof_full_time_equivalency DEC (10,2) /*Information not held in Mosaic; held in HR System (I-Trent)*/ ) INSERT #t ( -prof_table_id, -prof_professional_id, ---FIRST_NAMES, ---LAST_NAMES, ---prof_social_worker_registration_no, -prof_agency_worker_flag, -prof_professional_job_title, -prof_professional_department, -prof_full_time_equivalency + prof_table_id, -- [REVIEW] Change to prof_profesional_id? + prof_staff_id, + --FIRST_NAMES, + --LAST_NAMES, + --prof_social_worker_registration_no, + prof_agency_worker_flag, + prof_professional_job_title, + prof_professional_department, + prof_full_time_equivalency ) - -Select -d.prof_table_id, -d.prof_professional_id, ---d.FIRST_NAMES, ---d.LAST_NAMES, ---d.prof_social_worker_registration_no, -d.prof_agency_worker_flag, -d.prof_professional_job_title, -d.prof_professional_department, -d.prof_full_time_equivalency - -from +SELECT + d.prof_table_id, + d.prof_staff_id, + --d.FIRST_NAMES, + --d.LAST_NAMES, + --d.prof_social_worker_registration_no, + d.prof_agency_worker_flag, + d.prof_professional_job_title, + d.prof_professional_department, + d.prof_full_time_equivalency +FROM ( - Select - NULL prof_table_id /*Information not held as a separate field as Worker ID is unique*/, - a.ID prof_professional_id, - --a.FIRST_NAMES, - --a.LAST_NAMES, - --COALESCE(b.HCPCIdentifier, 'XX' + CAST(a.id as VARCHAR)) prof_social_worker_registration_no, - NULL prof_agency_worker_flag, /*Field removed from SSDS*/ - wrt.DESCRIPTION prof_professional_job_title, - org.NAME prof_professional_department, - NULL prof_full_time_equivalency, /*Information not held in Mosaic; held in HR System (I-Trent)*/ - DENSE_RANK() OVER(PARTITION BY a.ID ORDER BY COALESCE(wr.END_DATE, '99991231') DESC, wr.ID DESC) Rnk - - from moLive.dbo.WORKERS a - inner join moLive.dbo.WORKER_ROLES wr on a.ID = wr.WORKER_ID - inner join moLive.dbo.WORKER_ROLE_TYPES wrt on wr.ROLE = wrt.ROLE - inner join moLive.dbo.ORGANISATIONS org on wr.ORG_ID = org.ID - --left join Returns.CSCWC.HCPC b on a.ID = b.WID /*Table only in Data Warehoouse*/ - - where wrt.DESCRIPTION not like '%auth%' /*Authorisor roles which are additional to main role*/ - and wr.START_DATE <= @STARTTIME - and COALESCE(wr.END_DATE,'99991231') > @STARTTIME - - and wr.ORG_ID in - /*Get current Teams within 'Children's Social Care' in Mosaic Organisation Hierarchy*/ - ( - Select - d1.OHLevel1ID - - from - ( - Select - o1.ID OHLevel1ID, - o1.NAME OHLevel1Name, - o2.ID OHLevel2ID, - o2.NAME OHLevel2Name, - o3.ID OHLevel3ID, - o3.NAME OHLevel3Name, - o4.ID OHLevel4ID, - o4.NAME OHLevel4Name, - o5.ID OHLevel5ID, - o5.NAME OHLevel5Name, - o6.id OHLevel6ID, - o6.Name OHLevel6Name, - o7.id OHLevel7ID, - o7.Name OHLevel7Name - - from moLive.dbo.ORGANISATIONS o1 - left join moLive.dbo.ORGANISATION_STRUCTURE os1 on o1.id = os1.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o2 on os1.PARENT_ORG_ID = o2.id - left join moLive.dbo.ORGANISATION_STRUCTURE os2 on o2.id = os2.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o3 on os2.PARENT_ORG_ID = o3.id - left join moLive.dbo.ORGANISATION_STRUCTURE os3 on o3.id = os3.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o4 on os3.PARENT_ORG_ID = o4.id - left join moLive.dbo.ORGANISATION_STRUCTURE os4 on o4.id = os4.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o5 on os4.PARENT_ORG_ID = o5.id - left join moLive.dbo.ORGANISATION_STRUCTURE os5 on o5.id = os5.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o6 on os5.PARENT_ORG_ID = o6.id - left join moLive.dbo.ORGANISATION_STRUCTURE os6 on o6.id = os6.CHILD_ORG_ID - left join moLive.dbo.ORGANISATIONS o7 on os6.PARENT_ORG_ID = o7.id - - where o1.ID = 1221140 /*Children's Social Care*/ - or o2.ID = 1221140 - or o3.ID = 1221140 - or o4.ID = 1221140 - or o5.ID = 1221140 - or o6.ID = 1221140 - or o7.ID = 1221140 - ) - d1 - ) -) -d - -where d.Rnk = 1 - + SELECT + NULL prof_table_id /*Information not held as a separate field as Worker ID is unique*/, + a.ID prof_staff_id, + --a.FIRST_NAMES, + --a.LAST_NAMES, + --COALESCE(b.HCPCIdentifier, 'XX' + CAST(a.id as VARCHAR)) prof_social_worker_registration_no, + NULL prof_agency_worker_flag, /*Field removed from SSDS*/, + wrt.DESCRIPTION prof_professional_job_title, + org.NAME prof_professional_department, + NULL prof_full_time_equivalency, /*Information not held in Mosaic; held in HR System (I-Trent)*/, + DENSE_RANK() OVER(PARTITION BY a.ID ORDER BY COALESCE(wr.END_DATE, '99991231') DESC, wr.ID DESC) Rnk + FROM moLive.dbo.WORKERS a + INNER JOIN moLive.dbo.WORKER_ROLES wr ON a.ID = wr.WORKER_ID + INNER JOIN moLive.dbo.WORKER_ROLE_TYPES wrt ON wr.ROLE = wrt.ROLE + INNER JOIN moLive.dbo.ORGANISATIONS org ON wr.ORG_ID = org.ID + --LEFT JOIN Returns.CSCWC.HCPC b ON a.ID = b.WID /*Table only in Data Warehouse*/ + WHERE wrt.DESCRIPTION NOT LIKE '%auth%' /*Authorisor roles which are additional to main role*/ + AND wr.START_DATE <= @STARTTIME + AND COALESCE(wr.END_DATE,'99991231') > @STARTTIME + AND wr.ORG_ID IN + /*Get current Teams within 'Children's Social Care' in Mosaic Organisation Hierarchy*/ + ( + SELECT + d1.OHLevel1ID + FROM + ( + SELECT + o1.ID OHLevel1ID, + o1.NAME OHLevel1Name, + o2.ID OHLevel2ID, + o2.NAME OHLevel2Name, + o3.ID OHLevel3ID, + o3.NAME OHLevel3Name, + o4.ID OHLevel4ID, + o4.NAME OHLevel4Name, + o5.ID OHLevel5ID, + o5.NAME OHLevel5Name, + o6.ID OHLevel6ID, + o6.Name OHLevel6Name, + o7.ID OHLevel7ID, + o7.Name OHLevel7Name + FROM moLive.dbo.ORGANISATIONS o1 + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os1 ON o1.ID = os1.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o2 ON os1.PARENT_ORG_ID = o2.ID + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os2 ON o2.ID = os2.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o3 ON os2.PARENT_ORG_ID = o3.ID + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os3 ON o3.ID = os3.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o4 ON os3.PARENT_ORG_ID = o4.ID + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os4 ON o4.ID = os4.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o5 ON os4.PARENT_ORG_ID = o5.ID + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os5 ON o5.ID = os5.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o6 ON os5.PARENT_ORG_ID = o6.ID + LEFT JOIN moLive.dbo.ORGANISATION_STRUCTURE os6 ON o6.ID = os6.CHILD_ORG_ID + LEFT JOIN moLive.dbo.ORGANISATIONS o7 ON os6.PARENT_ORG_ID = o7.ID + WHERE o1.ID = 1221140 /*Children's Social Care*/ + OR o2.ID = 1221140 + OR o3.ID = 1221140 + OR o4.ID = 1221140 + OR o5.ID = 1221140 + OR o6.ID = 1221140 + OR o7.ID = 1221140 + ) d1 + ) +) d +WHERE d.Rnk = 1 /*Number of Open Cases*/ UPDATE #t SET prof_professional_caseload = d.prof_professional_caseload - -from #t t -inner join +FROM #t t +INNER JOIN ( - Select - pw.WORKER_ID prof_professional_id, - COUNT(*) prof_professional_caseload - - from moLive.dbo.PEOPLE_WORKERS pw - - where pw.START_DATE <= @STARTTIME - and COALESCE(pw.END_DATE, '99991231') > @STARTTIME - and pw.TYPE in ('ALLWKR' /*Allocated Worker*/, - 'AWAKENTEAN' /*Awaken Team*/, - 'FAMFINDSOC' /*Adoption*/, - 'FAMPLACEMENTWORK' /*Fostering*/, - 'PASSW') - - group by pw.WORKER_ID -) -d on t.prof_professional_id = d.prof_professional_id - + SELECT + pw.WORKER_ID prof_staff_id, + COUNT(*) prof_professional_caseload + FROM moLive.dbo.PEOPLE_WORKERS pw + WHERE pw.START_DATE <= @STARTTIME + AND COALESCE(pw.END_DATE, '99991231') > @STARTTIME + AND pw.TYPE IN ('ALLWKR' /*Allocated Worker*/, + 'AWAKENTEAN' /*Awaken Team*/, + 'FAMFINDSOC' /*Adoption*/, + 'FAMPLACEMENTWORK' /*Fostering*/, + 'PASSW') + GROUP BY pw.WORKER_ID +) d ON t.prof_staff_id = d.prof_staff_id /*Output Data*/ -Select -t.prof_table_id, -t.prof_professional_id, ---t.FIRST_NAMES, ---t.LAST_NAMES, -t.prof_social_worker_registration_no, -t.prof_agency_worker_flag, -t.prof_professional_job_title, -t.prof_professional_caseload, -t.prof_professional_department, -t.prof_full_time_equivalency - -from #t t - -order by t.prof_professional_id \ No newline at end of file +SELECT + t.prof_table_id, + t.prof_staff_id, + --t.FIRST_NAMES, + --t.LAST_NAMES, + t.prof_social_worker_registration_no, + t.prof_agency_worker_flag, + t.prof_professional_job_title, + t.prof_professional_caseload, + t.prof_professional_department, + t.prof_full_time_equivalency +FROM #t t +ORDER BY t.prof_staff_id diff --git a/cms_ssd_extract_sql/mosaic/populate_ssd_data_warehouse.sql b/cms_ssd_extract_sql/mosaic/populate_ssd_data_warehouse.sql index c982e2e..deb2027 100644 --- a/cms_ssd_extract_sql/mosaic/populate_ssd_data_warehouse.sql +++ b/cms_ssd_extract_sql/mosaic/populate_ssd_data_warehouse.sql @@ -1938,7 +1938,7 @@ Dependencies: -- create table ##ssd_professionals ( prof_table_id varchar(48), - prof_professional_id varchar(48), + prof_staff_id varchar(48), prof_social_worker_registration_no varchar(48), prof_agency_worker_flag varchar(100), prof_professional_job_title varchar(500), @@ -1949,7 +1949,7 @@ Dependencies: -- insert into ##ssd_professionals ( prof_table_id, - prof_professional_id, + prof_staff_id, prof_social_worker_registration_no, prof_agency_worker_flag, prof_professional_job_title, @@ -1959,7 +1959,7 @@ Dependencies: ) select null prof_table_id, - wkr.WORKER_ID prof_professional_id, + wkr.WORKER_ID prof_staff_id, null prof_social_worker_registration_no, null prof_agency_worker_flag, null prof_professional_job_title, @@ -6694,7 +6694,7 @@ begin try send_person_id nvarchar(48), send_upn nvarchar(48), send_uln nvarchar(48), - upn_unknown nvarchar(48) + send_upn_unknown nvarchar(48) ) -- return 0 diff --git a/tools-ssd_workflow/admin/mosaic_extra_variables.csv b/tools-ssd_workflow/admin/mosaic_extra_variables.csv index f648e9a..4e3a96e 100644 --- a/tools-ssd_workflow/admin/mosaic_extra_variables.csv +++ b/tools-ssd_workflow/admin/mosaic_extra_variables.csv @@ -1,85 +1,71 @@ Extra Variables Not in Spec -misw_person_id -clar_cla_episode_id -icpc_typ -misw_table_id -cine_referral_team +icpc_conf_date_question_user_codes +pers_upn +cina_assessment_outcome_further_intervention +clap_placement_distance clar_cla_person_id +clar_cla_episode_id +clae_episode_start_reason +prof_table_id +lacp_cla_care_plan +clae_cla_episode_cease_reason +perm_guardian_status +icpc_people_idx +icpc_date_question_user_codes post_code +clea_care_leaver_accomm_suitable +icpc_date addr_address_postode -icpc_date_question_user_codes -cina_assessment_worker_id -perm_allocated_worker -cppl_initial_cp_conference_id -cina_assessment_team -cppr_cp_person_id -cppl_cp_plan_team -lacp_cla_care_plan -care_leaver_status_info -clap_cla_episode_id -s47e_s47_completed_by_team -icpc_icpc_team -miss_cla_episode_id -perm_guardian_age -addr_start_date -cine_referral_worker_id -icpc_conf_date_question_user_codes +seen_bedroom +cppr_cp_review_outcome +lapp_previous_permanence_id cine_referral_source -Care_Leavers -pers_upn -cinp_cin_plan_team -cppl_cp_plan_worker_id +prof_rel_type_code +lacp_cla_care_plan_id clar_cla_due_date -clar_cla_review_last_iro_contact_date -pers_send +clap_cla_episode_id perm_decision_revered_date -clea_care_leaver_accomm_suitable -case_status +clap_cla_placement_la +icpc_typ icpc_next_actions -earl_episode_worker_id +clap_cla_placement_end +care_leavers_tmp +clar_cla_review_last_iro_contact_date +icpc_workflow_step_types +miss_cla_episode_id +perm_entered_care_date immi_Immigration_status_id only_subject_type_code -clap_placement_distance -icpc_workflow_step_types -clav_casenote_id +clai_immunisations_id +addr_start_date +cppl_cp_plan_team addr_end_date -perm_adoption_worker -clae_cla_episode_start -perm_guardian_status -cine_clos_reason -lapp_previous_permanence_id -prof_rel_type_code -cinv_cin_plan_id -perm_entered_care_date -miss_missing_episode_end -prof_table_id -seen_bedroom -cinp_cin_plan_start -miss_missing_episode_id -clea_care_leaver_worker_id +cont_contact_source curr_day -clap_cla_placement_end +care_leaver_status_info +perm_allocated_worker +care_leavers +clav_casenote_id +case_status cinp_cin_plan_end -cppr_cp_review_outcome -icpc_date -lacp_cla_care_plan_id +clea_care_leaver_id +perm_permanence_id csdq_sdq_id -care_leavers -clae_episode_start_reason -clea_care_leaver_allocated_team -clae_cla_episode_cease_reason -icpc_icpc_worker_id +cppl_initial_cp_conference_id +cinv_cin_plan_id cppv_visit_id -clai_immunisations_id -link_link_id -cina_assessment_outcome_further_intervention -miss_missing_episode_start -cinp_cin_plan_worker_id -clap_cla_placement_la +pers_send +cine_clos_reason +misw_table_id +miss_missing_episode_end +cinp_cin_plan_start +miss_missing_episode_id +misw_person_id addr_postcode -icpc_people_idx -care_leavers_tmp -clea_care_leaver_id -s47e_s47_completed_by_worker -cont_contact_source -perm_permanence_id +cppr_cp_person_id +cppl_cp_plan_worker_id +miss_missing_episode_start +clae_cla_episode_start +link_link_id +perm_guardian_age +Care_Leavers diff --git a/tools-ssd_workflow/admin/mosaic_not_found.csv b/tools-ssd_workflow/admin/mosaic_not_found.csv index afa0275..8256b26 100644 --- a/tools-ssd_workflow/admin/mosaic_not_found.csv +++ b/tools-ssd_workflow/admin/mosaic_not_found.csv @@ -1,20 +1,9 @@ item_ref,field_name PERS014A,pers_legacy_id FAMI003A,fami_table_id -EARL008A,earl_episode_worker_name -CINE008A,cine_referral_team_name -CINE009A,cine_referral_worker_name -CINA007A,cina_assessment_team_name -CINA008A,cina_assessment_worker_name CINP003A,cinp_cin_plan_start_date CINP004A,cinp_cin_plan_end_date -CINP005A,cinp_cin_plan_team_name -CINP006A,cinp_cin_plan_worker_name CINV007A,cinv_person_id -S47E008A,s47e_s47_completed_by_worker_name -S47E009A,s47e_s47_completed_by_team_name -ICPC007A,icpc_icpc_team_name -ICPC008A,icpc_icpc_worker_name CPPL011A,cppl_cp_plan_ola CPPV008A,cppv_person_id CPPR009A,cppr_cp_review_meeting_id @@ -28,10 +17,11 @@ LACP003A,lacp_cla_care_plan_json CSDQ001A,csdq_table_id CLEA001A,clea_table_id CLEA007A,clea_care_leaver_accom_suitable -CLEA011A,clea_care_leaver_allocated_team_name -CLEA012A,clea_care_leaver_worker_name PERM001A,perm_table_id -PERM023A,perm_adoption_worker_name INVO011A,invo_person_id PROF013A,prof_professional_name -SEND004A,send_upn_unknown +SEND004A,send_upn_unknown [done] +DEPT1001A,dept_team_id +DEPT1002A,dept_team_name +DEPT1003A,dept_team_parent_id +DEPT1004A,dept_team_parent_name diff --git a/tools-ssd_workflow/admin/systemc_extra_variables.csv b/tools-ssd_workflow/admin/systemc_extra_variables.csv index a59a53d..59d7dba 100644 --- a/tools-ssd_workflow/admin/systemc_extra_variables.csv +++ b/tools-ssd_workflow/admin/systemc_extra_variables.csv @@ -1,4 +1,6 @@ Extra Variables Not in Spec -item_status cine_cin_primary_need_code +item_status +cinp_cin_plan_team_name item_ref +cinp_cin_plan_worker_name diff --git a/tools-ssd_workflow/admin/systemc_not_found.csv b/tools-ssd_workflow/admin/systemc_not_found.csv index 5fb7613..b7f644a 100644 --- a/tools-ssd_workflow/admin/systemc_not_found.csv +++ b/tools-ssd_workflow/admin/systemc_not_found.csv @@ -1,2 +1,6 @@ item_ref,field_name CINE010A,cine_cin_primary_need +DEPT1001A,dept_team_id +DEPT1002A,dept_team_name +DEPT1003A,dept_team_parent_id +DEPT1004A,dept_team_parent_name