From 592a62aecdf51baf81db3c3a69e4eae896acce28 Mon Sep 17 00:00:00 2001 From: Marymary-dev Date: Fri, 3 May 2024 12:45:14 +0300 Subject: [PATCH] Adding IPT variables into linelist FactART --- Scripts/NDWH/C&T FACT TABLES/load_FactLatestObs.sql | 3 +++ .../data_quality/CT_cleaning_scripts/clean_CT_ipt.sql | 2 +- .../7_load_intermediate_LatestObs.sql | 11 ++++++++++- Scripts/REPORTING/1_load_Linelist-FACTART.sql | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Scripts/NDWH/C&T FACT TABLES/load_FactLatestObs.sql b/Scripts/NDWH/C&T FACT TABLES/load_FactLatestObs.sql index 91e17801..c27a8b93 100644 --- a/Scripts/NDWH/C&T FACT TABLES/load_FactLatestObs.sql +++ b/Scripts/NDWH/C&T FACT TABLES/load_FactLatestObs.sql @@ -30,6 +30,9 @@ select Pregnant, breastfeeding, TBScreening, + OnIPT, + StartIPT, + EverOnIPT, cast(getdate() as date) as LoadDate into NDWH.dbo.FactLatestObs from ODS.dbo.intermediate_LatestObs obs diff --git a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_ipt.sql b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_ipt.sql index 0518b7f1..43b753ab 100644 --- a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_ipt.sql +++ b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_ipt.sql @@ -4,7 +4,7 @@ UPDATE [ODS].[DBO].[CT_Ipt] WHEN IndicationForIPT = '1' THEN 'Screened' WHEN IndicationForIPT IN ('TB Screening not done', '0') THEN 'Not Screened' END -WHERE TBScreening IN ('1', 'Screening not done', '0') +WHERE TBScreening IN ('1','TB Screening not done','0') GO diff --git a/Scripts/ODS/load_intermediate_tables/CT_intermediate_tables/7_load_intermediate_LatestObs.sql b/Scripts/ODS/load_intermediate_tables/CT_intermediate_tables/7_load_intermediate_LatestObs.sql index 2c0f3915..ee87dc65 100644 --- a/Scripts/ODS/load_intermediate_tables/CT_intermediate_tables/7_load_intermediate_LatestObs.sql +++ b/Scripts/ODS/load_intermediate_tables/CT_intermediate_tables/7_load_intermediate_LatestObs.sql @@ -140,7 +140,10 @@ latest_Who as ( visits.TBScreening, visits.SiteCode, visits.VisitDate, - visits.VisitID + visits.VisitID, + visits.OnIPT, + visits.StartIPT, + visits.EverOnIPT from ODS.dbo.CT_IPT as visits WHERE VISITS.VOIDED=0 ), @@ -148,6 +151,9 @@ latest_Who as ( select distinct Screening.PatientPK, Screening.TBScreening, + Screening.OnIPT, + Screening.StartIPT, + Screening.EverOnIPT, Screening.SiteCode from last_TBScreening as Screening inner join ODS.dbo.Intermediate_LastVisitDate as last_visit on Screening.SiteCode = last_visit.SiteCode @@ -173,6 +179,9 @@ latest_Who as ( latest_breastfeeding.GestationAge, latest_Who.WhoStage, latest_TBScreening.TBScreening, + latest_TBScreening.OnIPT, + latest_TBScreening.StartIPT, + latest_TBScreening.EverOnIPT, cast(getdate() as date) as LoadDate into ODS.dbo.intermediate_LatestObs from ODS.dbo.CT_Patient as patient diff --git a/Scripts/REPORTING/1_load_Linelist-FACTART.sql b/Scripts/REPORTING/1_load_Linelist-FACTART.sql index 7239902c..78064331 100644 --- a/Scripts/REPORTING/1_load_Linelist-FACTART.sql +++ b/Scripts/REPORTING/1_load_Linelist-FACTART.sql @@ -101,6 +101,9 @@ Select distinct art.Pregnant, art.Breastfeeding, art.IsRTTLast12MonthsAfter3monthsIIT, + obs.OnIPT, + obs.StartIPT, + obs.EverOnIPT, cast (AsOfDateKey as date) as EndofMonthDate, cast(getdate() as date) as LoadDate INTO [REPORTING].[dbo].[Linelist_FACTART]