RedCap
in package
REDCap class used to represent a REDCap instance/site. This class is typically only useful if your progam needs to create REDCap projects and/or needs to access more than one REDCap project.
Table of Contents
- __construct() : mixed
- createProject() : RedCapProject
- Creates a REDCap project with the specified data.
- exportRedcapVersion() : string
- Gets the REDCap version number of the REDCap instance being used.
- getConnection() : RedCapApiConnectionInterface
- Gets the connection being used.
- getErrorHandler() : ErrorHandlerInterface
- Gets the error handler being used.
- getProject() : RedCapProject
- Gets the REDCap project for the specified API token.
- getProjectConstructorCallback() : callable
- Gets the function used to create projects.
- setConnection() : mixed
- Sets the connection that is used.
- setErrorHandler() : mixed
- Set the error handler that is used.
- setProjectConstructorCallback() : mixed
- Sets the function used to create projects in this class.
Methods
__construct()
public
__construct(string $apiUrl[, string $superToken = null ][, bool $sslVerify = false ][, string $caCertificateFile = null ][, ErrorHandlerInterface $errorHandler = null ][, RedCapApiConnectionInterface $connection = null ]) : mixed
Parameters
- $apiUrl : string
-
the URL for the API for your REDCap site.
- $superToken : string = null
-
the user's super token. This needs to be provided if you are going to create projects.
- $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 that will be used. This would normally only be set if you want to override the PHPCap's default error handler.
- $connection : RedCapApiConnectionInterface = null
-
the connection that will be used. 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.
Return values
mixed —createProject()
Creates a REDCap project with the specified data.
public
createProject(mixed $projectData[, $format = 'php' ][, string $odm = null ]) : RedCapProject
A super token must have been specified for this method to be used.
The data fields that can be set are as follows:
- project_title - the title of the project.
-
purpose - the purpose of the project:
- 0 - Practice/Just for fun
- 1 - Other
- 2 - Research
- 3 - Quality Improvement
- 4 - Operational Support
- purpose_other - text descibing purpose if purpose above is specified as 1.
- project_notes - notes about the project.
- is_longitudinal - indicates if the project is longitudinal (0 = False [default], 1 = True).
- surveys_enabled - indicates if surveys are enabled (0 = False [default], 1 = True).
- record_autonumbering_enabled - indicates id record autonumbering is enabled (0 = False [default], 1 = True).
Parameters
- $projectData : mixed
-
the data used for project creation. Note that if 'php' format is used, the data needs to be an array where the keys are the field names and the values are the field values.
- $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
- $odm : string = null
-
string in CDISC ODM XML format that contains metadata and optionally data to be imported into the created project.
Return values
RedCapProject —the project that was created.
exportRedcapVersion()
Gets the REDCap version number of the REDCap instance being used.
public
exportRedcapVersion() : string
A super token must have been specified for this method to be used.
Return values
string —the REDCap version number of the REDCap instance being used by the project.
getConnection()
Gets the connection being used.
public
getConnection() : RedCapApiConnectionInterface
Return values
RedCapApiConnectionInterface —the connection being used.
getErrorHandler()
Gets the error handler being used.
public
getErrorHandler() : ErrorHandlerInterface
Return values
ErrorHandlerInterface —the error handler being used.
getProject()
Gets the REDCap project for the specified API token.
public
getProject(string $apiToken) : RedCapProject
Parameters
- $apiToken : string
-
the API token for the project to get.
Return values
RedCapProject —the project for the specified API token.
getProjectConstructorCallback()
Gets the function used to create projects.
public
getProjectConstructorCallback() : callable
Return values
callable —the function used by this class to create projects.
setConnection()
Sets the connection that is used.
public
setConnection(RedCapApiConnectionInterface $connection) : mixed
Parameters
- $connection : RedCapApiConnectionInterface
-
the connection to use.
Return values
mixed —setErrorHandler()
Set the error handler that is used.
public
setErrorHandler(ErrorHandlerInterface $errorHandler) : mixed
Parameters
- $errorHandler : ErrorHandlerInterface
-
the error handler to use.
Return values
mixed —setProjectConstructorCallback()
Sets the function used to create projects in this class.
public
setProjectConstructorCallback(callable $projectConstructorCallback) : mixed
This method would normally only be used if you have extended the RedCapProject class and want RedCap to return projects using your extended class.
Parameters
- $projectConstructorCallback : callable
-
the function to call to create a new project. The function will be passed the same arguments as the RedCapProject constructor gets.