LoadConfigurations: Wrapper for creating REDCap configuration objects

load_configsR Documentation

Wrapper for creating REDCap configuration objects

Description

Cleaner way for instantiating REDCap configuration objects.

It uses an R data frame and character vectors to instantiate REDCap configuration objects.

This abstracts instantiation in R6 classes which is more complex and error prone.

Usage

load_configs(config_data = NULL, custom_code = NA, exclusion_pattern = NA)

Arguments

config_data

A dataset containing the configurations. For the column specifications and some common entries, see Details.

custom_code

A character vector containing custom code for error reporting. If located in a file use readLines to load the contents to a character vector

exclusion_pattern

A character vector containing regex patterns for variables to be excluded from error reporting.

The exclusion may be because these variables are handled specially in the custom code or do not add value to the error reporting process.

Details

This function acts as a wrapper for instantiating an object that abstracts the REDCap configurations.

It performs the necessary checks for instantiation hence avoids messy objects.

It then calls the new method of the underlying reference class.

The configuration dataset must contain the following variables:

key

The name of the configuration

value

The value the configuration takes

type

The data type for the configuration. Its either 'string', 'number', 'integer', 'date' or 'boolean'

Some common configuations include:

api_url

The url to the redcap api.

Just append /api/ to the REDCap instance's url link. [type : 'string'].

Defaults to http://localhost/redcap/api/ if not specified.

token

Token necessary for authentication.

Must have api rights to obtain this from REDCap. [type : 'string'].

Defaults to an empty string if not specified. This is invalid and therefore is the only configuration that must be specified.

local

Whether REDCap instance is local to the machine. [type: 'boolean'].

Defaults to TRUE if not specified.

chunked

Whether to pull data from REDCap / Validate data entry in chunks. This helps if the data size is large or in cases of network latency [type: 'boolean'].

Defaults to FALSE if not specified hence data operations are carried out in bulk by default.

chunksize

The size of the chunks to be used. Depends on the data size [type: 'integer'].

This is ignored if chunked is FALSE but must be provided in case chunked is TRUE.

date_var

The name of the variable that holds the date of record entry [type: 'string'].

This defaults to date_today in line with CIN's data governance framework if not specified.

hosp_var

The name of the variable that holds the date of record entry [type: 'string']

This defaults to hosp_id in line with CIN's data governance framework if not specified.

report_location

The path to the generated error report [type: 'string']

This defaults to a temporary file in a subdirectory of the default temporary directory if not specified.

hosp_to_validate

The id of the hospital to generate an error report on. [type: 'integer'].

During error reporting, if an entry's hospital id does not match this code a data entry error is raised.

This defaults to NA if not specified.

Value

A RedcapConfig object.

See Also

RedcapUpdate, Redcap, redcap_project

Other Configuration Objects: RedcapConfig, RedcapUpdate, config_keys, load_updates


smockin/RedcapData documentation built on Feb. 2, 2023, 3:19 a.m.