Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Apr 19, 2024
1 parent d7d12b1 commit f4a5b0a
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 112 deletions.
111 changes: 92 additions & 19 deletions R/years.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#'
#' @returns integer vector of years available to search
#'
#' @examplesIf interactive()
#' @examples
#' # `beneficiaries()`
#' bene_years("year")
#' bene_years("month")
#' bene_years(period = "year")
#'
#' bene_years(period = "month")
#'
#' # `open_payments()`
#' open_years()
Expand All @@ -26,58 +27,130 @@
#' rx_years()
#'
#' @name years
#'
#' @keywords internal
#'
NULL

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
open_years <- function() sort(open_ids("General Payment Data")$year)
open_years <- function() {
sort(
open_ids(
"General Payment Data")$year
)
}

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
out_years <- function() {
as.integer(cms_update("Medicare Outpatient Hospitals - by Provider and Service", "years"))
as.integer(
cms_update(
"Medicare Outpatient Hospitals - by Provider and Service",
"years"
)
)
}

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
rx_years <- function() {
as.integer(cms_update("Medicare Part D Prescribers - by Provider", "years"))
as.integer(
cms_update(
"Medicare Part D Prescribers - by Provider",
"years"
)
)
}

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
util_years <- function() {
as.integer(cms_update("Medicare Physician & Other Practitioners - by Provider", "years"))
as.integer(
cms_update(
"Medicare Physician & Other Practitioners - by Provider",
"years"
)
)
}

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
cc_years <- function() as.integer(cms_update("Specific Chronic Conditions", "years"))
cc_years <- function() {
as.integer(
cms_update(
"Specific Chronic Conditions",
"years"
)
)
}

#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
qpp_years <- function() as.integer(cms_update("Quality Payment Program Experience", "years"))
qpp_years <- function() {
as.integer(
cms_update(
"Quality Payment Program Experience",
"years"
)
)
}

#' @param period One of `"year"` or `"month"`
#' @param period `<chr>` One of `"year"` or `"month"`
#'
#' @rdname years
#'
#' @keywords internal
#'
#' @autoglobal
#'
#' @export
#' @keywords internal
bene_years <- function(period = c("year", "month")) {
if (period == "year") out <- beneficiaries(period = "Year", level = "National", tidy = FALSE)$YEAR
if (period == "month") out <- beneficiaries(period = "January", level = "National", tidy = FALSE)$YEAR

period <- match.arg(period)

if (period == "year") { # NOT WORKING
out <- beneficiaries(
period = "Year",
level = "National",
tidy = FALSE)$YEAR
}

if (period == "month") {
out <- beneficiaries(
period = "January",
level = "National",
tidy = FALSE)$YEAR
}
return(as.integer(out))
}
35 changes: 20 additions & 15 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ library(tidyr)
### `affiliations()`

```{r}
affiliations(npi = 1023630738,
pac = 9032521372,
facility_ccn = "37Z324") |>
affiliations(npi = 1023630738,
pac = 9032521372,
facility_ccn = 370781) |>
glimpse()
```


### `beneficiaries()`

```{r}
beneficiaries(year = 2022,
beneficiaries(year = 2023,
period = "Year",
level = "County",
state = "GA",
Expand Down Expand Up @@ -120,11 +120,7 @@ laboratories(clia = "11D0265516") |>

```{r}
nppes(npi = 1497535637) |>
add_counties(state,
zip,
add_fips = TRUE,
add_geo = TRUE,
as_sf = TRUE)
glimpse()
```


Expand All @@ -149,7 +145,8 @@ opt_out(npi = 1043522824) |>
### `order_refer()`

```{r}
order_refer(npi = 1043522824)
order_refer(npi = 1043522824, tidy = FALSE) |>
glimpse()
```


Expand All @@ -167,7 +164,7 @@ outpatient(year = 2021,
### `prescribers()`

```{r}
prescribers(year = 2019,
prescribers(year = 2021,
type = 'Provider',
npi = 1003000423) |>
glimpse()
Expand Down Expand Up @@ -213,14 +210,22 @@ quality_payment(year = 2021,
q <- quality_payment(year = 2021,
npi = 1932365699)
select(q, year, statuses) |>
unnest(statuses)
q |>
select(
year,
qpp_status
) |>
unnest(qpp_status)
```


```{r}
select(q, year, measures) |>
unnest(measures)
q |>
select(
year,
qpp_measures
) |>
unnest(qpp_measures)
```

### `quality_eligibility()`
Expand Down
Loading

0 comments on commit f4a5b0a

Please sign in to comment.