Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a column for EveronART to DimPatient #477

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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