Skip to content

Commit

Permalink
updated rvu, pfs pins
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Mar 5, 2024
1 parent 2adfc3a commit b351b73
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 125 deletions.
12 changes: 4 additions & 8 deletions R/calculations.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ calc_amounts <- function(wrvu,
#' @param locality numeric
#' @param mac numeric
#' @return description
#' @examples
#' @examplesIf interactive()
#' calc_amounts_df(hcpcs = "11646",
#' state = "GA",
#' locality = "99",
Expand All @@ -102,11 +102,9 @@ calc_amounts <- function(wrvu,
#' @export
calc_amounts_df <- function(hcpcs, state, locality, mac) {

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

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

gp <- gpci(
state = state,
Expand All @@ -116,9 +114,7 @@ calc_amounts_df <- function(hcpcs, state, locality, mac) {
fs <- pfs(
hcpcs = hcpcs,
locality = locality,
mac = mac) |>
dplyr::rename(mod_pfs = mod,
status_pfs = status)
mac = mac)

vctrs::vec_cbind(rvu, gp) |>
dplyr::left_join(fs,
Expand Down
6 changes: 0 additions & 6 deletions R/generated-globals.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# 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",
Expand All @@ -26,8 +22,6 @@ utils::globalVariables(c(
# <abb2full>
"state.name",
# <calc_amounts_df>
"status",
# <calc_amounts_df>
"wgpci",
# <calc_amounts_df>
"wrvu",
Expand Down
16 changes: 8 additions & 8 deletions R/reference.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ status_codes <- function() {
"T", "No Other Services Payable")

lookup <- c(
"A" = "These codes are separately paid under the Physician Fee Schedule if covered. There will be RVUs and payment amounts for codes with this status. The presence of an A indicator does not mean that Medicare has made a National Coverage Determination regarding the service. Carriers remain responsible for coverage decisions in the absence of a national Medicare policy.",
"X" = "These codes represent an item or service that is not in the statutory definition of 'physician services' for fee schedule payment purposes. No RVUs or payment amounts are shown for these codes and no payment may be made under the physician fee schedule. Ex: Ambulance services and Clinical Diagnostic Laboratory Services.",
"I" = "Medicare uses another code for reporting of, and payment for, these services. (Code NOT subject to a 90 day grace period.)",
"E" = "These codes are for items and/or services that CMS chose to exclude from the fee schedule payment by regulation. No RVUs or payment amounts are shown and no payment may be made under the fee schedule for these codes. Payment for them, when covered, continues under reasonable charge procedures.",
"A" = "Separately paid under the Physician Fee Schedule if covered. There will be RVUs and payment amounts. Does not mean that Medicare has made a National Coverage Determination regarding the service. Carriers remain responsible for coverage decisions in the absence of a national Medicare policy.",
"X" = "Item or service that is not in the statutory definition of 'physician services' for fee schedule payment purposes. No RVUs or payment amounts are shown for these codes and no payment may be made under the physician fee schedule. Ex: Ambulance Services and Clinical Diagnostic Laboratory Services.",
"I" = "Medicare uses another code for reporting of, and payment for, these services. Code is NOT subject to a 90-day grace period.",
"E" = "Item or service that CMS chose to exclude from the fee schedule payment by regulation. No RVUs or payment amounts are shown and no payment may be made under the fee schedule. Payment for them, when covered, continues under reasonable charge procedures.",
"M" = "Used for reporting purposes only.",
"C" = "Carriers will establish RVUs and payment amounts for these services, generally on an individual case basis following review of documentation such as an operative report.",
"R" = "Special coverage instructions apply.",
"N" = "These codes are carried on the HCPCS tape as noncovered services.",
"J" = "No relative Status units or payment amounts for anesthesia codes on the database, only used to facilitate the identification of anesthesia services.",
"P" = "There are no RVUs and no payment amounts for these services. No separate payment is made for them under the fee schedule. If the item or service is covered as incident to a physician service and is provided on the same day as a physician service, payment for it is bundled into the payment for the physician service to which it is incident (an example is an elastic bandage furnished by a physician incident to a physician service). If the item or service is covered as other than incident to a physician service, it is excluded from the fee schedule (for example, colostomy supplies) and is paid under the other payment provision of the Act.",
"B" = "Payment for covered services are always bundled into payment for other services not specified: There will be no RVUs or payment amounts for these codes and no separate payment is ever made. When these services are covered, payment for them is subsumed by the payment for the services to which they are incident (an example is a telephone call from a hospital nurse regarding care of a patient).",
"N" = "Noncovered services.",
"J" = "No RVUs or payment amounts for anesthesia codes on the database, only used to facilitate the identification of anesthesia services.",
"P" = "No RVUs and no payment amounts for these services. No separate payment is made for them under the fee schedule. If the item or service is covered as incident to a physician service and is provided on the same day as a physician service, payment for it is bundled into the payment for the physician service to which it is incident (an example is an elastic bandage furnished by a physician incident to a physician service). If the item or service is covered as other than incident to a physician service, it is excluded from the fee schedule (for example, colostomy supplies) and is paid under the other payment provision of the Act.",
"B" = "Payment for covered services are always bundled into payment for other services not specified. No RVUs or payment amounts and no separate payment is ever made. When these services are covered, payment for them is subsumed by the payment for the services to which they are incident (an example is a telephone call from a hospital nurse regarding care of a patient).",
"T" = "There are RVUs and payment amounts for these services, but they are only paid if there are no other services payable under the physician fee schedule billed on the same date by the same provider. If any other services payable under the physician fee schedule are billed on the same date by the same provider, these services are bundled into the physician services for which payment is made.")

status_codes |>
Expand Down
16 changes: 8 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ 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$nf_prvu,
prvu_f = rvu$f_prvu,
mrvu = rvu$mrvu,
cf = rvu$cf,
wgpci = gp$wgpci,
pgpci = gp$pgpci,
mgpci = gp$mgpci)
```

```{r}
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rvu |> glimpse()
> $ nf_prvu <dbl> 7.92
> $ f_prvu <dbl> 4.36
> $ mrvu <dbl> 0.99
> $ cf <chr> "32.744"
> $ cf <dbl> 32.744

``` r
gp <- gpci(
Expand All @@ -69,16 +69,26 @@ 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$nf_prvu,
prvu_f = rvu$f_prvu,
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.91
> Limiting Charge = $513.95

``` r
pfs(hcpcs = "11646",
mac = "10212",
Expand Down Expand Up @@ -112,9 +122,9 @@ calc_amounts_df(hcpcs = "11646",
> Rows: 1
> Columns: 55
> $ hcpcs <chr> "11646"
> $ mod_rvu <chr> "00"
> $ mod.x <chr> "00"
> $ description <chr> "Exc f/e/e/n/l mal+mrg >4 cm"
> $ status_rvu <chr> "A"
> $ status.x <chr> "A"
> $ unused <int> 0
> $ wrvu <dbl> 6.26
> $ nf_prvu <dbl> 7.92
Expand Down Expand Up @@ -149,10 +159,10 @@ calc_amounts_df(hcpcs = "11646",
> $ pgpci <dbl> 0.883
> $ mgpci <dbl> 1.125
> $ year <dbl> 2024
> $ mod_pfs <chr> NA
> $ mod.y <chr> NA
> $ fee_nf <dbl> 470.44
> $ fee_f <dbl> 367.51
> $ status_pfs <chr> "0"
> $ status.y <chr> "0"
> $ mult_surg <chr> "A"
> $ therapy_nf <dbl> 2
> $ flatfee_visit <dbl> 0
Expand Down
27 changes: 15 additions & 12 deletions data-raw/pfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,35 @@ names(pfs_pay) <- c(
"mac",
"locality",
"hcpcs",
"mod",
"mod_pfs",
"fee_nf", # "non_fac_fee_sched_amount"
"fee_f", # "facility_fee_sched_amount"
"pctc",
"status",
"mult_surg",
"therapy_nf", # "therapy_reduction_nonfac"
"flatfee_visit", # flat_visit_fee
"therapy_f", # "therapy_reduction_fac"
"status_pfs",
"mult_surg_pfs",
"ther_nf", # "therapy_reduction_nonfac"
"flat_vis", # flat_visit_fee
"ther_f", # "therapy_reduction_fac"
"opps", # "opps_indicator"
"opps_nf",
"opps_f"
)

pfs_pay <- pfs_pay |>
mutate(across(c(
year,
contains("fee"),
contains("therapy"),
contains("opps_")),
mutate(across(
c(
year,
contains("fee"),
contains("ther_"),
contains("opps_"),
flat_vis
),
readr::parse_number)) |>
select(-pctc)

# [990,482 x 15]
pfs_pay |>
filter(hcpcs == "A0021")
filter(hcpcs == "11646")

# Update Pin
board <- pins::board_folder(here::here("pins"))
Expand Down
140 changes: 86 additions & 54 deletions data-raw/rvu.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,111 @@ rvu <- read_excel(rvu_xl, col_types = "text") |>
post_op,
non_facility_pe_used_for_opps_payment_amount,
facility_pe_used_for_opps_payment_amount,
mp_used_for_opps_payment_amount), readr::parse_number)) |>
mp_used_for_opps_payment_amount),
readr::parse_number)) |>
mutate(
non_fac_na_indicator = ifelse(!is.na(non_fac_na_indicator), 1, 0),
facility_na_indicator = ifelse(!is.na(facility_na_indicator), 1, 0),
not_used_for_medicare_payment = ifelse(!is.na(not_used_for_medicare_payment), 1, 0),
mod = ifelse(is.na(mod), "00", mod),
diagnostic_imaging_family_indicator = ifelse(diagnostic_imaging_family_indicator == "88", 1, 0),
non_fac_na_indicator = as.integer(non_fac_na_indicator),
facility_na_indicator = as.integer(facility_na_indicator),
not_used_for_medicare_payment = as.integer(not_used_for_medicare_payment),
mult_proc = as.integer(mult_proc),
bilat_surg = as.integer(bilat_surg),
asst_surg = as.integer(asst_surg),
co_surg = as.integer(co_surg),
team_surg = as.integer(team_surg)
) |>
unite(rare, c("non_fac_na_indicator",
"facility_na_indicator"),
sep = "",
remove = TRUE) |>
rename(
status = status_code,
notused = not_used_for_medicare_payment,
status_rvu = status_code,
mod_rvu = mod,
unused = not_used_for_medicare_payment,
wrvu = work_rvu,
prvu_nf = non_fac_pe_rvu,
prvu_f = facility_pe_rvu,
nf_ind_na = non_fac_na_indicator,
f_ind_na = facility_na_indicator,
nf_prvu = non_fac_pe_rvu,
f_prvu = facility_pe_rvu,
mrvu = mp_rvu,
total_nf = non_facility_total,
total_f = facility_total,
nf_total = non_facility_total,
f_total = facility_total,
pctc = pctc_ind,
endo = endo_base,
cf = conv_factor,
phys_dxpx = physician_supervision_of_diagnostic_procedures,
calc = calculation_flag,
dximgfm_ind = diagnostic_imaging_family_indicator,
prvu_nf_opps = non_facility_pe_used_for_opps_payment_amount,
prvu_f_opps = facility_pe_used_for_opps_payment_amount,
mrvu_opps = mp_used_for_opps_payment_amount) |>
mutate(
nf_ind_na = ifelse(!is.na(nf_ind_na), 1, 0),
f_ind_na = ifelse(!is.na(f_ind_na), 1, 0),
notused = ifelse(!is.na(notused), 1, 0),
mod = ifelse(is.na(mod), "00", mod),
dximgfm_ind = ifelse(dximgfm_ind == "88", 1, 0),
nf_ind_na = as.integer(nf_ind_na),
f_ind_na = as.integer(f_ind_na),
notused = as.integer(notused),
mult_proc = as.integer(mult_proc),
bilat_surg = as.integer(bilat_surg),
asst_surg = as.integer(asst_surg),
co_surg = as.integer(co_surg),
team_surg = as.integer(team_surg)
) |>
rename(
nf_rare = nf_ind_na,
f_rare = f_ind_na,
nf_total = total_nf,
f_total = total_f,
unused = notused,
nf_prvu = prvu_nf,
f_prvu = prvu_f,
nf_prvu_opps = prvu_nf_opps,
f_prvu_opps = prvu_f_opps,
supvis = physician_supervision_of_diagnostic_procedures,
dximg = diagnostic_imaging_family_indicator,
nf_prvu_opps = non_facility_pe_used_for_opps_payment_amount,
f_prvu_opps = facility_pe_used_for_opps_payment_amount,
mrvu_opps = mp_used_for_opps_payment_amount,
global = glob_days,
op_pre = pre_op,
op_intra = intra_op,
op_post = post_op,
mult_proc_rvu = mult_proc,
surg_bilat = bilat_surg,
surg_asst = asst_surg,
surg_co = co_surg,
surg_team = team_surg,
dximg = dximgfm_ind,
supvis = phys_dxpx,
) |>
filter(!is.na(calc)) |>
mutate(calc = NULL,
cf = format(32.7442, digits = 5))
surg_team = team_surg) |>
filter(!is.na(calculation_flag)) |>
mutate(calculation_flag = NULL,
cf = format(32.7442, digits = 5),
nf_total = NULL,
f_total = NULL) |>
mutate(op_ind = op_pre + op_intra + op_post, .before = op_pre)

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

# [18,499 x 31]
rvu <- rvu |>
select(
hcpcs,
description,
mod_rvu,
status_rvu,
wrvu,
nf_prvu,
f_prvu,
mrvu,
cf,
nf_prvu_opps,
f_prvu_opps,
mrvu_opps,
global,
op_ind,
op_pre,
op_intra,
op_post,
pctc,
mult_proc_rvu,
surg_bilat,
surg_asst,
surg_co,
surg_team,
endo,
supvis,
dximg,
unused,
rare
)

# [18,499 x 28]


rvu |> select(cf) # [non_fac, facility]

rvu |>
mutate(hcpcs_letters = str_detect(hcpcs, regex("[A-Z]"))) |>
# mutate(level2 = str_detect(hcpcs, regex("^[A-Z]"))) |>
# mutate(level2 = str_detect(hcpcs, regex("[A-Z]$"))) |>
# mutate(cpt = str_detect(hcpcs, regex("^[0-9]"))) |>
filter(hcpcs_letters == TRUE) |>
slice(3000:5000)
mutate(rare = case_match(rare,
"00" ~ "Neither",
"10" ~ "Non-Facility",
"01" ~ "Facility",
"11" ~ "Both"),
rare = factor(rare,
levels = c("Neither", "Non-Facility", "Facility", "Both"))
)

rvu |> count(supvis)

# Update Pin
board <- pins::board_folder(here::here("pins"))
Expand Down
Loading

0 comments on commit b351b73

Please sign in to comment.