Skip to content

Commit

Permalink
Merge pull request #477 from palladiumkenya/Feauture--Add-Fact-CT-Pat…
Browse files Browse the repository at this point in the history
…ients

 Adding a column for EveronART to DimPatient
  • Loading branch information
DennisGibz authored Aug 12, 2024
2 parents 2105016 + 7049439 commit ded430c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Scripts/NDWH/ALL DIMENSIONS/load_DimPatient.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ BEGIN
cast(Getdate() AS DATE)
AS LoadDate,
coalesce(replace(patients.DateConfirmedHIVPositive,'-',''), replace(art.StartARTDate,'-',''),replace(patients.RegistrationAtCCC,'-','')) as DateConfirmedHIVPositiveKey,
patients.voided
patients.voided,
case when art.StartARTDate is not null then 1 else 0 end as EveronART
FROM ods.dbo.ct_patient AS patients
LEFT JOIN ods.dbo.ct_patientbaselines AS baselines
ON patients.patientpkhash = baselines.patientpkhash
Expand Down Expand Up @@ -113,6 +114,7 @@ BEGIN
ct_patient_source.datebaselinewhokey,
ct_patient_source.istxcurr,
ct_patient_source.DateConfirmedHIVPositiveKey,
ct_patient_source.EveronART,
hts_patient_source.htsnumberhash,
Cast(Getdate() AS DATE)
AS LoadDate
Expand Down Expand Up @@ -155,6 +157,7 @@ BEGIN
combined_data_ct_hts.datebaselinewhokey,
combined_data_ct_hts.istxcurr,
combined_data_ct_hts.DateConfirmedHIVPositiveKey,
combined_data_ct_hts.EverOnART,
combined_data_ct_hts.htsnumberhash,
prep_patient_source.prepnumber,
Cast(Format(prep_patient_source.prepenrollmentdate,
Expand Down Expand Up @@ -201,6 +204,7 @@ BEGIN
combined_data_ct_hts_prep.datebaselinewhokey,
combined_data_ct_hts_prep.istxcurr,
combined_data_ct_hts_prep.DateConfirmedHIVPositiveKey,
combined_data_ct_hts_prep.EverOnART,
combined_data_ct_hts_prep.htsnumberhash,
combined_data_ct_hts_prep.prepenrollmentdatekey,
combined_data_ct_hts_prep.prepnumber,
Expand Down Expand Up @@ -271,6 +275,7 @@ BEGIN
combined_data_ct_hts_prep_pmtct.datebaselinewhokey As datebaselinewhokey,
combined_data_ct_hts_prep_pmtct.istxcurr As istxcurr,
combined_data_ct_hts_prep_pmtct.DateConfirmedHIVPositiveKey,
combined_data_ct_hts_prep_pmtct.EverOnART,
combined_data_ct_hts_prep_pmtct.htsnumberhash,
NUll As sitetype,
LatestDisclosure.Disclosure,
Expand Down Expand Up @@ -299,9 +304,10 @@ BEGIN
Null datebaselinewhokey,
Null istxcurr,
Null DateConfirmedHIVPositiveKey,
Null EverOnART,
Null htsnumberhash,
sitetype,
LatestDisclosure.Disclosure,
LatestDisclosure.Disclosure,
Null LoadDate,
Null Voided,
Null PrepNumber,
Expand Down Expand Up @@ -339,7 +345,8 @@ BEGIN
combined_data_ct_hts_prep_pmtct_Ushauri.prepenrollmentdatekey,
combined_data_ct_hts_prep_pmtct_Ushauri.istxcurr,
combined_data_ct_hts_prep_pmtct_Ushauri.DateConfirmedHIVPositiveKey,
combined_data_ct_hts_prep_pmtct_Ushauri.Disclosure,
combined_data_ct_hts_prep_pmtct_Ushauri.EverOnART,
combined_data_ct_hts_prep_pmtct_Ushauri.Disclosure,
combined_data_ct_hts_prep_pmtct_Ushauri.patientmnchidhash,
combined_data_ct_hts_prep_pmtct_Ushauri.firstenrollmentatmnchdatekey,
combined_data_ct_hts_prep_pmtct_Ushauri.loaddate,
Expand All @@ -364,10 +371,11 @@ BEGIN
enrollmentwhokey,
datebaselinewhokey,
baselinewhokey,
PrepEnrollmentDateKey,
PrepEnrollmentDateKey,
istxcurr,
DateConfirmedHIVPositiveKey,
disclosure,
EverOnART,
disclosure,
loaddate,
voided)
VALUES(patientidhash,
Expand All @@ -387,7 +395,8 @@ BEGIN
PrepEnrollmentDateKey,
istxcurr,
DateConfirmedHIVPositiveKey,
disclosure,
EverOnART,
disclosure,
loaddate,
voided)
WHEN matched THEN
Expand All @@ -405,5 +414,6 @@ BEGIN
a.PrepEnrollmentDateKey = b.PrepEnrollmentDateKey,
a.voided = b.voided,
a.DateConfirmedHIVPositiveKey = b.DateConfirmedHIVPositiveKey,
a.EverOnART = b.EverOnART,
a.Disclosure = b.Disclosure;
END

0 comments on commit ded430c

Please sign in to comment.