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

Append order_refer info to opt_out #24

Closed
Tracked by #31
andrewallenbruce opened this issue Oct 25, 2023 · 0 comments
Closed
Tracked by #31

Append order_refer info to opt_out #24

andrewallenbruce opened this issue Oct 25, 2023 · 0 comments
Assignees
Labels
addendum 👍 additional context questioning ❔ unsure if addition or change needed

Comments

@andrewallenbruce
Copy link
Owner

library(provider)
library(tidyverse)

x <- opt_out(city = "Valdosta", state = "GA")

#> # A tibble: 3 × 12
#>   npi        first last  specialty order_refer optout_start_date optout_end_date
#>   <chr>      <chr> <chr> <chr>     <lgl>       <date>            <date>         
#> 1 1992848659 Jeff… Wood  Maxillof… TRUE        2016-01-11        2024-01-11     
#> 2 1073632659 Fern… Alva… Oral Sur… TRUE        2017-07-01        2025-07-01     
#> 3 1811005655 Sonya Merr… Plastic … TRUE        2022-01-01        2024-01-01     

y <- x |> 
  dplyr::filter(order_refer == TRUE) |> 
  dplyr::pull(npi) |> 
  purrr::map(\(x) order_refer(npi = x)) |> 
  purrr::list_rbind() |> 
  dplyr::select(npi, service) |> 
  dplyr::nest_by(npi, .key = 'eligibility')

#> # A tibble: 3 × 2
#> # Rowwise:  npi
#>   npi               eligibility
#>   <chr>      <list<tibble[,1]>>
#> 1 1073632659            [3 × 1]
#> 2 1811005655            [4 × 1]
#> 3 1992848659            [4 × 1]

z <- dplyr::left_join(x, y, by = dplyr::join_by(npi)) |> 
     dplyr::relocate(eligibility, .after = order_refer)

#> # A tibble: 3 × 13
#>   npi        first    last   specialty order_refer eligibility optout_start_date
#>   <chr>      <chr>    <chr>  <chr>     <lgl>       <list<tibb> <date>           
#> 1 1992848659 Jeffery  Wood   Maxillof… TRUE            [4 × 1] 2016-01-11       
#> 2 1073632659 Fernando Alvar… Oral Sur… TRUE            [3 × 1] 2017-07-01       
#> 3 1811005655 Sonya    Merri… Plastic … TRUE            [4 × 1] 2022-01-01       

tidyr::unnest(z, eligibility)
#> # A tibble: 11 × 13
#>    npi        first    last     specialty  order_refer service optout_start_date
#>    <chr>      <chr>    <chr>    <chr>      <lgl>       <chr>   <date>           
#>  1 1992848659 Jeffery  Wood     Maxillofa… TRUE        Medica… 2016-01-11       
#>  2 1992848659 Jeffery  Wood     Maxillofa… TRUE        Home H… 2016-01-11       
#>  3 1992848659 Jeffery  Wood     Maxillofa… TRUE        Durabl… 2016-01-11       
#>  4 1992848659 Jeffery  Wood     Maxillofa… TRUE        Power … 2016-01-11       
#>  5 1073632659 Fernando Alvarado Oral Surg… TRUE        Medica… 2017-07-01       
#>  6 1073632659 Fernando Alvarado Oral Surg… TRUE        Home H… 2017-07-01       
#>  7 1073632659 Fernando Alvarado Oral Surg… TRUE        Durabl… 2017-07-01       
#>  8 1811005655 Sonya    Merriman Plastic A… TRUE        Medica… 2022-01-01       
#>  9 1811005655 Sonya    Merriman Plastic A… TRUE        Home H… 2022-01-01       
#> 10 1811005655 Sonya    Merriman Plastic A… TRUE        Durabl… 2022-01-01       
#> 11 1811005655 Sonya    Merriman Plastic A… TRUE        Power … 2022-01-01       

Created on 2023-10-24 with reprex v2.0.2

@andrewallenbruce andrewallenbruce added the feature 📸 feature request label Oct 25, 2023
@andrewallenbruce andrewallenbruce self-assigned this Oct 25, 2023
@andrewallenbruce andrewallenbruce added enhancement 🤖 adds to the base functionality questioning ❔ unsure if addition or change needed addendum 👍 additional context and removed feature 📸 feature request enhancement 🤖 adds to the base functionality labels Oct 25, 2023
@andrewallenbruce andrewallenbruce mentioned this issue Oct 31, 2023
4 tasks
@andrewallenbruce andrewallenbruce changed the title Append Order & Referral info to Eligible Opt-Outs Append order_refer info to opt_out Nov 19, 2023
@andrewallenbruce andrewallenbruce closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addendum 👍 additional context questioning ❔ unsure if addition or change needed
Projects
None yet
Development

No branches or pull requests

1 participant