%%capture
%%R
<- redcap_dag_read(redcap_uri = url, token)$data dag
16 Data Access Groups (DAGs)
In addition to user roles for access control, DAGs control which records each user can access. Users assigned to a DAG can only access records assigned to that particular DAG, and are blinded to records outside of their group. DAGs are particularly useful in multi-site or multi-jurisdictional projects to restrict sites from viewing records from other sites.
Users can be assigned to a DAG after being added to the project. Users can be in multiple DAGs. Users not assigned to any DAG have global access and can see all records in the project.
Records are assigned to DAG’s using the ‘Record Status Dashboard’ in REDCap. In this project, one DAG group was created called ‘records1_2’ that contains Record IDs 1 & 2.
redcap_dag_read()
View the DAGs and their unique data_access_group_id
:
Use redcap_read_oneshot
to view record DAG assignments:
%%capture
%%R
<- redcap_read_oneshot(
data_dag = url,
redcap_uri = token,
token = TRUE,
export_data_access_groups = "record_id")$data fields
For the REDCapR package, refer to the data_user
table printed in Chapter 15 to see user DAG assignments.
export_dags()
, export_user_dag_assignment()
View the DAGs and their unique data_access_group_id
:
='df') project.export_dags(format_type
data_access_group_name | unique_group_name | data_access_group_id | |
---|---|---|---|
0 | Limited Access | limited_access | 2707 |
1 | records1_2 | records1_2 | 2716 |
View users’ DAG assignments:
='df') #exports users and their assigned DAGs (username and DAG) project.export_user_dag_assignment(format_type
username | redcap_data_access_group | |
---|---|---|
0 | alexey.gilman@doh.wa.gov | records1_2 |
1 | caitlin.drover@doh.wa.gov | NaN |
2 | emily.pearman@doh.wa.gov | NaN |
Use export_records
to view which records belong to which data access group.
= project.export_records(format_type = 'df', export_data_access_groups = True, fields = 'record_id')
dag dag.head()
redcap_repeat_instrument | redcap_repeat_instance | redcap_data_access_group | ||
---|---|---|---|---|
record_id | redcap_event_name | |||
1 | personal_info_arm_1 | NaN | NaN | records1_2 |
notifications_arm_1 | NaN | NaN | records1_2 | |
case_intake_arm_1 | NaN | 1.0 | records1_2 | |
2 | personal_info_arm_1 | NaN | NaN | records1_2 |
notifications_arm_1 | NaN | NaN | records1_2 |
Note: Even though only record_id
was specified for export under the fields
argument, PyCap will automatically include all the variables that make the unique_key (record_id
, redcap_event_name
, redcap_repeat_instrument
, redcap_repeat_instance
).