diff --git a/NAMESPACE b/NAMESPACE index 301b49b..3333203 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,23 +1,18 @@ # Generated by roxygen2: do not edit by hand -export(add_counties) export(affiliations) +export(api_names) export(bene_years) export(beneficiaries) export(betos) -export(change) -export(chg) export(clinicians) export(compare_hcpcs) -export(datasets) export(df2chr) export(display_long) export(distros_dac) export(distros_main) export(distros_open) -export(duration_vec) export(gen_data) -export(geomean) export(get_pin) export(gt_check_xmark) export(gt_datadict) @@ -28,7 +23,6 @@ export(hospitals) export(laboratories) export(last_dttm) export(list_pins) -export(make_interval) export(medline) export(mount_board) export(ndc_lookup) @@ -40,7 +34,6 @@ export(opt_out) export(order_refer) export(out_years) export(outpatient) -export(pct) export(pending) export(prescribers) export(prescribers_) @@ -51,17 +44,13 @@ export(quality_eligibility_) export(quality_payment) export(quality_payment_) export(reassignments) -export(ror) export(rx_years) export(rxnorm) -export(summary_stats) export(taxonomy_crosswalk) export(tidyup) export(util_years) export(utilization) export(utilization_) -export(years_df) -export(years_vec) import(rlang) importFrom(collapse,"%=%") importFrom(collapse,"%==%") diff --git a/R/calculations.R b/R/calculations.R index 4a1ad34..03dfb44 100644 --- a/R/calculations.R +++ b/R/calculations.R @@ -2,7 +2,7 @@ #' #' @description Common utility functions #' -#' @examples +#' @examplesIf FALSE #' ex <- gen_data(2020:2025) #' head(ex) #' diff --git a/R/cms.R b/R/cms.R index a231662..8887e84 100644 --- a/R/cms.R +++ b/R/cms.R @@ -265,5 +265,5 @@ api_years <- function(abb, year) { api <- cms_update(api) - fuimus::search_in(api, api[["year"]], year) + search_in(api, api[["year"]], year) } diff --git a/R/format_api_params.R b/R/format_api_params.R index af8fea8..bb7005c 100644 --- a/R/format_api_params.R +++ b/R/format_api_params.R @@ -191,5 +191,5 @@ api_years2 <- function(abb, year) { api <- cms_update(api) - fuimus::search_in(api, api[["year"]], year) + search_in(api, api[["year"]], year) } diff --git a/R/generated-globals.R b/R/generated-globals.R index 68605d4..7f4ad0d 100644 --- a/R/generated-globals.R +++ b/R/generated-globals.R @@ -9,6 +9,8 @@ utils::globalVariables(c( "a2la", # "aabb", + # + "abb", # "accredited", # @@ -122,8 +124,6 @@ utils::globalVariables(c( "confirmed_date", # "copy", - # - "county_fips", # "covered", # @@ -308,8 +308,6 @@ utils::globalVariables(c( "organizations_individualScenario", # "organizations_virtualGroups", - # - "params", # "participation_type", # @@ -371,7 +369,6 @@ utils::globalVariables(c( "specialty", # "star_value", - # # # # @@ -481,7 +478,5 @@ utils::globalVariables(c( # # "year", - # - "zip", NULL )) diff --git a/R/utils.R b/R/utils.R index 4c1347f..4696c99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -210,7 +210,7 @@ tidyup <- function(df, if (!is.null(chr)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(chr), as.character)) if (!is.null(up)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(up), toupper)) if (!is.null(cred)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(cred), clean_credentials)) - if (!is.null(zip)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(zip), zipcodeR::normalize_zip)) + if (!is.null(zip)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(zip), format_zipcode)) if (!is.null(lgl)) x <- dplyr::mutate(x, dplyr::across(dplyr::contains(lgl), as.logical)) return(x) diff --git a/man/add_counties.Rd b/man/add_counties.Rd deleted file mode 100644 index 9fffe2f..0000000 --- a/man/add_counties.Rd +++ /dev/null @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add_counties.R -\name{add_counties} -\alias{add_counties} -\title{Add county name, FIPs, and geometry to data frame with zip codes} -\usage{ -add_counties( - df, - statecol, - zipcol, - add_fips = FALSE, - add_geo = FALSE, - as_sf = FALSE -) -} -\arguments{ -\item{df}{data frame} - -\item{statecol}{bare column name column containing state abbreviations} - -\item{zipcol}{bare column name containing zip codes} - -\item{add_fips}{add county FIPS code column, default is \code{FALSE}} - -\item{add_geo}{add county geometry column, default is \code{FALSE}} - -\item{as_sf}{convert tibble to an \code{{sf}} object, default is \code{FALSE}} -} -\description{ -Add county name, FIPs, and geometry to data frame with zip codes -} -\examples{ -# Example data frame containing -# state abbreviation and zip code - -(ex <- dplyr::tibble(state = "GA", zip = "31605")) - -# Add county and latitude/longitude -ex |> add_counties(state, zip) - -# Add county FIPS -ex |> add_counties(state, zip, add_fips = TRUE) - -# Add county `geometry` column, -# based on county FIPS column -ex |> add_counties(state, zip, add_fips = TRUE, add_geo = TRUE) - -# Convert to an `sf` object -ex |> add_counties(state, zip, add_fips = TRUE, add_geo = TRUE, as_sf = TRUE) - -} diff --git a/man/api_names.Rd b/man/api_names.Rd new file mode 100644 index 0000000..1dfd777 --- /dev/null +++ b/man/api_names.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/format_api_params.R +\name{api_names} +\alias{api_names} +\title{CMS API Dataset Names Lookup} +\usage{ +api_names(fn_name) +} +\arguments{ +\item{fn_name}{\verb{} function name, can be a regex pattern} +} +\value{ +\verb{} API dataset name +} +\description{ +CMS API Dataset Names Lookup +} +\examples{ +api_names("quality_payment") + +api_names("utilization") + +api_names("provider") + +api_names("provider$") + +} +\keyword{internal} diff --git a/man/calculations.Rd b/man/calculations.Rd index 5153d1b..bab5cbd 100644 --- a/man/calculations.Rd +++ b/man/calculations.Rd @@ -2,79 +2,12 @@ % Please edit documentation in R/calculations.R \name{calculations} \alias{calculations} -\alias{change} -\alias{chg} -\alias{pct} -\alias{ror} -\alias{geomean} -\alias{years_df} -\alias{years_vec} -\alias{duration_vec} -\alias{make_interval} -\alias{summary_stats} \alias{gen_data} \title{Utility Functions} \usage{ -change(df, cols, csm = NULL, digits = 5) - -chg(x, n = 1L, fill_na = 0L) - -pct(x, n = 1L, fill_na = 0L) - -ror(df, col, n = 1L) - -geomean(x) - -years_df(df, date_col) - -years_vec(date_col) - -duration_vec(date_col) - -make_interval(df, start, end = lubridate::today()) - -summary_stats( - df, - condition = NULL, - group_vars = NULL, - summary_vars = NULL, - arr = NULL, - digits = 3 -) - gen_data(years) } \arguments{ -\item{df}{data frame} - -\item{cols}{numeric columns to calculate absolute/relative change & rate of return} - -\item{csm}{numeric cols to calculate cumulative sum for} - -\item{digits}{Number of digits to round to, default is 3} - -\item{x}{numeric vector} - -\item{n}{values to offset} - -\item{fill_na}{fill value for any NAs; default is 0} - -\item{col}{numeric column} - -\item{date_col}{date column} - -\item{start}{start date column} - -\item{end}{end date column} - -\item{condition}{filter condition, i.e. \code{patient == "new"}} - -\item{group_vars}{variables to group by, i.e. \code{c(specialty, state, hcpcs, cost)}} - -\item{summary_vars}{variables to summarise, i.e. \code{c(min, max, mode, range)}} - -\item{arr}{column to arrange data by, i.e. \code{cost}} - \item{years}{sequence of years, e.g. \code{2010:2020}} } \value{ @@ -86,16 +19,16 @@ tibble Common utility functions } \examples{ -# Example data +\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} ex <- gen_data(2020:2025) head(ex) -# Lagged absolute/percentage change, rate of return and cumulative sum -# `change()` +# Lagged absolute/percentage change, +# rate of return and cumulative sum dplyr::filter(ex, group == "A") |> change(pay) -# `geomean()` # Geometric mean +# Geometric mean ex |> dplyr::filter(group == "A") |> ror(pay) |> @@ -143,50 +76,6 @@ summary_stats(sm, group_vars = provider, summary_vars = c(charges, payment), arr = provider) - -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::filter(ex, group == "A") |> -change(pay) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::filter(ex, group == "A") |> -dplyr::mutate(change = chg(pay)) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::filter(ex, group == "A") |> -dplyr::mutate(pct_change = pct(pay)) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::filter(ex, group == "A") |> -ror(pay) - -ex |> -dplyr::group_by(group) |> -ror(pay) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::filter(ex, group == "A") |> -ror(pay) |> -dplyr::summarise(gmean = geomean(pay_ror)) - -ex |> -dplyr::group_by(group) |> -ror(pay) |> -dplyr::summarise(gmean = geomean(pay_ror)) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dt <- dplyr::tibble(date = lubridate::today() - 366) -dplyr::mutate(dt, years = years_vec(date)) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dplyr::tibble(date = lubridate::today() - 366, - date2 = date - 789) |> -dplyr::mutate(dur = duration_vec(date), - dur2 = duration_vec(date2)) -\dontshow{\}) # examplesIf} -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -dt <- dplyr::tibble(date = lubridate::today() - 366) -make_interval(dt, start = date) \dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/datasets.Rd b/man/datasets.Rd deleted file mode 100644 index 7fd1f5b..0000000 --- a/man/datasets.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zzz.R -\name{datasets} -\alias{datasets} -\title{CMS Dataset Distribution Names} -\usage{ -datasets() -} -\value{ -description -} -\description{ -CMS Dataset Distribution Names -} -\keyword{internal} diff --git a/man/distros_main.Rd b/man/distros_main.Rd index 80d6ac3..0e9f165 100644 --- a/man/distros_main.Rd +++ b/man/distros_main.Rd @@ -4,7 +4,7 @@ \alias{distros_main} \title{Main CMS Distributions} \usage{ -distros_main(datasets = datasets()) +distros_main(datasets = api_names("main")) } \arguments{ \item{datasets}{character vector of dataset names} diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 23a15a6..f8f5da7 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") + zip = "81303-1234") tidy2 <- tidy tidy2$date <- lubridate::mdy("03/07/1981")