redcap_download_instrument: Download REDCap Instruments

Description Usage Arguments Details Value Author(s) References Examples

View source: R/redcap-download-instrument.R

Description

Download instruments as a pdf, with or without responses.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
redcap_download_instrument(
  file_name = NULL,
  directory = NULL,
  overwrite = FALSE,
  redcap_uri,
  token,
  record = character(0),
  instrument = "",
  event = "",
  verbose = TRUE,
  config_options = NULL
)

Arguments

file_name

The name of the file where the downloaded pdf is saved. Optional.

directory

The directory where the file is saved. By default current directory. Optional.

overwrite

Boolean value indicating if existing files should be overwritten. Optional.

redcap_uri

The URI (uniform resource identifier) of the REDCap project. Required.

token

The user-specific string that serves as the password for a project. Required.

record

The record ID of the instrument(s). If empty, the responses are blank. Optional.

instrument

The instrument(s) to download. If empty, all instruments are returned. Optional.

event

The unique event name. For a longitudinal project, if record is not blank and event is blank, it will return data for all events from that record. If record is not blank and event is not blank, it will return data only for the specified event from that record. Optional.

verbose

A boolean value indicating if messages should be printed to the R console during the operation. Optional.

config_options

A list of options to pass to httr::POST() method in the 'httr' package. See the details below. Optional.

Details

Currently, the function doesn't modify any variable types to conform to REDCap's supported variables. See validate_for_write() for a helper function that checks for some common important conflicts.

Value

Currently, a list is returned with the following elements,

Author(s)

Will Beasley

References

The official documentation can be found on the 'API Help Page' and 'API Examples' pages on the REDCap wiki (i.e., https://community.projectredcap.org/articles/456/api-documentation.html and https://community.projectredcap.org/articles/462/api-examples.html). If you do not have an account for the wiki, please ask your campus REDCap administrator to send you the static material.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
uri     <- "https://bbmc.ouhsc.edu/redcap/api/"
token   <- "D70F9ACD1EDD6F151C6EA78683944E98" #pid=213
# event <- "" # only for longitudinal projects

(full_name <- base::temp(pattern="instruments-all-records-all", fileext=".pdf"))
result_1   <- REDCapR::redcap_download_instrument(
  file_name     = full_name,
  redcap_uri    = uri,
  token         = token
)
base::unlink(full_name)

(full_name <- base::tempfile(pattern="instruments-all-record-1-", fileext=".pdf"))
result_2   <- REDCapR::redcap_download_instrument(
  record        = 5,
  file_name     = full_name,
  redcap_uri    = uri,
  token         = token
)
base::unlink(full_name)
(full_name <- base::tempfile(pattern="instrument-1-record-1-", fileext=".pdf"))
result_3   <- REDCapR::redcap_download_instrument(
  record        = 5,
  instrument    = "health",
  file_name     = full_name,
  redcap_uri    = uri,
  token         = token
)
base::unlink(full_name)

## End(Not run)

REDCapR documentation built on July 22, 2021, 9:06 a.m.