Learn R Programming

redcapAPI (version 2.8.0)

dagAssignmentMethods: Export and Import Users Assigned to Data Access Groups

Description

These methods enable the user to export existing assignments of users to Data Access Groups, or import new or updated assignments to the project.

Usage

exportUserDagAssignments(rcon, ...)

importUserDagAssignments(rcon, data, ...)

# S3 method for redcapApiConnection exportUserDagAssignments( rcon, ..., error_handling = getOption("redcap_error_handling"), config = list(), api_param = list() )

# S3 method for redcapApiConnection importUserDagAssignments( rcon, data, ..., error_handling = getOption("redcap_error_handling"), config = list(), api_param = list() )

Value

exportUserDagAssignments method returns a data frame with two columns:

usernameThe unique user name for each user in the project.
redcap_data_access_groupThe unique Data Access Group name to which the user is assigned.

importUserDagAssignments has no return and prints a message indicating the number of assignments imported.

Arguments

rcon

A redcapConnection object.

data

data.frame with the columns username and redcap_data_access_group. The should only be one row per user name.

...

Arguments to pass to other methods

error_handling

character(1). One of c("error", "null"). An option for how to handle errors returned by the API. see redcapError().

config

A named list. Additional configuration parameters to pass to httr::POST(). These are appended to any parameters in rcon$config.

api_param

A named list. Additional API parameters to pass into the body of the API call. This provides users to execute calls with options that may not otherwise be supported by redcapAPI.

Functions

  • exportUserDagAssignments(): Export current User-DAG Assignments

  • importUserDagAssignments(): Import new or modified User-DAG Assignments.

Details

When modifying existing assignments using the import method, the user must provide the unique user name and the group name. If the redcap_data_access_group column is not provided, the REDCap user will not be assigned to any group.

See Also

exportDags(),
importDags(),
deleteDags(),
switchDag()

Examples

Run this code
if (FALSE) {
unlockREDCap(connections = c(rcon = "project_alias"), 
             url = "your_redcap_url", 
             keyring = "API_KEYs", 
             envir = globalenv())

# Export the current assignments
exportUserDagAssignments(rcon)

# Assign a user to a Data Access Group
ForImport <- data.frame(username = "user1", 
                        redcap_data_access_group = "facility_one")
importUserDagAssigments(rcon, 
                        data = ForImport)
                                          
# Assign a multiple users to a Data Access Group
ForImport <- data.frame(username = c("user1", "user2", "user3"), 
                        redcap_data_access_group = c("facility_one", 
                                                     "facility_one", 
                                                      "facility_two"))
importUserDagAssigments(rcon, 
                        data = ForImport)
                        
# Remove a user from all Data Access Groups
ForImport <- data.frame(username = "user1", 
                        redcap_data_access_group = NA_character_)
importUserDagAssigments(rcon, 
                        data = ForImport)
}

Run the code above in your browser using DataLab