CHOP-CGTInformatics / REDCapTidieR

Makes it easy to read REDCap Projects into R
https://chop-cgtinformatics.github.io/REDCapTidieR/
Other
33 stars 8 forks source link

Update link_arms, Add event_name to redcap_events Output in Longitudinal Supertibbles #203

Closed rsh52 closed 2 months ago

rsh52 commented 2 months ago

Description

This PR adds an additional REDCap API call to link_arms(), which only applies to longitudinal REDCap projects. Now that REDCapR 1.2.0 is on CRAN we have access to redcap_event_read() that allows us to directly retrieve REDCap event names/labels.

Proposed Changes

List changes below in bullet format:

Here is a sample output:

sprtbl <- read_redcap(Sys.getenv("REDCAP_URI"), token = Sys.getenv("REDCAPTIDIER_LONGITUDINAL_API"))

> sprtbl$redcap_events
[[1]]
# A tibble: 4 × 4
  redcap_event redcap_arm arm_name event_name
  <chr>             <int> <chr>    <chr>     
1 event_1               1 Arm 1    Event 1   
2 event_2               1 Arm 1    Event 2   
3 event_1               2 Arm 2    Event 1   
4 event_3               2 Arm 2    Event 3   

[[2]]
# A tibble: 1 × 4
  redcap_event redcap_arm arm_name event_name
  <chr>             <int> <chr>    <chr>     
1 event_1               1 Arm 1    Event 1   

[[3]]
# A tibble: 4 × 4
  redcap_event redcap_arm arm_name event_name
  <chr>             <int> <chr>    <chr>     
1 event_1               1 Arm 1    Event 1   
2 event_2               1 Arm 1    Event 2   
3 event_1               2 Arm 2    Event 1   
4 event_3               2 Arm 2    Event 3   

Issue Addressed

Closes #67

PR Checklist

Before submitting this PR, please check and verify below that the submission meets the below criteria:

Code Review

This section to be used by the reviewer and developers during Code Review after PR submission

Code Review Checklist

rsh52 commented 2 months ago

Awesome! What do you think about changing the variable order so event_name is after redcap_event?

Good call, done in recent commit:

> sprtbl$redcap_events
[[1]]
# A tibble: 4 × 4
  redcap_event event_name redcap_arm arm_name
  <chr>        <chr>           <int> <chr>   
1 event_1      Event 1             1 Arm 1   
2 event_2      Event 2             1 Arm 1   
3 event_1      Event 1             2 Arm 2   
4 event_3      Event 3             2 Arm 2   

[[2]]
# A tibble: 1 × 4
  redcap_event event_name redcap_arm arm_name
  <chr>        <chr>           <int> <chr>   
1 event_1      Event 1             1 Arm 1   

[[3]]
# A tibble: 4 × 4
  redcap_event event_name redcap_arm arm_name
  <chr>        <chr>           <int> <chr>   
1 event_1      Event 1             1 Arm 1   
2 event_2      Event 2             1 Arm 1   
3 event_1      Event 1             2 Arm 2   
4 event_3      Event 3             2 Arm 2