Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for exportSurveyFields API setting #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions redcapExport.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,23 @@ redcapExportMappings <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/
stringsAsFactors=FALSE, na.strings='')
}

redcapExportRecords <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/', format='csv', type='flat', rawOrLabel='raw', exportCheckboxLabel='false', forms=NULL, fields=NULL, events=NULL) {
redcapExportRecords <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/', format='csv', type='flat', rawOrLabel='raw', exportSurveyFields='false', exportCheckboxLabel='false', forms=NULL, fields=NULL, events=NULL) {
if (!require('RCurl')) {
stop('RCurl is not installed')
}
read.csv(text=postForm(uri=URI, token=APIKEY, content='record',
format=format, type=type,
# Redcap API options
rawOrLabel=rawOrLabel,
exportSurveyFields=exportSurveyFields,
exportCheckboxLabel=exportCheckboxLabel,
forms=forms, fields=fields, events=events,
# RCurl options
.opts=curlOptions(ssl.verifyhost=2)),
stringsAsFactors=FALSE, na.strings='')
}

redcapExport <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/', labels=TRUE, checkboxLabels=FALSE, forms=NULL, fields=NULL, events=NULL) {
redcapExport <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/', labels=TRUE, surveyFields=FALSE, checkboxLabels=FALSE, forms=NULL, fields=NULL, events=NULL) {
if (!require('RCurl')) {
stop('RCurl is not installed')
}
Expand Down Expand Up @@ -99,6 +100,7 @@ redcapExport <- function(APIKEY, URI='https://redcap.vanderbilt.edu/api/', label
data <- redcapExportRecords(APIKEY, URI=URI,
# Redcap API options
rawOrLabel=c('raw','label')[1 + labels], # real values or codes
exportSurveyFields=c('false','true')[1 + surveyFields], # real values or checked/unchecked
exportCheckboxLabel=c('false','true')[1 + checkboxLabels], # real values or checked/unchecked
forms=paste(forms, collapse=','),
fields=paste(fields, collapse=','),
Expand Down