Skip to content
Snippets Groups Projects
Commit 802dc5c6 authored by Thomas  OBADIA's avatar Thomas OBADIA
Browse files

Now that IPM data from the observational study are available, I need to split...

Now that IPM data from the observational study are available, I need to split the curation rule (that fixes the agey calculation) by country, because only the data from Ethiopia suffered from that bug.
parent 965ab4c3
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ dotenv::load_dot_env("./02_OBSERVATIONAL/.env")
# - TRUE : data will be dumped
# - FALSE: data will not be dumped
DATA_SOURCE_REDCAP_IPP_OBS <- FALSE
DATA_SOURCE_REDCAP_IPM_OBS <- FALSE
DATA_SOURCE_REDCAP_IPM_OBS <- TRUE
DATA_SOURCE_REDCAP_AHRI_OBS <- TRUE
......@@ -89,4 +89,5 @@ SEED <- 12345
## the raw data dumped from REDCap or not.
# - TRUE : curation rule will be enforced
# - FALSE: curation rule will not be enforced (default)
CURATE_DATA_RECALCULATE_AGEY <- TRUE
CURATE_DATA_RECALCULATE_AGEY_ETHIOPIA <- TRUE
CURATE_DATA_RECALCULATE_AGEY_MADAGASCAR <- FALSE
......@@ -32,16 +32,28 @@ source("./02_OBSERVATIONAL/OBSERVATIONAL_01_dump_REDCap_database.R")
## Start from the raw dataset generated in OBSERVATIONAL_01_dump_REDCap_database.R
dat_observational_curated <- dat_observational_raw %>%
# Go through each curation flag
mutate(agey = case_when(CURATE_DATA_RECALCULATE_AGEY & (dob_yn %in% c(1, "Yes") & !is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = dob,
units = "days")) / 365.25,
digits = 0),
CURATE_DATA_RECALCULATE_AGEY & (dob_yn %in% c(0, "No") | is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = as.Date(x = calc_dob_from_myob,
format = "%d-%m-%Y"),
units = "days")) / 365.25,
digits = 0),
.default = agey))
mutate(
# agey: distinct curation flages for Ethiopia & Madagascar
agey = case_when(CURATE_DATA_RECALCULATE_AGEY_ETHIOPIA & country %in% c("E", "Ethiopia") & (dob_yn %in% c(1, "Yes") & !is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = dob,
units = "days")) / 365.25,
digits = 0),
CURATE_DATA_RECALCULATE_AGEY_ETHIOPIA & country %in% c("E", "Ethiopia") & (dob_yn %in% c(0, "No") | is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = as.Date(x = calc_dob_from_myob,
format = "%d-%m-%Y"),
units = "days")) / 365.25,
digits = 0),
CURATE_DATA_RECALCULATE_AGEY_MADAGASCAR & country %in% c("M", "Madagascar") & (dob_yn %in% c(1, "Yes") & !is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = dob,
units = "days")) / 365.25,
digits = 0),
CURATE_DATA_RECALCULATE_AGEY_MADAGASCAR & country %in% c("M", "Madagascar") & (dob_yn %in% c(0, "No") | is.na(dob)) ~ round(x = as.numeric(difftime(time1 = visdat,
time2 = as.Date(x = calc_dob_from_myob,
format = "%d-%m-%Y"),
units = "days")) / 365.25,
digits = 0),
.default = agey))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment