redcap export report - part-cw/lambdanative GitHub Wiki
redcap-export-report
exports a data report from REDCap.
Parameter | Description |
---|---|
host | Server hostname |
token | Authentication token (project and user specific!) |
report | The unique REDCap ID of the report, as a string |
xargs | Optional parameters; see below |
Optional parameters must come in pairs of 'symbol "string"
.
Optional Parameter | Description |
---|---|
'format "[fmt]" | Sets desired output format. "[fmt]" may be one of "csv" , "xml" , or "json" (which will return a Scheme json object). Default is "json" . |
'tables #t/#f | Specify whether to use tables if the format is "json". Default is #f. Should be set to #t if (json-set-options! tables: #t) has been used. |
Example 1: Exporting a report.
> (define redcap:token "54CC....CC10")
> (define redcap:hostname "redcap.INSTITUTIONNAME.ca")
> (define reportID "1234")
> (redcap-export-report redcap:hostname redcap:token reportID)
((("record_id" . "id_1") ("field_1" . "val_1_1") ("field_2" . "val_2_1") ... )
(("record_id" . "id_2") ("field_1" . "val_1_2") ("field_2" . "val_2_2") ... )
(("record_id" . "id_3") ("field_1" . "val_1_3") ("field_2" . "val_2_3") ... )...)
Example 2: Exporting a report in CSV format.
> (define redcap:token "54CC....CC10")
> (define redcap:hostname "redcap.INSTITUTIONNAME.ca")
> (define reportID "1234")
> (redcap-export-report redcap:hostname redcap:token reportID 'format "csv")
"record_id,field_1,field_2,...\nid_1,val_1_1,val_2_1,...\nid_2,val_1_2,val_2_2,...\nid_3,val_1_3,val_2_3,...\n"
Example 2: Exporting a report as JSON using tables
Returns a list of tables, where each table is a record containing key-value pairs of field:value
> (define redcap:token "54CC....CC10")
> (define redcap:hostname "redcap.INSTITUTIONNAME.ca")
> (define reportID "1234")
> (json-set-options! tables: #t)
> (redcap-export-report redcap:hostname redcap:token reportID 'tables #t)
(<table1> <table2> <table3> ... )