diff --git a/DESCRIPTION b/DESCRIPTION index 4bccb7bb..33e4f3e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,6 @@ Depends: Imports: anytime, cli, - dint, dplyr, furrr, httr2, diff --git a/R/beneficiaries.R b/R/beneficiaries.R index 9a8efeda..c15203e0 100644 --- a/R/beneficiaries.R +++ b/R/beneficiaries.R @@ -147,7 +147,7 @@ beneficiaries <- function(year = NULL, results <- httr2::resp_body_json(response, simplifyVector = TRUE) - if (tidy) results <- cols_bene(tidyup(results, int = c("year", "_benes"), yr = 'year')) + if (tidy) results <- cols_bene(tidyup(results, int = c('year', '_benes'))) if (!is.null(period) && period == "Month") results <- dplyr::filter(results, period %in% month.name) return(results) diff --git a/R/conditions.R b/R/conditions.R index 5b6b71f6..fe3db5b4 100644 --- a/R/conditions.R +++ b/R/conditions.R @@ -207,8 +207,7 @@ conditions <- function(year, results$year <- year results <- cols_cc(tidyup(results, int = "year", - dbl = c("prvlnc", "_pc", "er_"), - yr = "year")) + dbl = c("prvlnc", "_pc", "er_"))) if (na.rm) {results <- narm(results)}} return(results) } diff --git a/R/open_payments.R b/R/open_payments.R index baf43990..5fbe480b 100644 --- a/R/open_payments.R +++ b/R/open_payments.R @@ -240,8 +240,7 @@ open_payments <- function(year, results <- tidyup(results, # yn = c(yncols), dbl = "dollars", - int = "program_year", - yr = "program_year") |> + int = "program_year") |> dplyr::mutate(change_type = changed_logical(change_type), covered_recipient_type = covered_recipient(covered_recipient_type), nature_of_payment_or_transfer_of_value = nature(nature_of_payment_or_transfer_of_value)) |> diff --git a/R/outpatient.R b/R/outpatient.R index 73e5985a..c85d5c0a 100644 --- a/R/outpatient.R +++ b/R/outpatient.R @@ -96,8 +96,7 @@ outpatient <- function(year, dbl = c('avg_tot_sbmtd_chrgs', 'avg_mdcr_alowd_amt', 'avg_mdcr_pymt_amt', - 'avg_mdcr_outlier_amt'), - yr = 'year') |> + 'avg_mdcr_outlier_amt')) |> cols_out() if (na.rm) results <- narm(results) } diff --git a/R/quality_payment.R b/R/quality_payment.R index 04e8f4e8..fc6d54d7 100644 --- a/R/quality_payment.R +++ b/R/quality_payment.R @@ -141,8 +141,8 @@ quality_payment <- function(year, "pi_bonus", "extreme_hardship_ia", "ia_study", - "extreme_hardship_cost"), - yr = 'year') |> cols_qpp("tidy") + "extreme_hardship_cost")) |> + cols_qpp("tidy") if (nest) { pcol <- list(q = c('quality_measure_id_', 'quality_measure_score_') %s+% rep(1:10, each = 2), diff --git a/R/utilization.R b/R/utilization.R index 0b8b13a6..a2b2e3b8 100644 --- a/R/utilization.R +++ b/R/utilization.R @@ -278,8 +278,7 @@ tidyup_provider <- function(results, nest, detailed) { int = c("year", "_hcpcs", "bene", "_srvcs"), dbl = c("pay", "pymt", "charges", "allowed", "cc_", "hcc"), cred = "credential", - ent = "entity_type", - yr = 'year') |> + ent = "entity_type") |> combine(address, c('rndrng_prvdr_st1', 'rndrng_prvdr_st2')) |> dplyr::mutate(specialty = correct_specialty(specialty), .copay_deduct = tot_allowed - tot_payment, @@ -318,8 +317,7 @@ tidyup_service <- function(results, rbcs) { results <- tidyup(results, yn = "_ind", int = c("year", "tot_"), - dbl = "avg_", - yr = 'year') |> + dbl = "avg_") |> combine(address, c('rndrng_prvdr_st1', 'rndrng_prvdr_st2')) |> cols_util("service") |> dplyr::mutate(specialty = correct_specialty(specialty)) @@ -339,8 +337,7 @@ tidyup_geography <- function(results, rbcs) { results <- tidyup(results, yn = "_ind", int = c("year", "tot_"), - dbl = "avg_", - yr = 'year') |> + dbl = "avg_") |> dplyr::mutate(place_of_srvc = pos_char(place_of_srvc)) |> cols_util("geography") diff --git a/R/utils.R b/R/utils.R index 79b4f0bd..0db51515 100644 --- a/R/utils.R +++ b/R/utils.R @@ -159,7 +159,6 @@ df2chr <- function(df) { #' @param up cols to convert to upper case #' @param cred cols to remove periods from #' @param ent cols to convert to NPI entity type -#' @param yr cols to convert to year with [dint::as_date_y()] #' @returns tidy data frame #' @autoglobal #' @export @@ -172,8 +171,7 @@ tidyup <- function(df, chr = NULL, up = NULL, cred = NULL, - ent = NULL, - yr = NULL) { + ent = NULL) { x <- janitor::clean_names(df) |> dplyr::tibble() |> @@ -191,7 +189,6 @@ tidyup <- function(df, 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(ent)) {x <- dplyr::mutate(x, dplyr::across(dplyr::contains(ent), entype_char))} - if (!is.null(yr)) {x <- dplyr::mutate(x, dplyr::across(dplyr::any_of(yr), dint::as_date_y))} return(x) } diff --git a/man/tidyup.Rd b/man/tidyup.Rd index 5c42782f..1f5f97d1 100644 --- a/man/tidyup.Rd +++ b/man/tidyup.Rd @@ -13,8 +13,7 @@ tidyup( chr = NULL, up = NULL, cred = NULL, - ent = NULL, - yr = NULL + ent = NULL ) } \arguments{ @@ -35,8 +34,6 @@ tidyup( \item{cred}{cols to remove periods from} \item{ent}{cols to convert to NPI entity type} - -\item{yr}{cols to convert to year with \code{\link[dint:date_y]{dint::as_date_y()}}} } \value{ tidy data frame diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 9454f54a..1726ddff 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -53,7 +53,6 @@ test_that("display_long() works", { test_that("tidyup() works", { df <- dplyr::tibble( name = "John Doe ", - year = "1981", date = "1981/03/07", int = "123456789", dbl = "12.34", @@ -68,7 +67,6 @@ test_that("tidyup() works", { tidy <- dplyr::tibble( name = "JOHN DOE", - year = dint::as_date_y(1981), date = anytime::anydate("1981/03/07"), int = 123456789, dbl = 12.34, @@ -82,8 +80,8 @@ test_that("tidyup() works", { dash = NA_character_) expect_equal(tidyup(df, yn = "yn", int = c("int", "year"), - dbl = "dbl", yr = "year", up = "name", - cred = "cred", ent = c("ind", "org")), tidy) + dbl = "dbl", up = "name", cred = "cred", + ent = c("ind", "org")), tidy) }) test_that("combine() works", {