diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..d2d542e --- /dev/null +++ b/.lintr @@ -0,0 +1,6 @@ +linters: linters_with_defaults( + line_length_linter(120), + object_usage_linter = NULL, + indentation_linter = NULL, + trailing_whitespace_linter = NULL + ) diff --git a/DESCRIPTION b/DESCRIPTION index 78092f5..3ba0127 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dv.clinlines Title: DaVinci's Clinical Timelines -Version: 1.0.3 +Version: 1.0.4 Authors@R: c( person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")), diff --git a/NEWS.md b/NEWS.md index 9b51484..19817b4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# dv.clinlines 1.0.4 + +* Adapt basic_info, filter, and drug_admin parameter to adhere module standard + # dv.clinlines 1.0.3 * Initial release of dv.clinlines package to GitHub. diff --git a/R/data_prep.R b/R/data_prep.R index cc8d9ca..431693f 100644 --- a/R/data_prep.R +++ b/R/data_prep.R @@ -33,13 +33,13 @@ prep_data <- function(data_list, data_list <- append(data_list, list(no_da = empty_drug_admin)) drug_admin <- list( - name = "no_da", + dataset_name = "no_da", start_var = "start", end_var = "end", detail_var = "details", label = "", - exp_dose = "dose", - exp_dose_unit = "unit" + dose_var = "dose", + dose_unit_var = "unit" ) } @@ -176,21 +176,21 @@ add_ids <- function(data_list) { #' @keywords internal set_basics <- function(data_list, basic_info = default_basic_info(), subjid_var) { # Extract subject level dataset from data_list - data <- data_list[[basic_info$data]] + data <- data_list[[basic_info$subject_level_dataset_name]] check_names( data, - var_names = c(basic_info$trt_start, basic_info$trt_end, basic_info$icf_date), + var_names = c(basic_info$trt_start_var, basic_info$trt_end_var, basic_info$icf_date_var), subjid_var = subjid_var ) - check_date_type(data, c(basic_info$trt_start, basic_info$trt_end, basic_info$icf_date)) + check_date_type(data, c(basic_info$trt_start_var, basic_info$trt_end_var, basic_info$icf_date_var)) return( list( data = dplyr::rename(data, dplyr::all_of(c(subject_id = subjid_var))), - trt_start = basic_info$trt_start, - trt_end = basic_info$trt_end, - icf_date = basic_info$icf_date + trt_start = basic_info$trt_start_var, + trt_end = basic_info$trt_end_var, + icf_date = basic_info$icf_date_var ) ) } @@ -299,9 +299,9 @@ set_events_intern <- function(data_list, mapping = default_mapping(), subjid_var #' \item{\code{detail_var}: Character name of the variable that contains the treatment #' information. Must exist in the dataset mentioned in the \code{name} element.} #' \item{\code{label}: Free-text character label for the drug administration event.} -#' \item{\code{exp_dose}: Character name of the variable that contains the dosis level +#' \item{\code{dose_var}: Character name of the variable that contains the dosis level #' information. Must exist in the dataset mentioned in the \code{name} element.} -#' \item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +#' \item{\code{dose_unit_var}: Character name of the variable that contains the dosis #' unit. Must exist in the dataset mentioned in the \code{name} element.} #' } #' @@ -314,7 +314,7 @@ set_events_intern <- function(data_list, mapping = default_mapping(), subjid_var #' \item{\code{detail_var}: Information about drug name and dosage.} #' \item{\code{set}: Name of the dataset the data origins from.} #' \item{\code{set_id}: Row ID's of the related dataset.} -#' \item{\code{exp_dose}: Indicates whether the dose of the treatment has increased, +#' \item{\code{dose_var}: Indicates whether the dose of the treatment has increased, #' decreased or stayed the same compared to the last dose at the same subject.} #' \item{\code{group}: Label for the event types.} #' } @@ -322,19 +322,19 @@ set_events_intern <- function(data_list, mapping = default_mapping(), subjid_var #' @keywords internal #' set_exp_intervals <- function(data_list, mapping = default_drug_admin(), subjid_var) { - col_list <- mapping[!names(mapping) %in% c("name")] + col_list <- mapping[!names(mapping) %in% c("dataset_name")] cols <- c(col_list$start_var, col_list$end_var, col_list$detail_var) - data <- data_list[[mapping$name]] + data <- data_list[[mapping$dataset_name]] data <- data %>% dplyr::group_by(get(subjid_var)) %>% dplyr::mutate( exp_dose = dplyr::case_when( - is.na(dplyr::lag(get(col_list$exp_dose))) ~ "start/equal", - dplyr::lag(get(col_list$exp_dose)) == get(col_list$exp_dose) ~ "start/equal", - dplyr::lag(get(col_list$exp_dose)) < get(col_list$exp_dose) ~ "increase", - dplyr::lag(get(col_list$exp_dose)) > get(col_list$exp_dose) ~ "decrease" + is.na(dplyr::lag(get(col_list$dose_var))) ~ "start/equal", + dplyr::lag(get(col_list$dose_var)) == get(col_list$dose_var) ~ "start/equal", + dplyr::lag(get(col_list$dose_var)) < get(col_list$dose_var) ~ "increase", + dplyr::lag(get(col_list$dose_var)) > get(col_list$dose_var) ~ "decrease" ) ) %>% dplyr::ungroup() @@ -346,8 +346,8 @@ set_exp_intervals <- function(data_list, mapping = default_drug_admin(), subjid_ dplyr::mutate( detail_var = paste( .data[[col_list$detail_var]], "-", - .data[[col_list$exp_dose]], - .data[[col_list$exp_dose_unit]] + .data[[col_list$dose_var]], + .data[[col_list$dose_unit_var]] ) ) %>% dplyr::select( @@ -358,10 +358,9 @@ set_exp_intervals <- function(data_list, mapping = default_drug_admin(), subjid_ start_exp = tidyselect::all_of(col_list$start_var), end_exp = tidyselect::all_of(col_list$end_var) ) %>% - dplyr::mutate(set = mapping$name) %>% + dplyr::mutate(set = mapping$dataset_name) %>% dplyr::rename(dplyr::all_of(c(subject_id = subjid_var))) - return(interval_df) } @@ -578,26 +577,26 @@ complete_events <- function(combined_data, trt_start, trt_end) { set_filter_dataset <- function(filter, data_list, mapping, subjid_var) { # Check for inconsistencies on modul definition side if (length(filter$ae_filter) < 3) stop("No ae_filter defined for Clinical Timelines!") - if (!filter$ae_filter$data_name %in% names(data_list)) { + if (!filter$ae_filter$dataset_name %in% names(data_list)) { msg <- paste0( "Clinical Timelines (dv.clinlines) cannot find ", - filter$ae_filter$data_name, + filter$ae_filter$dataset_name, " in your data list." ) stop(msg) } - only_filters <- filter$ae_filter[!names(filter$ae_filter) %in% c("data_name", "label")] + only_filters <- filter$ae_filter[!names(filter$ae_filter) %in% c("dataset_name", "label")] - check_names(data_list[[filter$ae_filter$data_name]], - unlist(only_filters), # drop data_name + check_names(data_list[[filter$ae_filter$dataset_name]], + unlist(only_filters), # drop dataset_name subjid_var = subjid_var ) - ae_info <- mapping[[filter$ae_filter$data_name]][[filter$ae_filter$label]] + ae_info <- mapping[[filter$ae_filter$dataset_name]][[filter$ae_filter$label]] - filter_dataset <- data_list[[filter$ae_filter$data_name]] %>% + filter_dataset <- data_list[[filter$ae_filter$dataset_name]] %>% dplyr::select( dplyr::all_of( c( diff --git a/R/helpers.R b/R/helpers.R index 4e075e4..70deefb 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -2,22 +2,27 @@ #' #' Helper function to support configuration of a Clinical Timelines module. #' -#' @param data Character name of the subject level analysis dataset (e.g. "adsl", "dm") +#' @param subject_level_dataset_name Character name of the subject level analysis dataset (e.g. "adsl", "dm") #' as it is called in the \code{data_list} parameter. -#' @param trt_start Character name of the variable that contains treatment start dates. -#' Must be present in the data frame mentioned in the \code{data} element. -#' @param trt_end Character name of the variable that contains treatment end dates. -#' Must be present in the data frame mentioned in the \code{data} element. -#' @param icf_date Character name of the variable that contains informed consent dates. -#' Must be present in the data frame mentioned in the \code{data} element. +#' @param trt_start_var Character name of the variable that contains treatment start dates. +#' Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element. +#' @param trt_end_var Character name of the variable that contains treatment end dates. +#' Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element. +#' @param icf_date_var Character name of the variable that contains informed consent dates. +#' Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element. #' #' @return A list that could directly be used as input for the \code{basic_info} parameter #' of \code{mod_clinical_timelines()} and \code{mod_clinical_timelines_server()}. #' @export #' -set_basic_info <- function(data, trt_start, trt_end, icf_date) { +set_basic_info <- function(subject_level_dataset_name, trt_start_var, trt_end_var, icf_date_var) { return( - list(data = data, trt_start = trt_start, trt_end = trt_end, icf_date = icf_date) + list( + subject_level_dataset_name = subject_level_dataset_name, + trt_start_var = trt_start_var, + trt_end_var = trt_end_var, + icf_date_var = icf_date_var + ) ) } @@ -70,7 +75,7 @@ set_event <- function(start_dt_var, #' #' Helper function to support configuration of a Clinical Timelines module. #' -#' @param name Character name of the data frame that holds drug administration data +#' @param dataset_name Character name of the data frame that holds drug administration data #' (e.g. ex domain) as it is called in the \code{data_list} parameter. #' @param start_var Character name of the variable that contains the start dates #' (e.g. exposure start dates). Must be present in the data frame mentioned in the name @@ -81,31 +86,31 @@ set_event <- function(start_dt_var, #' @param detail_var Character name of the variable that contains the treatment #' information. Must exist in the dataset mentioned in the name element. #' @param label Free-text character label for the drug administration event. -#' @param exp_dose Character name of the variable that contains the dosis level +#' @param dose_var Character name of the variable that contains the dosis level #' information. Must exist in the dataset mentioned in the name element. -#' @param exp_dose_unit Character name of the variable that contains the dosis unit. +#' @param dose_unit_var Character name of the variable that contains the dosis unit. #' Must exist in the dataset mentioned in the name element. #' #' @return A list that could directly be used as input for the \code{drug_admin} parameter #' of \code{mod_clinical_timelines()} and \code{mod_clinical_timelines_server()}. #' @export #' -set_drug_admin <- function(name, +set_drug_admin <- function(dataset_name, start_var, end_var, detail_var, label, - exp_dose, - exp_dose_unit) { + dose_var, + dose_unit_var) { return( list( - name = name, + dataset_name = dataset_name, start_var = start_var, end_var = end_var, detail_var = detail_var, label = label, - exp_dose = exp_dose, - exp_dose_unit = exp_dose_unit + dose_var = dose_var, + dose_unit_var = dose_unit_var ) ) } diff --git a/R/local_filter_setup.R b/R/local_filter_setup.R index 44143aa..3f96a24 100644 --- a/R/local_filter_setup.R +++ b/R/local_filter_setup.R @@ -7,8 +7,8 @@ #' local_filters <- function(ns) { ui_list <- list( - serious_AE = shiny::radioButtons( - ns("serious_AE"), + serious_ae = shiny::radioButtons( + ns("serious_ae"), label = "Serious Adverse Events?", choices = c("Yes" = "Y", "No" = "N", "All" = "all"), selected = "all" @@ -27,8 +27,8 @@ local_filters <- function(ns) { multiple = TRUE, options = list(placeholder = "All PT's selected") ), - drug_rel_AE = shiny::radioButtons( - ns("drug_rel_AE"), + drug_rel_ae = shiny::radioButtons( + ns("drug_rel_ae"), label = "Drug related Adverse Events?", choices = c("Yes" = "Y", "No" = "N", "All" = "all"), selected = "all" diff --git a/R/mock_clinical_timelines.R b/R/mock_clinical_timelines.R index f8c5a24..89ee5cf 100644 --- a/R/mock_clinical_timelines.R +++ b/R/mock_clinical_timelines.R @@ -13,7 +13,7 @@ mock_clinical_timelines_UI <- function(id = NULL) { # nolint shiny::tags$h1("BI Clinical Timelines", class = "mod-title"), mod_clinical_timelines_UI( ns("clin_tl"), - list("serious_AE", "soc", "pref_term", "drug_rel_AE") + list("serious_ae_var", "soc_var", "pref_term_var", "drug_rel_ae_var") ) ) @@ -35,10 +35,10 @@ mock_clinical_timelines_server <- function(input, output, session) { data_name = shiny::reactive("dummyData"), data_list, basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -68,23 +68,23 @@ mock_clinical_timelines_server <- function(input, output, session) { ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), subjid_var = "USUBJID", filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AEREL" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AEREL" ) ), ms = 50 diff --git a/R/mock_local_filter.R b/R/mock_local_filter.R index 3de15e4..b71555a 100644 --- a/R/mock_local_filter.R +++ b/R/mock_local_filter.R @@ -9,7 +9,7 @@ mock_local_filter_UI <- function(request) { # nolint shiny::bookmarkButton(), mod_local_filter_UI( "filter", - list("soc", "pref_term", "drug_rel_AE", "serious_AE") + list("soc_var", "pref_term_var", "drug_rel_ae_var", "serious_ae_var") ), shiny::tableOutput("table") ) @@ -69,7 +69,8 @@ mock_local_filter_server <- function(input, output, session) { filtered_data <- mod_local_filter_server( "filter", filter = list(ae_filter = list( - data_name = "adae", soc = "AESOC", pref_term = "AEDECOD", drug_rel_AE = "AEREL", serious_AE = "AESER" + dataset_name = "adae", soc_var = "AESOC", pref_term_var = "AEDECOD", drug_rel_ae_var = "AEREL", + serious_ae_var = "AESER" )), joined_data = initial_data, changed = shiny::reactive(1) diff --git a/R/mock_with_mm.R b/R/mock_with_mm.R index 929410f..631360b 100644 --- a/R/mock_with_mm.R +++ b/R/mock_with_mm.R @@ -19,10 +19,10 @@ mock_with_mm_app <- function() { "Clinical Timelines" = mod_clinical_timelines( module_id = "mod1", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -59,23 +59,23 @@ mock_with_mm_app <- function() { ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), subjid_var = "USUBJID", filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AERELFLG" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AERELFLG" ) ), ms = 50, diff --git a/R/mod_clinical_timelines.R b/R/mod_clinical_timelines.R index 58ed42e..66650b7 100644 --- a/R/mod_clinical_timelines.R +++ b/R/mod_clinical_timelines.R @@ -32,7 +32,11 @@ mod_clinical_timelines_UI <- function(module_id, # nolint ac <- checkmate::makeAssertCollection() checkmate::assert_string(module_id, min.chars = 1, add = ac) checkmate::assert_list(filter_list, types = "character", null.ok = TRUE, add = ac) - checkmate::assert_subset(unlist(filter_list), choices = c("soc", "serious_AE", "pref_term", "drug_rel_AE"), add = ac) + checkmate::assert_subset( + unlist(filter_list), + choices = c("soc_var", "serious_ae_var", "pref_term_var", "drug_rel_ae_var"), + add = ac + ) checkmate::assert_string(x_param, null.ok = TRUE, add = ac) checkmate::assert_subset(x_param, choices = c("date", "day"), add = ac) checkmate::reportAssertions(ac) @@ -110,7 +114,16 @@ mod_clinical_timelines_server <- function(module_id, checkmate::assert_multi_class(data_name, c("reactive", "shinymeta_reactive"), add = ac) checkmate::assert_multi_class(dataset_list, c("reactive", "shinymeta_reactive"), add = ac) checkmate::assert_list(basic_info, types = "character", add = ac) - checkmate::assert_subset(names(basic_info), choices = c("data", "trt_start", "trt_end", "icf_date"), add = ac) + checkmate::assert_subset( + names(basic_info), + choices = c( + "subject_level_dataset_name", + "trt_start_var", + "trt_end_var", + "icf_date_var" + ), + add = ac + ) checkmate::assert_list(mapping, types = "list", add = ac) checkmate::assert_character(unlist(mapping), add = ac) lapply(mapping, function(x) { @@ -124,7 +137,7 @@ mod_clinical_timelines_server <- function(module_id, checkmate::assert_list(drug_admin, types = "character", null.ok = TRUE, add = ac) checkmate::assert_subset( names(drug_admin), - choices = c("name", "start_var", "end_var", "detail_var", "label", "exp_dose", "exp_dose_unit"), + choices = c("dataset_name", "start_var", "end_var", "detail_var", "label", "dose_var", "dose_unit_var"), add = ac ) checkmate::assert_list(filter, types = "list", null.ok = TRUE, add = ac) @@ -132,7 +145,7 @@ mod_clinical_timelines_server <- function(module_id, lapply(filter, function(x) { checkmate::assert_subset( names(unlist(x)), - choices = c("data_name", "label", "soc", "serious_AE", "pref_term", "drug_rel_AE") + choices = c("dataset_name", "label", "soc_var", "serious_ae_var", "pref_term_var", "drug_rel_ae_var") ) }) checkmate::assert_string(subjid_var, min.chars = 1, add = ac) @@ -250,8 +263,8 @@ mod_clinical_timelines_server <- function(module_id, #' A character string that serves as unique identifier for the module. #' @param basic_info `[list(character(1)+)]` #' -#' A list of four elements: \code{data}, \code{trt_start}, -#' \code{trt_end}, and \code{icf_date}. Assigns the name +#' A list of four elements: \code{subject_level_dataset_name}, \code{trt_start_var}, +#' \code{trt_end_var}, and \code{icf_date_var}. Assigns the name #' of a subject level dataset and column names of treatment start and end, and informed #' consent variables. #' @param mapping `[list(list(list(character(1)+)))]` @@ -296,16 +309,16 @@ mod_clinical_timelines_server <- function(module_id, #' @details #' The \code{basic_info} list must contain the following elements: #' \itemize{ -#' \item{\code{data}: Character name of the subject level analysis dataset +#' \item{\code{subject_level_dataset_name}: Character name of the subject level analysis dataset #' (e.g. "adsl", "dm") as it is called in the datalist that is provided to the #' \pkg{modulemanager}.} -#' \item{\code{trt_start}: Character name of the variable that contains +#' \item{\code{trt_start_var}: Character name of the variable that contains #' treatment start dates which must be present in the dataset mentioned in the #' \code{data} element.} -#' \item{\code{trt_end}: Character name of the variable that contains +#' \item{\code{trt_end_var}: Character name of the variable that contains #' treatment end dates which must be present in the dataset mentioned in the #' \code{data} element.} -#' \item{\code{icf_date}: Character name of the variable that contains +#' \item{\code{icf_date_var}: Character name of the variable that contains #' informed consent dates which must be present in the dataset mentioned in the #' \code{data} element.} #' } @@ -361,7 +374,7 @@ mod_clinical_timelines_server <- function(module_id, #' #' If not NULL, the \code{drug_admin} list must contain the following elements: #' \itemize{ -#' \item{\code{name}: Character name of the dataset that holds drug administration data +#' \item{\code{dataset_name}: Character name of the dataset that holds drug administration data #' (e.g. ex domain), as it is called in the datalist that is provided to the #' \pkg{modulemanager}.} #' \item{\code{start_var}: Character name of the variable that contains the start dates @@ -373,9 +386,9 @@ mod_clinical_timelines_server <- function(module_id, #' \item{\code{detail_var}: Character name of the variable that contains the treatment #' information. Must exist in the dataset mentioned in the \code{name} element.} #' \item{\code{label}: Free-text character label for the drug administration event.} -#' \item{\code{exp_dose}: Character name of the variable that contains the dosis level +#' \item{\code{dose_var}: Character name of the variable that contains the dosis level #' information. Must exist in the dataset mentioned in the \code{name} element.} -#' \item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +#' \item{\code{dose_unit_var}: Character name of the variable that contains the dosis #' unit. Must exist in the dataset mentioned in the \code{name} element.} #' } #' @@ -385,25 +398,25 @@ mod_clinical_timelines_server <- function(module_id, #' If not \code{NULL}, \code{filter} defines local filters. #' So far, the following filters for adverse events are available: #' \itemize{ -#' \item{\code{serious_AE}: Filter for serious adverse events.} -#' \item{\code{soc}: Filter for system organ classes.} -#' \item{\code{pref_term}: Filter for preferred terms.} -#' \item{\code{drug_rel_AE}: Filter for drug related adverse events.} +#' \item{\code{serious_ae_var}: Filter for serious adverse events.} +#' \item{\code{soc_var}: Filter for system organ classes.} +#' \item{\code{pref_term_var}: Filter for preferred terms.} +#' \item{\code{drug_rel_ae_var}: Filter for drug related adverse events.} #' } #' The \code{filter} parameter must be a list that contains yet another list for adverse #' events filters, that is named \code{ae_filter}, and that holds the following elements: #' \itemize{ -#' \item{\code{data_name}: Character name of the adverse events dataset. Must be +#' \item{\code{dataset_name}: Character name of the adverse events dataset. Must be #' available in in the datalist that is provided to the \pkg{modulemanager}.} #' \item{\code{label}: Character value which is exactly the same as the name for the #' adverse events event defined in \code{mapping}.} -#' \item{\code{serious_AE}: Character name of the adverse events variable that contains +#' \item{\code{serious_ae_var}: Character name of the adverse events variable that contains #' serious adverse events flags (Y/N).} -#' \item{\code{soc}: Character name of the adverse events variable that contains +#' \item{\code{soc_var}: Character name of the adverse events variable that contains #' system organ classes.} -#' \item{\code{pref_term}: Character name of the adverse events variable that contains +#' \item{\code{pref_term_var}: Character name of the adverse events variable that contains #' preferred terms.} -#' \item{\code{drug_rel_AE}: Character name of the adverse events variable that contains +#' \item{\code{drug_rel_ae_var}: Character name of the adverse events variable that contains #' drug related (causality) flags (Y/N).} #' } #' @@ -441,7 +454,7 @@ mod_clinical_timelines <- function(module_id, mod <- list( ui = function(id) { # Extract available adverse event filter names - ae_filter <- !names(filter$ae_filter) %in% c("data_name", "label") + ae_filter <- !names(filter$ae_filter) %in% c("dataset_name", "label") # Select requested filters selected <- as.list(names(filter$ae_filter[ae_filter])) @@ -459,7 +472,8 @@ mod_clinical_timelines <- function(module_id, # afmm$dataset_metadata$name holds the name of the currently selected set of dataset (dv.manager) data_name = afmm$dataset_metadata$name, dataset_list = shiny::reactive({ - afmm$filtered_dataset()[unique(c(basic_info$data, names(mapping), drug_admin$name))] + needed_datasets <- unique(c(basic_info$subject_level_dataset_name, names(mapping), drug_admin$dataset_name)) + afmm$filtered_dataset()[needed_datasets] }), basic_info = basic_info, mapping = mapping, diff --git a/R/mod_local_filter.R b/R/mod_local_filter.R index 03f272b..0713dff 100644 --- a/R/mod_local_filter.R +++ b/R/mod_local_filter.R @@ -21,7 +21,7 @@ mod_local_filter_UI <- function(module_id, filter_list = NULL) { # nolint ui <- shiny::conditionalPanel( condition = cond, - all_filters[which(names(all_filters) %in% filter_list)], + all_filters[which(paste0(names(all_filters), "_var") %in% filter_list)], ns = ns ) @@ -53,7 +53,7 @@ mod_local_filter_server <- function(module_id, filter, joined_data, changed) { restored = FALSE, pt_input = NULL ) - only_filters <- filter$ae_filter[!names(filter$ae_filter) %in% c("data_name", "label")] + only_filters <- filter$ae_filter[!names(filter$ae_filter) %in% c("dataset_name", "label")] # No need for reactivity as this never changes during a session status_filters <- get_filter_status( names(local_filters(session$ns)), @@ -87,11 +87,11 @@ mod_local_filter_server <- function(module_id, filter, joined_data, changed) { selected_rel <- "all" } - shiny::updateRadioButtons(session, "serious_AE", selected = selected_sae) - shiny::updateRadioButtons(session, "drug_rel_AE", selected = selected_rel) + shiny::updateRadioButtons(session, "serious_ae", selected = selected_sae) + shiny::updateRadioButtons(session, "drug_rel_ae", selected = selected_rel) if (status_filters[["soc"]]) { - choices <- sort(unique(joined_data()[[filter$ae_filter$soc]])) + choices <- sort(unique(joined_data()[[filter$ae_filter$soc_var]])) shiny::updateSelectizeInput( inputId = "soc", @@ -134,7 +134,7 @@ mod_local_filter_server <- function(module_id, filter, joined_data, changed) { ) - # Choices need to be saved explicitely + # Choices need to be saved explicitly shiny::onBookmark(function(state) { state$values$soc_choices <- cache$soc_choices state$values$pt_choices <- cache$pt_choices @@ -146,8 +146,8 @@ mod_local_filter_server <- function(module_id, filter, joined_data, changed) { cache$soc_choices <<- state$values$soc_choices cache$pt_choices <<- state$values$pt_choices cache$pt_input <<- state$input$pref_term - cache$sae_choice <<- state$input$serious_AE - cache$rel_choice <<- state$input$drug_rel_AE + cache$sae_choice <<- state$input$serious_ae + cache$rel_choice <<- state$input$drug_rel_ae }) @@ -169,22 +169,22 @@ mod_local_filter_server <- function(module_id, filter, joined_data, changed) { filtered_data <- shiny::reactive({ - if (status_filters[["serious_AE"]]) { - shiny::req(input$serious_AE) + if (status_filters[["serious_ae"]]) { + shiny::req(input$serious_ae) } - if (status_filters[["drug_rel_AE"]]) { - shiny::req(input$drug_rel_AE) + if (status_filters[["drug_rel_ae"]]) { + shiny::req(input$drug_rel_ae) } filter_data( data = joined_data(), status_filters = status_filters, input_filters = list( - serious_AE = input$serious_AE, + serious_ae = input$serious_ae, soc = input$soc, pref_term = input$pref_term, - drug_rel_AE = input$drug_rel_AE + drug_rel_ae = input$drug_rel_ae ), filter = filter ) diff --git a/R/mod_main_view.R b/R/mod_main_view.R index a8951d0..724c7a0 100644 --- a/R/mod_main_view.R +++ b/R/mod_main_view.R @@ -348,19 +348,11 @@ mod_main_view_server <- function(module_id, initial_data, changed, ) }) - # tell if there was a click on the main plot - clicked <- shiny::reactiveVal(FALSE) - - shiny::observeEvent(input$plot_click, { - clicked(TRUE) - }) - - - # Get unique subject identifier either from click + # Get unique subject identifier from click subject_id <- shiny::reactive({ - shiny::req(input$plot_click, clicked()) + shiny::req(input$plot_click) - # Get y position of the click & find the matching subject identifier + # Get y position of the click and find the matching subject identifier position <- round(input$plot_click$y) subject <- input$plot_click$domain$discrete_limits$y[[position]] subject diff --git a/R/prep_dummy_data.R b/R/prep_dummy_data.R index 65edba6..26a458d 100644 --- a/R/prep_dummy_data.R +++ b/R/prep_dummy_data.R @@ -76,10 +76,10 @@ prep_dummy_data <- function(n = 200) { default_basic_info <- function() { return( set_basic_info( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ) ) } @@ -134,13 +134,13 @@ default_mapping <- function() { default_drug_admin <- function() { return( list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) ) } diff --git a/R/server_functions_local_filter.R b/R/server_functions_local_filter.R index 1a9ca0d..890d272 100644 --- a/R/server_functions_local_filter.R +++ b/R/server_functions_local_filter.R @@ -10,9 +10,10 @@ #' chosen by the user to be displayed (TRUE) or not (FALSE). #' @keywords internal get_filter_status <- function(all_filters, chosen_filters) { + all_filters <- paste0(all_filters, "_var") check_filters(filter_list = chosen_filters, filter_names = all_filters) status <- all_filters %in% chosen_filters - names(status) <- all_filters + names(status) <- gsub("_var", "", all_filters) return(status) } @@ -31,12 +32,12 @@ get_filter_status <- function(all_filters, chosen_filters) { set_pts <- function(status_filters, soc, prepped_data, filter) { if (status_filters[["soc"]] && !is.null(soc)) { pt_choices <- prepped_data %>% - dplyr::filter(.data[[filter$soc]] %in% soc) %>% - dplyr::select(tidyselect::all_of(filter$pref_term)) %>% + dplyr::filter(.data[[filter$soc_var]] %in% soc) %>% + dplyr::select(tidyselect::all_of(filter$pref_term_var)) %>% dplyr::distinct() %>% dplyr::arrange() } else { - pt_choices <- sort(unique(prepped_data[[filter$pref_term]])) + pt_choices <- sort(unique(prepped_data[[filter$pref_term_var]])) } } @@ -52,11 +53,11 @@ set_pts <- function(status_filters, soc, prepped_data, filter) { #' @keywords internal filter_data <- function(data, status_filters, input_filters, filter) { # .data$set != info_ae$name ensures to also display non-AE data - if (status_filters[["serious_AE"]]) { - if (input_filters$serious_AE != "all") { + if (status_filters[["serious_ae"]]) { + if (input_filters$serious_ae != "all") { data <- data %>% dplyr::filter( - .data[[filter$ae_filter$serious_AE]] == input_filters$serious | - .data$set != filter$ae_filter$data_name + .data[[filter$ae_filter$serious_ae_var]] == input_filters$serious | + .data$set != filter$ae_filter$dataset_name ) } } @@ -64,8 +65,8 @@ filter_data <- function(data, status_filters, input_filters, filter) { if (status_filters[["soc"]]) { if (!is.null(input_filters$soc)) { data <- data %>% dplyr::filter( - .data[[filter$ae_filter$soc]] %in% input_filters$soc | - .data$set != filter$ae_filter$data_name + .data[[filter$ae_filter$soc_var]] %in% input_filters$soc | + .data$set != filter$ae_filter$dataset_name ) } } @@ -73,17 +74,17 @@ filter_data <- function(data, status_filters, input_filters, filter) { if (status_filters[["pref_term"]]) { if (!is.null(input_filters$pref_term)) { data <- data %>% dplyr::filter( - .data[[filter$ae_filter$pref_term]] %in% input_filters$pref_term | - .data$set != filter$ae_filter$data_name + .data[[filter$ae_filter$pref_term_var]] %in% input_filters$pref_term | + .data$set != filter$ae_filter$dataset_name ) } } - if (status_filters[["drug_rel_AE"]]) { - if (input_filters$drug_rel_AE != "all") { + if (status_filters[["drug_rel_ae"]]) { + if (input_filters$drug_rel_ae != "all") { data <- data %>% dplyr::filter( - .data[[filter$ae_filter$drug_rel_AE]] == input_filters$drug_rel_AE | - .data$set != filter$ae_filter$data_name + .data[[filter$ae_filter$drug_rel_ae_var]] == input_filters$drug_rel_ae | + .data$set != filter$ae_filter$dataset_name ) } } diff --git a/README.md b/README.md index 692debd..ab68910 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ module_list <- list( "Clinical Timelines" = dv.clinlines::mod_clinical_timelines( module_id = "mod1", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -89,13 +89,13 @@ module_list <- list( ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) ) ) diff --git a/man/mod_clinical_timelines.Rd b/man/mod_clinical_timelines.Rd index 937d77e..63d78bc 100644 --- a/man/mod_clinical_timelines.Rd +++ b/man/mod_clinical_timelines.Rd @@ -23,8 +23,8 @@ A character string that serves as unique identifier for the module.} \item{basic_info}{\verb{[list(character(1)+)]} -A list of four elements: \code{data}, \code{trt_start}, -\code{trt_end}, and \code{icf_date}. Assigns the name +A list of four elements: \code{subject_level_dataset_name}, \code{trt_start_var}, +\code{trt_end_var}, and \code{icf_date_var}. Assigns the name of a subject level dataset and column names of treatment start and end, and informed consent variables.} @@ -85,16 +85,16 @@ Wrapper that serves as interface for defining an application in the \pkg{modulem \details{ The \code{basic_info} list must contain the following elements: \itemize{ -\item{\code{data}: Character name of the subject level analysis dataset +\item{\code{subject_level_dataset_name}: Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the datalist that is provided to the \pkg{modulemanager}.} -\item{\code{trt_start}: Character name of the variable that contains +\item{\code{trt_start_var}: Character name of the variable that contains treatment start dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{trt_end}: Character name of the variable that contains +\item{\code{trt_end_var}: Character name of the variable that contains treatment end dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{icf_date}: Character name of the variable that contains +\item{\code{icf_date_var}: Character name of the variable that contains informed consent dates which must be present in the dataset mentioned in the \code{data} element.} } @@ -150,7 +150,7 @@ the mapping list. If not NULL, the \code{drug_admin} list must contain the following elements: \itemize{ -\item{\code{name}: Character name of the dataset that holds drug administration data +\item{\code{dataset_name}: Character name of the dataset that holds drug administration data (e.g. ex domain), as it is called in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{start_var}: Character name of the variable that contains the start dates @@ -162,9 +162,9 @@ If not NULL, the \code{drug_admin} list must contain the following elements: \item{\code{detail_var}: Character name of the variable that contains the treatment information. Must exist in the dataset mentioned in the \code{name} element.} \item{\code{label}: Free-text character label for the drug administration event.} -\item{\code{exp_dose}: Character name of the variable that contains the dosis level +\item{\code{dose_var}: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the \code{name} element.} -\item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +\item{\code{dose_unit_var}: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the \code{name} element.} } @@ -173,25 +173,25 @@ unit. Must exist in the dataset mentioned in the \code{name} element.} If not \code{NULL}, \code{filter} defines local filters. So far, the following filters for adverse events are available: \itemize{ -\item{\code{serious_AE}: Filter for serious adverse events.} -\item{\code{soc}: Filter for system organ classes.} -\item{\code{pref_term}: Filter for preferred terms.} -\item{\code{drug_rel_AE}: Filter for drug related adverse events.} +\item{\code{serious_ae_var}: Filter for serious adverse events.} +\item{\code{soc_var}: Filter for system organ classes.} +\item{\code{pref_term_var}: Filter for preferred terms.} +\item{\code{drug_rel_ae_var}: Filter for drug related adverse events.} } The \code{filter} parameter must be a list that contains yet another list for adverse events filters, that is named \code{ae_filter}, and that holds the following elements: \itemize{ -\item{\code{data_name}: Character name of the adverse events dataset. Must be +\item{\code{dataset_name}: Character name of the adverse events dataset. Must be available in in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{label}: Character value which is exactly the same as the name for the adverse events event defined in \code{mapping}.} -\item{\code{serious_AE}: Character name of the adverse events variable that contains +\item{\code{serious_ae_var}: Character name of the adverse events variable that contains serious adverse events flags (Y/N).} -\item{\code{soc}: Character name of the adverse events variable that contains +\item{\code{soc_var}: Character name of the adverse events variable that contains system organ classes.} -\item{\code{pref_term}: Character name of the adverse events variable that contains +\item{\code{pref_term_var}: Character name of the adverse events variable that contains preferred terms.} -\item{\code{drug_rel_AE}: Character name of the adverse events variable that contains +\item{\code{drug_rel_ae_var}: Character name of the adverse events variable that contains drug related (causality) flags (Y/N).} } } diff --git a/man/mod_clinical_timelines_server.Rd b/man/mod_clinical_timelines_server.Rd index b09ea93..c95da61 100644 --- a/man/mod_clinical_timelines_server.Rd +++ b/man/mod_clinical_timelines_server.Rd @@ -37,8 +37,8 @@ manager.} \item{basic_info}{\verb{[list(character(1)+)]} -A list of four elements: \code{data}, \code{trt_start}, -\code{trt_end}, and \code{icf_date}. Assigns the name +A list of four elements: \code{subject_level_dataset_name}, \code{trt_start_var}, +\code{trt_end_var}, and \code{icf_date_var}. Assigns the name of a subject level dataset and column names of treatment start and end, and informed consent variables.} @@ -97,16 +97,16 @@ communication between main view and local filter module. \details{ The \code{basic_info} list must contain the following elements: \itemize{ -\item{\code{data}: Character name of the subject level analysis dataset +\item{\code{subject_level_dataset_name}: Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the datalist that is provided to the \pkg{modulemanager}.} -\item{\code{trt_start}: Character name of the variable that contains +\item{\code{trt_start_var}: Character name of the variable that contains treatment start dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{trt_end}: Character name of the variable that contains +\item{\code{trt_end_var}: Character name of the variable that contains treatment end dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{icf_date}: Character name of the variable that contains +\item{\code{icf_date_var}: Character name of the variable that contains informed consent dates which must be present in the dataset mentioned in the \code{data} element.} } @@ -162,7 +162,7 @@ the mapping list. If not NULL, the \code{drug_admin} list must contain the following elements: \itemize{ -\item{\code{name}: Character name of the dataset that holds drug administration data +\item{\code{dataset_name}: Character name of the dataset that holds drug administration data (e.g. ex domain), as it is called in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{start_var}: Character name of the variable that contains the start dates @@ -174,9 +174,9 @@ If not NULL, the \code{drug_admin} list must contain the following elements: \item{\code{detail_var}: Character name of the variable that contains the treatment information. Must exist in the dataset mentioned in the \code{name} element.} \item{\code{label}: Free-text character label for the drug administration event.} -\item{\code{exp_dose}: Character name of the variable that contains the dosis level +\item{\code{dose_var}: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the \code{name} element.} -\item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +\item{\code{dose_unit_var}: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the \code{name} element.} } @@ -185,25 +185,25 @@ unit. Must exist in the dataset mentioned in the \code{name} element.} If not \code{NULL}, \code{filter} defines local filters. So far, the following filters for adverse events are available: \itemize{ -\item{\code{serious_AE}: Filter for serious adverse events.} -\item{\code{soc}: Filter for system organ classes.} -\item{\code{pref_term}: Filter for preferred terms.} -\item{\code{drug_rel_AE}: Filter for drug related adverse events.} +\item{\code{serious_ae_var}: Filter for serious adverse events.} +\item{\code{soc_var}: Filter for system organ classes.} +\item{\code{pref_term_var}: Filter for preferred terms.} +\item{\code{drug_rel_ae_var}: Filter for drug related adverse events.} } The \code{filter} parameter must be a list that contains yet another list for adverse events filters, that is named \code{ae_filter}, and that holds the following elements: \itemize{ -\item{\code{data_name}: Character name of the adverse events dataset. Must be +\item{\code{dataset_name}: Character name of the adverse events dataset. Must be available in in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{label}: Character value which is exactly the same as the name for the adverse events event defined in \code{mapping}.} -\item{\code{serious_AE}: Character name of the adverse events variable that contains +\item{\code{serious_ae_var}: Character name of the adverse events variable that contains serious adverse events flags (Y/N).} -\item{\code{soc}: Character name of the adverse events variable that contains +\item{\code{soc_var}: Character name of the adverse events variable that contains system organ classes.} -\item{\code{pref_term}: Character name of the adverse events variable that contains +\item{\code{pref_term_var}: Character name of the adverse events variable that contains preferred terms.} -\item{\code{drug_rel_AE}: Character name of the adverse events variable that contains +\item{\code{drug_rel_ae_var}: Character name of the adverse events variable that contains drug related (causality) flags (Y/N).} } } diff --git a/man/prep_data.Rd b/man/prep_data.Rd index 0848df4..e1eb690 100644 --- a/man/prep_data.Rd +++ b/man/prep_data.Rd @@ -19,8 +19,8 @@ and further datasets with event specific data. Usually obtained from module mana \item{basic_info}{\verb{[list(character(1)+)]} -A list of four elements: \code{data}, \code{trt_start}, -\code{trt_end}, and \code{icf_date}. Assigns the name +A list of four elements: \code{subject_level_dataset_name}, \code{trt_start_var}, +\code{trt_end_var}, and \code{icf_date_var}. Assigns the name of a subject level dataset and column names of treatment start and end, and informed consent variables.} @@ -57,16 +57,16 @@ one data frame that can be used to plot the clinical timelines without local fil \details{ The \code{basic_info} list must contain the following elements: \itemize{ -\item{\code{data}: Character name of the subject level analysis dataset +\item{\code{subject_level_dataset_name}: Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the datalist that is provided to the \pkg{modulemanager}.} -\item{\code{trt_start}: Character name of the variable that contains +\item{\code{trt_start_var}: Character name of the variable that contains treatment start dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{trt_end}: Character name of the variable that contains +\item{\code{trt_end_var}: Character name of the variable that contains treatment end dates which must be present in the dataset mentioned in the \code{data} element.} -\item{\code{icf_date}: Character name of the variable that contains +\item{\code{icf_date_var}: Character name of the variable that contains informed consent dates which must be present in the dataset mentioned in the \code{data} element.} } @@ -122,7 +122,7 @@ the mapping list. If not NULL, the \code{drug_admin} list must contain the following elements: \itemize{ -\item{\code{name}: Character name of the dataset that holds drug administration data +\item{\code{dataset_name}: Character name of the dataset that holds drug administration data (e.g. ex domain), as it is called in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{start_var}: Character name of the variable that contains the start dates @@ -134,9 +134,9 @@ If not NULL, the \code{drug_admin} list must contain the following elements: \item{\code{detail_var}: Character name of the variable that contains the treatment information. Must exist in the dataset mentioned in the \code{name} element.} \item{\code{label}: Free-text character label for the drug administration event.} -\item{\code{exp_dose}: Character name of the variable that contains the dosis level +\item{\code{dose_var}: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the \code{name} element.} -\item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +\item{\code{dose_unit_var}: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the \code{name} element.} } @@ -145,25 +145,25 @@ unit. Must exist in the dataset mentioned in the \code{name} element.} If not \code{NULL}, \code{filter} defines local filters. So far, the following filters for adverse events are available: \itemize{ -\item{\code{serious_AE}: Filter for serious adverse events.} -\item{\code{soc}: Filter for system organ classes.} -\item{\code{pref_term}: Filter for preferred terms.} -\item{\code{drug_rel_AE}: Filter for drug related adverse events.} +\item{\code{serious_ae_var}: Filter for serious adverse events.} +\item{\code{soc_var}: Filter for system organ classes.} +\item{\code{pref_term_var}: Filter for preferred terms.} +\item{\code{drug_rel_ae_var}: Filter for drug related adverse events.} } The \code{filter} parameter must be a list that contains yet another list for adverse events filters, that is named \code{ae_filter}, and that holds the following elements: \itemize{ -\item{\code{data_name}: Character name of the adverse events dataset. Must be +\item{\code{dataset_name}: Character name of the adverse events dataset. Must be available in in the datalist that is provided to the \pkg{modulemanager}.} \item{\code{label}: Character value which is exactly the same as the name for the adverse events event defined in \code{mapping}.} -\item{\code{serious_AE}: Character name of the adverse events variable that contains +\item{\code{serious_ae_var}: Character name of the adverse events variable that contains serious adverse events flags (Y/N).} -\item{\code{soc}: Character name of the adverse events variable that contains +\item{\code{soc_var}: Character name of the adverse events variable that contains system organ classes.} -\item{\code{pref_term}: Character name of the adverse events variable that contains +\item{\code{pref_term_var}: Character name of the adverse events variable that contains preferred terms.} -\item{\code{drug_rel_AE}: Character name of the adverse events variable that contains +\item{\code{drug_rel_ae_var}: Character name of the adverse events variable that contains drug related (causality) flags (Y/N).} } } diff --git a/man/set_basic_info.Rd b/man/set_basic_info.Rd index e5e3ecd..b74f7fe 100644 --- a/man/set_basic_info.Rd +++ b/man/set_basic_info.Rd @@ -4,20 +4,25 @@ \alias{set_basic_info} \title{Create a list to be assigned to the \code{basic_info} parameter} \usage{ -set_basic_info(data, trt_start, trt_end, icf_date) +set_basic_info( + subject_level_dataset_name, + trt_start_var, + trt_end_var, + icf_date_var +) } \arguments{ -\item{data}{Character name of the subject level analysis dataset (e.g. "adsl", "dm") +\item{subject_level_dataset_name}{Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the \code{data_list} parameter.} -\item{trt_start}{Character name of the variable that contains treatment start dates. -Must be present in the data frame mentioned in the \code{data} element.} +\item{trt_start_var}{Character name of the variable that contains treatment start dates. +Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element.} -\item{trt_end}{Character name of the variable that contains treatment end dates. -Must be present in the data frame mentioned in the \code{data} element.} +\item{trt_end_var}{Character name of the variable that contains treatment end dates. +Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element.} -\item{icf_date}{Character name of the variable that contains informed consent dates. -Must be present in the data frame mentioned in the \code{data} element.} +\item{icf_date_var}{Character name of the variable that contains informed consent dates. +Must be present in the data frame mentioned in the \code{subject_level_dataset_name} element.} } \value{ A list that could directly be used as input for the \code{basic_info} parameter diff --git a/man/set_basics.Rd b/man/set_basics.Rd index 014bbe7..c4564ab 100644 --- a/man/set_basics.Rd +++ b/man/set_basics.Rd @@ -12,8 +12,8 @@ and further datasets with event specific data. Usually obtained from module mana \item{basic_info}{\verb{[list(character(1)+)]} -A list of four elements: \code{data}, \code{trt_start}, -\code{trt_end}, and \code{icf_date}. Assigns the name +A list of four elements: \code{subject_level_dataset_name}, \code{trt_start_var}, +\code{trt_end_var}, and \code{icf_date_var}. Assigns the name of a subject level dataset and column names of treatment start and end, and informed consent variables.} diff --git a/man/set_drug_admin.Rd b/man/set_drug_admin.Rd index 56b07e5..78a447b 100644 --- a/man/set_drug_admin.Rd +++ b/man/set_drug_admin.Rd @@ -5,17 +5,17 @@ \title{Create a list to be assigned to the \code{drug_admin} parameter} \usage{ set_drug_admin( - name, + dataset_name, start_var, end_var, detail_var, label, - exp_dose, - exp_dose_unit + dose_var, + dose_unit_var ) } \arguments{ -\item{name}{Character name of the data frame that holds drug administration data +\item{dataset_name}{Character name of the data frame that holds drug administration data (e.g. ex domain) as it is called in the \code{data_list} parameter.} \item{start_var}{Character name of the variable that contains the start dates @@ -31,10 +31,10 @@ information. Must exist in the dataset mentioned in the name element.} \item{label}{Free-text character label for the drug administration event.} -\item{exp_dose}{Character name of the variable that contains the dosis level +\item{dose_var}{Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the name element.} -\item{exp_dose_unit}{Character name of the variable that contains the dosis unit. +\item{dose_unit_var}{Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the name element.} } \value{ diff --git a/man/set_exp_intervals.Rd b/man/set_exp_intervals.Rd index 461af97..5c06d30 100644 --- a/man/set_exp_intervals.Rd +++ b/man/set_exp_intervals.Rd @@ -27,7 +27,7 @@ A data frame including the following columns: \item{\code{detail_var}: Information about drug name and dosage.} \item{\code{set}: Name of the dataset the data origins from.} \item{\code{set_id}: Row ID's of the related dataset.} -\item{\code{exp_dose}: Indicates whether the dose of the treatment has increased, +\item{\code{dose_var}: Indicates whether the dose of the treatment has increased, decreased or stayed the same compared to the last dose at the same subject.} \item{\code{group}: Label for the event types.} } @@ -51,9 +51,9 @@ The \code{mapping} list must contain the following elements: \item{\code{detail_var}: Character name of the variable that contains the treatment information. Must exist in the dataset mentioned in the \code{name} element.} \item{\code{label}: Free-text character label for the drug administration event.} -\item{\code{exp_dose}: Character name of the variable that contains the dosis level +\item{\code{dose_var}: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the \code{name} element.} -\item{\code{exp_dose_unit}: Character name of the variable that contains the dosis +\item{\code{dose_unit_var}: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the \code{name} element.} } } diff --git a/tests/testthat/apps/bmk_app/app.R b/tests/testthat/apps/bmk_app/app.R index fd86e75..4761d17 100644 --- a/tests/testthat/apps/bmk_app/app.R +++ b/tests/testthat/apps/bmk_app/app.R @@ -10,7 +10,7 @@ bmk_ui <- function(id) { shiny::fluidPage( shiny::bookmarkButton(), - mod_clinical_timelines_UI(ns("mod"), list("serious_AE", "soc", "pref_term", "drug_rel_AE")) + mod_clinical_timelines_UI(ns("mod"), list("serious_ae_var", "soc_var", "pref_term_var", "drug_rel_ae_var")) ) } @@ -29,10 +29,10 @@ bmk_server <- function(input, output, session) { data_name = shiny::reactive("dummyData"), data_list, basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -62,23 +62,23 @@ bmk_server <- function(input, output, session) { ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), subjid_var = "USUBJID", filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AEREL" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AEREL" ) ), ms = 50 diff --git a/tests/testthat/apps/large_app/app.R b/tests/testthat/apps/large_app/app.R index 224f288..84f8ab3 100644 --- a/tests/testthat/apps/large_app/app.R +++ b/tests/testthat/apps/large_app/app.R @@ -54,10 +54,10 @@ data_list <- list(adsl = adsl, adae = adae, exp = exp) clinlines <- dv.clinlines::mod_clinical_timelines( module_id = "mod", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -77,13 +77,13 @@ clinlines <- dv.clinlines::mod_clinical_timelines( ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), subjid_var = "USUBJID" ) diff --git a/tests/testthat/apps/mm_app/app.R b/tests/testthat/apps/mm_app/app.R index 16f5e64..025b04d 100644 --- a/tests/testthat/apps/mm_app/app.R +++ b/tests/testthat/apps/mm_app/app.R @@ -13,10 +13,10 @@ dummyData2 <- dv.clinlines:::prep_dummy_data(200) # nolint clinlines <- dv.clinlines::mod_clinical_timelines( module_id = "mod", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -46,23 +46,23 @@ clinlines <- dv.clinlines::mod_clinical_timelines( ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), subjid_var = "USUBJID", filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AERELFLG" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AERELFLG" ) ), default_plot_settings = list(x_param = "date", start_day = -5, boxheight_val = 50), diff --git a/tests/testthat/test-data_prep.R b/tests/testthat/test-data_prep.R index 8b36aa2..53d1182 100644 --- a/tests/testthat/test-data_prep.R +++ b/tests/testthat/test-data_prep.R @@ -51,10 +51,10 @@ test_that( data_list = data_list, filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER" + soc_var = "AESOC", + serious_ae_var = "AESER" ) ) ) @@ -114,7 +114,14 @@ test_that( { prepped_w_filter <- prep_data( data_list = data_list, - filter = list(ae_filter = list(data_name = "adae", label = "Adverse Events", soc = "AESOC", serious_AE = "AESER")) + filter = list( + ae_filter = list( + dataset_name = "adae", + label = "Adverse Events", + soc_var = "AESOC", + serious_ae_var = "AESER" + ) + ) ) expected <- data_list$adae %>% @@ -134,10 +141,10 @@ test_that("set_basics() returns a list with fixed names", { basic_list <- set_basics( data_list = list(adsl = df), basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), subjid_var = "USUBJID" ) @@ -276,12 +283,12 @@ test_that( filter_data <- set_filter_dataset( filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AEREL" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AEREL" ) ), data_list = data_list, @@ -343,7 +350,7 @@ test_that( { expect_error( set_filter_dataset( - filter = list(ae_filter = list(data_name = "adae")), + filter = list(ae_filter = list(dataset_name = "adae")), data_list = data_list, mapping = default_mapping(), subjid_var = "USUBJID" @@ -352,7 +359,7 @@ test_that( expect_error( set_filter_dataset( - filter = list(ae_filter = list(data_name = "xyz", soc = "AESOC", label = "Adverse Events")), + filter = list(ae_filter = list(dataset_name = "xyz", soc_var = "AESOC", label = "Adverse Events")), data_list = data_list, mapping = default_mapping(), subjid_var = "USUBJID" diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index c935408..4536d3c 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -1,7 +1,17 @@ # Tests for set_basic_info() ---- test_that("set_basic_info() returns a named list", { - outcome <- set_basic_info(data = "adsl", trt_start = "start", trt_end = "end", icf_date = "consent") - expected <- list(data = "adsl", trt_start = "start", trt_end = "end", icf_date = "consent") + outcome <- set_basic_info( + subject_level_dataset_name = "adsl", + trt_start_var = "start", + trt_end_var = "end", + icf_date_var = "consent" + ) + expected <- list( + subject_level_dataset_name = "adsl", + trt_start_var = "start", + trt_end_var = "end", + icf_date_var = "consent" + ) expect_equal(outcome, expected) }) @@ -23,12 +33,12 @@ test_that("set_event() returns a named list", { # Tests for set_drug_admin() ---- test_that("set_drug_admin() returns a named list", { outcome <- set_drug_admin( - name = "exp", start_var = "start date", end_var = "end date", - label = "some label", detail_var = "some details", exp_dose = "dose", exp_dose_unit = "unit" + dataset_name = "exp", start_var = "start date", end_var = "end date", + label = "some label", detail_var = "some details", dose_var = "dose", dose_unit_var = "unit" ) expected <- list( - name = "exp", start_var = "start date", end_var = "end date", - detail_var = "some details", label = "some label", exp_dose = "dose", exp_dose_unit = "unit" + dataset_name = "exp", start_var = "start date", end_var = "end date", + detail_var = "some details", label = "some label", dose_var = "dose", dose_unit_var = "unit" ) expect_equal(outcome, expected) }) diff --git a/tests/testthat/test-local_filter_setup.R b/tests/testthat/test-local_filter_setup.R index 71c33bc..5cad09a 100644 --- a/tests/testthat/test-local_filter_setup.R +++ b/tests/testthat/test-local_filter_setup.R @@ -5,6 +5,6 @@ outcome <- local_filters(ns) test_that("local_filters() returns a list of Shiny UI elements", { expect_type(outcome, "list") - exp_names <- c("serious_AE", "soc", "pref_term", "drug_rel_AE") + exp_names <- c("serious_ae", "soc", "pref_term", "drug_rel_ae") expect_named(outcome, exp_names) }) diff --git a/tests/testthat/test-mod_clinical_timelines.R b/tests/testthat/test-mod_clinical_timelines.R index 7709e54..61c6d94 100644 --- a/tests/testthat/test-mod_clinical_timelines.R +++ b/tests/testthat/test-mod_clinical_timelines.R @@ -87,26 +87,27 @@ test_that("local filters are resetted (only) after dataset switch" %>% ) # Set local filters - app$set_inputs(`mod-filter-serious_AE` = my_filters[["sae"]]) + app$set_inputs(`mod-filter-serious_ae` = my_filters[["sae"]]) app$set_inputs(`mod-filter-soc` = my_filters[["soc"]]) app$wait_for_idle() app$set_inputs(`mod-filter-pref_term` = my_filters[["pt"]]) - app$set_inputs(`mod-filter-drug_rel_AE` = my_filters[["rel"]]) + app$set_inputs(`mod-filter-drug_rel_ae` = my_filters[["rel"]]) app$wait_for_idle() # Dataset switch actual_before <- c( - "sae" = app$get_value(input = "mod-filter-serious_AE"), + "sae" = app$get_value(input = "mod-filter-serious_ae"), "soc" = app$get_value(input = "mod-filter-soc"), "pt" = app$get_value(input = "mod-filter-pref_term"), - "rel" = app$get_value(input = "mod-filter-drug_rel_AE") + "rel" = app$get_value(input = "mod-filter-drug_rel_ae") ) app$set_inputs(selector = "dummyData2") + app$wait_for_idle(duration = 3000, timeout = 15000) # cope with slow update under GH actions actual_after <- c( - "sae" = app$get_value(input = "mod-filter-serious_AE"), + "sae" = app$get_value(input = "mod-filter-serious_ae"), "soc" = app$get_value(input = "mod-filter-soc"), "pt" = app$get_value(input = "mod-filter-pref_term"), - "rel" = app$get_value(input = "mod-filter-drug_rel_AE") + "rel" = app$get_value(input = "mod-filter-drug_rel_ae") ) # Tests @@ -153,7 +154,7 @@ test_that("informative messages are visible in case a plot cannot be displayed" # Set inputs app$set_inputs(`mod-main_view-filter_event` = "Adverse Events") - app$set_inputs(`mod-filter-serious_AE` = "Y") + app$set_inputs(`mod-filter-serious_ae` = "Y") app$wait_for_idle() # Test @@ -174,10 +175,10 @@ test_that("bookmarking works as intended" %>% vdoc[["add_spec"]](specs$integrati app$set_inputs(`mod-main_view-x_scale` = "date") app$set_inputs(`mod-main_view-day_range` = c(0, 190)) app$set_inputs(`mod-main_view-filter_event` = "Adverse Events") - app$set_inputs(`mod-filter-serious_AE` = "N") + app$set_inputs(`mod-filter-serious_ae` = "N") app$set_inputs(`mod-filter-soc` = "CARDIAC DISORDERS") app$set_inputs(`mod-filter-pref_term` = "ATRIOVENTRICULAR BLOCK SECOND DEGREE") - app$set_inputs(`mod-filter-drug_rel_AE` = "Y") + app$set_inputs(`mod-filter-drug_rel_ae` = "Y") app$wait_for_idle() # Bookmarked app diff --git a/tests/testthat/test-mod_local_filter.R b/tests/testthat/test-mod_local_filter.R index 42ce514..6fdf615 100644 --- a/tests/testthat/test-mod_local_filter.R +++ b/tests/testthat/test-mod_local_filter.R @@ -1,6 +1,6 @@ # Tests for mod_local_filter_UI() ---- test_that("mod_local_filter_UI() returns a shiny.tag list", { - filter_list <- list("soc", "pref_term", "drug_rel_AE", "serious_AE") + filter_list <- list("soc", "pref_term", "drug_rel_ae", "serious_ae") ui <- mod_local_filter_UI("filter_tests", filter_list = filter_list) expect_equal(class(ui), "shiny.tag") @@ -12,11 +12,11 @@ test_that( vdoc[["add_spec"]](specs$sidebar_specs$AE_filter), { # two filters - filter_list <- list("soc", "pref_term") + filter_list <- list("soc_var", "pref_term_var") ui <- mod_local_filter_UI("filter_tests", filter_list = filter_list) expect_equal(length(ui$children[[1]]), length(filter_list)) - expect_named(ui$children[[1]], as.character(filter_list), ignore.order = TRUE) + expect_named(ui$children[[1]], gsub("_var", "", as.character(filter_list)), ignore.order = TRUE) # no filters filter_list <- NULL @@ -47,7 +47,7 @@ data <- shiny::reactive({ }) changed <- shiny::reactive(1) -filter <- list("soc", "drug_rel_AE") +filter <- list("soc", "drug_rel_ae") server <- function(id) { mod_local_filter_server( module_id = id, @@ -62,7 +62,7 @@ test_that( vdoc[["add_spec"]](specs$sidebar_specs$AE_filter), { shiny::testServer(server, { - session$setInputs(soc = "GASTROINTESTINAL DISORDERS", drug_rel_AE = "NONE") + session$setInputs(soc = "GASTROINTESTINAL DISORDERS", drug_rel_ae = "NONE") outcome <- session$returned() expect_equal(colnames(outcome), colnames(joined_data())) diff --git a/tests/testthat/test-prep_dummy_data.R b/tests/testthat/test-prep_dummy_data.R index 369eec5..2a562b1 100644 --- a/tests/testthat/test-prep_dummy_data.R +++ b/tests/testthat/test-prep_dummy_data.R @@ -20,7 +20,12 @@ test_that("prep_dummy_data() adds a flag for AEREL", { # Tests for default_basic_info() ---- test_that("default_basic_info() returns a named list with default settings ", { outcome <- default_basic_info() - expected <- list(data = "adsl", trt_start = "TRTSDT", trt_end = "TRTEDT", icf_date = "RFICDT") + expected <- list( + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" + ) expect_equal(outcome, expected) }) @@ -51,13 +56,13 @@ test_that("default_mapping() returns a named list with default settings", { test_that("default_drug_admin() returns a named list with default settings", { outcome <- default_drug_admin() expected <- list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) expect_equal(outcome, expected) diff --git a/tests/testthat/test-server_functions_local_filter.R b/tests/testthat/test-server_functions_local_filter.R index 59bf275..d53a3dc 100644 --- a/tests/testthat/test-server_functions_local_filter.R +++ b/tests/testthat/test-server_functions_local_filter.R @@ -1,6 +1,6 @@ # Tests for get_filter_status() ---- -all <- c("filter_serious_AE", "filter_soc", "filter_pref_term", "filter_drug") -chosen <- as.list(all[1:3]) +all <- c("filter_serious_ae", "filter_soc", "filter_pref_term", "filter_drug") +chosen <- as.list(paste0(all[1:3], "_var")) outcome <- get_filter_status(all_filters = all, chosen_filters = chosen) test_that( @@ -18,7 +18,7 @@ test_that( # Tests for set_pts() ---- status <- list(soc = TRUE) filter <- list( - ae_filters = list(data_name = "adae", label = "Adverse Events", soc = "AESOC", pref_term = "AEDECOD") + ae_filters = list(dataset_name = "adae", label = "Adverse Events", soc_var = "AESOC", pref_term_var = "AEDECOD") ) data <- prep_data(add_ids(prep_dummy_data()), filter = filter) socs <- unique(data[["AESOC"]]) @@ -60,8 +60,8 @@ test_that( # Tests for filter_data() ---- -status <- list(serious_AE = FALSE, soc = FALSE, pref_term = FALSE, drug_rel_AE = FALSE) -input <- list(serious_AE = NULL, soc = NULL, pref_term = NULL, drug_rel_AE = NULL) +status <- list(serious_ae = FALSE, soc = FALSE, pref_term = FALSE, drug_rel_ae = FALSE) +input <- list(serious_ae = NULL, soc = NULL, pref_term = NULL, drug_rel_ae = NULL) data_list <- add_ids(prep_dummy_data()) df <- prep_data(data_list) @@ -70,12 +70,12 @@ test_that( vdoc[["add_spec"]](specs$sidebar_specs$AE_filter), { # One filter - status$serious_AE <- TRUE - input$serious_AE <- "Y" + status$serious_ae <- TRUE + input$serious_ae <- "Y" filter <- list(ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - serious_AE = "AESER" + serious_ae_var = "AESER" )) df_w_ae <- prep_data(data_list, filter = filter) @@ -85,18 +85,18 @@ test_that( expect_equal(nrow(df_one_filter), nrow(df_filter_man)) # All filters - status$soc <- status$pref_term <- status$drug_rel_AE <- TRUE + status$soc <- status$pref_term <- status$drug_rel_ae <- TRUE input$soc <- c("cl B", "cl C") input$pref_term <- c("dcd B.2.2.3.1", "dcd B.1.1.1.1", "dcd C.1.1.1.3") - input$drug_rel_AE <- "N" + input$drug_rel_ae <- "N" filter <- list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AEREL" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AEREL" ) ) @@ -105,7 +105,7 @@ test_that( df_all_filters <- filter_data(df_w_ae, status, input, filter) df_filter_man <- df_w_ae[which( df_w_ae$AESER == "Y" & df_w_ae$AESOC %in% input$soc & df_w_ae$AEDECOD %in% input$pref_term & - df_w_ae$AEREL == input$drug_rel_AE | df_w_ae$set != "adae" + df_w_ae$AEREL == input$drug_rel_ae | df_w_ae$set != "adae" ), ] expect_equal(nrow(df_all_filters), nrow(df_filter_man)) @@ -119,16 +119,16 @@ test_that( { # No filter status <- list( - serious_AE = FALSE, + serious_ae = FALSE, soc = FALSE, pref_term = FALSE, - drug_rel_AE = FALSE + drug_rel_ae = FALSE ) input <- list( - serious_AE = NULL, + serious_ae = NULL, soc = NULL, pref_term = NULL, - drug_rel_AE = NULL + drug_rel_ae = NULL ) filter <- NULL df_no_filter <- filter_data(df, status, input, filter) @@ -143,7 +143,7 @@ test_that( "check_filters() throws an error when a non-existing filter is specified" %>% vdoc[["add_spec"]](c(specs$app_creation_specs$errors_def)), { - all <- c("serious_AE", "soc", "pref_term", "drug") + all <- c("serious_ae", "soc", "pref_term", "drug") chosen <- as.list(c(all[2:3], "serios")) expect_error(check_filters(chosen, all)) diff --git a/vignettes/ae-filter.Rmd b/vignettes/ae-filter.Rmd index 0e3fa70..76d3af4 100644 --- a/vignettes/ae-filter.Rmd +++ b/vignettes/ae-filter.Rmd @@ -18,19 +18,19 @@ knitr::opts_chunk$set( {dv.clinlines} offers optional local filters for adverse event data which will be added to the bottom of the sidebar. The following filters are available: -- `serious_AE`: Offers the possibility to filter adverse events to show only serious/non-serious adverse events. -- `soc`: Offers the possibility to filter adverse events by System Organ Class. -- `pref_term`: Offers the possibility to filter adverse events by Preferred Term. -- `drug_rel_AE`: Offers the possibility to filter adverse events to show only drug related/non drug related adverse events. +- `serious_ae_var`: Offers the possibility to filter adverse events to show only serious/non-serious adverse events. +- `soc_var`: Offers the possibility to filter adverse events by System Organ Class. +- `pref_term_var`: Offers the possibility to filter adverse events by Preferred Term. +- `drug_rel_ae_var`: Offers the possibility to filter adverse events to show only drug related/non drug related adverse events. Activate local filters by adding their names through a list to the `filter` parameter of the `mod_clinical_timelines()` call. Use `NULL` (the default) to turn all filters down. To specify one or multiple local adverse event filters, you need to provide a list with the following elements: -- `data_name`: Character name of the adverse events dataset of your loaded data list. Must be a single value. (Mandatory.) +- `dataset_name`: Character name of the adverse events dataset of your loaded data list. Must be a single value. (Mandatory.) - `label`: Character value which is exactly the same as the name for the adverse events event defined in the `mapping` parameter of `mod_clinical_timelines()`. -- `serious_AE`: Character name of the variable that holds Y/N flags for serious adverse events. Must be a single value. -- `soc`: Character name of the variable that holds system organ classes. Must be a single value. -- `pref_term`: Character name of the variable that holds preferred terms. Must be a single value. -- `drug_rel_AE`: Character name of the variable that holds Y/N flags for causality. Must be a single value. +- `serious_ae_var`: Character name of the variable that holds Y/N flags for serious adverse events. Must be a single value. +- `soc_var`: Character name of the variable that holds system organ classes. Must be a single value. +- `pref_term_var`: Character name of the variable that holds preferred terms. Must be a single value. +- `drug_rel_ae_var`: Character name of the variable that holds Y/N flags for causality. Must be a single value. Wrap this list with another list. The inner list must be named `ae_filter`. The outer list should be assigned to the `filter` parameter of `mod_clinical_timelines()`. @@ -43,12 +43,12 @@ filter <- NULL # To activate all local adverse event filters filter <- list( ae_filter = list( - data_name = "adae", # mandatory - as defined in the data list + dataset_name = "adae", # mandatory - as defined in the data list label = "Adverse Events", # mandatory - as defined in the mapping parameter - soc = "AESOC", - serious_AE = "AESER", - pref_term = "AEDECOD", - drug_rel_AE = "AEREL" + soc_var = "AESOC", + serious_ae_var = "AESER", + pref_term_var = "AEDECOD", + drug_rel_ae_var = "AEREL" ) ) ``` @@ -64,10 +64,10 @@ module_list <- list( "Clinical Timelines" = mod_clinical_timelines( module_id = "mod1", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -97,22 +97,22 @@ module_list <- list( ) ), drug_admin = list( - name = "exp", + dataset_name = "exp", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), filter = list( ae_filter = list( - data_name = "adae", + dataset_name = "adae", label = "Adverse Events", - soc = "AESOC", - serious_AE = "AESER", - drug_rel_AE = "AEREL" - # Note: The pref_term filter is not specified in this example. + soc_var = "AESOC", + serious_ae_var = "AESER", + drug_rel_ae_var = "AEREL" + # Note: The pref_term_var filter is not specified in this example. ) ) ) diff --git a/vignettes/clinlines.Rmd b/vignettes/clinlines.Rmd index 7ca74a7..6f87b2c 100644 --- a/vignettes/clinlines.Rmd +++ b/vignettes/clinlines.Rmd @@ -97,10 +97,10 @@ Mandatory parameters are: - `basic_info`: Assigns the name of a subject level dataset and variable names of treatment start and end, and informed consent variables. It must contain the following elements: - - `data`: Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the data list that is provided to the modulemanager. - - `trt_start`: Character name of the variable that contains treatment start dates which must be present in the dataset mentioned in the `data` element. - - `trt_end`: Character name of the variable that contains treatment end dates which must be present in the dataset mentioned in the `data` element. - - `icf_date`: Character name of the variable that contains informed consent dates which must be present in the dataset mentioned in the `data` element. + - `subject_level_dataset_name`: Character name of the subject level analysis dataset (e.g. "adsl", "dm") as it is called in the data list that is provided to the modulemanager. + - `trt_start_var`: Character name of the variable that contains treatment start dates which must be present in the dataset mentioned in the `data` element. + - `trt_end_var`: Character name of the variable that contains treatment end dates which must be present in the dataset mentioned in the `data` element. + - `icf_date_var`: Character name of the variable that contains informed consent dates which must be present in the dataset mentioned in the `data` element. - `mapping`: A list of lists. It serves as instruction on which event to take from which data domain / dataset, and further from which variables to take the start and end values, etc., that will be plotted as clinical timelines. The lists needs to follow a strict hierarchy. It must contain one entry per dataset/domain that serves as basis for the events. These entries need to be named according to the names of the data list that is provided to the Module Manager. The entries by oneself must again be lists. These second level lists contain the variable names that are needed to plot the events, gathered in yet another lists, which are named according to the labels that shall be assigned to each event, and that contain the following elements each. It is possible to define multiple events for one dataset, and multiple datasets in the mapping list. @@ -116,7 +116,7 @@ These second level lists contain the variable names that are needed to plot the - `detail_var`: Character name of the variable that contains further descriptive information that shall be displayed for the event. Can be set to NULL for no further information. - `drug_admin`: A list of named character strings that describes which variables to use to display drug administration events. If not NULL, it must contain the following elements: - - `name`: Character name of the dataset that holds drug administration data (e.g. ex domain), as it is called in the datalist that is provided to the modulemanager. + - `dataset_name`: Character name of the dataset that holds drug administration data (e.g. ex domain), as it is called in the datalist that is provided to the modulemanager. - `start_var`: Character name of the variable that contains the start dates (e.g. exposure start dates) which must be present in the dataset mentioned in the name element. @@ -126,9 +126,9 @@ These second level lists contain the variable names that are needed to plot the - `label`: Free-text character label for the drug administration event. - - `exp_dose`: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the name element. + - `dose_var`: Character name of the variable that contains the dosis level information. Must exist in the dataset mentioned in the name element. - - `exp_dose_unit`: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the name element. + - `dose_unit_var`: Character name of the variable that contains the dosis unit. Must exist in the dataset mentioned in the name element. Optional parameters of `mod_clinical_timelines()` are: @@ -148,10 +148,10 @@ module_list <- list( "Clinical Timelines" = dv.clinlines::mod_clinical_timelines( module_id = "mod1", basic_info = list( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -174,13 +174,13 @@ module_list <- list( ) ), drug_admin = list( - name = "adex", + dataset_name = "adex", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) ) ) @@ -199,10 +199,10 @@ module_list <- list( "Clinical Timelines" = mod_clinical_timelines( module_id = "mod1", basic_info = set_basic_info( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -217,13 +217,13 @@ module_list <- list( ) ), drug_admin = set_drug_admin( - name = "adex", + dataset_name = "adex", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) ) ) @@ -288,10 +288,10 @@ module_list <- list( "Clinical Timelines" = mod_clinical_timelines( module_id = "mod1", basic_info = set_basic_info( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subject_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list( @@ -306,13 +306,13 @@ module_list <- list( ) ), drug_admin = set_drug_admin( - name = "adex", + dataset_name = "adex", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ) ) ) diff --git a/vignettes/communication.Rmd b/vignettes/communication.Rmd index 079c0a3..273a8b5 100644 --- a/vignettes/communication.Rmd +++ b/vignettes/communication.Rmd @@ -35,22 +35,22 @@ module_list <- list( "Clinical Timelines" = mod_clinical_timelines( module_id = "mod1", basic_info = set_basic_info( - data = "adsl", - trt_start = "TRTSDT", - trt_end = "TRTEDT", - icf_date = "RFICDT" + subjet_level_dataset_name = "adsl", + trt_start_var = "TRTSDT", + trt_end_var = "TRTEDT", + icf_date_var = "RFICDT" ), mapping = list( adsl = list("Treatment Start" = set_event(start_dt_var = "TRTSDT")) ), drug_admin = set_drug_admin( - name = "adex", + dataset_name = "adex", start_var = "EXSTDTC", end_var = "EXENDTC", detail_var = "EXTRT", label = "Drug Administration", - exp_dose = "EXDOSE", - exp_dose_unit = "EXDOSU" + dose_var = "EXDOSE", + dose_unit_var = "EXDOSU" ), receiver_id = "mod2" ),