diff --git a/NAMESPACE b/NAMESPACE index 5d3f1f26..33800869 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ S3method(create_table,default) S3method(create_table,general) S3method(create_table,medical_history) S3method(create_table,medication) +export(check_appdata) export(collapse_column_vals) export(create_clinsight_config) export(create_clinsight_metadata) @@ -17,12 +18,15 @@ export(db_create) export(db_get_query) export(db_update) export(get_appdata) +export(get_available_data) export(get_base_value) export(get_db_connection) +export(get_meta_vars) export(get_metadata) export(get_raw_csv_data) export(get_review_data) export(get_test_results) +export(get_timeline_data) export(key_columns) export(merge_meta_with_data) export(run_app) diff --git a/NEWS.md b/NEWS.md index a6dd6461..348d3c38 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,10 @@ - Added additional navigation buttons next to the tabs to easier navigate between common forms and study forms (#255). - Add toggle to enable text wrapping in tables. - The timeline is now available in all forms, and can be toggled on or off (#1007). +- - Moved `app_data`, `app_vars`, `timeline_data` & `available_data` to pre-processing step so that doesn't need to compute every session. +- Export functions used to create the data objects above ^^^. +- Started using parquet read / writes for `merged_data`, `timeline_data` & `available_data` to speed startup time. + ## Bug fixes diff --git a/R/app_server.R b/R/app_server.R index 29bc3b55..a806e230 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -18,14 +18,25 @@ app_server <- function( output, session ){ + + # Read in pre-processed R objects + # merged_data <- golem::get_golem_options("data") meta <- golem::get_golem_options("meta") - merged_data <- golem::get_golem_options("data") + app_data <- golem::get_golem_options("app_data") + app_vars <- golem::get_golem_options("app_vars") + # app_tables <- golem::get_golem_options("app_tables") + timeline_data <- golem::get_golem_options("timeline_data") + available_data <- golem::get_golem_options("available_data") user_db <- golem::get_golem_options("user_db") credentials_db <- golem::get_golem_options("credentials_db") - app_data <- get_appdata(merged_data, meta = meta) - app_vars <- get_meta_vars(data = app_data, meta = meta) - check_appdata(app_data, meta) + # app_data <- get_appdata(merged_data, meta = meta) + # app_vars <- get_meta_vars(data = app_data, meta = meta) + # app_tables <- lapply( + # setNames(names(app_data), names(app_data)), \(x){ + # create_table(app_data[[x]], expected_columns = names(app_vars$items[[x]])) + # }) + # check_appdata(app_data, meta) session$userData$pending_review_records <- reactiveValues() session$userData$pending_form_review_status <- reactiveValues() @@ -39,14 +50,16 @@ app_server <- function( ) # For query item selector drop-down menus: - available_data <- get_available_data( - data = app_data, - form_repeat_name = with( - meta[["table_names"]], - table_name[raw_name == "form_repeat"] - ) |> - tryCatch(error = \(e) "N") - ) + # available_data <- get_available_data( + # data = app_data, + # tables = app_tables, # outdated arg + # all_forms = app_vars$all_forms, # outdated arg + # form_repeat_name = with( + # meta[["table_names"]], + # table_name[raw_name == "form_repeat"] + # ) |> + # tryCatch(error = \(e) "N") + # ) # For summary review data: static_overview_data <- get_static_overview_data( @@ -58,11 +71,11 @@ app_server <- function( ) # For timeline data - timeline_data <-get_timeline_data( - app_data, - available_data = available_data, - treatment_label = meta$settings$treatment_label %||% "\U1F48A T\U2093" - ) + # timeline_data <- get_timeline_data( + # app_data, + # available_data = available_data, + # treatment_label = meta$settings$treatment_label %||% "\U1F48A T\U2093" + # ) # think of using the pool package, but functions such as row_update are not yet supported. r <- reactiveValues( diff --git a/R/data.R b/R/data.R index 701ef0d5..0361c289 100644 --- a/R/data.R +++ b/R/data.R @@ -95,6 +95,100 @@ #' system.file("raw_data", package = "clinsight")))`. "clinsightful_data" + +#' Application Metadata +#' +#' A list of data frames and settings containing metadata that will be used for +#' the application. The metadata will be merged with raw data. It controls +#' the variables that will be used in the application, and in which tab the +#' variables will be shown. The goal is that most, if not all, study-specific +#' data will be captured in the metadata, leaving the scripts to run the +#' application largely unaltered between studies. See `vignette("Metadata")` for +#' in-depth information. +#' +#' @format `metadata`: A list with `r length(metadata)` objects. +#' +#' @source Can be created with an Excel file. The Excel file format is chosen so +#' that the metadata can be changed easily per study. See +#' `raw-data/metadata.R` for details. +"metadata" + + +#' Application Data +#' +#' A list of data frames split by `item_group`. It is currently +#' not needed to provide the application data in this format. However, the +#' function can be useful for clinsight data customization, especially in +#' combination with [create_table()]. It creates table classes of the +#' `item_group` name (in lower case letters, and all punctuation replaced by an +#' underscore), as long as there is a method available with the corresponding +#' item_group name for the function [create_table()]. If all data is of type +#' 'continuous', then laboratory values such as lab limits and units are +#' cleaned. +#' +#' @format ## `cs_app_data`: A list with `r length(cs_app_data)` objects. +#' +#' ```{r } +#' str(cs_app_data) +#' ``` +#' +#' @source See `raw-data/clinsightful_data.R` for details. +#' +"cs_app_data" + + +#' Application Variables +#' +#' Named list version of `metadata` object. +#' +#' @format ## `cs_app_vars`: A list with `r length(cs_app_vars)` objects. +#' +#' ```{r } +#' str(cs_app_vars) +#' ``` +#' +#' @source See `raw-data/clinsightful_data.R` for details. +#' +"cs_app_vars" + + +#' Application Timeline Data +#' +#' A data.frame containing timeline data. +#' +#' @format ## `cs_timeline_data`: data.frame formatted for consumption by +#' `timevis` package. +#' +#' ```{r } +#' str(cs_timeline_data) +#' ``` +#' +#' @source See `raw-data/clinsightful_data.R` for details. +#' +"cs_timeline_data" + + +#' Application 'Available Data' +#' +#' Data frame containing info about available data per individual, +#' such as visits, adverse events, etc. Will be used in module +#' [mod_queries_server()], to select available items to create a query for per +#' individual and per form. Required columns are the ones distinctively +#' identifying an item. For now that are site_code, event_name, subject_id, +#' event_label, item_group, item_name. +#' +#' @format a data.frame with `r nrow(cs_available_data)` rows and +#' `r ncol(cs_available_data)` variables. +#' +#' ```{r } +#' str(cs_available_data) +#' ``` +#' +#' @source See `raw-data/clinsightful_data.R` for details. +#' +"cs_available_data" + + #' ClinSight key columns #' #' A character string containing the names of the columns that are needed to diff --git a/R/fct_appdata_summary_tables.R b/R/fct_appdata_summary_tables.R index a2f34fb0..1bf8974a 100644 --- a/R/fct_appdata_summary_tables.R +++ b/R/fct_appdata_summary_tables.R @@ -16,7 +16,7 @@ #' treatment item in the timeline. #' #' @return A data frame with timeline data. -#' @keywords internal +#' @export #' get_timeline_data <- function( data, @@ -182,7 +182,7 @@ get_timeline_data <- function( #' duplicate names exist for each participant. #' #' @return A data frame with available data points per form. -#' @keywords internal +#' @export #' get_available_data <- function( data, diff --git a/R/fct_data_helpers.R b/R/fct_data_helpers.R index 7db911c7..456fdb9e 100644 --- a/R/fct_data_helpers.R +++ b/R/fct_data_helpers.R @@ -244,7 +244,7 @@ fix_multiple_choice_vars <- function( #' @param meta List. metadata to use. #' #' @return a list with all important names to be used in a clinical trial. -#' @keywords internal +#' @export #' get_meta_vars <- function(data = appdata, meta = metadata){ stopifnot(inherits(data, "list")) diff --git a/R/fct_data_tests.R b/R/fct_data_tests.R index 5b9c5abc..5c0606be 100644 --- a/R/fct_data_tests.R +++ b/R/fct_data_tests.R @@ -7,7 +7,7 @@ #' @param required_cols Character vector, containing the column names that are #' required for the application to run appropriately. #' -#' @keywords internal +#' @export #' check_appdata <- function( data = appdata, diff --git a/R/fct_test_clinsight.R b/R/fct_test_clinsight.R index 71273360..ba570d60 100644 --- a/R/fct_test_clinsight.R +++ b/R/fct_test_clinsight.R @@ -32,17 +32,67 @@ test_clinsight <- function( meta_data_path <- get_golem_config("meta_data", config = clinsight_config) if ( clinsight_config %in% c("default", "dev") | - !is.character(study_data_path) | !is.character(meta_data_path) + !is.character(study_data_path) | + !is.character(meta_data_path) #| ){ stop("The 'default' or 'dev' config cannot be used with custom data, ", - "and study_data and meta_data in the config file ", - "should be character vectors.") + "and meta_data, app_data, app_vars, timeline_data, & available_data ", + "in the config file should be character vectors.") } + # Build a version of `app_data` & app_vars + app_data <- get_appdata(data = clinsight_data, meta = meta_data) + app_vars <- get_meta_vars(data = app_data, meta = meta_data) + + # Build a 'app_tables' + # app_tables <- lapply( + # setNames(names(app_data), names(app_data)), \(x){ + # create_table(app_data[[x]], expected_columns = names(app_vars$items[[x]])) + # }) + + # Build a 'available_data' + available_data <- get_available_data( + data = app_data, + # tables = app_tables, # outdated arg + # all_forms = app_vars$all_forms, # outdated arg + form_repeat_name = with( + meta_data[["table_names"]], + table_name[raw_name == "form_repeat"] + ) |> + tryCatch(error = \(e) "N") + ) + + # For timeline data + timeline_data <- get_timeline_data( + app_data, + available_data = available_data, + treatment_label = meta_data$settings$treatment_label %||% "\U1F48A T\U2093" + ) temp_folder <- tempfile(tmpdir = tempdir()) dir.create(temp_folder, recursive = TRUE) - saveRDS(clinsight_data, file.path(temp_folder, basename(study_data_path))) - saveRDS(meta_data, file.path(temp_folder, basename(meta_data_path))) + # saveRDS(clinsight_data, file.path(temp_folder, basename(study_data_path))) + # saveRDS(meta_data, file.path(temp_folder, basename(meta_data_path))) + db_path <- file.path(temp_folder, "user_db.sqlite") + if(file.exists(db_path)) file.remove(db_path) + db_create(get_review_data(clinsight_data), + db_path = db_path + ) + save_objs <- c( + "clinsight_data", + "meta_data", + "app_data", + "app_vars", + # "app_tables", + "timeline_data", + "available_data") + purrr::walk(save_objs, function(x){ + rds_file <- file.path(temp_folder, paste0(x, ".rds")) + saveRDS(get(x), rds_file) + if(inherits(get(x), "data.frame")) { + pq_file <- file.path(temp_folder, paste0(x, ".parquet")) + arrow::write_parquet(get(x), pq_file) + } + }) old_config <- Sys.getenv("GOLEM_CONFIG_ACTIVE") Sys.setenv("GOLEM_CONFIG_ACTIVE" = clinsight_config) run_app( diff --git a/R/run_app.R b/R/run_app.R index eb6063ac..d3fc2f49 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -24,8 +24,13 @@ run_app <- function( ... ) { - data <- get_golem_config("study_data") + # data <- get_golem_config("study_data") meta <- get_golem_config("meta_data") + app_data <- get_golem_config("app_data") + app_vars <- get_golem_config("app_vars") + # app_tables <- get_golem_config("app_tables") + available_data <- get_golem_config("available_data") + timeline_data <- get_golem_config("timeline_data") user_db <- get_golem_config("user_db") use_shinymanager <- isTRUE(get_golem_config("user_identification") == "shinymanager") credentials_db <- get_golem_config("credentials_db") @@ -39,23 +44,51 @@ run_app <- function( "Custom folder path provided in the 'data_folder' argument.", "File paths specified in the config.yml will be ignored." ) - if(is.character(data)) data <- file.path(data_folder, basename(data)) + # if(is.character(data)) data <- file.path(data_folder, basename(data)) if(is.character(meta)) meta <- file.path(data_folder, basename(meta)) + if(is.character(app_data)) app_data <- file.path(data_folder, basename(app_data)) + if(is.character(app_vars)) app_vars <- file.path(data_folder, basename(app_vars)) + # if(is.character(app_tables)) app_tables <- file.path(data_folder, basename(app_tables)) + if(is.character(available_data)) available_data <- file.path(data_folder, basename(available_data)) + if(is.character(timeline_data)) timeline_data <- file.path(data_folder, basename(timeline_data)) user_db <- file.path(data_folder, basename(user_db)) if(!is.null(credentials_db)){ credentials_db <- file.path(data_folder, basename(credentials_db)) } } - ## Verify study data - if(is.character(data)){ - if(!file.exists(data)) stop(paste0("Cannot find '", data, "'.")) - if(tolower(tools::file_ext(data)) != "rds"){ - stop("Invalid data format. Expecting a file .rds format") + # ## Verify study data + # if(is.character(data)){ + # if(!file.exists(data)) stop(paste0("Cannot find '", data, "'.")) + # if(tolower(tools::file_ext(data)) != "rds"){ + # stop("Invalid data format. Expecting a file .rds format") + # } + # data <- readRDS(data) + # } + # stopifnot("Expecting study data to be in data frame format." = is.data.frame(data)) + + + ## Verify app_data list + if(is.character(app_data)){ + if(!file.exists(app_data)) stop(paste0("Cannot find '", app_data, "'.")) + if(tolower(tools::file_ext(app_data)) != "rds"){ + stop("Invalid 'app_data' format. Expecting a file .rds format") } - data <- readRDS(data) + app_data <- readRDS(app_data) } - stopifnot("Expecting study data to be in data frame format." = is.data.frame(data)) + stopifnot("Expecting 'app_data' to be in list format." = inherits(app_data, "list")) + + + ## Verify app_vars list + if(is.character(app_vars)){ + if(!file.exists(app_vars)) stop(paste0("Cannot find '", app_vars, "'.")) + if(tolower(tools::file_ext(app_vars)) != "rds"){ + stop("Invalid 'app_vars' format. Expecting a file .rds format") + } + app_vars <- readRDS(app_vars) + } + stopifnot("Expecting 'app_vars' to be in list format." = inherits(app_vars, "list")) + ## Verify metadata if(is.character(meta)){ @@ -65,7 +98,47 @@ run_app <- function( } meta <- readRDS(meta) } - stopifnot("Expecting metadata to be in a list format" = inherits(meta, "list")) + stopifnot("Expecting 'metadata' to be in a list format" = inherits(meta, "list")) + + + ## Verify app_tables list + # if(is.character(app_tables)){ + # if(!file.exists(app_tables)) stop(paste0("Cannot find '", app_tables, "'.")) + # if(tolower(tools::file_ext(app_tables)) != "rds"){ + # stop("Invalid 'app_tables' format. Expecting a file .rds format") + # } + # app_tables <- readRDS(app_tables) + # } + # stopifnot("Expecting 'app_tables' to be in list format." = inherits(app_tables, "list")) + + + ## Verify available_data + if(is.character(available_data)){ + if(!file.exists(available_data)) stop(paste0("Cannot find '", available_data, "'.")) + available_data <- + switch( + tolower(tools::file_ext(available_data)), + "rds" = readRDS(available_data), + "parquet" = arrow::read_parquet(available_data), + stop("Invalid 'available_data' format. Expecting an RDS or Parquet file.") + ) + } + stopifnot("Expecting 'available_data' to be in data frame format." = is.data.frame(available_data)) + + + ## Verify timeline_data + if(is.character(timeline_data)){ + if(!file.exists(timeline_data)) stop(paste0("Cannot find '", timeline_data, "'.")) + timeline_data <- + switch( + tolower(tools::file_ext(timeline_data)), + "rds" = readRDS(timeline_data), + "parquet" = arrow::read_parquet(timeline_data), + stop("Invalid 'timeline_data' format. Expecting an RDS or Parquet file.") + ) + } + stopifnot("Expecting 'timeline_data' to be in data frame format." = is.data.frame(timeline_data)) + ## Verify user database stopifnot("user_db should be a character vector with a file path" = @@ -125,7 +198,12 @@ run_app <- function( ), golem_opts = list( meta = meta, - data = data, + app_data = app_data, + app_vars = app_vars, + # app_tables = app_tables, + available_data = available_data, + timeline_data = timeline_data, + # data = data, user_db = user_db, credentials_db = credentials_db, credentials_pwd = credentials_pwd, diff --git a/data-raw/clinsightful_data.R b/data-raw/clinsightful_data.R index 37410c43..8cf3c1ba 100644 --- a/data-raw/clinsightful_data.R +++ b/data-raw/clinsightful_data.R @@ -1,9 +1,48 @@ devtools::load_all(".") +metadata <- get_metadata(filepath = app_sys("metadata.xlsx")) + clinsightful_data <- clinsight::get_raw_csv_data( - app_sys("raW_data"), + app_sys("raw_data"), synch_time = "2023-09-15 10:10:00 UTC" ) |> merge_meta_with_data(metadata) -usethis::use_data(clinsightful_data, overwrite = TRUE) \ No newline at end of file +# Build a version of `app_data` & app_vars +cs_app_data <- get_appdata(data = clinsightful_data, meta = metadata) +cs_app_vars <- get_meta_vars(data = cs_app_data, meta = metadata) + +# Build a 'app_tables' +# cs_app_tables <- lapply( +# setNames(names(cs_app_data), names(cs_app_data)), \(x){ +# create_table(cs_app_data[[x]], expected_columns = names(cs_app_vars$items[[x]])) +# }) + +# Build a 'available_data' +cs_available_data <- get_available_data( + data = cs_app_data, + # tables = cs_app_tables, # outdated arg + # all_forms = cs_app_vars$all_forms, # outdated arg + form_repeat_name = with( + metadata[["table_names"]], + table_name[raw_name == "form_repeat"] + ) |> + tryCatch(error = \(e) "N") +) + +# For timeline data +cs_timeline_data <- get_timeline_data( + cs_app_data, + available_data = cs_available_data, + treatment_label = metadata$settings$treatment_label %||% "\U1F48A T\U2093" +) + +usethis::use_data( + metadata, + clinsightful_data, + cs_app_data, + cs_app_vars, + # cs_app_tables, + cs_available_data, + cs_timeline_data, + overwrite = TRUE) diff --git a/data-raw/metadata.R b/data-raw/metadata.R deleted file mode 100644 index bacd9d40..00000000 --- a/data-raw/metadata.R +++ /dev/null @@ -1,6 +0,0 @@ -## code to prepare metadata. Raw data is expected to be in Excel format. -devtools::load_all(".") - -metadata <- get_metadata(filepath = app_sys("metadata.xlsx")) - -usethis::use_data(metadata, overwrite = TRUE) diff --git a/data/cs_app_data.rda b/data/cs_app_data.rda new file mode 100644 index 00000000..875112f4 Binary files /dev/null and b/data/cs_app_data.rda differ diff --git a/data/cs_app_tables.rda b/data/cs_app_tables.rda new file mode 100644 index 00000000..fcf69108 Binary files /dev/null and b/data/cs_app_tables.rda differ diff --git a/data/cs_app_vars.rda b/data/cs_app_vars.rda new file mode 100644 index 00000000..8fc6fc2e Binary files /dev/null and b/data/cs_app_vars.rda differ diff --git a/data/cs_available_data.rda b/data/cs_available_data.rda new file mode 100644 index 00000000..74d4f029 Binary files /dev/null and b/data/cs_available_data.rda differ diff --git a/data/cs_timeline_data.rda b/data/cs_timeline_data.rda new file mode 100644 index 00000000..93ae1a4f Binary files /dev/null and b/data/cs_timeline_data.rda differ diff --git a/dev/app.R b/dev/app.R index c1ebc1e5..cc95d608 100644 --- a/dev/app.R +++ b/dev/app.R @@ -15,11 +15,58 @@ merged_data <- merge_meta_with_data( data = my_raw_data, meta = metadata ) + +# Build a version of `app_data` & app_vars +app_data <- get_appdata(data = merged_data, meta = metadata) +app_vars <- get_meta_vars(data = app_data, meta = metadata) + +# Build a 'app_tables' +# app_tables <- lapply( +# setNames(names(app_data), names(app_data)), \(x){ +# create_table(app_data[[x]], expected_columns = names(app_vars$items[[x]])) +# }) + +# Build a 'available_data' +available_data <- get_available_data( + data = app_data, + # tables = app_tables, # outdated arg + # all_forms = app_vars$all_forms, # outdated arg + form_repeat_name = with( + metadata[["table_names"]], + table_name[raw_name == "form_repeat"] + ) |> + tryCatch(error = \(e) "N") +) + +# For timeline data +timeline_data <- get_timeline_data( + app_data, + available_data = available_data, + treatment_label = metadata$settings$treatment_label %||% "\U1F48A T\U2093" +) + # tempdir not useful for production mode data_folder <- "." -data_path <- file.path(data_folder, - "merged_data.rds") -saveRDS(merged_data, data_path) +# data_path <- file.path(data_folder, +# "merged_data.rds") +# saveRDS(merged_data, data_path) +# Current saves both RDS and Parquet for data frames for continuity purposes +save_objs <- c( + "metadata", + "app_data", + "app_vars", + # "app_tables", + "available_data", + "timeline_data") +purrr::walk(save_objs, function(x){ + rds_file <- file.path(data_folder, paste0(x, ".rds")) + saveRDS(get(x), rds_file) + if(inherits(get(x), "data.frame")) { + pq_file <- file.path(data_folder, paste0(x, ".parquet")) + arrow::write_parquet(get(x), pq_file) + } +}) + db_path <- file.path(data_folder, "user_db.sqlite") # if test_mode == FALSE, you'll need to setup... @@ -33,7 +80,7 @@ db_create(get_review_data(merged_data), ) run_app( - data = data_path, #merged_data, # or db_path works too + data = data_folder, # merged_data, # or db_path works too # user_db = db_path, # defaults to "user_db.sqlite" # onStart = \(){onStop(\(){unlink(data_folder, recursive = TRUE)})} # be careful here ) diff --git a/dev/run_dev.R b/dev/run_dev.R index bf2fecd3..20f7637e 100644 --- a/dev/run_dev.R +++ b/dev/run_dev.R @@ -20,12 +20,19 @@ load_and_run_app <- function(){ old_golem_config <- Sys.getenv("GOLEM_CONFIG_ACTIVE") Sys.setenv("GOLEM_CONFIG_ACTIVE" = "dev") + # create db + db_path <- file.path(temp_folder, "user_db.sqlite") + if(file.exists(db_path)) file.remove(db_path) + db_create(get_review_data(clinsightful_data), + db_path = db_path + ) + run_app( data_folder = temp_folder, onStart = \(){onStop(\(){ unlink(temp_folder, recursive = TRUE); Sys.setenv("GOLEM_CONFIG_ACTIVE" = old_golem_config) - })} + })} ) } diff --git a/inst/golem-config.yml b/inst/golem-config.yml index d496cc5a..3faa80b8 100644 --- a/inst/golem-config.yml +++ b/inst/golem-config.yml @@ -5,6 +5,11 @@ default: user_identification: test_user study_data: !expr clinsight::clinsightful_data meta_data: !expr clinsight::metadata + app_data: !expr clinsight::cs_app_data + app_vars: !expr clinsight::cs_app_vars + # app_tables: !expr clinsight::cs_app_tables + available_data: !expr clinsight::cs_available_data + timeline_data: !expr clinsight::cs_timeline_data user_db: user_db.sqlite user_roles: Administrator: admin @@ -18,8 +23,13 @@ default: dev: golem_wd: !expr golem::pkg_path() test: - study_data: study_data.rds - meta_data: metadata.rds + study_data: clinsight_data.rds + meta_data: meta_data.rds + app_data: app_data.rds + app_vars: app_vars.rds + # app_tables: app_tables.rds + available_data: available_data.rds + timeline_data: timeline_data.rds shinymanager: app_prod: yes user_identification: shinymanager diff --git a/man/check_appdata.Rd b/man/check_appdata.Rd index b58d31d6..06bae442 100644 --- a/man/check_appdata.Rd +++ b/man/check_appdata.Rd @@ -22,4 +22,3 @@ required for the application to run appropriately.} \description{ Checks data for compatibility with metadata. } -\keyword{internal} diff --git a/man/cs_app_data.Rd b/man/cs_app_data.Rd new file mode 100644 index 00000000..89cd4d57 --- /dev/null +++ b/man/cs_app_data.Rd @@ -0,0 +1,317 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{cs_app_data} +\alias{cs_app_data} +\title{Application Data} +\format{ +\subsection{\code{cs_app_data}: A list with 11 objects.}{ + +\if{html}{\out{
}}\preformatted{str(cs_app_data) +#> List of 11 +#> $ Adverse events : advrs_vn [719 x 22] (S3: adverse_events/common_forms/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:719] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:719] "BEL_04_772" "BEL_04_772" "BEL_04_772" "BEL_04_772" ... +#> ..$ event_id : chr [1:719] "COMMON_AE" "COMMON_AE" "COMMON_AE" "COMMON_AE" ... +#> ..$ event_date : Date[1:719], format: "2023-08-31" "2023-08-31" ... +#> ..$ event_repeat : int [1:719] 1 1 1 1 1 1 1 1 2 2 ... +#> ..$ form_id : chr [1:719] "AE" "AE" "AE" "AE" ... +#> ..$ form_repeat : int [1:719] 1 1 1 1 1 1 1 1 2 2 ... +#> ..$ edit_date_time: POSIXct[1:719], format: "2023-08-31 12:09:00" "2023-08-31 12:09:00" ... +#> ..$ day : 'difftime' num [1:719] 87 87 87 87 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:719] "Any visit" "Any visit" "Any visit" "Any visit" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: NA NA NA NA NA NA NA NA NA NA ... +#> ..$ form_type : chr [1:719] "common_forms" "common_forms" "common_forms" "common_forms" ... +#> ..$ item_name : chr [1:719] "AE Number" "AE Name" "AESI" "AE start date" ... +#> ..$ item_type : chr [1:719] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:719] "Adverse events" "Adverse events" "Adverse events" "Adverse events" ... +#> ..$ item_unit : chr [1:719] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:719] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ upper_lim : num [1:719] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ item_value : chr [1:719] "1" "Hypotension" "None" "2023-07-07" ... +#> ..$ significance : chr [1:719] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:719] NA NA NA NA ... +#> ..$ region : chr [1:719] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ CBC regular : continus [381 x 25] (S3: continuous/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:381] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:381] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:381] "SCR" "SCR" "SCR" "SCR" ... +#> ..$ event_date : Date[1:381], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:381] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ form_id : chr [1:381] "LBHM" "LBHM" "LBHM" "LBHM" ... +#> ..$ form_repeat : int [1:381] 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ edit_date_time: POSIXct[1:381], format: "2023-07-05 12:29:00" "2023-07-05 12:29:00" ... +#> ..$ day : 'difftime' num [1:381] 0 0 0 0 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:381] "Screening" "Screening" "Screening" "Screening" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ form_type : chr [1:381] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : Factor w/ 6 levels "Haemoglobin",..: 4 5 6 1 2 3 4 5 6 1 ... +#> ..$ item_type : chr [1:381] "continuous" "continuous" "continuous" "continuous" ... +#> ..$ item_group : chr [1:381] "CBC regular" "CBC regular" "CBC regular" "CBC regular" ... +#> ..$ item_unit : chr [1:381] "10^9/L" "10^9/L" "10^9/L" "g/dL" ... +#> ..$ lower_lim : num [1:381] 1.8 1.4 0.2 11.9 0.37 150 1.8 1.4 0.2 11.9 ... +#> ..$ upper_lim : num [1:381] 7.2 4 1 14.5 0.47 400 7.2 4 1 14.5 ... +#> ..$ item_value : num [1:381] 4.16 1.7 0.12 11.5 0.25 ... +#> ..$ significance : Factor w/ 5 levels "within limits",..: 2 1 2 2 2 2 2 1 2 2 ... +#> ..$ reason_notdone: chr [1:381] NA NA NA NA ... +#> ..$ region : chr [1:381] "BEL" "BEL" "BEL" "BEL" ... +#> ..$ value_scaled : num [1:381] 0.437 0.115 -0.1 -0.154 -1.2 ... +#> ..$ out_of_lim : Factor w/ 2 levels "1","0": 2 2 1 1 1 1 1 2 1 1 ... +#> ..$ text_label : chr [1:381] "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 4.16 10^9/L\\nLimits: 1.8-7.2\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 1.7 10^9/L\\nLimits: 1.4-4\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 0.12 10^9/L\\nLimits: 0.2-1\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 11.5 g/dL\\nLimits: 11.9-14.5\\nout of limits, clinically insignificant" ... +#> $ Conc. Procedures: cnc_prcd [28 x 22] (S3: conc_procedures/common_forms/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:28] "BEL07" "BEL07" "BEL07" "BEL07" ... +#> ..$ subject_id : chr [1:28] "BEL_07_645" "BEL_07_645" "BEL_07_645" "BEL_07_645" ... +#> ..$ event_id : chr [1:28] "COMMON_PR" "COMMON_PR" "COMMON_PR" "COMMON_PR" ... +#> ..$ event_date : Date[1:28], format: "2023-09-14" "2023-09-14" ... +#> ..$ event_repeat : int [1:28] 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ form_id : chr [1:28] "CP" "CP" "CP" "CP" ... +#> ..$ form_repeat : int [1:28] 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ edit_date_time: POSIXct[1:28], format: "2023-09-14 09:37:00" "2023-09-14 09:37:00" ... +#> ..$ day : 'difftime' num [1:28] 101 101 101 101 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:28] "Any visit" "Any visit" "Any visit" "Any visit" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: NA NA NA NA NA NA NA NA NA NA ... +#> ..$ form_type : chr [1:28] "common_forms" "common_forms" "common_forms" "common_forms" ... +#> ..$ item_name : chr [1:28] "CP Number" "CP Name" "CP Indication" "CP Start Date" ... +#> ..$ item_type : chr [1:28] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:28] "Conc. Procedures" "Conc. Procedures" "Conc. Procedures" "Conc. Procedures" ... +#> ..$ item_unit : chr [1:28] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:28] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ upper_lim : num [1:28] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ item_value : chr [1:28] "1" "Appendectomy" "Prophylaxis" "2019-NK-NK" ... +#> ..$ significance : chr [1:28] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:28] NA NA NA NA ... +#> ..$ region : chr [1:28] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ Electrolytes : continus [275 x 25] (S3: continuous/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:275] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:275] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:275] "SCR" "SCR" "SCR" "SCR" ... +#> ..$ event_date : Date[1:275], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:275] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ form_id : chr [1:275] "LBSER" "LBSER" "LBSER" "LBSER" ... +#> ..$ form_repeat : int [1:275] 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ edit_date_time: POSIXct[1:275], format: "2023-06-23 09:00:00" "2023-06-23 09:00:00" ... +#> ..$ day : 'difftime' num [1:275] 0 0 0 0 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:275] "Screening" "Screening" "Screening" "Screening" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 1 1 1 2 2 2 2 ... +#> ..$ form_type : chr [1:275] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : Factor w/ 6 levels "Sodium","Potassium",..: 1 2 3 4 5 6 1 2 3 4 ... +#> ..$ item_type : chr [1:275] "continuous" "continuous" "continuous" "continuous" ... +#> ..$ item_group : chr [1:275] "Electrolytes" "Electrolytes" "Electrolytes" "Electrolytes" ... +#> ..$ item_unit : chr [1:275] "mmol/L" "mmol/L" "mmol/L" "mmol/L" ... +#> ..$ lower_lim : num [1:275] 136 3 98 22 2.15 0.66 136 3 98 22 ... +#> ..$ upper_lim : num [1:275] 145 4.5 107 29 2.55 1.07 145 4.5 107 29 ... +#> ..$ item_value : num [1:275] 138 4.5 105 20.5 2.26 0.87 138 4.14 103 23 ... +#> ..$ significance : Factor w/ 5 levels "within limits",..: 1 2 1 3 1 1 1 2 1 1 ... +#> ..$ reason_notdone: chr [1:275] NA NA NA NA ... +#> ..$ region : chr [1:275] "BEL" "BEL" "BEL" "BEL" ... +#> ..$ value_scaled : num [1:275] 0.222 1 0.778 -0.214 0.275 ... +#> ..$ out_of_lim : Factor w/ 2 levels "0","1": 1 1 1 2 1 1 1 1 1 1 ... +#> ..$ text_label : chr [1:275] "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 138 mmol/L\\nLimits: 136-145\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 4.5 mmol/L\\nLimits: 3-4.5\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 105 mmol/L\\nLimits: 98-107\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 20.5 mmol/L\\nLimits: 22-29\\nout of limits, significance pending" ... +#> $ General : general [261 x 22] (S3: general/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:261] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:261] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:261] "SCR" "SCR" "SCR" "SCR" ... +#> ..$ event_date : Date[1:261], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:261] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ form_id : chr [1:261] "DM" "DM" "DM" "DM" ... +#> ..$ form_repeat : int [1:261] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ edit_date_time: POSIXct[1:261], format: "2023-06-23 08:31:00" "2023-06-23 08:31:00" ... +#> ..$ day : 'difftime' num [1:261] 0 0 0 0 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:261] "Screening" "Screening" "Screening" "Screening" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 1 1 1 1 1 1 2 ... +#> ..$ form_type : chr [1:261] "general" "general" "general" "general" ... +#> ..$ item_name : chr [1:261] "Age" "Sex" "ChildbearingPotential" "MenopauseReason" ... +#> ..$ item_type : chr [1:261] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:261] "General" "General" "General" "General" ... +#> ..$ item_unit : chr [1:261] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:261] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ upper_lim : num [1:261] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ item_value : chr [1:261] "88" "Male" "No" "Postmenopausal" ... +#> ..$ significance : chr [1:261] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:261] NA NA NA NA ... +#> ..$ region : chr [1:261] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ Liver function : continus [180 x 25] (S3: continuous/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:180] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:180] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:180] "SCR" "SCR" "SCR" "SCR" ... +#> ..$ event_date : Date[1:180], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:180] 1 1 1 1 1 1 1 1 3 3 ... +#> ..$ form_id : chr [1:180] "LBSER" "LBSER" "LBSER" "LBSER" ... +#> ..$ form_repeat : int [1:180] 1 1 1 1 2 2 2 2 3 3 ... +#> ..$ edit_date_time: POSIXct[1:180], format: "2023-06-23 09:00:00" "2023-07-05 12:33:00" ... +#> ..$ day : 'difftime' num [1:180] 0 0 0 0 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:180] "Screening" "Screening" "Screening" "Screening" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 1 2 2 2 2 4 4 ... +#> ..$ form_type : chr [1:180] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : Factor w/ 4 levels "Bilirubin","AST",..: 1 2 3 4 1 2 3 4 1 2 ... +#> ..$ item_type : chr [1:180] "continuous" "continuous" "continuous" "continuous" ... +#> ..$ item_group : chr [1:180] "Liver function" "Liver function" "Liver function" "Liver function" ... +#> ..$ item_unit : chr [1:180] "µmol/L" "U/L" "U/L" "U/L" ... +#> ..$ lower_lim : num [1:180] 0 10 10 5 0 10 10 5 0 10 ... +#> ..$ upper_lim : num [1:180] 21 35 25 36 21 35 25 36 21 35 ... +#> ..$ item_value : num [1:180] 6 21 35 24 11 32 45 25 8 43 ... +#> ..$ significance : Factor w/ 5 levels "within limits",..: 1 2 2 1 1 1 2 1 1 2 ... +#> ..$ reason_notdone: chr [1:180] NA NA NA NA ... +#> ..$ region : chr [1:180] "BEL" "BEL" "BEL" "BEL" ... +#> ..$ value_scaled : num [1:180] 0.286 0.44 1.667 0.613 0.524 ... +#> ..$ out_of_lim : Factor w/ 2 levels "0","1": 1 1 2 1 1 1 2 1 1 2 ... +#> ..$ text_label : chr [1:180] "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 6 µmol/L\\nLimits: 0-21\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 21 U/L\\nLimits: 10-35\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 35 U/L\\nLimits: 10-25\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 24 U/L\\nLimits: 5-36\\nwithin limits" ... +#> $ Medical History : mdcl_hst [757 x 22] (S3: medical_history/common_forms/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:757] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:757] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:757] "COMMON_MH" "COMMON_MH" "COMMON_MH" "COMMON_MH" ... +#> ..$ event_date : Date[1:757], format: "2023-06-23" "2023-06-23" ... +#> ..$ event_repeat : int [1:757] 1 1 1 1 1 1 1 1 2 2 ... +#> ..$ form_id : chr [1:757] "MH" "MH" "MH" "MH" ... +#> ..$ form_repeat : int [1:757] 1 1 1 1 1 1 1 1 2 2 ... +#> ..$ edit_date_time: POSIXct[1:757], format: "2023-06-23 09:12:00" "2023-06-23 09:12:00" ... +#> ..$ day : 'difftime' num [1:757] 18 18 18 18 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:757] "Any visit" "Any visit" "Any visit" "Any visit" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: NA NA NA NA NA NA NA NA NA NA ... +#> ..$ form_type : chr [1:757] "common_forms" "common_forms" "common_forms" "common_forms" ... +#> ..$ item_name : chr [1:757] "MH Number" "MH Name" "MH Ongoing" "MH Treatment" ... +#> ..$ item_type : chr [1:757] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:757] "Medical History" "Medical History" "Medical History" "Medical History" ... +#> ..$ item_unit : chr [1:757] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:757] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ upper_lim : num [1:757] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ item_value : chr [1:757] "1" "Epilepsy" "Yes" "Medication" ... +#> ..$ significance : chr [1:757] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:757] NA NA NA NA ... +#> ..$ region : chr [1:757] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ Medication : medicatn [2,856 x 22] (S3: medication/common_forms/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:2856] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:2856] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:2856] "COMMON_CM" "COMMON_CM" "COMMON_CM" "COMMON_CM" ... +#> ..$ event_date : Date[1:2856], format: "2023-06-23" "2023-06-23" ... +#> ..$ event_repeat : int [1:2856] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ form_id : chr [1:2856] "CM" "CM" "CM" "CM" ... +#> ..$ form_repeat : int [1:2856] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ edit_date_time: POSIXct[1:2856], format: "2023-06-23 09:17:00" "2023-06-23 09:17:00" ... +#> ..$ day : 'difftime' num [1:2856] 18 18 18 18 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:2856] "Any visit" "Any visit" "Any visit" "Any visit" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: NA NA NA NA NA NA NA NA NA NA ... +#> ..$ form_type : chr [1:2856] "common_forms" "common_forms" "common_forms" "common_forms" ... +#> ..$ item_name : chr [1:2856] "CM Number" "CM Name" "CM Indication" "CM Ongoing" ... +#> ..$ item_type : chr [1:2856] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:2856] "Medication" "Medication" "Medication" "Medication" ... +#> ..$ item_unit : chr [1:2856] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:2856] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ upper_lim : num [1:2856] NA NA NA NA NA NA NA NA NA NA ... +#> ..$ item_value : chr [1:2856] "1" "Paracetamol (Gliigestatrilat)" "Prophylaxis" "Yes" ... +#> ..$ significance : chr [1:2856] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:2856] NA NA NA NA ... +#> ..$ region : chr [1:2856] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ Renal function : continus [135 x 25] (S3: continuous/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:135] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:135] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:135] "SCR" "SCR" "SCR" "VIS1" ... +#> ..$ event_date : Date[1:135], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:135] 1 1 1 1 1 1 3 3 3 5 ... +#> ..$ form_id : chr [1:135] "LBSER" "LBSER" "LBSER" "LBSER" ... +#> ..$ form_repeat : int [1:135] 1 1 1 2 2 2 3 3 3 4 ... +#> ..$ edit_date_time: POSIXct[1:135], format: "2023-08-18 15:39:00" "2023-08-18 15:46:00" ... +#> ..$ day : 'difftime' num [1:135] 0 0 0 30 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:135] "Screening" "Screening" "Screening" "Visit 1" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 2 2 2 4 4 4 6 ... +#> ..$ form_type : chr [1:135] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : Factor w/ 3 levels "Creatinine","eGFR",..: 1 2 3 1 2 3 1 2 3 1 ... +#> ..$ item_type : chr [1:135] "continuous" "continuous" "continuous" "continuous" ... +#> ..$ item_group : chr [1:135] "Renal function" "Renal function" "Renal function" "Renal function" ... +#> ..$ item_unit : chr [1:135] "µmol/L" "ml/min/1.73 m²" "µmol/L" "µmol/L" ... +#> ..$ lower_lim : num [1:135] 45 60 140 45 60 2.9 45 60 2.9 45 ... +#> ..$ upper_lim : num [1:135] 84 90 340 84 90 8.2 84 90 8.2 84 ... +#> ..$ item_value : num [1:135] 58 48 288 110 89 4.1 61 90 7.5 117 ... +#> ..$ significance : Factor w/ 5 levels "within limits",..: 2 2 1 2 2 1 2 2 1 2 ... +#> ..$ reason_notdone: chr [1:135] NA NA NA NA ... +#> ..$ region : chr [1:135] "BEL" "BEL" "BEL" "BEL" ... +#> ..$ value_scaled : num [1:135] 0.333 -0.4 0.74 1.667 0.967 ... +#> ..$ out_of_lim : Factor w/ 2 levels "0","1": 1 2 1 2 1 1 1 1 1 2 ... +#> ..$ text_label : chr [1:135] "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 58 µmol/L\\nLimits: 45-84\\nout of limits, clinically insignificant" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 48 ml/min/1.73 m²\\nLimits: 60-90\\nout of limits, clini"| __truncated__ "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 288 µmol/L\\nLimits: 140-340\\nwithin limits" "BEL_04_133\\n2023-07-05\\nVisit 1 (day 30)\\nValue: 110 µmol/L\\nLimits: 45-84\\nout of limits, clinically insignificant" ... +#> $ Response : tibble [6 x 22] (S3: tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:6] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:6] "BEL_04_133" "BEL_04_133" "BEL_04_772" "BEL_04_772" ... +#> ..$ event_id : chr [1:6] "VIS5" "VIS5" "VIS5" "VIS5" ... +#> ..$ event_date : Date[1:6], format: "2023-08-30" "2023-08-30" ... +#> ..$ event_repeat : int [1:6] 5 5 5 5 5 5 +#> ..$ form_id : chr [1:6] "RS" "RS" "RS" "RS" ... +#> ..$ form_repeat : int [1:6] 1 1 1 1 1 1 +#> ..$ edit_date_time: POSIXct[1:6], format: "2023-09-13 15:23:00" "2023-09-13 15:23:00" ... +#> ..$ day : 'difftime' num [1:6] 86 86 86 86 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:6] "Visit 5" "Visit 5" "Visit 5" "Visit 5" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 6 6 6 6 6 6 +#> ..$ form_type : chr [1:6] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : chr [1:6] "Response" "Responder" "Response" "Responder" ... +#> ..$ item_type : chr [1:6] "other" "other" "other" "other" ... +#> ..$ item_group : chr [1:6] "Response" "Response" "Response" "Response" ... +#> ..$ item_unit : chr [1:6] "(unit missing)" "(unit missing)" "(unit missing)" "(unit missing)" ... +#> ..$ lower_lim : num [1:6] NA NA NA NA NA NA +#> ..$ upper_lim : num [1:6] NA NA NA NA NA NA +#> ..$ item_value : chr [1:6] "Stable disease (SD)" "No" "Cured" "Yes" ... +#> ..$ significance : chr [1:6] NA NA NA NA ... +#> ..$ reason_notdone: chr [1:6] NA NA NA NA ... +#> ..$ region : chr [1:6] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ Vital signs : continus [478 x 25] (S3: continuous/tbl_df/tbl/data.frame) +#> ..$ site_code : chr [1:478] "BEL04" "BEL04" "BEL04" "BEL04" ... +#> ..$ subject_id : chr [1:478] "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> ..$ event_id : chr [1:478] "SCR" "SCR" "SCR" "SCR" ... +#> ..$ event_date : Date[1:478], format: "2023-06-05" "2023-06-05" ... +#> ..$ event_repeat : int [1:478] 1 1 1 1 1 1 1 1 1 1 ... +#> ..$ form_id : chr [1:478] "VS" "VS" "VS" "VS" ... +#> ..$ form_repeat : int [1:478] 1 1 1 1 1 1 1 2 2 2 ... +#> ..$ edit_date_time: POSIXct[1:478], format: "2023-06-23 08:32:00" "2023-06-23 08:32:00" ... +#> ..$ day : 'difftime' num [1:478] 0 0 0 0 ... +#> .. ..- attr(*, "units")= chr "days" +#> ..$ event_name : chr [1:478] "Screening" "Screening" "Screening" "Screening" ... +#> ..$ event_label : Factor w/ 8 levels "SCR","V1","V2",..: 1 1 1 1 1 1 1 2 2 2 ... +#> ..$ form_type : chr [1:478] "study_forms" "study_forms" "study_forms" "study_forms" ... +#> ..$ item_name : Factor w/ 8 levels "Systolic blood pressure",..: 8 7 3 4 5 1 2 8 7 3 ... +#> ..$ item_type : chr [1:478] "continuous" "continuous" "continuous" "continuous" ... +#> ..$ item_group : chr [1:478] "Vital signs" "Vital signs" "Vital signs" "Vital signs" ... +#> ..$ item_unit : chr [1:478] "kg" "kg/m2" "beats/min" "breaths/min" ... +#> ..$ lower_lim : num [1:478] 45 18.5 60 12 35 90 55 45 18.5 60 ... +#> ..$ upper_lim : num [1:478] 200 30 100 20 38.5 160 90 200 30 100 ... +#> ..$ item_value : num [1:478] 50 24.5 60 19 36.7 ... +#> ..$ significance : Factor w/ 5 levels "within limits",..: 1 1 1 1 1 1 1 1 3 1 ... +#> ..$ reason_notdone: chr [1:478] NA NA NA NA ... +#> ..$ region : chr [1:478] "BEL" "BEL" "BEL" "BEL" ... +#> ..$ value_scaled : num [1:478] 0.0323 0.5235 0 0.875 0.4857 ... +#> ..$ out_of_lim : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 1 ... +#> ..$ text_label : chr [1:478] "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 50 kg\\nLimits: 45-200\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 24.52 kg/m2\\nLimits: 18.5-30\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 60 beats/min\\nLimits: 60-100\\nwithin limits" "BEL_04_133\\n2023-06-05\\nScreening (day 0)\\nValue: 19 breaths/min\\nLimits: 12-20\\nwithin limits" ... +}\if{html}{\out{
}} +} +} +\source{ +See \code{raw-data/clinsightful_data.R} for details. +} +\usage{ +cs_app_data +} +\description{ +A list of data frames split by \code{item_group}. It is currently +not needed to provide the application data in this format. However, the +function can be useful for clinsight data customization, especially in +combination with \code{\link[=create_table]{create_table()}}. It creates table classes of the +\code{item_group} name (in lower case letters, and all punctuation replaced by an +underscore), as long as there is a method available with the corresponding +item_group name for the function \code{\link[=create_table]{create_table()}}. If all data is of type +'continuous', then laboratory values such as lab limits and units are +cleaned. +} +\keyword{datasets} diff --git a/man/cs_app_vars.Rd b/man/cs_app_vars.Rd new file mode 100644 index 00000000..a6de469b --- /dev/null +++ b/man/cs_app_vars.Rd @@ -0,0 +1,62 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{cs_app_vars} +\alias{cs_app_vars} +\title{Application Variables} +\format{ +\subsection{\code{cs_app_vars}: A list with 6 objects.}{ + +\if{html}{\out{
}}\preformatted{str(cs_app_vars) +#> List of 6 +#> $ items :List of 11 +#> ..$ Adverse events : Named chr [1:17] "ae_number" "ae_name" "aesi" "ae_start_date" ... +#> .. ..- attr(*, "names")= chr [1:17] "AE Number" "AE Name" "AESI" "AE start date" ... +#> ..$ CBC regular : Named chr [1:6] "haemoglobin" "haematocrit" "platelets" "neutrophils" ... +#> .. ..- attr(*, "names")= chr [1:6] "Haemoglobin" "Haematocrit" "Platelets" "Neutrophils" ... +#> ..$ Conc. Procedures: Named chr [1:8] "cp_number" "cp_name" "cp_indication" "cp_start_date" ... +#> .. ..- attr(*, "names")= chr [1:8] "CP Number" "CP Name" "CP Indication" "CP Start Date" ... +#> ..$ Electrolytes : Named chr [1:6] "sodium" "potassium" "chloride" "bicarbonate" ... +#> .. ..- attr(*, "names")= chr [1:6] "Sodium" "Potassium" "Chloride" "Bicarbonate" ... +#> ..$ General : Named chr [1:20] "age" "sex" "ecog" "eligible" ... +#> .. ..- attr(*, "names")= chr [1:20] "Age" "Sex" "ECOG" "Eligible" ... +#> ..$ Liver function : Named chr [1:4] "bilirubin" "ast" "alt" "ggt" +#> .. ..- attr(*, "names")= chr [1:4] "Bilirubin" "AST" "ALT" "gGT" +#> ..$ Medical History : Named chr [1:7] "mh_number" "mh_name" "mh_start_date" "mh_ongoing" ... +#> .. ..- attr(*, "names")= chr [1:7] "MH Number" "MH Name" "MH Start Date" "MH Ongoing" ... +#> ..$ Medication : Named chr [1:12] "cm_number" "cm_name" "cm_indication" "cm_dose" ... +#> .. ..- attr(*, "names")= chr [1:12] "CM Number" "CM Name" "CM Indication" "CM Dose" ... +#> ..$ Renal function : Named chr [1:3] "creatinine" "egfr" "urate" +#> .. ..- attr(*, "names")= chr [1:3] "Creatinine" "eGFR" "Urate" +#> ..$ Response : Named chr [1:2] "response" "responder" +#> .. ..- attr(*, "names")= chr [1:2] "Response" "Responder" +#> ..$ Vital signs : Named chr [1:8] "systolic_blood_pressure" "diastolic_blood_pressure" "pulse" "resp" ... +#> .. ..- attr(*, "names")= chr [1:8] "Systolic blood pressure" "Diastolic blood pressure" "Pulse" "Resp" ... +#> $ all_forms :'data.frame': 10 obs. of 2 variables: +#> ..$ main_tab: chr [1:10] "Common events" "Common events" "Common events" "Common events" ... +#> ..$ form : chr [1:10] "Adverse events" "Medication" "Conc. Procedures" "Medical History" ... +#> $ subject_id : chr [1:25] "BEL_08_45" "BEL_04_133" "BEL_04_772" "BEL_07_193" ... +#> $ Sites : advrs_vn [9 x 2] (S3: adverse_events/common_forms/tbl_df/tbl/data.frame) +#> ..$ site_code: chr [1:9] "BEL04" "BEL07" "BEL08" "BEL09" ... +#> ..$ region : chr [1:9] "BEL" "BEL" "BEL" "BEL" ... +#> ..- attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +#> $ table_names : Named chr [1:16] "edit_date_time" "event_date" "event_label" "event_name" ... +#> ..- attr(*, "names")= chr [1:16] "Edit date" "Date" "Event" "Event" ... +#> $ form_level_data:'data.frame': 11 obs. of 4 variables: +#> ..$ item_group : chr [1:11] "Adverse events" "Medication" "Conc. Procedures" "Medical History" ... +#> ..$ item_scale : logi [1:11] NA NA NA NA FALSE TRUE ... +#> ..$ use_unscaled_limits: logi [1:11] NA NA NA NA TRUE FALSE ... +#> ..$ review_required : logi [1:11] TRUE TRUE TRUE TRUE TRUE TRUE ... +}\if{html}{\out{
}} +} +} +\source{ +See \code{raw-data/clinsightful_data.R} for details. +} +\usage{ +cs_app_vars +} +\description{ +Named list version of \code{metadata} object. +} +\keyword{datasets} diff --git a/man/cs_available_data.Rd b/man/cs_available_data.Rd new file mode 100644 index 00000000..4e05bc6b --- /dev/null +++ b/man/cs_available_data.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{cs_available_data} +\alias{cs_available_data} +\title{Application 'Available Data'} +\format{ +a data.frame with 2235 rows and +7 variables. + +\if{html}{\out{
}}\preformatted{str(cs_available_data) +#> 'data.frame': 2235 obs. of 7 variables: +#> $ subject_id : chr "BEL_04_772" "BEL_04_772" "BEL_04_772" "BEL_04_772" ... +#> $ item_name : chr "Hypotension" "Atrial Fibrillation (N: 2)" "Tachycardia" "Urinary Tract Infection" ... +#> $ form_repeat: int 1 2 3 4 5 1 1 1 2 3 ... +#> $ item_group : chr "Adverse events" "Adverse events" "Adverse events" "Adverse events" ... +#> $ event_name : chr "Any visit" "Any visit" "Any visit" "Any visit" ... +#> $ event_label: Factor w/ 8 levels "SCR","V1","V2",..: NA NA NA NA NA NA NA NA NA NA ... +#> $ event_date : Date, format: "2023-08-31" "2023-08-31" ... +#> - attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +}\if{html}{\out{
}} +} +\source{ +See \code{raw-data/clinsightful_data.R} for details. +} +\usage{ +cs_available_data +} +\description{ +Data frame containing info about available data per individual, +such as visits, adverse events, etc. Will be used in module +\code{\link[=mod_queries_server]{mod_queries_server()}}, to select available items to create a query for per +individual and per form. Required columns are the ones distinctively +identifying an item. For now that are site_code, event_name, subject_id, +event_label, item_group, item_name. +} +\keyword{datasets} diff --git a/man/cs_timeline_data.Rd b/man/cs_timeline_data.Rd new file mode 100644 index 00000000..674d40df --- /dev/null +++ b/man/cs_timeline_data.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{cs_timeline_data} +\alias{cs_timeline_data} +\title{Application Timeline Data} +\format{ +\subsection{\code{cs_timeline_data}: data.frame formatted for consumption by}{ + +\code{timevis} package. + +\if{html}{\out{
}}\preformatted{str(cs_timeline_data) +#> 'data.frame': 203 obs. of 11 variables: +#> $ subject_id : chr "BEL_04_133" "BEL_04_133" "BEL_04_133" "BEL_04_133" ... +#> $ content : chr "Screening" "Visit 1" "Visit 2" "Visit 3" ... +#> $ form_repeat: int NA NA NA NA NA NA NA NA NA NA ... +#> $ item_group : chr NA NA NA NA ... +#> $ start : Date, format: "2023-06-05" "2023-07-05" ... +#> $ group : Factor w/ 4 levels "SAE","Adverse event",..: 4 4 4 4 4 4 4 4 4 4 ... +#> $ end : Date, format: NA NA ... +#> $ title : chr "2023-06-05 | Screening" "2023-07-05 | Visit 1" "2023-07-19 | Visit 2" "2023-08-02 | Visit 3" ... +#> $ className : chr "bg-light" "bg-light" "bg-light" "bg-light" ... +#> $ id : int 1 2 3 4 5 6 7 8 9 10 ... +#> $ order : num 4 4 4 4 4 4 4 4 4 4 ... +#> - attr(*, "synch_time")= chr "2023-09-15 10:10:00 UTC" +}\if{html}{\out{
}} +} +} +\source{ +See \code{raw-data/clinsightful_data.R} for details. +} +\usage{ +cs_timeline_data +} +\description{ +A data.frame containing timeline data. +} +\keyword{datasets} diff --git a/man/get_available_data.Rd b/man/get_available_data.Rd index ceecde4a..c00f1361 100644 --- a/man/get_available_data.Rd +++ b/man/get_available_data.Rd @@ -25,4 +25,3 @@ individual and per form. Required columns are the ones distinctively identifying an item. For now that are site_code, event_name, subject_id, event_label, item_group, item_name. } -\keyword{internal} diff --git a/man/get_meta_vars.Rd b/man/get_meta_vars.Rd index 82833b25..ad1cdbea 100644 --- a/man/get_meta_vars.Rd +++ b/man/get_meta_vars.Rd @@ -19,4 +19,3 @@ Prepares and extracts consistent variable names based on both metadata and the provided data. To be used in both the UI and server functions of a Shiny app. } -\keyword{internal} diff --git a/man/get_timeline_data.Rd b/man/get_timeline_data.Rd index 161567c4..91e46aff 100644 --- a/man/get_timeline_data.Rd +++ b/man/get_timeline_data.Rd @@ -39,4 +39,3 @@ A data frame with timeline data. Function to create timeline data, to be used in a \code{timevis::timeline()} object. } -\keyword{internal} diff --git a/man/metadata.Rd b/man/metadata.Rd index e875ec61..3a57c5de 100644 --- a/man/metadata.Rd +++ b/man/metadata.Rd @@ -64,13 +64,21 @@ #> ..$ upper_limit: chr [1:220] NA NA NA NA ... }\if{html}{\out{}} } + +\code{metadata}: A list with 9 objects. } \source{ +Can be created with an Excel file. The Excel file format is chosen so +that the metadata can be changed easily per study. See +\code{raw-data/metadata.R} for details. + Can be created with an Excel file. The Excel file format is chosen so that the metadata can be changed easily per study. See \code{raw-data/metadata.R} for details. } \usage{ +metadata + metadata } \description{ @@ -81,5 +89,13 @@ variables will be shown. The goal is that most, if not all, study-specific data will be captured in the metadata, leaving the scripts to run the application largely unaltered between studies.See \code{vignette("Metadata")} for in-depth information. + +A list of data frames and settings containing metadata that will be used for +the application. The metadata will be merged with raw data. It controls +the variables that will be used in the application, and in which tab the +variables will be shown. The goal is that most, if not all, study-specific +data will be captured in the metadata, leaving the scripts to run the +application largely unaltered between studies. See \code{vignette("Metadata")} for +in-depth information. } \keyword{datasets} diff --git a/tests/testthat/test-mod_main_sidebar.R b/tests/testthat/test-mod_main_sidebar.R index f375871a..ff56dd73 100644 --- a/tests/testthat/test-mod_main_sidebar.R +++ b/tests/testthat/test-mod_main_sidebar.R @@ -14,7 +14,8 @@ describe("mod_main_sidebar. Feature 1 | Load application module in isolation.", ), db_path = "", forms_to_review = reactiveVal(), - available_data = data.frame() + available_data = data.frame(), + timeline_data = data.frame() ) it("Can load the module UI, with functioning internal parameters.", {