Skip to contents

cmsmrf is an R package in early development at CentralStatz Statistical & Data Sciences LLC. It is intended for analysts, researchers, data scientists, and developers who need to understand and use healthcare price transparency machine-readable files (MRFs) published under Centers for Medicare & Medicaid Services (CMS) requirements.

CRAN Status CRAN_Download_CounterR CMD check pkgdown License: Apache 2.0 Codecov test coverage

Installation

Install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("centralstatz/cmsmrf")

Current status

The package is at development version 0.0.0.9000 and has not been released on CRAN. mrf_specification() returns the package’s static reference to the CMS Hospital Price Transparency (HPT) JSON v3 schema and data dictionary:

This reference identifies the specification used for package development. It does not assess whether an individual hospital file conforms to that specification.

For an executable introduction using the bundled fictional files, open vignette("cmsmrf", package = "cmsmrf") after installation.

mrf_inspect() reports a small source overview. mrf_parse() extracts the approved source fields and relations from one or more local HPT JSON v3 files, in the supplied order, into one persistent DuckDB database. For example:

path <- system.file("examples", "hospital-basic.json", package = "cmsmrf")
inspection <- cmsmrf::mrf_inspect(path)
inspection[c("hospital_name", "service_count", "type_2_npi_count")]
paths <- system.file("examples", c("hospital-basic.json", "hospital-detailed.json"), package = "cmsmrf")
database <- tempfile(fileext = ".duckdb")
cmsmrf::mrf_parse(paths, database, quiet = TRUE)
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = database, read_only = TRUE)
DBI::dbGetQuery(con, "SELECT file_id, file_name, sha256, status FROM source_file ORDER BY file_id")
DBI::dbGetQuery(con, "SELECT file_id, hospital_name FROM mrf_file ORDER BY file_id")
DBI::dbGetQuery(con, "SELECT file_id, provision_id, provisions FROM contract_provision")
DBI::dbGetQuery(con, "SELECT file_id, modifier_code, modifier_id FROM charge_modifier")
DBI::dbGetQuery(con, "SELECT file_id, relation_name, row_count FROM file_summary WHERE relation_name = 'service' ORDER BY file_id")
DBI::dbGetQuery(con, "SELECT file_id, diagnostic_id, message FROM diagnostic ORDER BY file_id, diagnostic_id")
DBI::dbDisconnect(con)

Inspection describes source contents; the database reports rows actually extracted. Each input receives a one-based file_id, including failed and repeated inputs. The sha256 column identifies the supplied file bytes when a fingerprint is obtainable, even if extraction later fails. It is not a record key, and identical fingerprints do not collapse repeated inputs. Files are assumed to remain unchanged during processing. Each file is processed in its own transaction: a failed attempt retains its source_file row and failure diagnostic, without partial source rows or summaries; later inputs continue when the database remains usable. A completed operation returns the database path even when every input fails. Extraction success means that the supported operations completed, not that the source conforms to CMS requirements. All 12 approved source relations and their documented fields have extraction paths, including optional contract provisions, modifier definitions and references, notes, and historical allowed-amount statistics. Numeric values use ordinary double-precision conversion; an unconvertible value becomes NULL with a field-level diagnostic while other usable information remains available. An unresolved modifier reference retains its original code and a NULL link, with a concise finding. If fingerprinting fails but extraction succeeds, sha256 remains NULL and a provenance finding is recorded. A successful file can have no findings; an empty diagnostic relation does not certify CMS conformance. file_summary counts rows actually materialized per successful file, including zeros.

Data model

The database has 16 relations: 12 preserve source-disclosed hospital information, and four record database creation context, attempted files, per-file counts, and consequential processing findings. source_file identifies every attempted input; an mrf_file row represents its materialized JSON root. The diagram shows their relationships.

High-level HPT JSON relational model

The HPT JSON Relational Data Model vignette is the authoritative contract for grains, fields, keys, CMS source mappings, processing information, and interpretation limits. From an installed package, open it with vignette("data-model", package = "cmsmrf").

Fictional example files

Two independently authored HPT JSON v3 files are bundled for reading and extraction examples. hospital-basic.json shows a small hospital disclosure; hospital-detailed.json adds repeated services, pricing forms, drugs, modifiers, and optional context. All hospital, payer, plan, and price information is fictional. Locate and open the raw files with standard R package file access:

system.file("examples", package = "cmsmrf")
system.file("examples", "hospital-basic.json", package = "cmsmrf")
system.file("examples", "hospital-detailed.json", package = "cmsmrf")

Both files can be inspected with mrf_inspect() and extracted individually or together with mrf_parse(). Large sources may need substantial memory and disk space; successful extraction of two realistic single-root files does not establish support for arbitrary larger files.

Planned initial release

The intended v0.0.1 release focuses on HPT files in the JSON v3 format. The source-aware relational model, fictional examples, lightweight inspection, and verified one-file or multi-file extraction across the approved source model, with file-byte fingerprints and consequential diagnostics, are available. The final public workflow and release work remain planned. CSV layouts, Transparency in Coverage files, and other CMS specification families are outside the initial release scope.

Development takes place in the cmsmrf repository. The package website provides the current package reference, and issues can be reported in the issue tracker.