REDCap allows strict control of user rights for each project. These rights include a user’s ability to edit, export and view data, add or edit reports, import data, create records, etc. Privileges to view and export data are specified for each instrument.
User roles can be set with predefined privileges and users can then be assigned to these user role groups.
Users
Cannot be imported with REDCapR. See Section 27.1 for more information.
import_users()
In this example, we will export the project’s users and re-import it so that no changes are made to the project.
users = project.export_users(format_type= 'df' )
users
0
alexey.gilman@doh.wa.gov
Alexey.Gilman@doh.wa.gov
Alexey
Gilman
NaN
NaN
NaN
1
1
1
...
1
0
1
1
1
0
0
1
demographics:3,symptoms:1,test_information:1,c...
demographics:1,symptoms:1,test_information:1,c...
1
caitlin.drover@doh.wa.gov
Caitlin.Drover@doh.wa.gov
Caitlin
Drover
NaN
NaN
NaN
1
1
1
...
1
0
1
1
1
0
0
1
demographics:3,symptoms:1,test_information:1,c...
demographics:1,symptoms:1,test_information:1,c...
2
emily.pearman@doh.wa.gov
emily.pearman@doh.wa.gov
Emily
Pearman
NaN
NaN
NaN
1
1
1
...
1
1
1
1
1
0
0
0
demographics:1,symptoms:1,test_information:1,c...
demographics:1,symptoms:1,test_information:1,c...
3 rows × 34 columns
project.import_users(users, import_format= 'df' )
Note: attemping to import a user already assigned to a user role will result in an error.
User Roles
Cannot be imported with REDCapR. See Section 27.1 for more information.
Roles can be imported using import_user_roles()
and assigned to a project user using import_user_role_assignment()
.
Importing User Roles
user_roles = project.export_user_roles(format_type= 'df' )
user_roles
0
U-1564393FT9
Limited Role
0
0
0
0
0
0
0
0
...
0
0
0
0
0
0
0
0
demographics:0,symptoms:0,test_information:0,c...
demographics:0,symptoms:0,test_information:0,c...
1
U-5354FA3HYL
Admin
1
1
1
1
1
1
1
1
...
1
0
1
1
1
1
0
0
demographics:3,symptoms:1,test_information:1,c...
demographics:3,symptoms:1,test_information:1,c...
2 rows × 29 columns
Note: the unique_role_name
is automatically generated by REDCap.
project.import_user_roles(user_roles, import_format= 'df' )
Importing User Role Assignments
user_role_assign = project.export_user_role_assignment(format_type= 'df' )
user_role_assign
0
alexey.gilman@doh.wa.gov
NaN
NaN
1
caitlin.drover@doh.wa.gov
NaN
NaN
2
emily.pearman@doh.wa.gov
NaN
NaN
user_role_assign['unique_role_name' ].astype(str ).replace('nan' , np.NaN)
user_role_assign.loc[0 ,'unique_role_name' ] = 'U-5354FA3HYL'
user_role_assign
0
alexey.gilman@doh.wa.gov
U-5354FA3HYL
NaN
1
caitlin.drover@doh.wa.gov
NaN
NaN
2
emily.pearman@doh.wa.gov
NaN
NaN
project.import_user_role_assignment(user_role_assign, import_format= 'df' )