From 6e7f769aaa363d69259934c74212137e0e13aab1 Mon Sep 17 00:00:00 2001 From: Marymary-dev Date: Thu, 25 Apr 2024 19:23:06 +0300 Subject: [PATCH 1/2] Clean Regimen Lines --- .../clean_CT_art_patients.sql | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql index 09c5e367..88cffe6a 100644 --- a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql +++ b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql @@ -152,9 +152,23 @@ INNER JOIN ods.dbo.lkp_patient_source ON lkp_patient_source.source_name = ARTPat GO --- TODO: clean Start RegimenLine - - - - --- TODO: clean Last RegimenLine +-- clean Start RegimenLine +UPDATE ODS.dbo.CT_ARTPatients SET StartRegimenLine = CASE + WHEN StartRegimenLine in ('1','1st Alternative','1st line','Adult ART FirstLine','Adult first line','Child first line','First line','First line substitute','Paeds ART FirstLine') THEN 'First Line' + WHEN StartRegimenLine in ('2','2nd line','Adult ART SecondLine','Adult second line','Paeds ART Secondline','Second line','Second line substitute') Then 'Second Line' + WHEN StartRegimenLine in ('3','Adult ART ThirdLine','Third line') Then 'Third Line' + WHEN StartRegimenLine in ('PMTCT Maternal Regimens','PMTCT Regimens','') Then 'PMTCT' + WHEN StartRegimenLine in ('Other','Adult intensive') Then 'Other' + END + + + +GO +-- clean Last RegimenLine +UPDATE ODS.dbo.CT_ARTPatients SET LastRegimenLine = CASE + WHEN LastRegimenLine in ('1','1st Alternative','1st line','Adult ART FirstLine','Adult first line','Child first line','First line','First line substitute','Paeds ART FirstLine') THEN 'First Line' + WHEN LastRegimenLine in ('2','2nd line','Adult ART SecondLine','Adult second line','Paeds ART Secondline','Second line','Second line substitute') Then 'Second Line' + WHEN LastRegimenLine in ('3','Adult ART ThirdLine','Third line') Then 'Third Line' + WHEN LastRegimenLine in ('PMTCT Maternal Regimens','PMTCT Regimens','') Then 'PMTCT' + WHEN LastRegimenLine in ('Other','Adult intensive') Then 'Other' + END From 0fa3d323e4dc4ba694cb162b6c0e5eba1f833245 Mon Sep 17 00:00:00 2001 From: Marymary-dev Date: Mon, 29 Apr 2024 11:59:08 +0300 Subject: [PATCH 2/2] Refactoring the clena Regimen lines to map to values in lkp table --- .../clean_CT_art_patients.sql | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql index 88cffe6a..b4bdc284 100644 --- a/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql +++ b/Scripts/ODS/data_quality/CT_cleaning_scripts/clean_CT_art_patients.sql @@ -153,22 +153,16 @@ GO -- clean Start RegimenLine -UPDATE ODS.dbo.CT_ARTPatients SET StartRegimenLine = CASE - WHEN StartRegimenLine in ('1','1st Alternative','1st line','Adult ART FirstLine','Adult first line','Child first line','First line','First line substitute','Paeds ART FirstLine') THEN 'First Line' - WHEN StartRegimenLine in ('2','2nd line','Adult ART SecondLine','Adult second line','Paeds ART Secondline','Second line','Second line substitute') Then 'Second Line' - WHEN StartRegimenLine in ('3','Adult ART ThirdLine','Third line') Then 'Third Line' - WHEN StartRegimenLine in ('PMTCT Maternal Regimens','PMTCT Regimens','') Then 'PMTCT' - WHEN StartRegimenLine in ('Other','Adult intensive') Then 'Other' - END + UPDATE ODS.DBO.CT_ARTPatients + SET StartRegimenLine = ODS.dbo.lkp_RegimenLineMap.Target_Regimen +FROM ODS.DBO.CT_ARTPatients AS ARTPatients +INNER JOIN ods.dbo.lkp_RegimenLineMap ON lkp_RegimenLineMap.Source_Regimen = ARTPatients.StartRegimenLine GO -- clean Last RegimenLine -UPDATE ODS.dbo.CT_ARTPatients SET LastRegimenLine = CASE - WHEN LastRegimenLine in ('1','1st Alternative','1st line','Adult ART FirstLine','Adult first line','Child first line','First line','First line substitute','Paeds ART FirstLine') THEN 'First Line' - WHEN LastRegimenLine in ('2','2nd line','Adult ART SecondLine','Adult second line','Paeds ART Secondline','Second line','Second line substitute') Then 'Second Line' - WHEN LastRegimenLine in ('3','Adult ART ThirdLine','Third line') Then 'Third Line' - WHEN LastRegimenLine in ('PMTCT Maternal Regimens','PMTCT Regimens','') Then 'PMTCT' - WHEN LastRegimenLine in ('Other','Adult intensive') Then 'Other' - END + UPDATE ODS.DBO.CT_ARTPatients + SET LastRegimenLine = ODS.dbo.lkp_RegimenLineMap.Target_Regimen +FROM ODS.DBO.CT_ARTPatients AS ARTPatients +INNER JOIN ods.dbo.lkp_RegimenLineMap ON lkp_RegimenLineMap.Source_Regimen = ARTPatients.LastRegimenLine