Skip to contents

Setup or Load the project object for pipeline.

Usage

setup_project(
  short_name,
  dir_path,
  redcap_base,
  token_name = paste0("REDCapSync_", short_name),
  sync_frequency = "daily",
  reset = FALSE,
  get_type = "identified",
  labelled = TRUE,
  metadata_only = FALSE,
  batch_size_download = 2000,
  batch_size_upload = 500,
  entire_log = FALSE,
  days_of_log = 10,
  get_files = FALSE,
  get_file_repository = FALSE,
  original_file_names = FALSE,
  merge_form_name = "merged",
  use_csv = FALSE,
  silent = FALSE
)

load_project(short_name)

load_test_project(short_name = "TEST_repeating", with_data = FALSE)

Arguments

short_name

A character string with no spaces or symbols representing the unique short name for the REDCap project.

dir_path

Optional character string representing the directory path where you want the REDCap project data to be stored. If missing, project object will only be in current R session.

redcap_base

A character string representing the base URL of the REDCap server.

token_name

An optional character string for setting your token name. Default is REDCapSync_<short_name>

sync_frequency

Frequency of sync. Options are "always", "hourly", 'daily', 'weekly', "monthly",and "never". The check is only triggered by calling the function, but can be automated with other packages. Default is daily

reset

Logical (TRUE/FALSE). If TRUE, forces the setup even if the project object already exists. Default is FALSE.

get_type

optional character of REDCap API call type. data as if user ran sync_project. Default is FALSE.

labelled

Logical (TRUE/FALSE). For whether or not to use labelled vs raw coded data in output.

metadata_only

Logical (TRUE/FALSE). If TRUE, updates only the metadata. Default is FALSE.

batch_size_download

Integer. Number of records to process in each batch. Default is 2000.

batch_size_upload

Integer. Number of records to process in each batch. Default is 500.

entire_log

Logical (TRUE/FALSE). If TRUE, retrieves the entire log. Default is FALSE.

days_of_log

Integer. Number of days to be checked in the log if a reset or new project is setup. Default is 10.

get_files

Logical (TRUE/FALSE). If TRUE, retrieves files from REDCap. Default is FALSE.

get_file_repository

Logical (TRUE/FALSE). If TRUE, retrieves file repository from REDCap. Default is FALSE.

original_file_names

Logical (TRUE/FALSE). If TRUE, uses original file names for retrieved files. Default is FALSE.

merge_form_name

A character string representing the name of the merged form. Default is "merged".

use_csv

Logical (TRUE/FALSE). If TRUE, uses CSV files for data storage. Default is FALSE.

silent

Logical (TRUE/FALSE). For messages.

with_data

Logical (TRUE/FALSE). If TRUE, loads the test project object with data included.

Value

REDCapSync project list object.

Details

This function sets up the project object by storing the REDCap API token and other configurations required for interacting with the REDCap server. It ensures that the token is valid and ready for use in subsequent API calls. Neither function directly attempts communication with REDCap.

setup_project is used the first time you initialize/link a REDCap project. Mainly, it sets your unique short_name and your intended directory. Unless you run reset = TRUE the default will first try load_project. dir_path is technically optional but without it the user cannot save/load/update projects.

load_project can be used with just the short_name parameter after you have already run setup_project in the past with an established directory. dir_path is optional for this function but can be used if you relocated the directory.

See also

get_projects for retrieving a list of projects from the directory cache.

Other project object: save_project()

Examples

if (FALSE) {
# Initialize the project object with the REDCap API token and URL
project <- setup_project(
  short_name = "TEST",
  dir_path = "path/to/secure/file/storage",
  redcap_base = "https://redcap.yourinstitution.edu/"
)
project <- load_project("TEST")
}