Skip to contents

utilization()

future::plan(multisession, workers = 4)

# Retrieve provider's overall utilization data
ind     <- utilization_(npi = 1043477615, type = "Provider")
# Retrieve provider's utilization data by HCPCS
srvc    <- utilization_(npi = 1023076643, type = "Service")
#> Error:
#>  In index: 1.
#> Caused by error in `dplyr::select()`:
#> ! Can't select columns that don't exist.
#>  Column `subcategory` doesn't exist.
# Retrieve state & national HCPCS data to compare with
hcpcs   <- compare_hcpcs(srvc)
#> Error: object 'srvc' not found
future::plan(sequential)

Overall Performance

performance <- ind |> 
  unnest(performance) |> 
  select(year, tot_hcpcs:.pymt_per_srvc)
performance
#> # A tibble: 9 × 12
#>    year tot_hcpcs tot_benes tot_srvcs tot_charges tot_allowed tot_payment
#>   <int>     <int>     <int>     <int>       <dbl>       <dbl>       <dbl>
#> 1  2014        45       598       823      319401      42429.      33775.
#> 2  2015        54      1042      1449      551630      82729.      64720.
#> 3  2016        62       619      1000      653517     111283.      87144.
#> 4  2017        65       606       972      460677      88160.      68173.
#> 5  2018        54       505      1034      504640     102857.      80079.
#> 6  2019        55       532      1252      617797     134101.     104987.
#> 7  2020        57       650      1260      482488     106512.      81868.
#> 8  2021        58       748      1369      444671      97159.      75295.
#> 9  2022        52       828      1498      347737      85192.      64041.
#> # ℹ 5 more variables: tot_std_pymt <dbl>, .copay_deduct <dbl>,
#> #   .srvcs_per_bene <dbl>, .pymt_per_bene <dbl>, .pymt_per_srvc <dbl>
ggplot(performance, aes(x = .pymt_per_srvc, 
                        y = .srvcs_per_bene, 
                        fill = year, group = year)) +
  geom_point(shape = 21, size = 4, alpha = 0.75) +
  theme_minimal()

ind |> 
  unnest(performance) |> 
  select(year, tot_hcpcs:tot_srvcs) |> 
  change(!year, csm = "_chg") |> 
  gt(rowname_col = "year") |> 
  opt_table_font(font = google_font(name = "Fira Code")) |> 
  fmt_currency(columns = starts_with("avg_"), decimals = 0)
tot_hcpcs tot_benes tot_srvcs tot_hcpcs_chg tot_benes_chg tot_srvcs_chg tot_hcpcs_pct tot_benes_pct tot_srvcs_pct tot_hcpcs_ror tot_benes_ror tot_srvcs_ror tot_hcpcs_chg_cusum tot_benes_chg_cusum tot_srvcs_chg_cusum
2014 45 598 823 0 0 0 0.00000000 0.00000000 0.000000000 1.0000000 1.0000000 1.0000000 0 0 0
2015 54 1042 1449 9 444 626 0.20000000 0.74247492 0.760631835 1.2000000 1.7424749 1.7606318 9 444 626
2016 62 619 1000 8 -423 -449 0.14814815 -0.40595010 -0.309868875 1.1481481 0.5940499 0.6901311 17 21 177
2017 65 606 972 3 -13 -28 0.04838710 -0.02100162 -0.028000000 1.0483871 0.9789984 0.9720000 20 8 149
2018 54 505 1034 -11 -101 62 -0.16923077 -0.16666667 0.063786008 0.8307692 0.8333333 1.0637860 9 -93 211
2019 55 532 1252 1 27 218 0.01851852 0.05346535 0.210831721 1.0185185 1.0534653 1.2108317 10 -66 429
2020 57 650 1260 2 118 8 0.03636364 0.22180451 0.006389776 1.0363636 1.2218045 1.0063898 12 52 437
2021 58 748 1369 1 98 109 0.01754386 0.15076923 0.086507937 1.0175439 1.1507692 1.0865079 13 150 546
2022 52 828 1498 -6 80 129 -0.10344828 0.10695187 0.094229364 0.8965517 1.1069519 1.0942294 7 230 675
ind |> 
  unnest(performance) |> 
  select(year, tot_charges:tot_payment) |> 
  change(!year) |> 
  gt(rowname_col = "year") |> 
  opt_table_font(font = google_font(name = "Fira Code")) |> 
  fmt_currency(columns = c(tot_charges, tot_allowed, tot_payment), decimals = 0) |> 
  fmt_currency(columns = ends_with("_chg"), decimals = 0, force_sign = TRUE) |> 
  fmt_percent(columns = ends_with("_pct"), decimals = 0, force_sign = TRUE) |> 
  fmt_percent(columns = ends_with("_ror"), decimals = 0)
tot_charges tot_allowed tot_payment tot_charges_chg tot_allowed_chg tot_payment_chg tot_charges_pct tot_allowed_pct tot_payment_pct tot_charges_ror tot_allowed_ror tot_payment_ror
2014 $319,401 $42,429 $33,775 $0 $0 $0 0% 0% 0% 100% 100% 100%
2015 $551,630 $82,729 $64,720 +$232,229 +$40,300 +$30,946 +73% +95% +92% 173% 195% 192%
2016 $653,517 $111,283 $87,144 +$101,887 +$28,554 +$22,424 +18% +35% +35% 118% 135% 135%
2017 $460,677 $88,160 $68,173 −$192,840 −$23,123 −$18,971 −30% −21% −22% 70% 79% 78%
2018 $504,640 $102,857 $80,079 +$43,963 +$14,697 +$11,906 +10% +17% +17% 110% 117% 117%
2019 $617,797 $134,101 $104,987 +$113,157 +$31,244 +$24,908 +22% +30% +31% 122% 130% 131%
2020 $482,488 $106,512 $81,868 −$135,309 −$27,589 −$23,119 −22% −21% −22% 78% 79% 78%
2021 $444,671 $97,159 $75,295 −$37,817 −$9,352 −$6,573 −8% −9% −8% 92% 91% 92%
2022 $347,737 $85,192 $64,041 −$96,934 −$11,967 −$11,254 −22% −12% −15% 78% 88% 85%
ind |> 
  unnest(performance) |> 
  select(year, .copay_deduct:.pymt_per_srvc) |> 
  change(!year) |> 
  gt(rowname_col = "year") |> 
  opt_table_font(font = google_font(name = "Fira Code")) |> 
  fmt_currency(columns = starts_with(".pymt"), decimals = 2)
.copay_deduct .srvcs_per_bene .pymt_per_bene .pymt_per_srvc .copay_deduct_chg .srvcs_per_bene_chg .pymt_per_bene_chg .pymt_per_srvc_chg .copay_deduct_pct .srvcs_per_bene_pct .pymt_per_bene_pct .pymt_per_srvc_pct .copay_deduct_ror .srvcs_per_bene_ror .pymt_per_bene_ror .pymt_per_srvc_ror
2014 8654.31 1.376254 $56.48 $41.04 0.00 0.00000000 $0.00 $0.00 0.00000000 0.000000000 $0.00 $0.00 1.0000000 1.0000000 $1.00 $1.00
2015 18008.80 1.390595 $62.11 $44.67 9354.49 0.01434083 $5.63 $3.63 1.08090535 0.010420189 $0.10 $0.09 2.0809054 1.0104202 $1.10 $1.09
2016 24139.05 1.615509 $140.78 $87.14 6130.25 0.22491388 $78.67 $42.48 0.34040303 0.161739309 $1.27 $0.95 1.3404030 1.1617393 $2.27 $1.95
2017 19987.25 1.603960 $112.50 $70.14 -4151.80 -0.01154849 −$28.29 −$17.01 -0.17199517 -0.007148515 −$0.20 −$0.20 0.8280048 0.9928515 $0.80 $0.80
2018 22778.23 2.047525 $158.57 $77.45 2790.98 0.44356436 $46.08 $7.31 0.13963802 0.276543210 $0.41 $0.10 1.1396380 1.2765432 $1.41 $1.10
2019 29113.51 2.353383 $197.34 $83.86 6335.28 0.30585871 $38.77 $6.41 0.27812872 0.149379736 $0.24 $0.08 1.2781287 1.1493797 $1.24 $1.08
2020 24643.63 1.938462 $125.95 $64.97 -4469.88 -0.41492192 −$71.39 −$18.88 -0.15353284 -0.176308675 −$0.36 −$0.23 0.8464672 0.8236913 $0.64 $0.77
2021 21864.13 1.830214 $100.66 $55.00 -2779.50 -0.10824763 −$25.29 −$9.97 -0.11278777 -0.055842034 −$0.20 −$0.15 0.8872122 0.9441580 $0.80 $0.85
2022 21150.38 1.809179 $77.34 $42.75 -713.75 -0.02103516 −$23.32 −$12.25 -0.03264479 -0.011493279 −$0.23 −$0.22 0.9673552 0.9885067 $0.77 $0.78

HCPCS Utilization Data

srvc |> 
  group_by(year, family) |> 
  mutate(hcpcs_level = dplyr::min_rank(dplyr::pick(avg_allowed, avg_payment))) |> 
  select(year, 
         hcpcs, 
         hcpcs_desc, 
         rank = hcpcs_level, 
         subcategory, 
         family, 
         tot_benes:tot_srvcs, 
         avg_charge:avg_payment) |> 
  arrange(year, family, rank) |> 
  gt(groupname_col = "subcategory") |> 
  gt_merge_stack(hcpcs, hcpcs_desc) |> 
  fmt_roman(rank) |> 
  cols_label(
    tot_benes = "Beneficiaries",
    tot_srvcs = "Services",
    avg_charge = "Charge",
    avg_allowed= "Allowed",
    avg_payment = "Payment") |> 
  opt_table_font(font = google_font(name = "Fira Code")) |> 
  fmt_currency(columns = starts_with("avg_"), decimals = 0) |> 
  opt_all_caps()
#> Error: object 'srvc' not found


srvc |> 
  select(year, 
         hcpcs, 
         family, 
         tot_benes, 
         tot_srvcs, 
         avg_charge, 
         avg_allowed, 
         avg_payment) |> 
  group_by(year, family) |> 
  summarise(tot_benes = sum(tot_benes),
            tot_srvcs = sum(tot_srvcs),
            avg_charge = mean(avg_charge), 
            avg_allowed = mean(avg_allowed), 
            avg_payment = mean(avg_payment), .groups = "drop") |>
  arrange(family) |> 
  gt(rowname_col = "year") |> 
  fmt_currency(columns = starts_with("avg_"), decimals = 0) |>
  cols_label(
    tot_benes = "Beneficiaries",
    tot_srvcs = "Services",
    avg_charge = "Charge",
    avg_allowed= "Allowed",
    avg_payment = "Payment") |> 
  opt_table_font(font = google_font(name = "JetBrains Mono")) |> 
  opt_all_caps()
#> Error: object 'srvc' not found
hcpcs |> 
  group_by(year, level, subcategory) |>
  summarise(Beneficiaries = sum(beneficiaries),
            Services = sum(services),
            "Average Payment" = mean(avg_payment), .groups = "drop") |>
  arrange(year, subcategory) |>
  gt(rowname_col = "year") |> 
  cols_align("left", level) |> 
  cols_move_to_start(columns = subcategory) |> 
  fmt_integer(columns = c(Beneficiaries, Services)) |> 
  fmt_currency(columns = c('Average Payment'), decimals = 2) |> 
  opt_table_font(font = google_font(name = "JetBrains Mono")) |>
  tab_header(title = md("**Medicare Part B** Utilization")) |> 
  opt_horizontal_padding(scale = 2) |> 
  tab_options(table.width = pct(50),
              column_labels.font.weight = "bold",
              row_group.font.weight = "bold",
              heading.background.color = "black",
              heading.align = "left") |> 
  opt_all_caps()
#> Error: object 'hcpcs' not found
hcpcs |> 
  select(year, 
         level,
         hcpcs,
         category,
         subcategory,
         family, 
         beneficiaries, 
         services, 
         avg_charge, 
         avg_allowed, 
         avg_payment) |> 
  arrange(hcpcs, year) |>
  gt(rowname_col = "year") |> 
  cols_label(
    hcpcs = "HCPCS",
    avg_charge = "Charge",
    avg_allowed= "Allowed",
    avg_payment = "Payment") |> 
  cols_align(columns = "level", align = "left") |>
  fmt_integer(columns = c(beneficiaries, services)) |>
  fmt_currency(columns = starts_with("avg_"), decimals = 0) |>
  opt_table_font(font = google_font(name = "JetBrains Mono")) |> 
  opt_all_caps()
#> Error: object 'hcpcs' not found

Demographics

ind |> 
  unnest(performance, demographics) |> 
  select(year, tot_benes, starts_with("bene_")) |> 
  select(-bene_race_detailed) |> 
  gt(rowname_col = "year") |> 
  cols_label(tot_benes = "Total") |>  
  fmt_percent(columns = starts_with("cc_"), decimals = 0) |>
  opt_table_font(font = google_font(name = "JetBrains Mono")) |> 
  sub_missing(missing_text = "") |>
  sub_zero(zero_text = "") |>
  opt_all_caps()
Total bene_age_avg bene_age_lt65 bene_age_65_74 bene_age_75_84 bene_age_gt84 bene_gen_female bene_gen_male bene_race_wht bene_race_nonwht bene_dual bene_ndual
2014 598 73 92 231 183 92 285 313 558 40 84 514
2015 1042 72 191 398 313 140 498 544 963 79 181 861
2016 619 73 95 235 211 78 306 313 572 47 104 515
2017 606 73 85 246 179 96 287 319 558 48 81 525
2018 505 74 63 206 167 69 221 284 478 27 65 440
2019 532 74 59 222 173 78 226 306 494 38 61 471
2020 650 75 65 270 205 110 278 372 611 39 62 588
2021 748 75 57 333 232 126 343 405 692 56 62 686
2022 828 75 65 331 293 139 365 463 766 62 78 750

Chronic Conditions

ind |> 
  unnest(performance) |> 
  select(year, tot_benes, conditions) |> 
  unnest(conditions) |>
  gt(rowname_col = "year") |> 
  cols_label(tot_benes = "Total") |>  
  fmt_percent(columns = starts_with("cc_"), decimals = 0) |>
  opt_table_font(font = google_font(name = "JetBrains Mono")) |> 
  sub_missing(missing_text = "") |>
  sub_zero(zero_text = "") |>
  opt_all_caps()
Total hcc_risk_avg
2014 598 1.6600
2015 1042 1.7875
2016 619 1.9854
2017 606 1.8878
2018 505 2.0006
2019 532 1.9231
2020 650 1.7989
2021 748 1.7815
2022 828 1.7543