Skip to content

Commit

Permalink
Merge pull request #283 from palladiumkenya/Feature/-Adding-additiona…
Browse files Browse the repository at this point in the history
…l-indicators-on-NCDs-on-the-reporting-layer

Feature/Adding-additional-indicators-on-NCDs-on-the-reporting-layer
  • Loading branch information
nobert-mumo authored Nov 20, 2023
2 parents 3efd56a + df219a0 commit d2f8896
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Scripts/REPORTING/1_load_Linelist-FACTART.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ IF OBJECT_ID(N'[REPORTING].[dbo].[Linelist_FACTART]', N'U') IS NOT NULL
DROP TABLE [REPORTING].[dbo].[Linelist_FACTART];
BEGIN

with ncd_indicators as (
select
PatientKey,
Hypertension as HasHypertension,
ScreenedBPLastVisit,
IsBPControlledAtLastVisit,
Diabetes as HasDiabetes,
ScreenedDiabetes,
IsDiabetesControlledAtLastTest
from NDWH.dbo.FactNCD
)
Select distinct
pat.PatientIDHash,
pat.PatientPKHash,
Expand Down Expand Up @@ -51,6 +62,12 @@ Select distinct
vl.LowViremia,
pat.ISTxCurr,
dif.DifferentiatedCare,
coalesce(ncd.HasHypertension, 0) as HasHypertension,
coalesce(ncd.ScreenedBPLastVisit, 0) as ScreenedBPLastVisit,
coalesce(ncd.IsBPControlledAtLastVisit, 0) as IsBPControlledAtLastVisit,
coalesce(ncd.HasDiabetes, 0) as HasDiabetes,
coalesce(ncd.ScreenedDiabetes, 0) as ScreenedDiabetes,
coalesce(ncd.IsDiabetesControlledAtLastTest, 0) as IsDiabetesControlledAtLastTest,
CD4.LastCD4,
CD4.LastCD4Percentage,
WhoStage,
Expand All @@ -72,6 +89,7 @@ left join NDWH.dbo.FactViralLoads as vl on vl.PatientKey = ART.PatientKey
left join NDWH.dbo.FactLatestObs as obs on obs.PatientKey = ART.PatientKey
left join NDWH.dbo.DimDifferentiatedCare as dif on dif.DifferentiatedCareKey = obs.DifferentiatedCareKey
left join NDWH.dbo.DimDate as lastVL on lastVL.DateKey = vl.LastVLDateKey
left join ncd_indicators as ncd on ncd.PatientKey = ART.PatientKey
left join NDWH.dbo.FactCD4 as CD4 on CD4.PatientKey= ART.PatientKey
WHERE ART.ARTOutcomeKey IS NOT NULL;
END
Expand Down

0 comments on commit d2f8896

Please sign in to comment.