Skip to content
Snippets Groups Projects
Commit 94eb3db7 authored by Thomas  OBADIA's avatar Thomas OBADIA :speech_balloon:
Browse files

Make casting for REDCAP system variables explicit to address changes in the redcapAPI methods

parent 8f8abcbd
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@
### SOURCE THE R ENVIRONMENT
######################################################################
source("./03_INTERVENTIONAL_M0/INTERVENTIONAL_M0_00_R_environment.R")
source("./03_INTERVENTIONAL_M0/INTERVENTIONAL_M0_00_R_functions.R")
......@@ -105,27 +106,37 @@ if (!DATA_EXTRACT_IS_RECENT_INT_M0) {
# Radio buttons reported as label instead of code
"radio" = castLabelCharacter,
"yesno" = castLabelCharacter,
"dropdown" = castLabelCharacter
"dropdown" = castLabelCharacter,
"system" = castLabelCharacter
)) %>%
# Convert the '999' code to NA, except in Date/POSIX fields because it'll mess them up
mutate(across(-c(where(is.POSIXt),
where(is.Date)), function(x) (ifelse(x == 999, NA, x)))) %>%
where(is.Date)), function(x) (ifelse(as.character(x) == "999", NA, x)))) %>%
# Add data source for convenience
mutate(data_source = RCON)
## Check for invalid records before moving on
print(reviewInvalidRecords(dat_interventional_m0_raw[[RCON]]))
}
# Cleanup that loop
rm(RCON)
## Propagate baseline data to subsequent events
dat_interventional_m0_raw[[RCON]] <- propagate_unique_data(x = dat_interventional_m0_raw[[RCON]],
metadata = RCON_INTERVENTIONAL_M0[[RCON]]$metadata(),
events.from = c("participant_screening",
"eligibility_consent",
"identification_demographics",
"safety_of_study_drugs",
"final_status"))
}
# Concatenate all data into a single table
dat_interventional_m0_raw <- dat_interventional_m0_raw %>%
bind_rows()
# Cleanup that loop
rm(RCON)
## Passive Case Detection datasets
for (RCON in names(RCON_INTERVENTIONAL_PCD)) {
cat("Extracting data from RCON_INTERVENTIONAL_PCD element: ",
......@@ -138,7 +149,8 @@ if (!DATA_EXTRACT_IS_RECENT_INT_M0) {
# Radio buttons reported as label instead of code
"radio" = castLabelCharacter,
"yesno" = castLabelCharacter,
"dropdown" = castLabelCharacter
"dropdown" = castLabelCharacter,
"system" = castLabelCharacter
)) %>%
# Convert the '999' code to NA, except in Date/POSIX fields because it'll mess them up
......@@ -228,4 +240,3 @@ rm(INTERVENTIONAL_M0_OUT_01_FILENAME,
DATA_EXTRACT_IS_RECENT_INT_M0 <- as.logical(difftime(time1 = Sys.Date(),
time2 = as.Date(ifelse(exists("DATA_EXTRACT_TS_INT_M0"), DATA_EXTRACT_TS_INT_M0, DATA_EXTRACT_TS_DEFAULT)),
units = "days") <= DATA_EXTRACT_EXPIRY_TIME_D)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment