Skip to content

Commit

Permalink
Merge pull request #420 from palladiumkenya/Bugfix/-Adapting-Fact-ART…
Browse files Browse the repository at this point in the history
…-to-handle-updated-logic-for-NCD-controlled-and-screened

Bugfix/-Adapting-Fact-ART-to-handle-updated-logic-for-NCD-controlled-and-screened
  • Loading branch information
nobert-mumo authored Apr 29, 2024
2 parents e0f327e + cdc748a commit 421c5b2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Scripts/NDWH/C&T FACT TABLES/load_FactART.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@ ncd_screening as (
select
patient.PatientPKHash,
patient.SiteCode,
ScreenedDiabetes,
ScreenedBPLastVisit
case
when latest_diabetes.Controlled in ('Yes', 'No') then 1
else 0
end as ScreenedDiabetes,
case
when latest_hypertension.Controlled in ('Yes', 'No') then 1
else 0
end as ScreenedBPLastVisit
from Patient
left join ODS.dbo.Intermediate_LatestDiabetesTests as latest_diabetes_test on latest_diabetes_test.PatientPKHash = Patient.PatientPKHash
and latest_diabetes_test.SiteCode = Patient.SiteCode
left join ODS.dbo.Intermediate_LastVisitDate as visit on visit.PatientPK = Patient.PatientPK
and visit.SiteCode = Patient.SiteCode
left join ODS.dbo.Intermediate_NCDControlledStatusLastVisit as latest_diabetes on latest_diabetes.PatientPKHash = Patient.PatientPKHash
and latest_diabetes.SiteCode = Patient.SiteCode
and latest_diabetes.Disease = 'Diabetes'
left join ODS.dbo.Intermediate_NCDControlledStatusLastVisit as latest_hypertension on latest_hypertension.PatientPKHash = Patient.PatientPKHash
and latest_hypertension.SiteCode = Patient.SiteCode
and latest_hypertension.Disease = 'Hypertension'
),
rtt_within_last_12_months as (
select
Expand Down

0 comments on commit 421c5b2

Please sign in to comment.