Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

rsh52
Copy link
Collaborator

@rsh52 rsh52 commented Sep 11, 2024

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:

  • Add redcap_event_read() to NAMESPACE, link_arms() calls
  • Update link_arms() tests
  • Add "event_name" to add_event_mapping() to include event name/label in redcap_event column output of longitudinal supertibbles
  • Update the NEWS.md file to include the additional changes we've made in prep for 1.2.0 release

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:

  • New/revised functions have associated tests
  • [NA] New/revised functions that update downstream outputs have associated static testing files (.RDS) updated under inst/testdata/create_test_data.R
  • New/revised functions use appropriate naming conventions
  • New/revised functions don't repeat code
  • Code changes are less than 250 lines total
  • Issues linked to the PR using GitHub's list of keywords
  • The appropriate reviewer is assigned to the PR
  • The appropriate developers are assigned to the PR
  • [NA] Pre-release package version incremented using usethis::use_version()
    • To be included in REDCapTidieR 1.2.0

Code Review

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

Code Review Checklist

  • I checked that new files follow naming conventions and are in the right place
  • I checked that documentation is complete, clear, and without typos
  • I added/edited comments to explain "why" not "how"
  • I checked that all new variable and function names follow naming conventions
  • I checked that new tests have been written for key business logic and/or bugs that this PR fixes
  • I checked that new tests address important edge cases

@rsh52 rsh52 added the enhancement New feature or request label Sep 11, 2024
@rsh52 rsh52 self-assigned this Sep 11, 2024
@rsh52 rsh52 marked this pull request as ready for review September 11, 2024 15:47
@rsh52 rsh52 requested a review from ezraporter September 11, 2024 15:47
Copy link
Collaborator

@ezraporter ezraporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rsh52
Copy link
Collaborator Author

rsh52 commented Sep 11, 2024

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  

@ezraporter ezraporter self-requested a review September 11, 2024 19:10
@rsh52 rsh52 merged commit 82a49b7 into main Sep 11, 2024
4 checks passed
@rsh52 rsh52 deleted the redcap-event-names branch September 11, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Include event labels in redcap_events tibbles
2 participants