Skip to content

Instantly share code, notes, and snippets.

@spgarbet
Last active May 4, 2023 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spgarbet/650b88332ca867e3f0ec087f31cc59e5 to your computer and use it in GitHub Desktop.
Save spgarbet/650b88332ca867e3f0ec087f31cc59e5 to your computer and use it in GitHub Desktop.
exportBulkRecords example interface
unlockREDCap(c(test_conn = 'TestRedcapAPI',
sandbox_conn = 'SandboxAPI'),
keyring = 'MyKeyring',
envir = globalenv(),
url = 'https://<REDCAP_URL>/api/')
# After user interaction to unlock the local encrypted keyring
# the global environment will contain the REDCap connections
# `test_conn` and `sandbox_conn`
#
# Next the user wants to bulk specify importing all the forms
# of interest and post process
exportBulkRecords(
rcon = list(test = test_conn,
sand = sandbox_conn),
forms = list(test = c('form1', 'form2'),
envir = globalenv(),
post = function(Records, rcon) {
Records |>
mChoiceCast(rcon) |>
guessDat(rcon) |>
widerRepeating(rcon)
}
)
# The environment now contains the data.frames: `test.form1`, `test.form2`, `sand`.
# Each of these were retrieved, possibly using the forms argument and all were
# post processed in the same manner as specified by `post`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment