RedCapProject
in package
REDCap project class used to retrieve data from, and modify, REDCap projects.
Table of Contents
- JSON_RESULT_ERROR_PATTERN = '/^[\\s]*{"error":[\\s]*"(.*)"}[\\s]*$/'
- __construct() : mixed
- Creates a REDCapProject object for the specifed project.
- createFileRepositoryFolder() : int
- Creates the specified folder in the file repository.
- deleteArms() : int
- Deletes the specified arms from the project.
- deleteDags() : int
- Deletes the specified dags from the project.
- deleteEvents() : int
- Deletes the specified events from the project.
- deleteFile() : mixed
- Deletes the specified file.
- deleteFileRepositoryFile() : mixed
- Deletes the specified file repository file.
- deleteRecords() : int
- Deletes the specified records from the project.
- deleteUserRoles() : int
- Deletes the specified user roles.
- deleteUsers() : int
- Deletes the specified users.
- exportArms() : mixed
- Exports the numbers and names of the arms in the project.
- exportDags() : mixed
- Exports the Data Access Groups for a project.
- exportEvents() : array<string|int, mixed>
- Exports information about the specified events.
- exportFieldNames() : mixed
- Exports the fields names for a project.
- exportFile() : string
- Exports the specified file. The contents of the file are returned by the method.
- exportFileRepositoryFile() : string
- Exports the specified file from the file repository.
- exportFileRepositoryList() : array<string|int, mixed>
- Exports a list of the files and folders contained within the specified folder.
- exportInstrumentEventMappings() : array<string|int, mixed>
- Gets the instrument to event mapping for the project.
- exportInstruments() : mixed
- Exports information about the instruments (data entry forms) for the project.
- exportLogging() : array<string|int, mixed>
- Exports the logging (audit trail) of all changes made to this project, including data exports, data changes, project metadata changes, modification of user rights, etc.
- exportMetadata() : array<string|int, mixed>
- Exports metadata about the project, i.e., information about the fields in the project.
- exportPdfFileOfInstruments() : string
- Exports a PDF version of the requested instruments (forms).
- exportProjectInfo() : array<string|int, mixed>
- Exports information about the project, e.g., project ID, project title, creation time.
- exportProjectXml() : string
- Exports the specified information of project in XML format.
- exportRecords() : mixed
- Exports the specified records.
- exportRecordsAp() : mixed
- Export records using an array parameter, where the keys of the array passed to this method are the argument names, and the values are the argument values. The argument names to use correspond to the variable names in the exportRecords method.
- exportRedcapVersion() : string
- Gets the REDCap version number of the REDCap instance being used by the project.
- exportRepeatingInstrumentsAndEvents() : mixed
- Exports the repeating instruments and events.
- exportReports() : mixed
- Exports the records produced by the specified report.
- exportSurveyLink() : string
- Exports the survey link for the specified inputs.
- exportSurveyParticipants() : mixed
- Exports the list of survey participants for the specified form and, for longitudinal studies, event.
- exportSurveyQueueLink() : string
- Exports the survey queue link for the specified record ID.
- exportSurveyReturnCode() : string
- Exports the code for returning to a survey that was not completed.
- exportUserDagAssignment() : mixed
- Exports the User-DataAccessGroup assignaments for a project.
- exportUserRoleAssignments() : mixed
- Exports the user role assignments of the project.
- exportUserRoles() : mixed
- Exports the user roles of the project.
- exportUsers() : mixed
- Exports the users of the project.
- generateNextRecordName() : string
- This method returns the next potential record ID for a project, but it does NOT actually create a new record. The record ID returned will generally be the current maximum record ID number incremented by one (but see the REDCap documentation for the case where Data Access Groups are being used).
- getApiToken() : string
- Gets the API token for the project.
- getApiUrl() : string
- Gets the REDCap API URL specified to create the object.
- getConnection() : RedCapApiConnectionInterface
- Returns the underlying REDCap API connection being used by the project.
- getErrorHandler() : ErrorHandlerInterface
- Gets the error handler.
- getPhpCapVersion() : mixed
- Gets the PHPCap version number.
- getRecordIdBatches() : array<string|int, mixed>
- Gets an array of record ID batches.
- getRecordIdFieldName() : string
- Gets the record ID field name for the project.
- importArms() : int
- Imports the specified arms into the project.
- importDags() : int
- Imports the specified dags into the project. Allows import of new DAGs or update of the data_access_group_name of any existing DAGs. DAGs can be renamed by changing the data_access_group_name. A DAG can be created by providing group name value with unique group name set to blank.
- importEvents() : int
- Imports the specified events into the project.
- importFile() : mixed
- Imports the file into the field of the record with the specified event and/or repeat instance, if any.
- importFileRepositoryFile() : mixed
- Imports the specified file from the file repository.
- importInstrumentEventMappings() : int
- Imports the specified instrument-event mappings into the project.
- importMetadata() : int
- Imports the specified metadata (field information) into the project.
- importProjectInfo() : int
- Imports the specified project information into the project.
- importRecords() : mixed
- Imports the specified records into the project.
- importRepeatingInstrumentsAndEvents() : int
- Imports the repeating instruments and events.
- importUserDagAssignment() : int
- Imports User-DAG assignments, allowing you to assign users to any data access group.o the project. If you wish to modify an existing mapping, you must provide its unique username and group name.
- importUserRoleAssignments() : int
- Imports the specified user role assignments into the project.
- importUserRoles() : int
- Imports the specified user roles into the project.
- importUsers() : int
- Imports the specified users into the project. This method can also be used to update user priveleges by importing a users that already exist in the project and specifying new privleges for that user in the user data that is imported.
- renameRecord() : mixed
- Renames the specified record with the new specified record ID.
- setConnection() : mixed
- Sets the connection used for calling the REDCap API.
- setErrorHandler() : mixed
- Sets the error handler used by the project.
- switchDag() : mixed
- Switches the DAG (Data Access Group) to the specified DAG.
Constants
JSON_RESULT_ERROR_PATTERN
public
mixed
JSON_RESULT_ERROR_PATTERN
= '/^[\\s]*{"error":[\\s]*"(.*)"}[\\s]*$/'
Methods
__construct()
Creates a REDCapProject object for the specifed project.
public
__construct(string $apiUrl, string $apiToken[, bool $sslVerify = false ][, string $caCertificateFile = null ][, ErrorHandlerInterface $errorHandler = null ][, RedCapApiConnectionInterface $connection = null ]) : mixed
Example Usage:
$apiUrl = 'https://redcap.someplace.edu/api/'; # replace with your API URL
$apiToken = '11111111112222222222333333333344'; # replace with your API token
$sslVerify = true;
# See the PHPCap documentation for information on how to set this file up
$caCertificateFile = 'USERTrustRSACertificationAuthority.crt';
$project = new RedCapProject($apiUrl, $apiToken, $sslVerify, $caCertificateFile);
Parameters
- $apiUrl : string
-
the URL for the API for the REDCap site that has the project.
- $apiToken : string
-
the API token for this project.
- $sslVerify : bool = false
-
indicates if SSL connection to REDCap web site should be verified.
- $caCertificateFile : string = null
-
the full path name of the CA (Certificate Authority) certificate file.
- $errorHandler : ErrorHandlerInterface = null
-
the error handler used by the project. This would normally only be set if you want to override the PHPCap's default error handler.
- $connection : RedCapApiConnectionInterface = null
-
the connection used by the project. This would normally only be set if you want to override the PHPCap's default connection. If this argument is specified, the $apiUrl, $sslVerify, and $caCertificateFile arguments will be ignored, and the values for these set in the connection will be used.
Tags
Return values
mixed —createFileRepositoryFolder()
Creates the specified folder in the file repository.
public
createFileRepositoryFolder(string $name[, int $parentFolderId = null ][, int $dagId = null ][, int $roleId = null ]) : int
Parameters
- $name : string
-
the name of the folder to be created.
- $parentFolderId : int = null
-
the id of the folder where the new folder should be created. If this is unset, then the folder will be created in the top-level folder.
- $dagId : int = null
-
the DAG (Data Access Group) ID that should be used to restrict access to this folder.
- $roleId : int = null
-
the role ID that should be used to restrict access to this folder.
Return values
int —the folder ID of the folder that was created.
deleteArms()
Deletes the specified arms from the project.
public
deleteArms(array<string|int, mixed> $arms) : int
Parameters
- $arms : array<string|int, mixed>
-
array of arm numbers to delete.
Tags
Return values
int —the number of arms deleted.
deleteDags()
Deletes the specified dags from the project.
public
deleteDags(array<string|int, mixed> $dags) : int
Parameters
- $dags : array<string|int, mixed>
-
an array of the unique_group_names to delete.
Tags
Return values
int —the number of DAGs imported.
deleteEvents()
Deletes the specified events from the project.
public
deleteEvents(array<string|int, mixed> $events) : int
Parameters
- $events : array<string|int, mixed>
-
array of event names of events to delete.
Tags
Return values
int —the number of events deleted.
deleteFile()
Deletes the specified file.
public
deleteFile(string $recordId, string $field[, string $event = null ][, int $repeatInstance = null ]) : mixed
Parameters
- $recordId : string
-
the record ID of the file to delete.
- $field : string
-
the field name of the file to delete.
- $event : string = null
-
the event of the file to delete (only for longitudinal studies).
- $repeatInstance : int = null
-
repeat instance of the file to delete (only for studies that have repeating events and/or instruments).
Return values
mixed —deleteFileRepositoryFile()
Deletes the specified file repository file.
public
deleteFileRepositoryFile(int $docId) : mixed
Parameters
- $docId : int
-
the doc ID for the file to delete from the file repository.
Return values
mixed —deleteRecords()
Deletes the specified records from the project.
public
deleteRecords(array<string|int, mixed> $recordIds[, string $arm = null ][, string $form = null ][, string $event = null ][, int $repeatInstance = null ][, int $deleteLogging = null ]) : int
Parameters
- $recordIds : array<string|int, mixed>
-
array of record IDs to delete
- $arm : string = null
-
if an arm is specified, only records that have one of the specified record IDs that are in that arm will be deleted.
- $form : string = null
-
form for which fields should be deleted (only these field will be deleted).
- $event : string = null
-
event for which fields should be deleted (must be spefied for longitudinal studies if an event is spcified).
- $repeatInstance : int = null
-
for repeating events and forms, the instance for which fields should be deleted.
- $deleteLogging : int = null
-
flag that indicates if the logging associated with the records being deleted should also be deleted. This is only applicable for projects where the setting to delete logging for deleted records has been enabled by an admin. For these projects, set $deleteLogging to 1 (or leave it unset) to delete the logging for the deleted records, and set $deleteLogging to 0 to keep the logging for the deleted records.
Tags
Return values
int —the number of records deleted.
deleteUserRoles()
Deletes the specified user roles.
public
deleteUserRoles(array<string|int, mixed> $userRoles) : int
Parameters
- $userRoles : array<string|int, mixed>
-
array of unique roles names of roles to delete.
Return values
int —the number of user roles deleted.
deleteUsers()
Deletes the specified users.
public
deleteUsers(array<string|int, mixed> $users) : int
Parameters
- $users : array<string|int, mixed>
-
array of usernames for users to delete.
Return values
int —the number of users deleted.
exportArms()
Exports the numbers and names of the arms in the project.
public
exportArms([ $format = 'php' ][, array<string|int, mixed> $arms = [] ]) : mixed
Parameters
- $format : = 'php'
-
string the format used to export the arm data.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $arms : array<string|int, mixed> = []
-
array of integers or numeric strings that are the numbers of the arms to export. If no arms are specified, then information for all arms will be returned.
Return values
mixed —For 'php' format, array of arrays that have the following keys:
- 'arm_num'
- 'name'
exportDags()
Exports the Data Access Groups for a project.
public
exportDags([ $format = 'php' ]) : mixed
Parameters
- $format : = 'php'
-
string the format used to export the data.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
mixed —For 'php' format, array of arrays that have the following keys:
- 'data_access_group_name'
- 'unique_group_name'
exportEvents()
Exports information about the specified events.
public
exportEvents([string $format = 'php' ][, array<string|int, mixed> $arms = [] ]) : array<string|int, mixed>
Example usage:
#export information about all events in CSV (Comma-Separated Values) format.
$eventInfo = $project->exportEvents('csv');
# export events in XML format for arms 1 and 2.
$eventInfo = $project->exportEvents('xml', [1, 2]);
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $arms : array<string|int, mixed> = []
-
array of integers or numeric strings that are the arm numbers for which events should be exported. If no arms are specified, then all events will be returned.
Return values
array<string|int, mixed> —information about the specified events. Each element of the array is an associative array with the following keys: 'event_name', 'arm_num', 'day_offset', 'offset_min', 'offset_max', 'unique_event_name', 'custom_event_label'
exportFieldNames()
Exports the fields names for a project.
public
exportFieldNames([string $format = 'php' ][, string $field = null ]) : mixed
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $field : string = null
-
the name of the field for which to export field name information. If no field is specified, information for all fields is exported.
Return values
mixed —information on the field specified, or all fields if no field was specified. If 'php' or no format was specified, results will be returned as a PHP array of maps (associative arrays), where the keys for the maps:
- original_field_name
- choice_value
- export_field_name
exportFile()
Exports the specified file. The contents of the file are returned by the method.
public
exportFile(string $recordId, string $field[, string $event = null ][, int $repeatInstance = null ][, array<string|int, mixed> &$fileInfo = null ]) : string
If the $fileInfo argument is used and set to an array before the call to this method, the method will set it to contain information about the exported file. Note that if a file does not have an event and/or repeat instance, do not include these arguments or set them to null if you need to specify an argument that comes after them.
Example usage:
...
$recordId = '1001';
$field = 'patient_document';
$event = 'enrollment_arm_1';
$repeatInstance = 1;
$fileInfo = array();
$fileContents = $project->exportFile($recordId, $field, $event, $repeatInstance, $fileInfo);
print("File name: {$fileInfo['name']}, file MIME type: {$fileInfo['mime_type']}\n");
...
Parameters
- $recordId : string
-
the record ID for the file to be exported.
- $field : string
-
the name of the field containing the file to export.
- $event : string = null
-
name of event for file export (for longitudinal studies).
- $repeatInstance : int = null
-
the instance (if repeating) of the record
- $fileInfo : array<string|int, mixed> = null
-
output array for getting file information. $fileInfo must be set to an array before calling this method, and on successful return it will include elements with the following keys: 'name', 'mime_type', and 'charset' (if the file is a text file).
Tags
Return values
string —the contents of the file that was exported.
exportFileRepositoryFile()
Exports the specified file from the file repository.
public
exportFileRepositoryFile(int $docId[, array<string|int, mixed> &$fileInfo = null ]) : string
Parameters
- $docId : int
-
the doc ID of the file to export.
- $fileInfo : array<string|int, mixed> = null
-
output array for getting file information. $fileInfo must be set to an array before calling this method, and on successful return it will include elements with the following keys: 'name', 'mime_type', and 'charset' (if the file is a text file).
Return values
string —the contents of the file that was exported.
exportFileRepositoryList()
Exports a list of the files and folders contained within the specified folder.
public
exportFileRepositoryList([string $format = 'php' ][, int $folderId = null ]) : array<string|int, mixed>
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $folderId : int = null
-
the folder ID of the folder to list. If no folder ID is specified, then a list of the top-level folder is returned.
Return values
array<string|int, mixed> —an array of maps that include 'name' and 'doc_id' (for files) or 'folder_id' (for folders).
exportInstrumentEventMappings()
Gets the instrument to event mapping for the project.
public
exportInstrumentEventMappings([string $format = 'php' ][, array<string|int, mixed> $arms = [] ]) : array<string|int, mixed>
For example, the following code:
$map = $project->exportInstrumentEventMappings();
print_r($map[0]); # print first element of map
might generate the following output:
Array ( [arm_num] => 1 [unique_event_name] => enrollment_arm_1 [form] => demographics )
Parameters
- $format : string = 'php'
-
the format in which to export the records:
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $arms : array<string|int, mixed> = []
-
array of integers or numeric strings that are the numbers of the arms for which instrument/event mapping infomation should be exported. If no arms are specified, then information for all arms will be exported.
Return values
array<string|int, mixed> —an array of arrays that have the following keys:
- 'arm_num'
- 'unique_event_name'
- 'form'
exportInstruments()
Exports information about the instruments (data entry forms) for the project.
public
exportInstruments([ $format = 'php' ]) : mixed
Example usage:
$instruments = $project->getInstruments();
foreach ($instruments as $instrumentName => $instrumentLabel) {
print "{$instrumentName} : {$instrumentLabel}\n";
}
Parameters
- $format : = 'php'
-
string format instruments are exported in:
- 'php' - [default] returns data as a PHP array
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded data
- 'xml' - string of XML encoded data
Return values
mixed —For the 'php' format, and array map of instrument names to instrument labels is returned. For all other formats a string is returned.
exportLogging()
Exports the logging (audit trail) of all changes made to this project, including data exports, data changes, project metadata changes, modification of user rights, etc.
public
exportLogging([string $format = 'php' ][, string $logType = null ][, string $username = null ][, string $recordId = null ][, string $dag = null ][, string $beginTime = null ][, string $endTime = null ]) : array<string|int, mixed>
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $logType : string = null
-
type of logging to return. Defaults to NULL to return all types.
- $username : string = null
-
returns only the events belong to specific username. If not specified, it will assume all users.
- $recordId : string = null
-
the record ID for the file to be exported.
- $dag : string = null
-
returns only the events belong to specific DAG (referring to group_id), provide a dag. If not specified, it will assume all dags.
- $beginTime : string = null
-
specifies to return only those records after a given date/time, provide a timestamp in the format YYYY-MM-DD HH:MM (e.g., '2017-01-01 17:00' for January 1, 2017 at 5:00 PM server time). If not specified, it will assume no begin time.
- $endTime : string = null
-
returns only records that have been logged before a given date/time, provide a timestamp in the format YYYY-MM-DD HH:MM (e.g., '2017-01-01 17:00' for January 1, 2017 at 5:00 PM server time). If not specified, it will use the current server time.
Tags
Return values
array<string|int, mixed> —information, filtered by event (logtype), listing all changes made to thise project. Each element of the array is an associative array with the following keys: 'timestamp', 'username', 'action', 'details'
exportMetadata()
Exports metadata about the project, i.e., information about the fields in the project.
public
exportMetadata([string $format = 'php' ][, array<string|int, mixed> $fields = [] ][, array<string|int, mixed> $forms = [] ]) : array<string|int, mixed>
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $fields : array<string|int, mixed> = []
-
array of field names for which metadata should be exported
- $forms : array<string|int, mixed> = []
-
array of form names. Metadata will be exported for all fields in the specified forms.
Return values
array<string|int, mixed> —associative array (map) of metatdata for the project, which consists of information about each field. Some examples of the information provided are: 'field_name', 'form_name', 'field_type', 'field_label'. See REDCap API documentation for more information, or use the print_r function on the results of this method.
exportPdfFileOfInstruments()
Exports a PDF version of the requested instruments (forms).
public
exportPdfFileOfInstruments([string $file = null ][, string $recordId = null ][, string $event = null ][, string $form = null ][, bool $allRecords = null ][, mixed $compactDisplay = null ][, mixed $repeatInstance = null ]) : string
Parameters
- $file : string = null
-
the name of the file (possibly with a path specified also) to store the PDF instruments in.
- $recordId : string = null
-
if record ID is specified, the forms retrieved will be filled with values for that record. Otherwise, they will be blank.
- $event : string = null
-
(only for longitudinal projects) a unique event name that is used when a record ID has been specified to return only forms that are in that event (for the specified records).
- $form : string = null
-
if this is specified, only this form will be returned.
- $allRecords : bool = null
-
if this is set to true, all forms for all records will be retrieved (the $recordId, $event, and $form arguments will be ignored).
- $compactDisplay : mixed = null
- $repeatInstance : mixed = null
Tags
Return values
string —PDF content of requested instruments (forms).
exportProjectInfo()
Exports information about the project, e.g., project ID, project title, creation time.
public
exportProjectInfo([string $format = 'php' ]) : array<string|int, mixed>
Parameters
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
array<string|int, mixed> —associative array (map) of project information. See REDCap API documentation for a list of the fields, or use the print_r function on the results of this method.
exportProjectXml()
Exports the specified information of project in XML format.
public
exportProjectXml([bool $returnMetadataOnly = false ][, array<string|int, mixed> $recordIds = null ][, array<string|int, mixed> $fields = null ][, array<string|int, mixed> $events = null ][, string $filterLogic = null ][, bool $exportSurveyFields = false ][, bool $exportDataAccessGroups = false ][, bool $exportFiles = false ]) : string
Parameters
- $returnMetadataOnly : bool = false
-
if this is set to true, only the metadata for the project is returned. If it is not set to true, the metadata and data for the project is returned.
- $recordIds : array<string|int, mixed> = null
-
array of strings with record id's that are to be retrieved.
- $fields : array<string|int, mixed> = null
-
array of field names to export
- $events : array<string|int, mixed> = null
-
array of event names for which fields should be exported
- $filterLogic : string = null
-
logic used to restrict the records retrieved, e.g., "[last_name] = 'Smith'".
- $exportSurveyFields : bool = false
-
specifies whether survey fields should be exported.
- true - export the following survey fields:
- survey identifier field ('redcap_survey_identifier')
- survey timestamp fields (instrument+'_timestamp')
- false - [default] survey fields are not exported.
- true - export the following survey fields:
- $exportDataAccessGroups : bool = false
-
specifies whether the data access group field ('redcap_data_access_group') should be exported.
- true - export the data access group field if there is at least one data access group, and the user calling the method (as identified by the API token) is not in a data access group.
- false - [default] don't export the data access group field.
- $exportFiles : bool = false
-
If this is set to true, files will be exported in the XML. If it is not set to true, files will not be exported.
Return values
string —the specified information for the project in XML format.
exportRecords()
Exports the specified records.
public
exportRecords([string $format = 'php' ][, string $type = 'flat' ][, array<string|int, mixed> $recordIds = null ][, array<string|int, mixed> $fields = null ][, array<string|int, mixed> $forms = null ][, array<string|int, mixed> $events = null ][, string $filterLogic = null ][, string $rawOrLabel = 'raw' ][, string $rawOrLabelHeaders = 'raw' ][, bool $exportCheckboxLabel = false ][, bool $exportSurveyFields = false ][, bool $exportDataAccessGroups = false ][, string $dateRangeBegin = null ][, string $dateRangeEnd = null ][, string $csvDelimiter = ',' ][, string $decimalCharacter = null ][, bool $exportBlankForGrayFormStatus = false ]) : mixed
Example usage:
$records = $project->exportRecords($format = 'csv', $type = 'flat');
$recordIds = [1001, 1002, 1003];
$records = $project->exportRecords('xml', 'eav', $recordIds);
Note: date ranges do not work for records that were imported at the time the project was created.
Parameters
- $format : string = 'php'
-
the format in which to export the records:
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- 'odm' - string with CDISC ODM XML format, specifically ODM version 1.3.1
- $type : string = 'flat'
-
the type of records exported:
- 'flat' - [default] exports one record per row.
- 'eav' - exports one data point per row:, so, for non-longitudinal studies, each record will have the following fields: record_id, field_name, value. For longitudinal studies, each record will have the fields: record_id, field_name, value, redcap_event_name.
- $recordIds : array<string|int, mixed> = null
-
array of strings with record id's that are to be retrieved.
- $fields : array<string|int, mixed> = null
-
array of field names to export
- $forms : array<string|int, mixed> = null
-
array of form names for which fields should be exported
- $events : array<string|int, mixed> = null
-
array of event names for which fields should be exported
- $filterLogic : string = null
-
logic used to restrict the records retrieved, e.g., "[last_name] = 'Smith'".
- $rawOrLabel : string = 'raw'
-
indicates what should be exported for options of multiple choice fields:
- 'raw' - [default] export the raw coded values
- 'label' - export the labels
- $rawOrLabelHeaders : string = 'raw'
-
when exporting with 'csv' format 'flat' type, indicates what format should be used for the CSV headers:
- 'raw' - [default] export the variable/field names
- 'label' - export the field labels
- $exportCheckboxLabel : bool = false
-
specifies the format for checkbox fields for the case where $format = 'csv', $rawOrLabel = true, and $type = 'flat'. For other cases this parameter is effectively ignored.
- true - checked checkboxes will have a value equal to the checkbox option's label (e.g., 'Choice 1'), and unchecked checkboxes will have a blank value.
- false - [default] checked checkboxes will have a value of 'Checked', and unchecked checkboxes will have a value of 'Unchecked'.
- $exportSurveyFields : bool = false
-
specifies whether survey fields should be exported.
- true - export the following survey fields:
- survey identifier field ('redcap_survey_identifier')
- survey timestamp fields (instrument+'_timestamp')
- false - [default] survey fields are not exported.
- true - export the following survey fields:
- $exportDataAccessGroups : bool = false
-
specifies whether the data access group field ('redcap_data_access_group') should be exported.
- true - export the data access group field if there is at least one data access group, and the user calling the method (as identified by the API token) is not in a data access group.
- false - [default] don't export the data access group field.
- $dateRangeBegin : string = null
-
specifies to return only those records have been created or modified after the date entered. Date needs to be in YYYY_MM-DD HH:MM:SS, e.g., '2020-01-31 00:00:00'.
- $dateRangeEnd : string = null
-
specifies to return only those records have been created or modified before the date entered. Date needs to be in YYYY_MM-DD HH:MM:SS, e.g., '2020-01-31 00:00:00'.
- $csvDelimiter : string = ','
-
specifies what delimiter is used to separate values in a CSV file (for CSV format only). Options are:
- ',' - comma, this is the default
- 'tab' - tab
- ';' - semi-colon
- '|' - pipe
- '^' - caret
- $decimalCharacter : string = null
-
specifies what decimal format to apply to numeric values being returned. Options are:
- '.' - dot/full stop
- ',' - comma
- null - numbers will be exported using the fields' native decimal format
- $exportBlankForGrayFormStatus : bool = false
-
indicates if the complete field for a form that has not been started should be returned as a blank (instead of a zero).
Return values
mixed —If 'php' format is specified, an array of records will be returned where the format of the records depends on the 'type'parameter (see above). For other formats, a string is returned that contains the records in the specified format.
exportRecordsAp()
Export records using an array parameter, where the keys of the array passed to this method are the argument names, and the values are the argument values. The argument names to use correspond to the variable names in the exportRecords method.
public
exportRecordsAp([array<string|int, mixed> $arrayParameter = [] ]) : mixed
Example usage:
# return all records with last name "Smith" in CSV format
$records = $project->exportRecordsAp(['format' => 'csv', 'filterLogic' => "[last_name] = 'Smith'"]);
# export only records that have record ID 1001, 1002, or 1003
$result = $project->exportRecordsAp(['recordIds' => [1001, 1002, 1003]]);
# export only the fields on the 'lab_data' form and field 'study_id'
$records = $project->exportRecordsAp(['forms' => ['lab_data'], 'fields' => ['study_id']]);
Parameters
- $arrayParameter : array<string|int, mixed> = []
-
parameter array.
Tags
Return values
mixed —the specified records.
exportRedcapVersion()
Gets the REDCap version number of the REDCap instance being used by the project.
public
exportRedcapVersion() : string
Return values
string —the REDCap version number of the REDCap instance being used by the project.
exportRepeatingInstrumentsAndEvents()
Exports the repeating instruments and events.
public
exportRepeatingInstrumentsAndEvents([string $format = 'php' ]) : mixed
Parameters
- $format : string = 'php'
-
the format in which to export the records:
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- 'odm' - string with CDISC ODM XML format, specifically ODM version 1.3.1
Return values
mixed —an array will be returned for the 'php' format, and a string for all other formats. For classic (non-longitudinal) studies, the 'form name' and 'custom form label' will be returned for each repeating form. Longitudinal studies additionally return the 'event name'. For repeating events in longitudinal studies, a blank value will be returned for the form_name. In all cases, a blank value will be returned for the 'custom form label' if it is not defined.
exportReports()
Exports the records produced by the specified report.
public
exportReports(mixed $reportId[, string $format = 'php' ][, string $rawOrLabel = 'raw' ][, string $rawOrLabelHeaders = 'raw' ][, bool $exportCheckboxLabel = false ][, string $csvDelimiter = ',' ][, string $decimalCharacter = null ]) : mixed
Parameters
- $reportId : mixed
-
integer or numeric string ID of the report to use.
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $rawOrLabel : string = 'raw'
-
indicates what should be exported for options of multiple choice fields:
- 'raw' - [default] export the raw coded values
- 'label' - export the labels
- $rawOrLabelHeaders : string = 'raw'
-
when exporting with 'csv' format 'flat' type, indicates what format should be used for the CSV headers:
- 'raw' - [default] export the variable/field names
- 'label' - export the field labels
- $exportCheckboxLabel : bool = false
-
specifies the format for checkbox fields for the case where $format = 'csv', $rawOrLabel = true, and $type = 'flat'. For other cases this parameter is effectively ignored.
- true - checked checkboxes will have a value equal to the checkbox option's label (e.g., 'Choice 1'), and unchecked checkboxes will have a blank value.
- false - [default] checked checkboxes will have a value of 'Checked', and unchecked checkboxes will have a value of 'Unchecked'.
- $csvDelimiter : string = ','
-
specifies what delimiter is used to separate values in a CSV file (for CSV format only). Options are:
- ',' - comma, this is the default
- 'tab' - tab
- ';' - semi-colon
- '|' - pipe
- '^' - caret
- $decimalCharacter : string = null
-
specifies what decimal format to apply to numeric values being returned. Options are:
- '.' - dot/full stop
- ',' - comma
- null - numbers will be exported using the fields' native decimal format
Return values
mixed —the records generated by the specefied report in the specified format.
exportSurveyLink()
Exports the survey link for the specified inputs.
public
exportSurveyLink(string $recordId, string $form[, string $event = null ][, int $repeatInstance = null ]) : string
Parameters
- $recordId : string
-
the record ID for the link.
- $form : string
-
the form for the link.
- $event : string = null
-
event for link (for longitudinal studies only).
- $repeatInstance : int = null
-
for repeatable forms, the instance of the form to return a link for.
Return values
string —survey link.
exportSurveyParticipants()
Exports the list of survey participants for the specified form and, for longitudinal studies, event.
public
exportSurveyParticipants(string $form[, string $format = 'php' ][, string $event = null ]) : mixed
Parameters
- $form : string
-
the form for which the participants should be exported.
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $event : string = null
-
the event name for which survey participants should be exported.
Return values
mixed —for the 'php' format, an array of arrays of participant information is returned, for all other formats, the data is returned in the specified format as a string.
exportSurveyQueueLink()
Exports the survey queue link for the specified record ID.
public
exportSurveyQueueLink(string $recordId) : string
Parameters
- $recordId : string
-
the record ID of the survey queue link that should be returned.
Return values
string —survey queue link.
exportSurveyReturnCode()
Exports the code for returning to a survey that was not completed.
public
exportSurveyReturnCode(string $recordId, string $form[, string $event = null ][, int $repeatInstance = null ]) : string
Parameters
- $recordId : string
-
the record ID for the survey to return to.
- $form : string
-
the form name of the survey to return to.
- $event : string = null
-
the unique event name (for longitudinal studies) for the survey to return to.
- $repeatInstance : int = null
-
the repeat instance (if any) for the survey to return to.
Return values
string —survey return code.
exportUserDagAssignment()
Exports the User-DataAccessGroup assignaments for a project.
public
exportUserDagAssignment( $format) : mixed
Parameters
- $format :
-
string the format used to export the data.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
mixed —For 'php' format, array of arrays that have the following keys:
- 'username'
- 'redcap_data_access_group'
exportUserRoleAssignments()
Exports the user role assignments of the project.
public
exportUserRoleAssignments([string $format = 'php' ]) : mixed
Parameters
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
mixed —a list of user roles assignments. For the 'php' format an array of associative arrays is returned, where the keys are the field names and the values are the field values. For all other formats, a string is returned with the data in the specified format.
exportUserRoles()
Exports the user roles of the project.
public
exportUserRoles([string $format = 'php' ]) : mixed
Parameters
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
mixed —a list of user roles. For the 'php' format an array of associative arrays is returned, where the keys are the field names and the values are the field values. For all other formats, a string is returned with the data in the specified format.
exportUsers()
Exports the users of the project.
public
exportUsers([string $format = 'php' ]) : mixed
Parameters
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
mixed —a list of users. For the 'php' format an array of associative arrays is returned, where the keys are the field names and the values are the field values. For all other formats, a string is returned with the data in the specified format.
generateNextRecordName()
This method returns the next potential record ID for a project, but it does NOT actually create a new record. The record ID returned will generally be the current maximum record ID number incremented by one (but see the REDCap documentation for the case where Data Access Groups are being used).
public
generateNextRecordName() : string
This method is intended for use with projects that have record-autonumbering enabled.
Return values
string —the next record name.
getApiToken()
Gets the API token for the project.
public
getApiToken() : string
Return values
string —the API token for the project.
getApiUrl()
Gets the REDCap API URL specified to create the object.
public
getApiUrl() : string
Return values
string —the REDCap API URL for the project.
getConnection()
Returns the underlying REDCap API connection being used by the project.
public
getConnection() : RedCapApiConnectionInterface
This can be used to make calls to the REDCap API, possibly to access functionality not supported by PHPCap.
Return values
RedCapApiConnectionInterface —the underlying REDCap API connection being used by the project.
getErrorHandler()
Gets the error handler.
public
getErrorHandler() : ErrorHandlerInterface
Return values
ErrorHandlerInterface —the error handler being used.
getPhpCapVersion()
Gets the PHPCap version number.
public
getPhpCapVersion() : mixed
Return values
mixed —getRecordIdBatches()
Gets an array of record ID batches.
public
getRecordIdBatches([int $batchSize = null ][, string $filterLogic = null ][, $recordIdFieldName = null ]) : array<string|int, mixed>
These can be used for batch processing of records exports to lessen memory requirements, for example:
...
# Get all the record IDs of the project in 10 batches
$recordIdBatches = $project->getRecordIdBatches(10);
foreach ($recordIdBatches as $recordIdBatch) {
$records = $project->exportRecordsAp(['recordIds' => $recordIdBatch]);
...
}
...
Parameters
- $batchSize : int = null
-
the batch size in number of record IDs. The last batch may have less record IDs. For example, if you had 500 record IDs and specified a batch size of 200, the first 2 batches would have 200 record IDs, and the last batch would have 100.
- $filterLogic : string = null
-
logic used to restrict the records retrieved, e.g., "[last_name] = 'Smith'". This could be used for batch processing a subset of the records.
- $recordIdFieldName : = null
-
the name of the record ID field. Specifying this is not necessary, but will speed things up, because it will eliminate the need for this method to call the REDCap API to retrieve the value.
Return values
array<string|int, mixed> —an array or record ID arrays, where each record ID array is considered to be a batch. Each batch can be used as the value for the records IDs parameter for an export records method.
getRecordIdFieldName()
Gets the record ID field name for the project.
public
getRecordIdFieldName() : string
Return values
string —the field name of the record ID field of the project.
importArms()
Imports the specified arms into the project.
public
importArms(mixed $arms[, string $format = 'php' ][, bool $override = false ]) : int
Parameters
- $arms : mixed
-
the arms to import. This will be a PHP array of associative arrays if no format, or 'php' format was specified, and a string otherwise. The field names (keys) used in both cases are: arm_num, name
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $override : bool = false
-
- false - [default] don't delete existing arms; only add new arms or renames existing arms.
- true - delete all existing arms before importing.
Tags
Return values
int —the number of arms imported.
importDags()
Imports the specified dags into the project. Allows import of new DAGs or update of the data_access_group_name of any existing DAGs. DAGs can be renamed by changing the data_access_group_name. A DAG can be created by providing group name value with unique group name set to blank.
public
importDags(mixed $dags[, string $format = 'php' ]) : int
Parameters
- $dags : mixed
-
the DAGs to import. This will be a PHP array of associative arrays if no format, or 'php' format was specified, and a string otherwise. The field names (keys) used in both cases are: data_access_group_name, unique_group_name
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Tags
Return values
int —the number of DAGs imported.
importEvents()
Imports the specified events into the project.
public
importEvents(mixed $events[, string $format = 'php' ][, bool $override = false ]) : int
Parameters
- $events : mixed
-
the events to import. This will be a PHP array of associative arrays if no format, or 'php' format is specified, and a string otherwise. The field names (keys) used in both cases are: event_name, arm_num
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- $override : bool = false
-
- false - [default] don't delete existing arms; only add new arms or renames existing arms.
- true - delete all existing arms before importing.
Tags
Return values
int —the number of events imported.
importFile()
Imports the file into the field of the record with the specified event and/or repeat instance, if any.
public
importFile(string $filename, string $recordId, string $field[, string $event = null ][, int $repeatInstance = null ]) : mixed
Example usage:
...
$file = '../data/consent1001.txt';
$recordId = '1001';
$field = 'patient_document';
$event = 'enrollment_arm_1';
$project->importFile($file, $recordId, $field, $event);
...
Parameters
- $filename : string
-
the name of the file to import.
- $recordId : string
-
the record ID of the record to import the file into.
- $field : string
-
the field of the record to import the file into.
- $event : string = null
-
the event of the record to import the file into (only for longitudinal studies).
- $repeatInstance : int = null
-
the repeat instance of the record to import the file into (only for studies that have repeating events and/or instruments).
Tags
Return values
mixed —importFileRepositoryFile()
Imports the specified file from the file repository.
public
importFileRepositoryFile(string $filename[, int $folderId = null ]) : mixed
Parameters
- $filename : string
-
the name of the file to import.
- $folderId : int = null
-
the ID of the folder in the file repositoryt from which the file should be imported. If no folder ID is specified, then the top-level folder of the file repository is used.
Return values
mixed —importInstrumentEventMappings()
Imports the specified instrument-event mappings into the project.
public
importInstrumentEventMappings(mixed $mappings[, string $format = 'php' ]) : int
Parameters
- $mappings : mixed
-
the mappings to import. This will be a PHP array of associative arrays if no format, or 'php' format, was specified, and a string otherwise. In all cases, the field names that are used in the mappings are: arm_num, unique_event_name, form
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Tags
Return values
int —the number of mappings imported.
importMetadata()
Imports the specified metadata (field information) into the project.
public
importMetadata(mixed $metadata[, string $format = 'php' ]) : int
Parameters
- $metadata : mixed
-
the metadata to import. This will be a PHP associative array if no format, or 'php' format was specified, and a string otherwise.
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Tags
Return values
int —the number of fields imported.
importProjectInfo()
Imports the specified project information into the project.
public
importProjectInfo(mixed $projectInfo[, string $format = 'php' ]) : int
The valid fields that can be imported are:
project_title, project_language, purpose, purpose_other, project_notes, custom_record_label, secondary_unique_field, is_longitudinal, surveys_enabled, scheduling_enabled, record_autonumbering_enabled, randomization_enabled, project_irb_number, project_grant_number, project_pi_firstname, project_pi_lastname, display_today_now_button bypass_branching_erase_field_prompt
You do not need to specify all of these fields when doing an import, only the ones that you actually want to change. For example:
...
# Set the project to be longitudinal and enable surveys
$projectInfo = ['is_longitudinal' => 1, 'surveys_enabled' => 1];
$project->importProjectInfo($projectInfo);
...
Parameters
- $projectInfo : mixed
-
the project information to import. This will be a PHP associative array if no format, or 'php' format was specified, and a string otherwise.
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Tags
Return values
int —the number of project info values specified that were valid, whether or not each valid value actually caused an update (i.e., was different from the existing value before the method call).
importRecords()
Imports the specified records into the project.
public
importRecords(mixed $records[, string $format = 'php' ][, string $type = 'flat' ][, string $overwriteBehavior = 'normal' ][, string $dateFormat = 'YMD' ][, string $returnContent = 'count' ][, bool $forceAutoNumber = false ][, string $csvDelimiter = ',' ][, bool $backgroundProcess = false ]) : mixed
Parameters
- $records : mixed
-
If the 'php' (default) format is being used, an array of associated arrays (maps) where each key is a field name, and its value is the value to store in that field. If any other format is being used, then the records are represented by a string.
- $format : string = 'php'
-
One of the following formats can be specified
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
- 'odm' - CDISC ODM XML format, specifically ODM version 1.3.1
- $type : string = 'flat'
-
- 'flat' - [default] each data element is a record
- 'eav' - each data element is one value
- $overwriteBehavior : string = 'normal'
-
- normal - [default] blank/empty values will be ignored
- overwrite - blank/empty values are valid and will overwrite data
- $dateFormat : string = 'YMD'
-
date format which can be one of the following:
- 'YMD' - [default] Y-M-D format (e.g., 2016-12-31)
- 'MDY' - M/D/Y format (e.g., 12/31/2016)
- 'DMY' - D/M/Y format (e.g., 31/12/2016)
- $returnContent : string = 'count'
-
specifies what should be returned:
- 'count' - [default] the number of records imported
- 'ids' - an array of the record IDs imported is returned
- 'auto_ids' - an array of comma-separated record ID pairs, with the new ID created and the corresponding ID that was sent, for the records that were imported. This can only be used if $forceAutoNumber is set to true.
- $forceAutoNumber : bool = false
-
enables automatic assignment of record IDs of imported records by REDCap. If this is set to true, and auto-numbering for records is enabled for the project, auto-numbering of imported records will be enabled.
- $csvDelimiter : string = ','
-
specifies which delimiter separates the values in the CSV data file (for CSV format only).
- ',' - comman [default]
- 'tab'
- ';' - semi-colon
- '|' - pipe
- '^' - caret
- $backgroundProcess : bool = false
-
if true, indicates that the records import should be done in the background.
Return values
mixed —if 'count' was specified for 'returnContent', then an integer will be returned that is the number of records imported. If 'ids' was specified, then an array of record IDs that were imported will be returned. If 'auto_ids' was specified, an array that maps newly created IDs to sent IDs will be returned.
importRepeatingInstrumentsAndEvents()
Imports the repeating instruments and events.
public
importRepeatingInstrumentsAndEvents(mixed $formsEvents[, string $format = 'php' ]) : int
Parameters
- $formsEvents : mixed
-
for 'php' format or if no format is specified, this will be a PHP array of associative arrays. For other formats, this will be a string formatted in the specified format (e.g. json).
- $format : string = 'php'
-
the format in which to export the records:
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
int —the number of repeated instruments or repeated events imported.
importUserDagAssignment()
Imports User-DAG assignments, allowing you to assign users to any data access group.o the project. If you wish to modify an existing mapping, you must provide its unique username and group name.
public
importUserDagAssignment(mixed $dagAssignments[, string $format = 'php' ]) : int
If the 'redcap_data_access_group' column is not provided, user will not be assigned to any group. There should be only one record per username.
Parameters
- $dagAssignments : mixed
-
the User-DAG assignments to import. This will be a PHP array of associative arrays if no format, or 'php' format was specified, and a string otherwise. The field names (keys) used in both cases are: username, recap_data_access_group
- $format : string = 'php'
-
the format for the export.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Tags
Return values
int —the number of DAGs imported.
importUserRoleAssignments()
Imports the specified user role assignments into the project.
public
importUserRoleAssignments(mixed $userRoleAssignments[, string $format = 'php' ]) : int
This method can also be used to update user role assignments by importing a user role that already exist in the project and specifying new values in the data that is imported.
The data is a map from username to unqiue_role_name.
See the REDCap API documentation for more information, or print the results of PHPCap's exportUsers method to see what the data looks like for the current users.
Parameters
- $userRoleAssignments : mixed
-
for 'php' format, an array should be used that maps usernames to unique role names. For all other formats a string should be used that has the data in the correct format.
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
int —the number of user roles added or updated.
importUserRoles()
Imports the specified user roles into the project.
public
importUserRoles(mixed $userRoles[, string $format = 'php' ]) : int
This method can also be used to update user roles by importing a user role that already exist in the project and specifying new values in the data that is imported.
The available field names for user import are:
unique_role_name, role_label, design, user_rights, data_access_groups,
reports, stats_and_charts, manage_survey_participants, calendar,
data_import_tool, data_comparison_tool, logging, file_repository,
data_quality_create, data_quality_execute,
api_export, api_import, mobile_app, mobile_app_download_data,
record_create, record_rename, record_delete,
lock_records_customization, lock_records, lock_records_all_forms,
forms, forms_export
See the REDCap API documentation for more information, or print the results of PHPCap's exportUsers method to see what the data looks like for the current users.
Parameters
- $userRoles : mixed
-
for 'php' format, an array should be used that maps field names to field values. For all other formats a string should be used that has the data in the correct format.
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
int —the number of user roles added or updated.
importUsers()
Imports the specified users into the project. This method can also be used to update user priveleges by importing a users that already exist in the project and specifying new privleges for that user in the user data that is imported.
public
importUsers(mixed $users[, string $format = 'php' ]) : int
The available field names for user import are:
username, expiration, data_access_group, design,
user_rights, data_access_groups, data_export, reports, stats_and_charts,
manage_survey_participants, calendar, data_import_tool, data_comparison_tool,
logging, file_repository, data_quality_create, data_quality_execute,
api_export, api_import, mobile_app, mobile_app_download_data,
record_create, record_rename, record_delete,
lock_records_customization, lock_records, lock_records_all_forms,
forms, forms_export
Privileges for fields above can be set as follows:
- Data Export: 0=No Access, 2=De-Identified, 1=Full Data Set
- Form Rights: 0=No Access, 2=Read Only, 1=View records/responses and edit records (survey responses are read-only), 3=Edit survey responses
- Other field values: 0=No Access, 1=Access.
See the REDCap API documentation for more information, or print the results of PHPCap's exportUsers method to see what the data looks like for the current users.
Parameters
- $users : mixed
-
for 'php' format, an array should be used that maps field names to field values. For all other formats a string should be used that has the data in the correct format.
- $format : string = 'php'
-
output data format.
- 'php' - [default] array of maps of values
- 'csv' - string of CSV (comma-separated values)
- 'json' - string of JSON encoded values
- 'xml' - string of XML encoded data
Return values
int —the number of users added or updated.
renameRecord()
Renames the specified record with the new specified record ID.
public
renameRecord(string $recordId, string $newRecordId[, string $arm = null ]) : mixed
Parameters
- $recordId : string
-
the record ID of the record to rename.
- $newRecordId : string
-
the new record ID to set for the specified records.
- $arm : string = null
-
if specified, the rename will only be done for the redcord ID in that arm.
Return values
mixed —"1" if the records was successfully renamed, and throws an exception otherwise.
setConnection()
Sets the connection used for calling the REDCap API.
public
setConnection(RedCapApiConnectionInterface $connection) : mixed
Parameters
- $connection : RedCapApiConnectionInterface
-
the connection to use for calls to the REDCap API.
Return values
mixed —setErrorHandler()
Sets the error handler used by the project.
public
setErrorHandler(ErrorHandlerInterface $errorHandler) : mixed
Parameters
- $errorHandler : ErrorHandlerInterface
-
the error handler to use.
Return values
mixed —switchDag()
Switches the DAG (Data Access Group) to the specified DAG.
public
switchDag(string $dag) : mixed
Parameters
- $dag : string
-
the DAG to switch to.
Return values
mixed —"1" if the records was successfully renamed, and throws an exception otherwise.