Skip to content

Commit

Permalink
* removed chronic conditions functions, as their endpoints have disap…
Browse files Browse the repository at this point in the history
…peared
  • Loading branch information
andrewallenbruce committed Jul 21, 2024
1 parent bb7831e commit ad6a8a8
Show file tree
Hide file tree
Showing 22 changed files with 653 additions and 874 deletions.
7 changes: 3 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Package: provider
Title: Access Public Healthcare Provider Data
Version: 0.0.1
Authors@R:
person("Andrew", "Bruce", , "andrew.bruce@northstarrevenueintegrity.com", role = c("aut", "cre", "cph"))
Maintainer: Andrew Bruce <andrew.bruce@northstarrevenueintegrity.com>
person("Andrew", "Bruce", , "andrewallenbruce@gmail.com", role = c("aut", "cre", "cph"))
Maintainer: Andrew Bruce <andrewallenbruce@gmail.com>
Description: Provides various features to facilitate easy access to
publicly available healthcare provider data. Includes functions to
tidy the data being accessed, whether for reporting purposes or
Expand Down Expand Up @@ -75,7 +75,6 @@ Remotes:
github::andrewallenbruce/fuimus,
github::anthonynorth/roxyglobals,
github::nt-williams/rxnorm,
github::rstudio/gt,
github::yutannihilation/ggsflabel
Config/roxyglobals/filename: generated-globals.R
Config/roxyglobals/unique: TRUE
Expand All @@ -86,4 +85,4 @@ Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE, roclets = c("collate", "namespace", "rd",
"roxyglobals::global_roclet"))
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ export(affiliations)
export(bene_years)
export(beneficiaries)
export(betos)
export(cc_years)
export(change)
export(chg)
export(clinicians)
export(compare_conditions)
export(compare_hcpcs)
export(conditions)
export(df2chr)
export(display_long)
export(duration_vec)
Expand Down
10 changes: 8 additions & 2 deletions R/cms.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#' Update CMS.gov API distribution IDs
#'
#' @param api name of the api
#'
#' @param check `"base"`, `"id"`, or `"years"`, default is `"id"`
#'
#' @return A [tibble()] containing the updated ids.
#'
#' @examplesIf interactive()
#' cms_update("Provider of Services File - Clinical Laboratories", "base")
#' cms_update("Provider of Services File - Clinical Laboratories", "id")
#' cms_update("Provider of Services File - Clinical Laboratories", "years")
#'
#' @autoglobal
#'
#' @noRd
cms_update <- function(api, check = "id") {

Expand Down Expand Up @@ -239,8 +245,8 @@ api_years <- function(fn) {
"rxp" ~ "Medicare Part D Prescribers - by Provider",
"outps" ~ "Medicare Outpatient Hospitals - by Provider and Service",
"outgs" ~ "Medicare Outpatient Hospitals - by Geography and Service",
"scc" ~ "Specific Chronic Conditions",
"mcc" ~ "Multiple Chronic Conditions",
# "scc" ~ "Specific Chronic Conditions",
# "mcc" ~ "Multiple Chronic Conditions",
"qpp" ~ "Quality Payment Program Experience",
.default = NULL)

Expand Down
111 changes: 5 additions & 106 deletions R/compare.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
#' Compare Provider Performance
#'
#' @description
#'
#' + `compare_hcpcs()` allows the user to compare a provider's yearly HCPCS
#' `compare_hcpcs()` allows the user to compare a provider's yearly HCPCS
#' utilization data to state and national averages
#'
#' + `compare_conditions()` allows the user to compare the average yearly
#' prevalence of chronic conditions among a provider's patient mix to state and
#' national averages
#'
#' @return A [tibble][tibble::tibble-package] containing:
#' + `compare_hcpcs()`
#' + `compare_conditions()`
#' @name compare
NULL

#' @param df < *tbl_df* > // **required**
#'
#' [tibble()] returned from `utilization(type = "Service")`
#' [tibble][tibble::tibble-package] returned from `utilization(type = "Service")`
#'
#' @examplesIf interactive()
#' @returns A [tibble][tibble::tibble-package]
#'
#' @examplesIf interactive()
#' compare_hcpcs(utilization(year = 2018,
#' type = "Service",
#' npi = 1023076643))
Expand All @@ -30,8 +19,8 @@ NULL
#' type = "Service")) |>
#' compare_hcpcs()
#'
#' @rdname compare
#' @autoglobal
#'
#' @export
compare_hcpcs <- function(df) {

Expand Down Expand Up @@ -91,93 +80,3 @@ hcpcs_cols <- function(df) {

df |> dplyr::select(dplyr::any_of(cols))
}

#' @param df < *tbl_df* > // **required** [tibble()] returned from `utilization(type = "Provider")`
#'
#' @param pivot < *boolean* > // __default:__ `FALSE` Pivot output
#'
#' @rdname compare
#'
#' @examplesIf interactive()
#'
#' compare_conditions(utilization(year = 2018,
#' type = "Provider",
#' npi = 1023076643))
#'
#' map_dfr(util_years(), ~utilization(year = .x,
#' npi = 1023076643,
#' type = "Provider")) |>
#' compare_conditions()
#'
#' @autoglobal
#' @export
compare_conditions <- function(df, pivot = FALSE) {

if (!inherits(df, "utilization_provider")) {
cli::cli_abort(c(
"{.var df} must be of class {.cls 'utilization_provider'}.",
"x" = "{.var df} is of class {.cls {class(df)}}."))
}
#########################
x <- dplyr::select(df, year, sublevel = state, conditions) |>
tidyr::unnest(conditions) |>
dplyr::mutate(hcc_risk_avg = NULL, level = "Provider", .after = year) |>
cnd_rename() |>
tidyr::pivot_longer(cols = !c(year, level, sublevel),
names_to = "condition",
values_to = "prevalence") |>
dplyr::filter(!is.na(prevalence), year %in% cc_years())

y <- dplyr::select(x, year, condition, sublevel)

y$set <- "Specific"
y$demo <- "All"
y$subdemo <- "All"
y$age <- "All"
y
state <- y
national <- y
national$sublevel <- "National"

req <- vctrs::vec_rbind(state, national)

res <- furrr::future_pmap_dfr(req, conditions,
.options = furrr::furrr_options(seed = NULL))

res <- dplyr::select(res, year, level, condition, prevalence)
x$sublevel <- NULL
results <- vctrs::vec_rbind(x, res)
results$level <- fct_level(results$level)
results$condition <- fct_cc(results$condition)
#######################
if (pivot) {
results <- tidyr::pivot_wider(results,
names_from = c(year, level),
values_from = prevalence)
}
return(results)
}

#' @param df data frame
#' @autoglobal
#' @noRd
cnd_rename <- function(df) {
cols <- c('Atrial Fibrillation' = 'cc_af',
"Alzheimer's Disease/Dementia" = 'cc_alz',
'Asthma' = 'cc_asth',
'Cancer' = 'cc_canc',
'Heart Failure' = 'cc_chf',
'Chronic Kidney Disease' = 'cc_ckd',
'COPD' = 'cc_copd',
'Depression' = 'cc_dep',
'Diabetes' = 'cc_diab',
'Hyperlipidemia' = 'cc_hplip',
'Hypertension' = 'cc_hpten',
'Ischemic Heart Disease' = 'cc_ihd',
'Osteoporosis' = 'cc_opo',
'Arthritis' = 'cc_raoa',
'Schizophrenia and Other Psychotic Disorders' = 'cc_sz',
'Stroke' = 'cc_strk')

df |> dplyr::rename(dplyr::any_of(cols))
}
13 changes: 0 additions & 13 deletions R/generated-globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ utils::globalVariables(c(
"cola",
# <mips_2021>
"collection_type",
# <compare_conditions>
"condition",
# <laboratories>
"confirmed",
# <laboratories>
Expand Down Expand Up @@ -164,8 +162,6 @@ utils::globalVariables(c(
"definition",
# <gt_datadict>
"Definition",
# <conditions>
"demographic",
# <meta.json>
"describedBy",
# <cms_dataset_search>
Expand Down Expand Up @@ -225,7 +221,6 @@ utils::globalVariables(c(
# <cms_update>
# <meta.json>
"distribution_title",
# <conditions>
# <outpatient>
# <prescribers>
# <quality_payment>
Expand Down Expand Up @@ -323,7 +318,6 @@ utils::globalVariables(c(
# <meta.json>
"landingPage",
# <compare_hcpcs>
# <compare_conditions>
# <tidyup_geography.rx>
# <tidyup_drug.rx>
# <tidyup_service.util>
Expand Down Expand Up @@ -414,8 +408,6 @@ utils::globalVariables(c(
"pos",
# <nppes>
"pr",
# <compare_conditions>
"prevalence",
# <mips_2021>
"prf_rate",
# <rbcs_util>
Expand Down Expand Up @@ -481,7 +473,6 @@ utils::globalVariables(c(
# <tidyup_service.util>
"state",
# <beneficiaries>
# <conditions>
# <prescribers>
# <utilization>
# <fct_stabb>
Expand All @@ -507,8 +498,6 @@ utils::globalVariables(c(
"subgroup_general",
# <hospitals>
"subgroup_other",
# <compare_conditions>
"sublevel",
# <hospitals>
"subtotal",
# <medline>
Expand Down Expand Up @@ -569,7 +558,6 @@ utils::globalVariables(c(
# <beneficiaries>
# <betos>
# <clinicians>
# <conditions>
# <hospitals>
# <laboratories>
# <mips_2021>
Expand All @@ -592,7 +580,6 @@ utils::globalVariables(c(
# <change_year>
# <cms_update>
# <compare_hcpcs>
# <compare_conditions>
# <open_ids>
# <cols_qelig>
"year",
Expand Down
Loading

0 comments on commit ad6a8a8

Please sign in to comment.