diff --git a/R/cms.R b/R/cms.R index 8887e84..bf309f2 100644 --- a/R/cms.R +++ b/R/cms.R @@ -247,7 +247,7 @@ build_url <- function(abb, args = NULL) { #' @autoglobal #' #' @noRd -api_years <- function(abb, year) { +api_years <- function(abb, year = NULL) { api <- dplyr::case_match( abb, diff --git a/R/outpatient.R b/R/outpatient.R index 15fe839..28481c9 100644 --- a/R/outpatient.R +++ b/R/outpatient.R @@ -62,9 +62,7 @@ outpatient <- function(year, 'Rndrng_Prvdr_RUCA', ruca, 'APC_Cd', apc) - id <- dplyr::filter(api_years("outps"), - year == {{ year }}) |> - dplyr::pull(distro) + id <- api_years("outps", year = as.integer(year))[["distro"]] url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data.json?", encode_param(args)) diff --git a/R/prescribers.R b/R/prescribers.R index 4a1cc35..c3c9c4e 100644 --- a/R/prescribers.R +++ b/R/prescribers.R @@ -269,25 +269,15 @@ prescribers <- function(year, 'Antbtc_Drug_Flag', antibiotic, 'Antpsyct_Drug_Flag', antipsychotic) - yr <- switch( + id <- switch( type, - 'Provider' = api_years('rxp'), - 'Drug' = api_years('rxd'), - 'Geography' = api_years('rxg')) - - id <- dplyr::filter( - yr, - year == {{ year }}) |> - dplyr::pull(distro) - - url <- paste0( - "https://data.cms.gov/data-api/v1/dataset/", - id, - "/data.json?", - encode_param(args)) - - response <- httr2::request(url) |> - httr2::req_perform() + "Provider" = api_years("rxp", year = as.integer(year))[["distro"]], + "Drug" = api_years("rxd", year = as.integer(year))[["distro"]], + "Geography" = api_years("rxg", year = as.integer(year))[["distro"]]) + + url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data.json?", encode_param(args)) + + response <- httr2::request(url) |> httr2::req_perform() if (vctrs::vec_is_empty(response$body)) { diff --git a/R/quality_payment.R b/R/quality_payment.R index 8572ba8..1e0efe4 100644 --- a/R/quality_payment.R +++ b/R/quality_payment.R @@ -101,9 +101,7 @@ quality_payment <- function(year, # id <- "b3438273-b4a6-44ca-8fb2-9e6026b74642" - id <- api_years("qpp") |> - dplyr::filter(year == {{ year }}) |> - dplyr::pull(distro) + id <- api_years("qpp", year = as.integer(year))[["distro"]] url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data?", encode_param(args)) diff --git a/R/utilization.R b/R/utilization.R index e1a55a1..9af5d39 100644 --- a/R/utilization.R +++ b/R/utilization.R @@ -243,23 +243,13 @@ utilization <- function(year, "Place_Of_Srvc", pos, "Rndrng_Prvdr_Geo_Lvl", level) - yr <- switch(type, - 'Provider' = api_years('prv'), - 'Service' = api_years('srv'), - 'Geography' = api_years('geo')) - - id <- dplyr::filter( - yr, - year == {{ year }} - ) |> - dplyr::pull(distro) - - url <- paste0( - "https://data.cms.gov/data-api/v1/dataset/", - id, - "/data.json?", - - encode_param(args)) + id <- switch( + type, + "Provider" = api_years("prv", year = as.integer(year))[["distro"]], + "Service" = api_years("srv", year = as.integer(year))[["distro"]], + "Geography" = api_years("geo", year = as.integer(year))[["distro"]]) + + url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data.json?", encode_param(args)) response <- httr2::request(url) |> httr2::req_perform() diff --git a/R/years.R b/R/years.R index 991ed55..c320474 100644 --- a/R/years.R +++ b/R/years.R @@ -14,9 +14,6 @@ #' # `utilization()` #' util_years() #' -#' # `conditions()` -#' # cc_years() -#' #' # `quality_payment()` #' qpp_years() #' diff --git a/README.Rmd b/README.Rmd index b7b6a90..c2521a3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,5 +1,7 @@ --- output: github_document +editor_options: + chunk_output_type: console --- @@ -22,6 +24,7 @@ knitr::opts_chunk$set( > Providing easy access to [healthcare provider](https://en.wikipedia.org/wiki/Health_care_provider) data through publicly available APIs. +![GitHub R package version](https://img.shields.io/github/r-package/v/andrewallenbruce/provider?style=flat-square&logo=R&label=Package&color=%23192a38) [![R-CMD-check](https://github.com/andrewallenbruce/provider/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrewallenbruce/provider/actions/workflows/R-CMD-check.yaml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://choosealicense.com/licenses/mit/) [![code size](https://img.shields.io/github/languages/code-size/andrewallenbruce/provider.svg)](https://github.com/andrewallenbruce/provider) @@ -53,60 +56,55 @@ library(tidyr) ### `affiliations()` ```{r} -affiliations(npi = 1023630738, - pac = 9032521372, - facility_ccn = 370781) |> - glimpse() +affiliations(facility_ccn = 370781) ``` ### `beneficiaries()` ```{r} -beneficiaries(year = 2024, - period = "Month", - level = "County", - state = "GA", - county = "Lowndes County") |> +beneficiaries( + year = 2023, + period = "Year", + level = "County", + state = "GA", + county = "Lowndes County") |> glimpse() ``` ### `clinicians()` ```{r} -clinicians(npi = 1932365699) |> - glimpse() +clinicians(npi = 1932365699) |> glimpse() ``` ### `hospitals()` ```{r} -hospitals(npi = 1720098791) |> - glimpse() +hospitals(npi = 1720098791) |> glimpse() ``` ### `laboratories()` ```{r} -laboratories(clia = "11D0265516") |> - glimpse() +laboratories(clia = "11D0265516") |> glimpse() ``` ### `nppes()` ```{r} -nppes(npi = 1497535637) |> - glimpse() +nppes(npi = 1497535637) |> glimpse() ``` ### `open_payments()` ```{r} -open_payments(year = 2021, - npi = 1023630738, - na.rm = TRUE) |> +open_payments( + year = 2021, + npi = 1023630738, + na.rm = TRUE) |> glimpse() ``` @@ -114,26 +112,25 @@ open_payments(year = 2021, ### `opt_out()` ```{r} -opt_out(npi = 1043522824) |> - glimpse() +opt_out(npi = 1043522824) |> glimpse() ``` ### `order_refer()` ```{r} -order_refer(npi = 1043522824, tidy = FALSE) |> - glimpse() +order_refer(npi = 1043522824) |> glimpse() ``` ### `outpatient()` ```{r} -outpatient(year = 2021, - state = "GA", - city = "Valdosta", - apc = "5072") |> +outpatient( + year = 2021, + state = "GA", + city = "Valdosta", + apc = "5072") |> glimpse() ``` @@ -141,139 +138,101 @@ outpatient(year = 2021, ### `prescribers()` ```{r} -prescribers(year = 2019, - type = 'Provider', - npi = 1003000126) |> +prescribers( + year = 2022, + type = 'Provider', + npi = 1003000126) |> glimpse() ``` ```{r} -prescribers(year = 2019, - npi = 1003000126, - type = 'Drug', - brand_name = 'Atorvastatin Calcium') |> +prescribers( + year = 2022, + npi = 1003000126, + type = 'Drug', + brand_name = 'Atorvastatin Calcium') |> glimpse() ``` ```{r} -prescribers(year = 2021, - type = 'Geography', - level = 'National', - brand_name = 'Clotrimazole-Betamethasone') |> +prescribers( + year = 2022, + type = 'Geography', + level = 'National', + brand_name = 'Clotrimazole-Betamethasone') |> glimpse() ``` - ### `providers()` ```{r} -providers(npi = 1720098791, - enid = "O20040610001257") |> +providers( + npi = 1720098791, + enid = "O20040610001257") |> glimpse() ``` ### `quality_payment()` ```{r} -quality_payment(year = 2021, - npi = 1932365699) |> +quality_payment( + year = 2021, + npi = 1932365699) |> glimpse() ``` - -```{r} -q <- quality_payment(year = 2021, - npi = 1932365699) - -q |> - select( - year, - qpp_status - ) |> - unnest(qpp_status) -``` - - -```{r} -q |> - select( - year, - qpp_measures - ) |> - unnest(qpp_measures) -``` - ### `quality_eligibility()` ```{r} -quality_eligibility(year = 2021, - npi = 1932365699) |> +quality_eligibility( + year = 2024, + npi = 1932365699, + tidy = FALSE, + unnest = FALSE, + pivot = FALSE, + na.rm = FALSE) |> glimpse() ``` ### `reassignments()` ```{r} -reassignments(npi = 1932365699, - pac_org = 7719037548) |> +reassignments( + npi = 1932365699, + pac_org = 7719037548) |> glimpse() ``` - ### `utilization()` ```{r} -utilization(year = 2021, - npi = 1932365699, - type = "Provider") |> +utilization( + year = 2022, + npi = 1932365699, + type = "Provider") |> glimpse() ``` - - ```{r} -p <- utilization(year = 2021, - npi = 1932365699, - type = "Provider") - -select(p, year, performance) |> - unnest(performance) |> - glimpse() -``` - - -```{r} -select(p, year, demographics) |> - unnest(demographics) |> - glimpse() -``` - - -```{r} -select(p, year, conditions) |> - unnest(conditions) |> +utilization( + year = 2022, + npi = 1932365699, + hcpcs = "99214", + type = "Service", + rbcs = FALSE) |> glimpse() ``` - - -```{r} -utilization(year = 2021, - npi = 1932365699, - hcpcs = "99214", - type = "Service") |> - glimpse() -``` - - ```{r} -utilization(year = 2021, - hcpcs = "99205", - level = "National", - pos = "F", - type = "Geography") |> +utilization( + year = 2022, + hcpcs = "99205", + level = "National", + pos = "F", + type = "Geography", + rbcs = FALSE) |> glimpse() ``` diff --git a/README.md b/README.md index bc35ce9..b3b83c7 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ +![GitHub R package +version](https://img.shields.io/github/r-package/v/andrewallenbruce/provider?style=flat-square&logo=R&label=Package&color=%23192a38) [![R-CMD-check](https://github.com/andrewallenbruce/provider/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrewallenbruce/provider/actions/workflows/R-CMD-check.yaml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://choosealicense.com/licenses/mit/) @@ -41,66 +43,74 @@ library(tidyr) ### `affiliations()` ``` r -affiliations(npi = 1023630738, - pac = 9032521372, - facility_ccn = 370781) |> - glimpse() +affiliations(facility_ccn = 370781) ``` - #> Rows: 1 - #> Columns: 6 - #> $ npi "1023630738" - #> $ pac "9032521372" - #> $ first "ALYSIA" - #> $ last "SMITH" - #> $ facility_type Hospital - #> $ facility_ccn "370781" + #> # A tibble: 16 × 7 + #> npi pac first middle last facility_type facility_ccn + #> + #> 1 1053547950 7618131160 AARON S SIZELOVE Hospital 370781 + #> 2 1083618003 6406913474 KEITH J KASSABIAN Hospital 370781 + #> 3 1225098460 2466474713 BRENDA K HUENERGARDT Hospital 370781 + #> 4 1245239045 4082508833 STEVE M MADRID Hospital 370781 + #> 5 1316939622 2769376508 CHESTER WRAY BEAM Hospital 370781 + #> 6 1417376823 0941531362 MICHAEL TRAN Hospital 370781 + #> 7 1427045400 7517858608 THOMAS MCGARRY Hospital 370781 + #> 8 1487435053 8426405796 NICHOLAS RUSSENBERG… Hospital 370781 + #> 9 1568453835 3870487739 DWAYNE A SCHMIDT Hospital 370781 + #> 10 1629043369 6103878764 JANA NIKOLE MORRIS Hospital 370781 + #> 11 1659758472 3375853419 ALYSSA B MIZE Hospital 370781 + #> 12 1740291517 1052341575 WILLIAM LANCE GARNER Hospital 370781 + #> 13 1780762195 1052581154 CHRISTIAN L KOOPMAN Hospital 370781 + #> 14 1790005809 2668699729 RYAN B HURST Hospital 370781 + #> 15 1891248191 1658620976 MATTHEW I ORGEL Hospital 370781 + #> 16 1922361740 1052633591 LYNNETTE MORRISON Hospital 370781 ### `beneficiaries()` ``` r -beneficiaries(year = 2024, - period = "Month", - level = "County", - state = "GA", - county = "Lowndes County") |> +beneficiaries( + year = 2023, + period = "Year", + level = "County", + state = "GA", + county = "Lowndes County") |> glimpse() ``` - #> Rows: 3 + #> Rows: 1 #> Columns: 26 - #> $ year 2024, 2024, 2024 - #> $ period January, February, March - #> $ level County, County, County - #> $ state GA, GA, GA - #> $ state_name Georgia, Georgia, Georgia - #> $ county "Lowndes County", "Lowndes County", "Lowndes County" - #> $ fips "13185", "13185", "13185" - #> $ bene_total 20848, 20854, 20874 - #> $ bene_orig 10648, 10609, 10579 - #> $ bene_ma_oth 10200, 10245, 10295 - #> $ bene_total_aged 17556, 17561, 17581 - #> $ bene_aged_esrd 118, 114, 112 - #> $ bene_aged_no_esrd 17438, 17447, 17469 - #> $ bene_total_dsb 3292, 3293, 3293 - #> $ bene_dsb_esrd 144, 144, 142 - #> $ bene_dsb_no_esrd 3148, 3149, 3151 - #> $ bene_total_ab 19357, 19403, 19424 - #> $ bene_ab_orig 9172, 9173, 9148 - #> $ bene_ab_ma_oth 10185, 10230, 10276 - #> $ bene_total_rx 15492, 15512, 15529 - #> $ bene_rx_pdp 5868, 5835, 5809 - #> $ bene_rx_mapd 9624, 9677, 9720 - #> $ bene_rx_lis_elig 5669, 5675, 5678 - #> $ bene_rx_lis_full 600, 595, 601 - #> $ bene_rx_lis_part 23, 23, 22 - #> $ bene_rx_lis_no 9200, 9219, 9228 + #> $ year 2023 + #> $ period Year + #> $ level County + #> $ state GA + #> $ state_name Georgia + #> $ county "Lowndes County" + #> $ fips "13185" + #> $ bene_total 20536 + #> $ bene_orig 11128 + #> $ bene_ma_oth 9408 + #> $ bene_total_aged 17059 + #> $ bene_aged_esrd 125 + #> $ bene_aged_no_esrd 16933 + #> $ bene_total_dsb 3477 + #> $ bene_dsb_esrd 145 + #> $ bene_dsb_no_esrd 3333 + #> $ bene_total_ab 19048 + #> $ bene_ab_orig 9646 + #> $ bene_ab_ma_oth 9402 + #> $ bene_total_rx 14843 + #> $ bene_rx_pdp 5942 + #> $ bene_rx_mapd 8901 + #> $ bene_rx_lis_elig 5558 + #> $ bene_rx_lis_full 475 + #> $ bene_rx_lis_part 159 + #> $ bene_rx_lis_no 8651 ### `clinicians()` ``` r -clinicians(npi = 1932365699) |> - glimpse() +clinicians(npi = 1932365699) |> glimpse() ``` #> Rows: 1 @@ -122,14 +132,13 @@ clinicians(npi = 1932365699) |> #> $ address_org "1165 S CAMINO DEL RIO SUITE 100" #> $ city_org "DURANGO" #> $ state_org CO - #> $ zip_org "81303" + #> $ zip_org "813036824" #> $ phone_org "9702478762" ### `hospitals()` ``` r -hospitals(npi = 1720098791) |> - glimpse() +hospitals(npi = 1720098791) |> glimpse() ``` #> Rows: 1 @@ -148,7 +157,7 @@ hospitals(npi = 1720098791) |> #> $ address "710 N IRWIN AVE" #> $ city "OCILLA" #> $ state GA - #> $ zip "31774" + #> $ zip "317745011" #> $ location_type "OTHER HOSPITAL PRACTICE LOCATION: REH" #> $ registration Non-Profit #> $ multi_npi FALSE @@ -160,8 +169,7 @@ hospitals(npi = 1720098791) |> ### `laboratories()` ``` r -laboratories(clia = "11D0265516") |> - glimpse() +laboratories(clia = "11D0265516") |> glimpse() ``` #> Rows: 1 @@ -195,8 +203,7 @@ laboratories(clia = "11D0265516") |> ### `nppes()` ``` r -nppes(npi = 1497535637) |> - glimpse() +nppes(npi = 1497535637) |> glimpse() ``` #> Rows: 1 @@ -216,7 +223,7 @@ nppes(npi = 1497535637) |> #> $ address "2501 N PATTERSON ST" #> $ city "VALDOSTA" #> $ state GA - #> $ zip "31602" + #> $ zip "316021785" #> $ country "US" #> $ phone "229-433-1000" #> $ tx_code "363L00000X" @@ -228,9 +235,10 @@ nppes(npi = 1497535637) |> ### `open_payments()` ``` r -open_payments(year = 2021, - npi = 1023630738, - na.rm = TRUE) |> +open_payments( + year = 2021, + npi = 1023630738, + na.rm = TRUE) |> glimpse() ``` @@ -286,8 +294,7 @@ open_payments(year = 2021, ### `opt_out()` ``` r -opt_out(npi = 1043522824) |> - glimpse() +opt_out(npi = 1043522824) |> glimpse() ``` #> Rows: 1 @@ -303,33 +310,29 @@ opt_out(npi = 1043522824) |> #> $ address "8585 E HARTFORD DR STE 111" #> $ city "SCOTTSDALE" #> $ state AZ - #> $ zip "85255" + #> $ zip "852555472" ### `order_refer()` ``` r -order_refer(npi = 1043522824, tidy = FALSE) |> - glimpse() +order_refer(npi = 1043522824) |> glimpse() ``` - #> Rows: 1 - #> Columns: 8 - #> $ NPI "1043522824" - #> $ LAST_NAME "SMITH" - #> $ FIRST_NAME "JAMES" - #> $ PARTB "Y" - #> $ DME "Y" - #> $ HHA "Y" - #> $ PMD "Y" - #> $ HOSPICE "N" + #> Rows: 4 + #> Columns: 4 + #> $ npi "1043522824", "1043522824", "1043522824", "1043522824" + #> $ first "JAMES", "JAMES", "JAMES", "JAMES" + #> $ last "SMITH", "SMITH", "SMITH", "SMITH" + #> $ eligible Medicare Part B, Home Health Agency, Durable Medical Equipmen… ### `outpatient()` ``` r -outpatient(year = 2021, - state = "GA", - city = "Valdosta", - apc = "5072") |> +outpatient( + year = 2021, + state = "GA", + city = "Valdosta", + apc = "5072") |> glimpse() ``` @@ -357,97 +360,100 @@ outpatient(year = 2021, ### `prescribers()` ``` r -prescribers(year = 2019, - type = 'Provider', - npi = 1003000126) |> +prescribers( + year = 2022, + type = 'Provider', + npi = 1003000126) |> glimpse() ``` #> Rows: 1 - #> Columns: 27 - #> $ year 2019 - #> $ npi "1003000126" - #> $ entity_type Individual - #> $ first "Ardalan" - #> $ last "Enkeshafi" - #> $ gender Male - #> $ credential "MD" - #> $ specialty "Internal Medicine" - #> $ source "Claim-Specialty" - #> $ address "900 Seton Dr" - #> $ city "Cumberland" - #> $ state MD - #> $ zip "21502" - #> $ fips "24" - #> $ ruca "1" - #> $ country "US" - #> $ tot_claims 589 - #> $ tot_fills 681.7333 - #> $ tot_cost 28902.12 - #> $ tot_supply 15955 - #> $ tot_benes 214 - #> $ rx_rate_opioid 5.093379 - #> $ bene_race_blk 73 - #> $ hcc_risk_avg 2.708114 - #> $ detailed [] - #> $ demographics [] - #> $ gte_65 [] + #> Columns: 28 + #> $ year 2022 + #> $ npi "1003000126" + #> $ entity_type Individual + #> $ first "Ardalan" + #> $ last "Enkeshafi" + #> $ gender Male + #> $ credential "MD" + #> $ specialty "Internal Medicine" + #> $ source "Claim-Specialty" + #> $ address "6410 Rockledge Dr Ste 304" + #> $ city "Bethesda" + #> $ state MD + #> $ zip "20817" + #> $ fips "24" + #> $ ruca "1" + #> $ country "US" + #> $ tot_claims 413 + #> $ tot_fills 715.7667 + #> $ tot_cost 36330.41 + #> $ tot_supply 19258 + #> $ tot_benes 155 + #> $ rx_rate_opioid 3.1477 + #> $ rx_rate_opioid_la 0 + #> $ bene_race_blk 20 + #> $ hcc_risk_avg 2.059633 + #> $ detailed [] + #> $ demographics [] + #> $ gte_65 [] ``` r -prescribers(year = 2019, - npi = 1003000126, - type = 'Drug', - brand_name = 'Atorvastatin Calcium') |> +prescribers( + year = 2022, + npi = 1003000126, + type = 'Drug', + brand_name = 'Atorvastatin Calcium') |> glimpse() ``` #> Rows: 1 - #> Columns: 18 - #> $ year 2019 + #> Columns: 17 + #> $ year 2022 #> $ npi "1003000126" #> $ last "Enkeshafi" #> $ first "Ardalan" - #> $ city "Cumberland" + #> $ city "Bethesda" #> $ state MD #> $ fips "24" #> $ specialty "Internal Medicine" #> $ source "Claim-Specialty" #> $ brand_name "Atorvastatin Calcium" #> $ generic_name "Atorvastatin Calcium" - #> $ tot_claims 41 - #> $ tot_fills 50 - #> $ tot_supply 1482 - #> $ tot_cost 373.6 - #> $ tot_benes 22 + #> $ tot_claims 11 + #> $ tot_fills 29 + #> $ tot_supply 870 + #> $ tot_cost 286.69 #> $ level Provider #> $ gte_65 [] ``` r -prescribers(year = 2021, - type = 'Geography', - level = 'National', - brand_name = 'Clotrimazole-Betamethasone') |> +prescribers( + year = 2022, + type = 'Geography', + level = 'National', + brand_name = 'Clotrimazole-Betamethasone') |> glimpse() ``` #> Rows: 1 #> Columns: 20 - #> $ year 2021 + #> $ year 2022 #> $ level National #> $ state National #> $ brand_name "Clotrimazole-Betamethasone" #> $ generic_name "Clotrimazole/Betamethasone Dip" - #> $ tot_prescribers 203283 - #> $ tot_claims 1611886 - #> $ tot_fills 1694182 - #> $ tot_cost 43735273 - #> $ tot_benes 887643 - #> $ tot_claims_ge65 1363536 - #> $ tot_fills_ge65 1435849 - #> $ tot_cost_ge65 36509742 - #> $ tot_benes_ge65 763073 - #> $ tot_cost_lis 877005.8 - #> $ tot_cost_nlis 11891222 + #> $ tot_prescribers 205696 + #> $ tot_claims 1598558 + #> $ tot_fills 1688104 + #> $ tot_cost 48271880 + #> $ tot_benes 879153 + #> $ tot_claims_ge65 1361135 + #> $ tot_fills_ge65 1439915 + #> $ tot_cost_ge65 40468578 + #> $ tot_benes_ge65 760752 + #> $ tot_cost_lis 767079.3 + #> $ tot_cost_nlis 12326159 #> $ opioid FALSE #> $ opioid_la FALSE #> $ antibiotic FALSE @@ -456,8 +462,9 @@ prescribers(year = 2021, ### `providers()` ``` r -providers(npi = 1720098791, - enid = "O20040610001257") |> +providers( + npi = 1720098791, + enid = "O20040610001257") |> glimpse() ``` @@ -474,151 +481,142 @@ providers(npi = 1720098791, ### `quality_payment()` ``` r -quality_payment(year = 2021, - npi = 1932365699) |> +quality_payment( + year = 2021, + npi = 1932365699) |> glimpse() ``` #> Rows: 1 - #> Columns: 47 - #> $ year 2021 - #> $ npi "1932365699" - #> $ npi_type Individual - #> $ first "STEFAN" - #> $ middle "MICHAEL" - #> $ last "SMITH" - #> $ state CO - #> $ first_approved_date 2008-11-15 - #> $ years_in_medicare 13 - #> $ participation_type Group - #> $ beneficiaries 555 - #> $ services 1157 - #> $ charges 112449 - #> $ final_score 60 - #> $ pay_adjust 0 - #> $ quality_score 45 - #> $ pi_score 0 - #> $ ia_score 0 - #> $ cost_score 0 - #> $ complex_bonus 2.54 - #> $ qi_bonus 0 - #> $ newly_enrolled FALSE - #> $ is_maqi FALSE - #> $ org_id 1 - #> $ org_size 3 - #> $ org_name "LEE ANN HOVEN OD PC" - #> $ org_address "ADVANCED EYE CARE 1165S CAMINO DEL RIO SUITE 100" - #> $ org_city "DURANGO" - #> $ org_state CO - #> $ org_zip "81303" - #> $ org_hosp_vbp_name NA - #> $ org_facility_based FALSE - #> $ ind_lvt_status_code "BOTH" - #> $ ind_lvt_status_desc "Both the unique beneficiaries and Part B" - #> $ ind_hosp_vbp_score 0 - #> $ specialty "Optometry" - #> $ specialty_desc "Optometry" - #> $ specialty_type "Doctor of Optometry" - #> $ specialty_cat "Physicians" - #> $ ind_specialty_code "41" - #> $ ind_specialty_desc "Optometry" - #> $ ind_specialty_type "Doctor of Optometry" - #> $ ind_specialty_cat "Physicians" - #> $ qpp_status [] - #> $ qpp_measures [] - #> $ ind_status [] - #> $ grp_status [] - -``` r -q <- quality_payment(year = 2021, - npi = 1932365699) - -q |> - select( - year, - qpp_status - ) |> - unnest(qpp_status) -``` - - #> # A tibble: 9 × 2 - #> year qualified - #> - #> 1 2021 Engaged - #> 2 2021 Small Practitioner - #> 3 2021 Rural Clinician - #> 4 2021 HPSA Clinician - #> 5 2021 Extreme Hardship - #> 6 2021 Extreme Hardship (Quality) - #> 7 2021 Extreme Hardship (PI) - #> 8 2021 Extreme Hardship (IA) - #> 9 2021 Extreme Hardship (Cost) - -``` r -q |> - select( - year, - qpp_measures - ) |> - unnest(qpp_measures) -``` - - #> # A tibble: 6 × 4 - #> year category measure_id score - #> - #> 1 2021 Quality 141 3 - #> 2 2021 Quality 014 3 - #> 3 2021 Quality 110 3 - #> 4 2021 Quality 47 3 - #> 5 2021 Quality 1 0 - #> 6 2021 Quality 117 0 + #> Columns: 92 + #> $ `provider key` "000493218" + #> $ `practice state or us territory` "CO" + #> $ `practice size` "3" + #> $ `clinician specialty` "Optometry" + #> $ `years in medicare` "14" + #> $ npi "1932365699" + #> $ engaged "True" + #> $ `participation type` "Group" + #> $ `medicare patients` "555" + #> $ `allowed charges` "112449" + #> $ services "1157" + #> $ `opted into mips` "False" + #> $ `small practitioner` "True" + #> $ `rural clinician` "True" + #> $ `hpsa clinician` "True" + #> $ `ambulatory surgical center` "False" + #> $ `hospital-based clinician` "False" + #> $ `non-patient facing` "False" + #> $ `facility-based` "False" + #> $ `extreme hardship` "True" + #> $ `final score` "60" + #> $ `payment adjustment percentage` "0" + #> $ `complex patient bonus` "2.54" + #> $ `extreme hardship quality` "True" + #> $ `quality category score` "45" + #> $ `quality improvement bonus` "0" + #> $ `quality bonus` "False" + #> $ `quality measure id 1` "141" + #> $ `quality measure score 1` "3" + #> $ `quality measure id 2` "014" + #> $ `quality measure score 2` "3" + #> $ `quality measure id 3` "110" + #> $ `quality measure score 3` "3" + #> $ `quality measure id 4` "47" + #> $ `quality measure score 4` "3" + #> $ `quality measure id 5` "1" + #> $ `quality measure score 5` "0" + #> $ `quality measure id 6` "117" + #> $ `quality measure score 6` "0" + #> $ `quality measure id 7` "" + #> $ `quality measure score 7` "" + #> $ `quality measure id 8` "" + #> $ `quality measure score 8` "" + #> $ `quality measure id 9` "" + #> $ `quality measure score 9` "" + #> $ `quality measure id 10` "" + #> $ `quality measure score 10` "" + #> $ `promoting interoperability (pi) category score` "0" + #> $ `extreme hardship pi` "True" + #> $ `pi hardship` "False" + #> $ `pi reweighting` "False" + #> $ `pi bonus` "False" + #> $ `pi cehrt id` "" + #> $ `pi measure id 1` "" + #> $ `pi measure score 1` "" + #> $ `pi measure id 2` "" + #> $ `pi measure score 2` "" + #> $ `pi measure id 3` "" + #> $ `pi measure score 3` "" + #> $ `pi measure id 4` "" + #> $ `pi measure score 4` "" + #> $ `pi measure id 5` "" + #> $ `pi measure score 5` "" + #> $ `pi measure id 6` "" + #> $ `pi measure score 6` "" + #> $ `pi measure id 7` "" + #> $ `pi measure score 7` "" + #> $ `pi measure id 8` "" + #> $ `pi measure score 8` "" + #> $ `pi measure id 9` "" + #> $ `pi measure score 9` "" + #> $ `pi measure id 10` "" + #> $ `pi measure score 10` "" + #> $ `pi measure id 11` "" + #> $ `pi measure score 11` "" + #> $ `ia score` "0" + #> $ `extreme hardship ia` "True" + #> $ `ia study` "False" + #> $ `ia measure id 1` "" + #> $ `ia measure score 1` "" + #> $ `ia measure id 2` "" + #> $ `ia measure score 2` "" + #> $ `ia measure id 3` "" + #> $ `ia measure score 3` "" + #> $ `ia measure id 4` "" + #> $ `ia measure score 4` "" + #> $ `cost score` "0" + #> $ `extreme hardship cost` "True" + #> $ `cost measure id 1` "" + #> $ `cost measure score 1` "" + #> $ `cost measure id 2` "" + #> $ `cost measure score 2` "" ### `quality_eligibility()` ``` r -quality_eligibility(year = 2021, - npi = 1932365699) |> +quality_eligibility( + year = 2024, + npi = 1932365699, + tidy = FALSE, + unnest = FALSE, + pivot = FALSE, + na.rm = FALSE) |> glimpse() ``` #> Rows: 1 - #> Columns: 30 - #> $ year 2021 - #> $ npi "1932365699" - #> $ npi_type Individual - #> $ first "STEFAN" - #> $ middle "MICHAEL" - #> $ last "SMITH" - #> $ first_approved_date 2008-11-15 - #> $ years_in_medicare 13 - #> $ newly_enrolled FALSE - #> $ specialty_desc "Optometry" - #> $ specialty_type "Doctor of Optometry" - #> $ specialty_cat "Physicians" - #> $ is_maqi FALSE - #> $ org_id 1 - #> $ org_name "LEE ANN HOVEN OD PC" - #> $ org_hosp_vbp_name NA - #> $ org_facility_based FALSE - #> $ org_address "ADVANCED EYE CARE 1165S CAMINO DEL RIO SUITE 100" - #> $ org_city "DURANGO" - #> $ org_state CO - #> $ org_zip "81303" - #> $ ind_lvt_status_code "BOTH" - #> $ ind_lvt_status_desc "Both the unique beneficiaries and Part B" - #> $ ind_hosp_vbp_score 0 - #> $ ind_specialty_code "41" - #> $ ind_specialty_desc "Optometry" - #> $ ind_specialty_type "Doctor of Optometry" - #> $ ind_specialty_cat "Physicians" - #> $ ind_status [] - #> $ grp_status [] + #> Columns: 13 + #> $ year "2024" + #> $ firstName "STEFAN" + #> $ middleName "MICHAEL" + #> $ lastName "SMITH" + #> $ npi "1932365699" + #> $ nationalProviderIdentifierType 1 + #> $ firstApprovedDate "2008-11-15" + #> $ yearsInMedicare 16 + #> $ pecosEnrollmentDate 2008 + #> $ newlyEnrolled FALSE + #> $ specialty + #> $ isMaqi FALSE + #> $ organizations [] ### `reassignments()` ``` r -reassignments(npi = 1932365699, - pac_org = 7719037548) |> +reassignments( + npi = 1932365699, + pac_org = 7719037548) |> glimpse() ``` @@ -640,15 +638,16 @@ reassignments(npi = 1932365699, ### `utilization()` ``` r -utilization(year = 2021, - npi = 1932365699, - type = "Provider") |> +utilization( + year = 2022, + npi = 1932365699, + type = "Provider") |> glimpse() ``` #> Rows: 1 #> Columns: 20 - #> $ year 2021 + #> $ year 2022 #> $ npi "1932365699" #> $ entity_type Individual #> $ first "Stefan" @@ -670,76 +669,21 @@ utilization(year = 2021, #> $ conditions [] ``` r -p <- utilization(year = 2021, - npi = 1932365699, - type = "Provider") - -select(p, year, performance) |> - unnest(performance) |> - glimpse() -``` - - #> Rows: 1 - #> Columns: 12 - #> $ year 2021 - #> $ tot_hcpcs 19 - #> $ tot_benes 279 - #> $ tot_srvcs 475 - #> $ tot_charges 57098.8 - #> $ tot_allowed 48345.19 - #> $ tot_payment 31966.13 - #> $ tot_std_pymt 31316.51 - #> $ .copay_deduct 16379.06 - #> $ .srvcs_per_bene 1.702509 - #> $ .pymt_per_bene 114.5739 - #> $ .pymt_per_srvc 67.29712 - -``` r -select(p, year, demographics) |> - unnest(demographics) |> - glimpse() -``` - - #> Rows: 1 - #> Columns: 13 - #> $ year 2021 - #> $ bene_age_avg 72 - #> $ bene_age_lt65 16 - #> $ bene_age_65_74 181 - #> $ bene_age_75_84 63 - #> $ bene_age_gt84 19 - #> $ bene_gen_female 157 - #> $ bene_gen_male 122 - #> $ bene_race_wht 245 - #> $ bene_race_nonwht 34 - #> $ bene_dual 40 - #> $ bene_ndual 239 - #> $ bene_race_detailed [] - -``` r -select(p, year, conditions) |> - unnest(conditions) |> - glimpse() -``` - - #> Rows: 1 - #> Columns: 2 - #> $ year 2021 - #> $ hcc_risk_avg 0.7719 - -``` r -utilization(year = 2021, - npi = 1932365699, - hcpcs = "99214", - type = "Service") |> +utilization( + year = 2022, + npi = 1932365699, + hcpcs = "99214", + type = "Service", + rbcs = FALSE) |> glimpse() ``` #> Rows: 1 - #> Columns: 32 - #> $ year 2021 + #> Columns: 29 + #> $ year 2022 #> $ npi "1932365699" #> $ level Provider + #> $ entity_type "I" #> $ first "Stefan" #> $ middle "M" #> $ last "Smith" @@ -755,51 +699,45 @@ utilization(year = 2021, #> $ country "US" #> $ par TRUE #> $ hcpcs "99214" - #> $ hcpcs_desc "Established patient outpatient visit, total time 30-39 m… - #> $ category "E&M" - #> $ subcategory "Office/Outpatient Services" - #> $ family "Office E&M - Established" - #> $ procedure Non-procedure + #> $ hcpcs_desc "Established patient office or other outpatient visit, 30… #> $ drug FALSE #> $ pos Non-facility - #> $ tot_benes 24 - #> $ tot_srvcs 27 - #> $ tot_day 27 - #> $ avg_charge 134.7407 - #> $ avg_allowed 132.7281 - #> $ avg_payment 102.7159 - #> $ avg_std_pymt 99.46074 + #> $ tot_benes 38 + #> $ tot_srvcs 46 + #> $ tot_day 46 + #> $ avg_charge 135 + #> $ avg_allowed 130.6146 + #> $ avg_payment 80.1337 + #> $ avg_std_pymt 78.30435 ``` r -utilization(year = 2021, - hcpcs = "99205", - level = "National", - pos = "F", - type = "Geography") |> +utilization( + year = 2022, + hcpcs = "99205", + level = "National", + pos = "F", + type = "Geography", + rbcs = FALSE) |> glimpse() ``` #> Rows: 1 - #> Columns: 19 - #> $ year 2021 + #> Columns: 15 + #> $ year 2022 #> $ level National #> $ state National #> $ hcpcs "99205" - #> $ hcpcs_desc "New patient outpatient visit, total time 60-74 minutes" - #> $ category "E&M" - #> $ subcategory "Office/Outpatient Services" - #> $ family "Office E&M - New" - #> $ procedure Non-procedure + #> $ hcpcs_desc "New patient office or other outpatient visit, 60-74 minu… #> $ drug FALSE #> $ pos Facility - #> $ tot_provs 65502 - #> $ tot_benes 574426 - #> $ tot_srvcs 653339 - #> $ tot_day 653311 - #> $ avg_charge 493.5003 - #> $ avg_allowed 186.2096 - #> $ avg_payment 143.4408 - #> $ avg_std_pymt 139.6115 + #> $ tot_provs 67438 + #> $ tot_benes 589940 + #> $ tot_srvcs 672234 + #> $ tot_day 672211 + #> $ avg_charge 506.3615 + #> $ avg_allowed 183.1025 + #> $ avg_payment 139.1145 + #> $ avg_std_pymt 137.0229 ------------------------------------------------------------------------ diff --git a/man/years.Rd b/man/years.Rd index 6bc6e45..76a88b5 100644 --- a/man/years.Rd +++ b/man/years.Rd @@ -43,9 +43,6 @@ open_years() # `utilization()` util_years() -# `conditions()` -# cc_years() - # `quality_payment()` qpp_years() diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index f8f5da7..1e526d9 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -101,7 +101,7 @@ test_that("tidyup() works", { star = NA_character_, dash = NA_character_, lgl = TRUE, - zip = "81303-1234") + zip = "813031234") tidy2 <- tidy tidy2$date <- lubridate::mdy("03/07/1981")