From f46c16671df44d594db97e14f7cbf5542eb7a154 Mon Sep 17 00:00:00 2001 From: Andrew Bruce Date: Mon, 18 Nov 2024 00:03:46 -0800 Subject: [PATCH] cleanup --- DESCRIPTION | 1 - NAMESPACE | 4 -- R/beneficiaries.R | 32 ++++++------ R/generated-globals.R | 84 -------------------------------- R/years.R | 12 ++--- {R => data-raw/dev}/ccn.R | 0 {R => data-raw/dev}/ccn_checks.R | 0 {R => data-raw/dev}/metadata.R | 0 man/beneficiaries.Rd | 3 +- man/meta.funs.Rd | 25 ---------- man/meta.json.Rd | 30 ------------ man/meta.open.Rd | 28 ----------- man/meta.store.Rd | 26 ---------- man/years.Rd | 8 +-- tests/testthat/_snaps/utils.md | 4 +- tests/testthat/test-years.R | 4 +- 16 files changed, 31 insertions(+), 230 deletions(-) rename {R => data-raw/dev}/ccn.R (100%) rename {R => data-raw/dev}/ccn_checks.R (100%) rename {R => data-raw/dev}/metadata.R (100%) delete mode 100644 man/meta.funs.Rd delete mode 100644 man/meta.json.Rd delete mode 100644 man/meta.open.Rd delete mode 100644 man/meta.store.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 698b2833..221889ed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,6 @@ Imports: dplyr, furrr, httr2, - ivs, janitor, lifecycle, lubridate, diff --git a/NAMESPACE b/NAMESPACE index 7474b7df..9c3891be 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,10 +23,6 @@ export(hospitals) export(laboratories) export(make_interval) export(medline) -export(meta.funs) -export(meta.json) -export(meta.open) -export(meta.store) export(ndc_lookup) export(nppes) export(open_payments) diff --git a/R/beneficiaries.R b/R/beneficiaries.R index 6909d25e..747f810b 100644 --- a/R/beneficiaries.R +++ b/R/beneficiaries.R @@ -80,8 +80,7 @@ #' period = "July", #' state = "Georgia") #' -#' beneficiaries(level = "State", -#' fips = "10") +#' beneficiaries(level = "State", fips = "10") #' #' @autoglobal #' @export @@ -112,21 +111,21 @@ beneficiaries <- function(year = NULL, year <- as.character(year) if (!is.null(period) && period %in% "Year") { - year <- rlang::arg_match(year, as.character(bene_years("year")))} + year <- rlang::arg_match0(year, as.character(bene_years("Year")))} if (!is.null(period) && period %in% c("Month", month.name)) { - year <- rlang::arg_match(year, as.character(bene_years("month")))} + year <- rlang::arg_match0(year, as.character(bene_years("Month")))} } if (!is.null(period)) { - period <- rlang::arg_match(period, c("Year", "Month", month.name)) + period <- rlang::arg_match0(period, c("Year", "Month", month.name)) if (period == "Month") period <- NULL } - level <- level %nn% rlang::arg_match(level, c("National", "State", "County")) + level <- level %nn% rlang::arg_match0(level, c("National", "State", "County")) if (!is.null(state)) { - state <- rlang::arg_match(state, c(state.abb, state.name, "US")) + state <- rlang::arg_match0(state, c(state.abb, state.name, "US")) if (state %in% c(state.name, "United States")) { state_name <- state @@ -137,14 +136,14 @@ beneficiaries <- function(year = NULL, if (is.null(state)) state_name <- NULL args <- dplyr::tribble( - ~param, ~arg, - "YEAR", year, - "MONTH", period, - "BENE_GEO_LVL", level, - "BENE_STATE_ABRVTN", state, - "BENE_STATE_DESC", state_name, - "BENE_COUNTY_DESC", county, - "BENE_FIPS_CD", fips) + ~param, ~arg, + "YEAR", year, + "MONTH", period, + "BENE_GEO_LVL", level, + "BENE_STATE_ABRVTN", state, + "BENE_STATE_DESC", state_name, + "BENE_COUNTY_DESC", county, + "BENE_FIPS_CD", fips) response <- httr2::request(build_url("ben", args)) |> httr2::req_perform() @@ -162,6 +161,7 @@ beneficiaries <- function(year = NULL, tidyr::unnest(cols = c(y)) format_cli(cli_args) + return(invisible(NULL)) } @@ -173,7 +173,7 @@ beneficiaries <- function(year = NULL, level = fct_level(level), state = fct_stabb(state), state_name = fct_stname(state_name)) - if (!is.null(period) && period == "Month") results <- dplyr::filter(results, period %in% month.name) + if (!is.null(period) && period == "Month") results <- dplyr::filter(results, period %in% month.name) } return(results) } diff --git a/R/generated-globals.R b/R/generated-globals.R index 3e395fce..0d7e0c40 100644 --- a/R/generated-globals.R +++ b/R/generated-globals.R @@ -9,16 +9,12 @@ utils::globalVariables(c( # # ":=", - # - "@type", # "a2la", # "aabb", # "accredited", - # - "accrualPeriodicity", # "aco_id_1", # @@ -162,11 +158,7 @@ utils::globalVariables(c( "definition", # "Definition", - # - "describedBy", # - # - # "description", # # @@ -174,52 +166,15 @@ utils::globalVariables(c( # "display_name", # - # - # # "distribution", - # - "distribution.data", - # - "distribution.data_%Ref:downloadURL", - # - "distribution.data_%Ref:downloadURL.data", - # - "distribution.data_%Ref:downloadURL.data_checksum", - # - "distribution.data_%Ref:downloadURL.data_filePath", - # - "distribution.data_%Ref:downloadURL.data_identifier", - # - "distribution.data_%Ref:downloadURL.data_mimeType", - # - "distribution.data_%Ref:downloadURL.data_perspective", - # - "distribution.data_%Ref:downloadURL.data_version", - # - "distribution.data_%Ref:downloadURL.identifier", - # - "distribution.data_@type", - # - "distribution.data_format", - # - "distribution.data_mediaType", - # - "distribution.data_title", - # - "distribution.identifier", - # - "distribution.title", # - # "distribution_accessURL", # "distribution_format", # - # "distribution_modified", # - # "distribution_title", # # @@ -248,11 +203,6 @@ utils::globalVariables(c( "five_star_benchmark", # "flag", - # - "function_call", - # - # - "function_name", # # # @@ -287,8 +237,6 @@ utils::globalVariables(c( # "id", # - # - # # # "identifier", @@ -301,22 +249,13 @@ utils::globalVariables(c( # "individual_state_code", # - # "interval", # "invs_msr", - # - "is_between", - # - # - "issued", # "jcaho", # "keyword", - # - # - "landingPage", # # # @@ -336,9 +275,6 @@ utils::globalVariables(c( "medical", # # - # - # - # # "modified", # @@ -391,14 +327,6 @@ utils::globalVariables(c( "pay_total", # "pdi_1", - # - "period", - # - "period_end", - # - "period_start", - # - "periodicity", # "pgm_trmntn_cd", # @@ -424,9 +352,6 @@ utils::globalVariables(c( "prvdr_ctgry_cd", # "prvdr_ctgry_sbtyp_cd", - # - # - "publisher", # "purpose", # @@ -437,10 +362,6 @@ utils::globalVariables(c( "recipient_state", # "record_type", - # - "references", - # - "released", # "rgn_cd", # @@ -512,13 +433,10 @@ utils::globalVariables(c( "taxonomy_grouping", # "taxonomy_specialization", - # - "temporal", # "timelength_days", # # - # # # "title", @@ -543,8 +461,6 @@ utils::globalVariables(c( "type_1", # "type_of_action", - # - "update_schedule", # "val", # diff --git a/R/years.R b/R/years.R index bf2b3ddc..991ed55f 100644 --- a/R/years.R +++ b/R/years.R @@ -4,9 +4,9 @@ #' #' @examples #' # `beneficiaries()` -#' bene_years(period = "year") +#' bene_years(period = "Year") #' -#' bene_years(period = "month") +#' bene_years(period = "Month") #' #' # `open_payments()` #' open_years() @@ -110,7 +110,7 @@ qpp_years <- function() { ) } -#' @param period `` One of `"year"` or `"month"` +#' @param period `` One of `"Year"` or `"Month"` #' #' @rdname years #' @@ -119,18 +119,18 @@ qpp_years <- function() { #' @autoglobal #' #' @export -bene_years <- function(period = c("year", "month")) { +bene_years <- function(period = c("Year", "Month")) { period <- match.arg(period) - if (period == "year") { # NOT WORKING + if (period == "Year") { # NOT WORKING out <- beneficiaries( period = "Year", level = "National", tidy = FALSE)$YEAR } - if (period == "month") { + if (period == "Month") { out <- beneficiaries( period = "January", level = "National", diff --git a/R/ccn.R b/data-raw/dev/ccn.R similarity index 100% rename from R/ccn.R rename to data-raw/dev/ccn.R diff --git a/R/ccn_checks.R b/data-raw/dev/ccn_checks.R similarity index 100% rename from R/ccn_checks.R rename to data-raw/dev/ccn_checks.R diff --git a/R/metadata.R b/data-raw/dev/metadata.R similarity index 100% rename from R/metadata.R rename to data-raw/dev/metadata.R diff --git a/man/beneficiaries.Rd b/man/beneficiaries.Rd index 1bef73df..b2fbcb3e 100644 --- a/man/beneficiaries.Rd +++ b/man/beneficiaries.Rd @@ -112,7 +112,6 @@ beneficiaries(year = 2022, period = "July", state = "Georgia") -beneficiaries(level = "State", - fips = "10") +beneficiaries(level = "State", fips = "10") \dontshow{\}) # examplesIf} } diff --git a/man/meta.funs.Rd b/man/meta.funs.Rd deleted file mode 100644 index 8afb6c75..00000000 --- a/man/meta.funs.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metadata.R -\name{meta.funs} -\alias{meta.funs} -\title{Look up Dataset's API title} -\usage{ -meta.funs(fn) -} -\arguments{ -\item{call}{function name} -} -\value{ -A list containing the function name and the dataset's API title -} -\description{ -Look up Dataset's API title -} -\examples{ -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -meta.funs('affiliations') -meta.funs('clinicians') -meta.funs('beneficiaries') -\dontshow{\}) # examplesIf} -} -\keyword{internal} diff --git a/man/meta.json.Rd b/man/meta.json.Rd deleted file mode 100644 index e34edb14..00000000 --- a/man/meta.json.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metadata.R -\name{meta.json} -\alias{meta.json} -\title{Return Metadata about function's dataset} -\usage{ -meta.json(fn = NULL, title = NULL, first = TRUE) -} -\arguments{ -\item{fn}{function using the dataset} - -\item{title}{dataset's API title} - -\item{first}{only need the first row} -} -\value{ -A \code{\link[=tibble]{tibble()}} containing the updated ids. -} -\description{ -Return Metadata about function's dataset -} -\examples{ -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -meta.json(title = 'Medicare Fee-For-Service Public Provider Enrollment') -meta.json(title = 'Provider of Services File - Clinical Laboratories') -meta.json(fn = 'providers') -meta.json(fn = 'laboratories') -\dontshow{\}) # examplesIf} -} -\keyword{internal} diff --git a/man/meta.open.Rd b/man/meta.open.Rd deleted file mode 100644 index 5aaf1235..00000000 --- a/man/meta.open.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metadata.R -\name{meta.open} -\alias{meta.open} -\title{Return Metadata about function's dataset} -\usage{ -meta.open(search = NULL, tidy = TRUE, year = NULL) -} -\arguments{ -\item{search}{dataset title} - -\item{tidy}{TRUE} - -\item{year}{dataset year} -} -\value{ -A list of metadata describing each API's dataset -} -\description{ -Return Metadata about function's dataset -} -\examples{ -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -meta.open('General Payment Data') -meta.open(meta_funs('open_payments'), year = 2022) -\dontshow{\}) # examplesIf} -} -\keyword{internal} diff --git a/man/meta.store.Rd b/man/meta.store.Rd deleted file mode 100644 index cde2092d..00000000 --- a/man/meta.store.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metadata.R -\name{meta.store} -\alias{meta.store} -\title{Return Metadata about function's dataset} -\usage{ -meta.store(fn = NULL, title = NULL) -} -\arguments{ -\item{call}{function using the dataset} -} -\value{ -A list of metadata describing each API's dataset -} -\description{ -Return Metadata about function's dataset -} -\examples{ -\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -meta.store(title = 'Facility Affiliation Data') -meta.store(title = 'National Downloadable File') -meta.store(fn = 'affiliations') -meta.store(fn = 'beneficiaries') -\dontshow{\}) # examplesIf} -} -\keyword{internal} diff --git a/man/years.Rd b/man/years.Rd index 4a58eb34..6bc6e459 100644 --- a/man/years.Rd +++ b/man/years.Rd @@ -20,10 +20,10 @@ util_years() qpp_years() -bene_years(period = c("year", "month")) +bene_years(period = c("Year", "Month")) } \arguments{ -\item{period}{\verb{} One of \code{"year"} or \code{"month"}} +\item{period}{\verb{} One of \code{"Year"} or \code{"Month"}} } \value{ integer vector of years available to search @@ -33,9 +33,9 @@ Years Currently Searchable for APIs } \examples{ # `beneficiaries()` -bene_years(period = "year") +bene_years(period = "Year") -bene_years(period = "month") +bene_years(period = "Month") # `open_payments()` open_years() diff --git a/tests/testthat/_snaps/utils.md b/tests/testthat/_snaps/utils.md index cc581846..4c48972e 100644 --- a/tests/testthat/_snaps/utils.md +++ b/tests/testthat/_snaps/utils.md @@ -44,14 +44,14 @@ Code file_url(fn = "c", args = args, offset = 0L) Output - [1] "https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%20fd3842af-b247-5cd5-8229-923a0d1f87a3%5D%5BWHERE%20NPI%20=%20%221144544834%22%5D%5BLIMIT%2010000%20OFFSET%200%5D;&show_db_columns" + [1] "https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%20fa844ce1-fef1-5082-9fef-ae017c385b84%5D%5BWHERE%20NPI%20=%20%221144544834%22%5D%5BLIMIT%2010000%20OFFSET%200%5D;&show_db_columns" --- Code file_url(fn = "a", args = args, offset = 0L) Output - [1] "https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%20cc079864-b9c6-5df5-bd7f-4cdd873c2d56%5D%5BWHERE%20NPI%20=%20%221144544834%22%5D%5BLIMIT%2010000%20OFFSET%200%5D;&show_db_columns" + [1] "https://data.cms.gov/provider-data/api/1/datastore/sql?query=%5BSELECT%20%2A%20FROM%20e7eabe0d-75c1-58e6-8fba-bae965a2c6d2%5D%5BWHERE%20NPI%20=%20%221144544834%22%5D%5BLIMIT%2010000%20OFFSET%200%5D;&show_db_columns" # format_cli() works diff --git a/tests/testthat/test-years.R b/tests/testthat/test-years.R index 8e266f8f..eca883a5 100644 --- a/tests/testthat/test-years.R +++ b/tests/testthat/test-years.R @@ -41,11 +41,11 @@ test_that("qpp_years() works", { test_that("bene_years() works", { - benyr <- bene_years("year") + benyr <- bene_years("Year") expect_equal(benyr, 2013:2023) expect_vector(benyr, ptype = integer(), size = 11) - benmn <- bene_years("month") + benmn <- bene_years("Month") expect_equal(benmn, 2013:2024) expect_vector(benmn, ptype = integer(), size = 12)