Skip to content

Commit

Permalink
vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Mar 4, 2024
1 parent 08e8762 commit dede2de
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 49 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Suggests:
gt,
knitr,
rmarkdown,
roxyglobals
roxyglobals,
qs
VignetteBuilder: knitr
Config/roxyglobals/filename: generated-globals.R
Config/roxyglobals/unique: TRUE
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(calc_amounts)
export(calc_amounts_df)
export(calc_limiting_charge)
export(calc_nonpar_amount)
export(cpt_descriptors)
export(gpci)
export(hcpcs)
export(payment)
export(pfs)
export(rvu)
46 changes: 46 additions & 0 deletions R/calculations.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,49 @@ calc_amounts <- function(wrvu,
nonparnf = nf$nonpar,
limitnf = nf$limit)
}

#' Calculate Physician Fee Schedule Payment Amounts
#' @param hcpcs numeric
#' @param state numeric
#' @param locality numeric
#' @param mac numeric
#' @return description
#' @examples
#' calc_amounts_df(hcpcs = "11646",
#' state = "GA",
#' locality = "99",
#' mac = "10212")
#' @autoglobal
#' @export
calc_amounts_df <- function(hcpcs, state, locality, mac) {

rvu <- rvu(hcpcs = hcpcs) |>
dplyr::rename(mod_rvu = mod,
status_rvu = status)

rvu$cf <- as.double(rvu$cf)

gp <- gpci(
state = state,
locality = locality,
mac = mac)

fs <- pfs(
hcpcs = hcpcs,
locality = locality,
mac = mac) |>
dplyr::rename(mod_pfs = mod,
status_pfs = status)

vctrs::vec_cbind(rvu, gp) |>
dplyr::left_join(fs,
by = dplyr::join_by(hcpcs, mac, locality)) |>
dplyr::mutate(
par_amt_f = ((wrvu * wgpci) + (f_prvu * pgpci) + (mrvu * mgpci)) * cf,
par_amt_nf = ((wrvu * wgpci) + (nf_prvu * pgpci) + (mrvu * mgpci)) * cf,
nonpar_amt_f = calc_nonpar_amount(par_amt_f),
nonpar_amt_nf = calc_nonpar_amount(par_amt_nf),
limit_f = calc_limiting_charge(par_amt_f),
limit_nf = calc_limiting_charge(par_amt_nf))

}
8 changes: 4 additions & 4 deletions R/databases.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ rvu <- function(hcpcs = NULL) {
#' @param locality description
#' @return a [dplyr::tibble()]
#' @examplesIf interactive()
#' payment(hcpcs = "11646", locality = "01", mac = "10212")
#' pfs(hcpcs = "11646", locality = "01", mac = "10212")
#' @export
payment <- function(hcpcs = NULL,
mac = NULL,
locality = NULL) {
pfs <- function(hcpcs = NULL,
mac = NULL,
locality = NULL) {

pmt <- pins::pin_read(mount_board(), "pymt")

Expand Down
24 changes: 24 additions & 0 deletions R/generated-globals.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
# Generated by roxyglobals: do not edit by hand

utils::globalVariables(c(
# <calc_amounts_df>
"cf",
# <status_codes>
"code",
# <calc_amounts_df>
"f_prvu",
# <calc_amounts_df>
"mgpci",
# <calc_amounts_df>
"mod",
# <calc_amounts_df>
"mrvu",
# <calc_amounts_df>
"nf_prvu",
# <calc_amounts_df>
"par_amt_f",
# <calc_amounts_df>
"par_amt_nf",
# <calc_amounts_df>
"pgpci",
# <abb2full>
"state.abb",
# <abb2full>
"state.name",
# <calc_amounts_df>
"status",
# <calc_amounts_df>
"wgpci",
# <calc_amounts_df>
"wrvu",
# <abb2full>
"x",
# <abb2full>
Expand Down
37 changes: 24 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ rvu <- rvu(hcpcs = "11646") |>
select(hcpcs,
description,
wrvu,
prvu_nf,
prvu_f,
nf_prvu,
f_prvu,
mrvu,
cf)
Expand All @@ -62,24 +62,35 @@ gp |> glimpse()
```

```{r}
calc_amounts(wrvu = rvu$wrvu,
prvu_nf = rvu$prvu_nf,
prvu_f = rvu$prvu_f,
mrvu = rvu$mrvu,
cf = rvu$cf,
wgpci = gp$wgpci,
pgpci = gp$pgpci,
mgpci = gp$mgpci)
# calc_amounts(wrvu = rvu$wrvu,
# prvu_nf = rvu$prvu_nf,
# prvu_f = rvu$prvu_f,
# mrvu = rvu$mrvu,
# cf = rvu$cf,
# wgpci = gp$wgpci,
# pgpci = gp$pgpci,
# mgpci = gp$mgpci)
```

```{r}
payment(hcpcs = "11646",
mac = "10212",
locality = "99") |>
pfs(hcpcs = "11646",
mac = "10212",
locality = "99") |>
select(hcpcs,
mac,
locality,
fee_nf,
fee_f) |>
glimpse()
```

## Return Information about HCPCS Code

```{r}
calc_amounts_df(hcpcs = "11646",
state = "GA",
locality = "99",
mac = "10212") |>
glimpse()
```

110 changes: 84 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ rvu <- rvu(hcpcs = "11646") |>
select(hcpcs,
description,
wrvu,
prvu_nf,
prvu_f,
nf_prvu,
f_prvu,
mrvu,
cf)

Expand All @@ -44,10 +44,10 @@ rvu |> glimpse()
> $ hcpcs <chr> "11646"
> $ description <chr> "Exc f/e/e/n/l mal+mrg >4 cm"
> $ wrvu <dbl> 6.26
> $ prvu_nf <dbl> 7.92
> $ prvu_f <dbl> 4.36
> $ nf_prvu <dbl> 7.92
> $ f_prvu <dbl> 4.36
> $ mrvu <dbl> 0.99
> $ cf <dbl> 32.7442
> $ cf <chr> "32.744"

``` r
gp <- gpci(
Expand All @@ -69,30 +69,20 @@ gp |> glimpse()
> $ mgpci <dbl> 1.125

``` r
calc_amounts(wrvu = rvu$wrvu,
prvu_nf = rvu$prvu_nf,
prvu_f = rvu$prvu_f,
mrvu = rvu$mrvu,
cf = rvu$cf,
wgpci = gp$wgpci,
pgpci = gp$pgpci,
mgpci = gp$mgpci)
# calc_amounts(wrvu = rvu$wrvu,
# prvu_nf = rvu$prvu_nf,
# prvu_f = rvu$prvu_f,
# mrvu = rvu$mrvu,
# cf = rvu$cf,
# wgpci = gp$wgpci,
# pgpci = gp$pgpci,
# mgpci = gp$mgpci)
```

> Facility:
> Participating Amount = $367.51
> Non-Particpating Amount = $349.13
> Limiting Charge = $401.50
>
> Non-Facility:
> Participating Amount = $470.44
> Non-Particpating Amount = $446.92
> Limiting Charge = $513.96

``` r
payment(hcpcs = "11646",
mac = "10212",
locality = "99") |>
pfs(hcpcs = "11646",
mac = "10212",
locality = "99") |>
select(hcpcs,
mac,
locality,
Expand All @@ -108,3 +98,71 @@ payment(hcpcs = "11646",
> $ locality <chr> "99"
> $ fee_nf <dbl> 470.44
> $ fee_f <dbl> 367.51

## Return Information about HCPCS Code

``` r
calc_amounts_df(hcpcs = "11646",
state = "GA",
locality = "99",
mac = "10212") |>
glimpse()
```

> Rows: 1
> Columns: 55
> $ hcpcs <chr> "11646"
> $ mod_rvu <chr> "00"
> $ description <chr> "Exc f/e/e/n/l mal+mrg >4 cm"
> $ status_rvu <chr> "A"
> $ unused <int> 0
> $ wrvu <dbl> 6.26
> $ nf_prvu <dbl> 7.92
> $ nf_rare <int> 0
> $ f_prvu <dbl> 4.36
> $ f_rare <int> 0
> $ mrvu <dbl> 0.99
> $ nf_total <dbl> 15.17
> $ f_total <dbl> 11.61
> $ pctc <chr> "0"
> $ global <chr> "010"
> $ op_pre <dbl> 0.1
> $ op_intra <dbl> 0.8
> $ op_post <dbl> 0.1
> $ mult_proc <int> 2
> $ surg_bilat <int> 0
> $ surg_asst <int> 1
> $ surg_co <int> 0
> $ surg_team <int> 0
> $ endo <chr> NA
> $ cf <dbl> 32.744
> $ supvis <chr> "09"
> $ dximg <dbl> 0
> $ nf_prvu_opps <dbl> 0
> $ f_prvu_opps <dbl> 0
> $ mrvu_opps <dbl> 0
> $ mac <chr> "10212"
> $ state <fct> GA
> $ locality <chr> "99"
> $ name <chr> "REST OF GEORGIA"
> $ wgpci <dbl> 1
> $ pgpci <dbl> 0.883
> $ mgpci <dbl> 1.125
> $ year <dbl> 2024
> $ mod_pfs <chr> NA
> $ fee_nf <dbl> 470.44
> $ fee_f <dbl> 367.51
> $ status_pfs <chr> "0"
> $ mult_surg <chr> "A"
> $ therapy_nf <dbl> 2
> $ flatfee_visit <dbl> 0
> $ therapy_f <dbl> 0
> $ opps <chr> "9"
> $ opps_nf <dbl> 0
> $ opps_f <dbl> 0
> $ par_amt_f <dbl> 367.5065
> $ par_amt_nf <dbl> 470.4366
> $ nonpar_amt_f <dbl> 349.1312
> $ nonpar_amt_nf <dbl> 446.9148
> $ limit_f <dbl> 401.5009
> $ limit_nf <dbl> 513.952
29 changes: 29 additions & 0 deletions man/calc_amounts_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/payment.Rd → man/pfs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vignettes/fee-schedule.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ library(northstar)
library(dplyr)
```

## Return Information about HCPCS Code

```{r}
calc_amounts_df(hcpcs = "11646",
state = "GA",
locality = "99",
mac = "10212") |>
glimpse()
```

# Fee Schedule Calculation

```{r}
Expand Down

0 comments on commit dede2de

Please sign in to comment.