importFileToRecord {redcapAPI} | R Documentation |
Import a File With Option to Create A Record to Receive the File
Description
There are times when the user may desire to create a record
and import a file as part of a single action. For example, a study
consent form may have been collected and needs to be stored with the
data of the new study participant. importFileToRecord
extends
importFiles
to allow the concurrent creation of the record in which
the file will be stored.
Usage
importFileToRecord(
rcon,
file,
record = NULL,
field,
event,
overwrite = TRUE,
repeat_instance = NULL,
...
)
Arguments
rcon |
A |
file |
|
record |
|
field |
|
event |
|
overwrite |
|
repeat_instance |
|
... |
Arguments to pass to other methods |
Details
The behavior of importFileToRecord
depends on
whether record auto numbering has been enabled in the project,
if the record is specified by the user
if the record specified by the user exists.
The following table details the actions taken based on these conditions.
(force_auto_number
is an argument to importRecords()
).
Autonumbering enabled | record | Record Exists | Action |
Yes | NULL | No | Create a new record (using force_auto_number = TRUE ) and import the file to the new record |
Yes | Specified | Yes | Import the file to the existing record |
Yes | Specified | No | Create a new record (using force_auto_number = TRUE )and import the file to the new record |
No | NULL | No | Error: record must be provided when auto numbering is not enabled |
No | Specified | Yes | Import the file to the existing record |
No | Specified | No | Create the record (using force_auto_number = FALSE ) and import the file to the new record. |
See Also
importFiles()
,
importRecords()
Examples
## Not run:
unlockREDCap(connections = c(rcon = "project_alias"),
url = "your_redcap_url",
keyring = "API_KEYs",
envir = globalenv())
importFileToRecord(rcon,
file = "file_to_upload.txt"
record = NULL,
field = "file_upload_test")
## End(Not run)