Skip to content

Commit

Permalink
* rebuild readme
Browse files Browse the repository at this point in the history
* fix more warnings and errors
  • Loading branch information
andrewallenbruce committed Dec 11, 2024
1 parent 9e168e2 commit 435d48f
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 529 deletions.
2 changes: 1 addition & 1 deletion R/cms.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ build_url <- function(abb, args = NULL) {
#' @autoglobal
#'
#' @noRd
api_years <- function(abb, year) {
api_years <- function(abb, year = NULL) {

api <- dplyr::case_match(
abb,
Expand Down
4 changes: 1 addition & 3 deletions R/outpatient.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ outpatient <- function(year,
'Rndrng_Prvdr_RUCA', ruca,
'APC_Cd', apc)

id <- dplyr::filter(api_years("outps"),
year == {{ year }}) |>
dplyr::pull(distro)
id <- api_years("outps", year = as.integer(year))[["distro"]]

url <- paste0("https://data.cms.gov/data-api/v1/dataset/",
id, "/data.json?", encode_param(args))
Expand Down
26 changes: 8 additions & 18 deletions R/prescribers.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,25 +269,15 @@ prescribers <- function(year,
'Antbtc_Drug_Flag', antibiotic,
'Antpsyct_Drug_Flag', antipsychotic)

yr <- switch(
id <- switch(
type,
'Provider' = api_years('rxp'),
'Drug' = api_years('rxd'),
'Geography' = api_years('rxg'))

id <- dplyr::filter(
yr,
year == {{ year }}) |>
dplyr::pull(distro)

url <- paste0(
"https://data.cms.gov/data-api/v1/dataset/",
id,
"/data.json?",
encode_param(args))

response <- httr2::request(url) |>
httr2::req_perform()
"Provider" = api_years("rxp", year = as.integer(year))[["distro"]],
"Drug" = api_years("rxd", year = as.integer(year))[["distro"]],
"Geography" = api_years("rxg", year = as.integer(year))[["distro"]])

url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data.json?", encode_param(args))

response <- httr2::request(url) |> httr2::req_perform()

if (vctrs::vec_is_empty(response$body)) {

Expand Down
4 changes: 1 addition & 3 deletions R/quality_payment.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ quality_payment <- function(year,

# id <- "b3438273-b4a6-44ca-8fb2-9e6026b74642"

id <- api_years("qpp") |>
dplyr::filter(year == {{ year }}) |>
dplyr::pull(distro)
id <- api_years("qpp", year = as.integer(year))[["distro"]]

url <- paste0("https://data.cms.gov/data-api/v1/dataset/",
id, "/data?", encode_param(args))
Expand Down
24 changes: 7 additions & 17 deletions R/utilization.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,13 @@ utilization <- function(year,
"Place_Of_Srvc", pos,
"Rndrng_Prvdr_Geo_Lvl", level)

yr <- switch(type,
'Provider' = api_years('prv'),
'Service' = api_years('srv'),
'Geography' = api_years('geo'))

id <- dplyr::filter(
yr,
year == {{ year }}
) |>
dplyr::pull(distro)

url <- paste0(
"https://data.cms.gov/data-api/v1/dataset/",
id,
"/data.json?",

encode_param(args))
id <- switch(
type,
"Provider" = api_years("prv", year = as.integer(year))[["distro"]],
"Service" = api_years("srv", year = as.integer(year))[["distro"]],
"Geography" = api_years("geo", year = as.integer(year))[["distro"]])

url <- paste0("https://data.cms.gov/data-api/v1/dataset/", id, "/data.json?", encode_param(args))

response <- httr2::request(url) |> httr2::req_perform()

Expand Down
3 changes: 0 additions & 3 deletions R/years.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#' # `utilization()`
#' util_years()
#'
#' # `conditions()`
#' # cc_years()
#'
#' # `quality_payment()`
#' qpp_years()
#'
Expand Down
Loading

0 comments on commit 435d48f

Please sign in to comment.