From f9e7f2e49df40dd39b7a43b12de64fd927bb9f61 Mon Sep 17 00:00:00 2001 From: Mugo Date: Tue, 2 Jul 2024 19:06:08 +0300 Subject: [PATCH 1/7] modified the asOfDateKey column to asOfDate --- .../REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index d07d3896..ddd18c51 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -17,10 +17,9 @@ BEGIN when ARTOutcome.ARTOutcomeDescription in ('DEAD') Then 'MORTALITY' else ARTOutcome.ARTOutcomeDescription end ARTOutcome - ,asofdatekey + ,[Date].[Date] As asofdatekey ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth - ,cast(asofdatekey as datetime2) As OutcomeYearMonth ,COUNT(1) AS NoOfClients INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory @@ -49,7 +48,7 @@ BEGIN ,Patient.DOB ,[Partner].PartnerName ,ARTOutcome.ARTOutcomeDescription - ,asofdatekey + ,[Date].[Date] ,DateConfirmedHIVPositiveKey ,[AgeGroup].DATIMAgeGroup ORDER BY DateConfirmedHIVPositiveKey DESC; From ff60925db459a308a5f6998f177d92858977fa01 Mon Sep 17 00:00:00 2001 From: Mugo Date: Tue, 2 Jul 2024 19:17:16 +0300 Subject: [PATCH 2/7] modified the asOfDateKey column to asOfDate --- Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index ddd18c51..ccd14a90 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -17,6 +17,7 @@ BEGIN when ARTOutcome.ARTOutcomeDescription in ('DEAD') Then 'MORTALITY' else ARTOutcome.ARTOutcomeDescription end ARTOutcome + ,[Date].[Date] As asofdatekey ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth From 4b0ca1710d826a0572eabb852c9e9c315bbdb7f0 Mon Sep 17 00:00:00 2001 From: Mugo Date: Tue, 2 Jul 2024 19:28:35 +0300 Subject: [PATCH 3/7] modified the asOfDateKey column to asOfDate --- .../REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index ccd14a90..d3bfb5c5 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -17,8 +17,8 @@ BEGIN when ARTOutcome.ARTOutcomeDescription in ('DEAD') Then 'MORTALITY' else ARTOutcome.ARTOutcomeDescription end ARTOutcome - - ,[Date].[Date] As asofdatekey + + ,[Date].[Date] As asofdate ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth ,COUNT(1) AS NoOfClients From 5c83242ea521c83358a8afea46fd27acf5ca1993 Mon Sep 17 00:00:00 2001 From: Mugo Date: Wed, 3 Jul 2024 19:02:31 +0300 Subject: [PATCH 4/7] Removed the reference on dimAgegroup on the script --- .../HIVCaseSurveillance/load_cs_TxContinuity.sql | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index d3bfb5c5..4a337298 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -8,9 +8,10 @@ BEGIN ,Facility.County ,Facility.SubCounty ,Patient.PatientPKHash + ,Patient.PatientKey ,Patient.Gender ,Patient.DOB - ,[AgeGroup].DATIMAgeGroup + ,FactARTHistory.AgeGroup ,[Partner].PartnerName ,case when ARTOutcome.ARTOutcomeDescription in ('LOSS TO FOLLOW UP','UNDOCUMENTED LOSS') Then 'IIT' @@ -22,7 +23,7 @@ BEGIN ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth ,COUNT(1) AS NoOfClients - INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] + --INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory LEFT OUTER JOIN [NDWH].[dbo].[DimFacility] Facility ON FactARTHistory.FacilityKey = Facility.FacilityKey @@ -36,10 +37,8 @@ BEGIN on FactARTHistory.ARTOutcomeKey = ARTOutcome.ARTOutcomeKey LEFT OUTER JOIN [NDWH].[dbo].[DimDate] [Date] ON FactARTHistory.AsOfDateKey = [Date].[Date] - LEFT OUTER JOIN [NDWH].[dbo].[DimAgeGroup] [AgeGroup] - ON FactARTHistory.AgeGroup = [AgeGroup].DATIMAgeGroup WHERE Facility.MFLCode IS NOT NULL AND FactARTHistory.ARTOutcomeKey in (2,3,6,8) -- MORTALITY{2="DEAD"},Txcurr{6="ACTIVE},IIT{8=UNDOCUMENTED LOSS" 3="LOSS TO FOLLOW UP"} - AND YEAR(AsOfDateKey) <= YEAR(GETDATE()) + AND YEAR(AsOfDateKey) <= YEAR(GETDATE()) GROUP BY Facility.FacilityName ,Facility.MFLCode ,Facility.County @@ -50,8 +49,10 @@ BEGIN ,[Partner].PartnerName ,ARTOutcome.ARTOutcomeDescription ,[Date].[Date] + ,Patient.PatientKey ,DateConfirmedHIVPositiveKey - ,[AgeGroup].DATIMAgeGroup + ,FactARTHistory.AgeGroup ORDER BY DateConfirmedHIVPositiveKey DESC; END + From 161f9dc7cbe10745dd01ffbf0f61772f194f1f27 Mon Sep 17 00:00:00 2001 From: Mugo Date: Wed, 3 Jul 2024 19:03:21 +0300 Subject: [PATCH 5/7] Removed the reference on dimAgegroup on the script --- Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index 4a337298..c5d588bf 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -23,7 +23,7 @@ BEGIN ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth ,COUNT(1) AS NoOfClients - --INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] + INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory LEFT OUTER JOIN [NDWH].[dbo].[DimFacility] Facility ON FactARTHistory.FacilityKey = Facility.FacilityKey From 19db9ac37e545fa41fb52f8f5301eafd0439f7cf Mon Sep 17 00:00:00 2001 From: Mugo Date: Mon, 22 Jul 2024 10:54:17 +0300 Subject: [PATCH 6/7] Added EOM for the cohort --- Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index c5d588bf..b8bdc093 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -21,7 +21,7 @@ BEGIN ,[Date].[Date] As asofdate ,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear - ,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth + ,EOMONTH(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYearMonth ,COUNT(1) AS NoOfClients INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory From a6469dcf31ee49cf1bdcc2d36dfbf9a4786053bd Mon Sep 17 00:00:00 2001 From: Mugo Date: Thu, 16 Jan 2025 12:58:40 +0300 Subject: [PATCH 7/7] Modified the dims and facts to read from the availed new schemas --- .../HIVCaseSurveillance/load_cs_TxContinuity.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql index b8bdc093..e641f091 100644 --- a/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql +++ b/Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql @@ -24,18 +24,18 @@ BEGIN ,EOMONTH(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYearMonth ,COUNT(1) AS NoOfClients INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity] - FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory - LEFT OUTER JOIN [NDWH].[dbo].[DimFacility] Facility + FROM [NDWH].[Fact].[FactARTHistory] FactARTHistory + LEFT OUTER JOIN [NDWH].[Dim].[DimFacility] Facility ON FactARTHistory.FacilityKey = Facility.FacilityKey - LEFT OUTER JOIN [NDWH].[dbo].[DimPatient] Patient + LEFT OUTER JOIN [NDWH].[Dim].[DimPatient] Patient on FactARTHistory.PatientKey = Patient.PatientKey - LEFT OUTER JOIN [NDWH].[dbo].[DimPartner] [Partner] + LEFT OUTER JOIN [NDWH].[Dim].[DimPartner] [Partner] on FactARTHistory.PartnerKey = [Partner].PartnerKey - LEFT OUTER JOIN [NDWH].[dbo].[DimAgency] Agency + LEFT OUTER JOIN [NDWH].[Dim].[DimAgency] Agency on FactARTHistory.AgencyKey = Agency.AgencyKey - LEFT OUTER JOIN [NDWH].[dbo].[DimARTOutcome] ARTOutcome + LEFT OUTER JOIN [NDWH].[Dim].[DimARTOutcome] ARTOutcome on FactARTHistory.ARTOutcomeKey = ARTOutcome.ARTOutcomeKey - LEFT OUTER JOIN [NDWH].[dbo].[DimDate] [Date] + LEFT OUTER JOIN [NDWH].[Dim].[DimDate] [Date] ON FactARTHistory.AsOfDateKey = [Date].[Date] WHERE Facility.MFLCode IS NOT NULL AND FactARTHistory.ARTOutcomeKey in (2,3,6,8) -- MORTALITY{2="DEAD"},Txcurr{6="ACTIVE},IIT{8=UNDOCUMENTED LOSS" 3="LOSS TO FOLLOW UP"} AND YEAR(AsOfDateKey) <= YEAR(GETDATE())