Skip to content

Commit

Permalink
quality_eligibility() function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Nov 14, 2023
1 parent aeb0b12 commit a79ae5c
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 52 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export(pct)
export(pending)
export(providers)
export(qpp_years)
export(quality_eligibility)
export(quality_payment)
export(quality_payment_)
export(reassignments)
Expand Down
3 changes: 2 additions & 1 deletion R/affiliations.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ affiliations <- function(npi = NULL,

}
if (tidy) {
results <- cols_aff(tidyup(results)) |> dplyr::mutate(facility_type = fct_fac(facility_type))
results <- cols_aff(tidyup(results)) |>
dplyr::mutate(facility_type = fct_fac(facility_type))
if (na.rm) results <- narm(results)
}
return(results)
Expand Down
2 changes: 1 addition & 1 deletion R/clinicians.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ clinicians <- function(npi = NULL,
"state", state,
"zip_code", zip)

error_body <- function(response) {httr2::resp_body_json(response)$message}
error_body <- function(response) httr2::resp_body_json(response)$message

response <- httr2::request(file_url("c", args, offset)) |>
httr2::req_error(body = error_body) |>
Expand Down
31 changes: 16 additions & 15 deletions R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,22 @@ utils::globalVariables(c(
"y", # <outpatient>
"y", # <pending>
"y", # <providers>
"apms", # <quality_eligibility>
"individual_scenario", # <quality_eligibility>
"group_scenario", # <quality_eligibility>
"apms.extremeHardshipReasons", # <quality_eligibility>
"apms.qpPatientScores", # <quality_eligibility>
"apms.qpPaymentScores", # <quality_eligibility>
"individual_scenario.extremeHardshipReasons", # <quality_eligibility>
"individual_scenario.lowVolumeStatusReasons", # <quality_eligibility>
"individual_scenario.specialty", # <quality_eligibility>
"individual_scenario.isEligible", # <quality_eligibility>
"group_scenario.extremeHardshipReasons", # <quality_eligibility>
"group_scenario.lowVolumeStatusReasons", # <quality_eligibility>
"group_scenario.isEligible", # <quality_eligibility>
"individual_scenario.lowVolumeStatusReasons_1", # <quality_eligibility>
"group_scenario.lowVolumeStatusReasons_1", # <quality_eligibility>
"y", # <quality_eligibility>
"apms", # <quality_eligibility2>
"individual_scenario", # <quality_eligibility2>
"group_scenario", # <quality_eligibility2>
"apms.extremeHardshipReasons", # <quality_eligibility2>
"apms.qpPatientScores", # <quality_eligibility2>
"apms.qpPaymentScores", # <quality_eligibility2>
"individual_scenario.extremeHardshipReasons", # <quality_eligibility2>
"individual_scenario.lowVolumeStatusReasons", # <quality_eligibility2>
"individual_scenario.specialty", # <quality_eligibility2>
"individual_scenario.isEligible", # <quality_eligibility2>
"group_scenario.extremeHardshipReasons", # <quality_eligibility2>
"group_scenario.lowVolumeStatusReasons", # <quality_eligibility2>
"group_scenario.isEligible", # <quality_eligibility2>
"individual_scenario.lowVolumeStatusReasons_1", # <quality_eligibility2>
"group_scenario.lowVolumeStatusReasons_1", # <quality_eligibility2>
"y", # <mips_2021>
"org_pac_id", # <mips_2021>
"aco_id_1", # <mips_2021>
Expand Down
11 changes: 6 additions & 5 deletions R/open_payments.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ open_payments <- function(year,
combine(address,
c('recipient_primary_business_street_address_line1',
'recipient_primary_business_street_address_line2')) |>
cols_open() |>
narm()
cols_open()

## ------------------------------------------------------------------------
if (pivot) {
pcol <- c(paste0('name_', 1:5),
paste0('covered_', 1:5),
Expand All @@ -265,7 +265,7 @@ open_payments <- function(year,
paste0('pdi_', 1:5))

results <- results |>
dplyr::mutate(id = dplyr::row_number(), .before = name_1) |>
dplyr::mutate(top_id = dplyr::row_number(), .before = name_1) |>
tidyr::pivot_longer(
cols = dplyr::any_of(pcol),
names_to = c("attr", "group"),
Expand All @@ -282,6 +282,7 @@ open_payments <- function(year,
pay_total = dplyr::if_else(group > 1, NA, pay_total))

if (rlang::has_name(results, "pdi")) results$pdi <- dplyr::na_if(results$pdi, "N/A")
## ------------------------------------------------------------------------
}
if (na.rm) results <- narm(results)
}
Expand All @@ -291,12 +292,12 @@ open_payments <- function(year,
#' Parallelized [open_payments()]
#' @param year < *integer* > // **required** Year data was reported, in `YYYY`
#' format. Run [open_years()] to return a vector of the years currently available.
#' @param na.rm < *boolean* > // __default:__ `TRUE` Remove empty rows and columns
#' @param na.rm < *boolean* > // __default:__ `FALSE` Remove empty rows and columns
#' @param ... Pass arguments to [open_payments()].
#' @autoglobal
#' @export
open_payments_ <- function(year = open_years(),
na.rm = TRUE,
na.rm = FALSE,
...) {
results <- furrr::future_map_dfr(year,
open_payments,
Expand Down
Loading

0 comments on commit a79ae5c

Please sign in to comment.