The cms package implements a set of tools to download and clean publically available Medicare data, published on https://www.cms.gov, for analysis in R. This vignette provides an overview of the key features of the package.
The get_mpfs
function returns national payment files for the Medicare Physician Fee Schedule (MPFS). All revisions for a specified year between 2014 and 2020, inclusive (specified as 2-digit integer, 14 through 20) are downloaded from the CMS website to a user-specified path.
# Example, code not run within vignette itself.
# Result is hardcoded and displayed for illustrative purposes.
library(cms)
# download and view first few rows of 2020 MPFS database
mpfs20 <- get_mpfs(20, storage_path = 'storage', keep_downloads = TRUE)
head(mpfs20, 3)
#> Year Carrier Number Locality HCPCS Code Modifier PCTC Indicator Status Code
#> 1 2020 01112 05 G0076 none 0 A
#> 2 2020 01112 06 G0076 none 0 A
#> 3 2020 01112 07 G0076 none 0 A
#> Multiple Surgery Indicator 50% Therapy Reduction Amount (non-institutional)
#> 1 0 0000000.00
#> 2 0 0000000.00
#> 3 0 0000000.00
#> 50% Therapy Reduction Amount (institutional) OPPS Indicator Facility Fee
#> 1 0000000.00 9 63.64
#> 2 0000000.00 9 63.64
#> 3 0000000.00 9 63.64
#> Non-Facility Fee OPPS Facility Fee OPPS Non-Facility Fee
#> 1 63.64 0 0
#> 2 63.64 0 0
#> 3 63.64 0 0
By default, get_mpfs
will store downloaded .zip
files so that subsequent calls to get_mpfs
with the same year and storage path will not require redownloading the raw data to import the database. get_mpfs
will instead delete downloaded files by passing the argument keep_downloads = FALSE
.
Optionally, users can specify a valid 7-digit locality code (5-digit carrier number + 2-digit locality, passed as a single string) to instruct get_mpfs
to return only the data corresponding to that locality:
# Example, code not run within vignette itself.
# Result is hardcoded and displayed for illustrative purposes.
mpfs20_ohio <- get_mpfs(20, storage_path = 'storage', locality = '1520200')
head(mpfs20_ohio, 3)
#> Year Carrier Number Locality HCPCS Code Modifier PCTC Indicator Status Code
#> 1 2020 15202 00 G0076 none 0 A
#> 2 2020 15202 00 G0077 none 0 A
#> 3 2020 15202 00 G0078 none 0 A
#> Multiple Surgery Indicator 50% Therapy Reduction Amount (non-institutional)
#> 1 0 0000000.00
#> 2 0 0000000.00
#> 3 0 0000000.00
#> 50% Therapy Reduction Amount (institutional) OPPS Indicator Facility Fee
#> 1 0000000.00 9 55.71
#> 2 0000000.00 9 79.54
#> 3 0000000.00 9 131.29
#> Non-Facility Fee OPPS Facility Fee OPPS Non-Facility Fee
#> 1 55.71 0 0
#> 2 79.54 0 0
#> 3 131.29 0 0
The locality_dict
dataset contains the locality definitions used by the MPFS, updated for 2020.