redcap export records - part-cw/lambdanative GitHub Wiki
(redcap-export-records host token . xargs)
redcap-export-records
exports records from REDCap.
Parameter | Description |
---|---|
host | Server hostname |
token | Authentication token (project and user specific!) |
xargs | Optional parameters; see below |
Optional parameters must come in pairs of 'symbol "string"
or 'symbol '("list" "of" "strings")
.
Optional Parameter | Description |
---|---|
'type "[type]" | Declares the format of the data parameter. "[type]" may be "eav" (one data point per row) or "flat" (one record per row). Default is "eav" . |
'records '("[rec1]" ...) | Gets records with the given names. |
'events '("[evt1]" ...) | Gets records of the given events for longitudinal projects. |
'forms '("[form1]" ...) | Gets records of the given forms. |
'fields '("[field1]" ...) | Gets the given fields for the record. If the study number field is included, it will also pull the event field (for longitudinal projects) and the instrument and instance fields (for projects with repeatable instruments or events). |
'filter "[filter]" | Filters the records by the given query. For instance, "[age] > 50" will filter for entries with age greater than 50, and "[name] = red" will filter for entries with the name "red". |
Examples
Example 1: Exporting records with subject_ids
"1" and "4" from a project.
> (define redcap:token "54CC....CC10")
> (define redcap:hostname "redcap.INSTITUTIONNAME.ca")
> (redcap-export-records redcap:hostname redcap:token 'records (list "4" "1"))
((("participant_id" . "1")
("study_id" . "1")
("first_name" . "John")
("last_name" . "Smith")
("number_test" . "")
("test_file" . "[document]")
("test1" . "helloWorld")
[...]
Example 2: Exporting only the study_id
, spo2_site
, spo2_median
, hr_median
, sqi_avg
, and spo2_date
fields of all records of a non-longitudinal project with no repeated events or instances, with the output formatted in CSV.
> (redcap-export-records redcap:hostname redcap:token 'format "csv" 'fields
(list "study_id" "spo2_site" "spo2_median" "hr_median" "sqi_avg" "spo2_date"))
"study_id,spo2_site,spo2_median,hr_median,sqi_avg,spo2_date\n1,1,97,85,99,2017-04-04\n2,3,99,75,87,2017-04-05\n"