Skip to contents

Why these files?

Hospitals publish machine-readable files (MRFs) of standard charges and related context under CMS Hospital Price Transparency requirements. A file can contain many nested service, code, charge, and payer-term records. This article uses cmsmrf to turn three actual Aspirus Health price-transparency files into one relational DuckDB database, then asks a few exploratory questions of that database.

The selection is Aspirus Wausau Hospital, Aspirus Eagle River Hospital, and Aspirus Divine Savior Hospital. They are examples for this tutorial, not the full Aspirus collection or a representative sample of hospital prices. Start with Getting Started with cmsmrf for the smaller fictional workflow and use the data-model guide for complete relation and field definitions. The package currently supports HPT JSON schema V3.0.0, informed by data dictionary v3.0:

library(cmsmrf)
reference <- mrf_specification()
reference[c("format", "schema_version", "dictionary_version",
            "reference_date", "repository_commit")]
#> $format
#> [1] "JSON"
#> 
#> $schema_version
#> [1] "3.0.0"
#> 
#> $dictionary_version
#> [1] "3.0"
#> 
#> $reference_date
#> [1] "2026-11-27"
#> 
#> $repository_commit
#> [1] "6855f04377ec6e87f88798cd618a27a826eebd2a"

That pinned CMS reference describes the structure the package targets. Neither it nor a successful extraction certifies a hospital’s regulatory compliance.

Find and acquire three hospital files

Aspirus publishes a hospital MRF inventory with repeated groups of location-name, source-page-url, mrf-url, and contact lines. We read the hospital names and URLs in their published order, then select exactly three names. Edit work_dir or set CMSMRF_ASPIRUS_DIR to a directory with enough space outside the package repository. The directory retains the inventory, source files, and database for later exploration.

work_dir <- Sys.getenv(
  "CMSMRF_ASPIRUS_DIR",
  unset = file.path(path.expand("~"), "cmsmrf-aspirus")
)
dir.create(work_dir, recursive = TRUE, showWarnings = FALSE)
inventory_url <- paste0(
  "https://www.aspirus.org/Uploads/Public/Documents/PriceEstimate/",
  "TransparencyFY27/cms-hpt.txt"
)
inventory_file <- file.path(work_dir, "cms-hpt.txt")
old_timeout <- getOption("timeout")
options(timeout = max(600, old_timeout))
if (!file.exists(inventory_file)) {
  download.file(inventory_url, inventory_file, mode = "wb",
                method = "libcurl", quiet = TRUE)
}

lines <- readLines(inventory_file, warn = FALSE)
hospital_names <- sub("^location-name: ", "",
                      grep("^location-name: ", lines, value = TRUE))
mrf_urls <- sub("^mrf-url: ", "",
                grep("^mrf-url: ", lines, value = TRUE))
stopifnot(length(hospital_names) == length(mrf_urls))
inventory <- data.frame(hospital = hospital_names, url = mrf_urls)
data.frame(inventory_entries = nrow(inventory),
           distinct_urls = length(unique(inventory$url)))
#>   inventory_entries distinct_urls
#> 1                18            18

chosen_names <- c("Aspirus Wausau Hospital", "Aspirus Eagle River Hospital",
                  "Aspirus Divine Savior Hospital")
stopifnot(all(vapply(chosen_names, function(x) sum(inventory$hospital == x) == 1L,
                     logical(1))))
selected <- inventory[match(chosen_names, inventory$hospital), ]
knitr::kable(data.frame(hospital = selected$hospital,
                        source_file = basename(selected$url)))
hospital source_file
Aspirus Wausau Hospital 391138241_1558363986_aspirus-wausau-hospital_standardcharges.json
Aspirus Eagle River Hospital 390985690_1346204385_aspirus-eagle-river-hospital_standardcharges.json
Aspirus Divine Savior Hospital 390806250_1124083894_aspirus-divine-savior-hospital_standardcharges.json

The mrf-url values in selected$url came from the retrieved inventory. Its 18 entries and 18 distinct URLs are publisher listings; we intentionally download only the three selected files. If an inventory repeats a URL, a reader may avoid a duplicate transfer, while mrf_parse() will still treat each path supplied to it as a separate input occurrence.

These URLs end in .json and the publisher reported uncompressed files of roughly 161–212 MB each when this article was prepared. Allow time and disk space for the downloads and a database; a filename or HTTP header alone does not prove that a source will be processable. The following code downloads missing files into work_dir. Existing files are reused deliberately, so start with a fresh directory if you want a fresh published snapshot. If a transfer leaves a partial file, remove that file before trying again.

paths <- file.path(work_dir, basename(selected$url))
for (i in seq_along(paths)) {
  if (!file.exists(paths[[i]])) {
    download.file(selected$url[[i]], paths[[i]], mode = "wb",
                  method = "libcurl", quiet = TRUE)
  }
}
options(timeout = old_timeout)
stopifnot(all(file.exists(paths)))
knitr::kable(data.frame(hospital = selected$hospital,
                        source_mb = round(file.info(paths)$size / 1e6, 1)))
hospital source_mb
Aspirus Wausau Hospital 211.7
Aspirus Eagle River Hospital 160.6
Aspirus Divine Savior Hospital 207.5

For the displayed snapshot, the inventory was retrieved on 2026-12-02. Wausau and Eagle River bytes had been acquired on 2026-11-30 for earlier package work; their sizes and SHA-256 fingerprints matched that earlier record and their current publisher size and modification headers. Divine Savior was downloaded on 2026-12-02. The three files total about 580 MB. Later inventory entries or file contents may differ.

Inspect and extract

Inspection gives a compact look at each source before extraction. The supported-version flag compares the file’s declared template version with the version recognized by cmsmrf; it is not a CMS compliance judgment.

inspected <- lapply(paths, mrf_inspect)
knitr::kable(do.call(rbind, lapply(seq_along(inspected), function(i) {
  x <- inspected[[i]]
  data.frame(hospital = x$hospital_name, updated = x$last_updated_on,
             declared_version = x$declared_version,
             supported = x$supported_version,
             service_entries = x$service_count)
})))
hospital updated declared_version supported service_entries
Aspirus Wausau Hospital 2026-04-01 3.0.0 TRUE 379822
Aspirus Eagle River Hospital 2026-04-01 3.0.0 TRUE 370518
Aspirus Divine Savior Hospital 2026-04-01 3.0.0 TRUE 379603

All three inspected sources declare version 3.0.0 and update date 2026-04-01. We now put them into one persistent database. The order in chosen_names determines file_id: Wausau is 1, Eagle River 2, and Divine Savior 3. mrf_parse() will not overwrite an existing database, so the conditional below reuses a completed working database during article development. A reader starting with an empty working directory executes the same one-call extraction. The small elapsed-time record keeps that measurement with the working database; it is not a package artifact.

database <- file.path(work_dir, "aspirus-three.duckdb")
elapsed_file <- file.path(work_dir, "extraction-seconds.rds")
if (!file.exists(database)) {
  seconds <- unname(system.time(
    mrf_parse(paths, output = database, quiet = TRUE)
  )[["elapsed"]])
  saveRDS(seconds, elapsed_file)
}
elapsed_seconds <- if (file.exists(elapsed_file)) readRDS(elapsed_file) else NA_real_
knitr::kable(data.frame(
  extraction_minutes = round(elapsed_seconds / 60, 1),
  database_mb = round(file.info(database)$size / 1e6, 1)
))
extraction_minutes database_mb
7.9 287.6

This run took about 7.9 minutes and created a 287.6 MB DuckDB file. Duration and storage are observations for these bytes and this environment, not guarantees for other files. The completed database can be reopened independently, including after the producing R session ends. Read-only access is appropriate for exploration:

con <- suppressMessages(DBI::dbConnect(
  duckdb::duckdb(), dbdir = database, read_only = TRUE
))

What was extracted?

First check database context and source outcomes. source_file has one row per attempted input, including failures; its full SHA-256 value describes the supplied bytes, not a hospital identity or deduplication key. The table below displays only a short fingerprint prefix for readability.

knitr::kable(DBI::dbGetQuery(con, "
  SELECT package_version, schema_version, dictionary_version, reference_date
  FROM database_metadata
"))
package_version schema_version dictionary_version reference_date
0.0.0.9000 3.0.0 3.0 2026-11-27
knitr::kable(DBI::dbGetQuery(con, "
  SELECT sf.file_id, mf.hospital_name,
         round(sf.file_size_bytes / 1000000.0, 1) AS source_mb,
         sf.status, substr(sf.sha256, 1, 12) AS sha256_prefix
  FROM source_file AS sf
  LEFT JOIN mrf_file AS mf ON mf.file_id = sf.file_id
  ORDER BY sf.file_id
"))
file_id hospital_name source_mb status sha256_prefix
1 Aspirus Wausau Hospital 211.7 success 30e731215ce0
2 Aspirus Eagle River Hospital 160.6 success 7fcf6ece2837
3 Aspirus Divine Savior Hospital 207.5 success a34394598f75

All three attempts succeeded. Successful files have one mrf_file root row and 12 file_summary rows, one for each source-derived relation. The following summary compares source occurrences, not distinct real-world services or payer contracts. service_code counts each reported code occurrence; charge counts charge contexts; payer_charge counts disclosed payer terms.

knitr::kable(DBI::dbGetQuery(con, "
  SELECT mf.hospital_name,
    max(CASE WHEN fs.relation_name = 'service' THEN fs.row_count END) AS services,
    max(CASE WHEN fs.relation_name = 'service_code' THEN fs.row_count END) AS codes,
    max(CASE WHEN fs.relation_name = 'charge' THEN fs.row_count END) AS charges,
    max(CASE WHEN fs.relation_name = 'payer_charge' THEN fs.row_count END) AS payer_terms
  FROM file_summary AS fs
  JOIN mrf_file AS mf ON mf.file_id = fs.file_id
  GROUP BY mf.file_id, mf.hospital_name
  ORDER BY mf.file_id
"), format.args = list(big.mark = ","))
hospital_name services codes charges payer_terms
Aspirus Wausau Hospital 379,822 1,103,438 383,606 252,014
Aspirus Eagle River Hospital 370,518 1,094,134 372,690 37,315
Aspirus Divine Savior Hospital 379,603 1,103,219 382,105 256,781
knitr::kable(DBI::dbGetQuery(con,
  "SELECT count(*) AS recorded_findings FROM diagnostic"))
recorded_findings
0

The files have similarly large service tables, but Eagle River has substantially fewer payer-term rows than the other two in this snapshot. That describes the number of source records materialized; it does not establish how many patients or covered services each hospital has. The empty diagnostic table means no implemented reactive finding was recorded for these files, not that the files are error-free or CMS-compliant. The data-model guide also explains location, NPI, drug, modifier, and other relation families that are not expanded here.

Two ways to explore the disclosures

How are payer terms expressed?

The three sources disclose fee-schedule dollars, percentages of billed charges, and other methods that include algorithms. Count the reported methodology labels before interpreting any amount:

knitr::kable(DBI::dbGetQuery(con, "
  SELECT mf.hospital_name, count(*) AS payer_terms,
    count(*) FILTER (WHERE p.methodology = 'fee schedule') AS fee_schedule,
    count(*) FILTER (WHERE p.methodology = 'percent of total billed charges')
      AS percentage,
    count(*) FILTER (WHERE p.methodology = 'other') AS other
  FROM payer_charge AS p
  JOIN mrf_file AS mf ON mf.file_id = p.file_id
  GROUP BY mf.file_id, mf.hospital_name
  ORDER BY mf.file_id
"), format.args = list(big.mark = ","))
hospital_name payer_terms fee_schedule percentage other
Aspirus Wausau Hospital 252,014 209,188 11,509 31,317
Aspirus Eagle River Hospital 37,315 15,743 7,642 13,930
Aspirus Divine Savior Hospital 256,781 219,927 5,609 31,245

The method mix differs markedly: Eagle River has many fewer fee-schedule dollar terms and a larger share of percentage and other rows than the other two. These are counts of disclosed terms, not measures of payer market share or comparable service prices.

For a concrete example, consider one Wausau inpatient facility charge under the source’s MS-DRG 216 entry. Two of its payer terms illustrate different forms. The join to service and charge uses the full file/service/charge parent key; the selected positional IDs identify this source occurrence, not a stable cross-hospital procedure.

terms <- DBI::dbGetQuery(con, "
  SELECT p.payer_id, p.payer_name, p.plan_name, p.methodology,
         p.standard_charge_percentage, p.standard_charge_algorithm,
         p.allowed_amount_count, p.median_amount
  FROM payer_charge AS p
  JOIN charge AS ch
    ON ch.file_id = p.file_id AND ch.service_id = p.service_id
   AND ch.charge_id = p.charge_id
  JOIN service AS s
    ON s.file_id = ch.file_id AND s.service_id = ch.service_id
  WHERE p.file_id = 1 AND p.service_id = 377380 AND p.charge_id = 2
    AND p.payer_id IN (33, 34)
    AND ch.setting = 'inpatient' AND ch.billing_class = 'facility'
  ORDER BY p.payer_id
")
knitr::kable(data.frame(
  payer = terms$payer_name,
  plan = terms$plan_name,
  reported_term = ifelse(
    is.na(terms$standard_charge_percentage),
    terms$standard_charge_algorithm,
    paste0(terms$standard_charge_percentage, "% of total billed charges")
  ),
  historical_count = terms$allowed_amount_count,
  historical_median = terms$median_amount
))
payer plan reported_term historical_count historical_median
Security Health Plan Of Wisconsin, Inc. Security Health Plan Wisconsin Medicare Advantage Plans [MSDRG Base Rate: 103% of Medicare] 1 through 10 79772.66
The Alliance (F/K/A Employer Health Care Alliance Cooperative) The Alliance Network Commercial Plans 81.99% of total billed charges 1 through 10 139894.46

One term reports 81.99% of total billed charges; the other gives an MS-DRG base-rate algorithm. Neither is a directly reported negotiated dollar amount for that charge. The historical median allowed amounts and count categories describe past claims and do not supply a future patient bill. Gross charges, discounted cash charges, negotiated dollars, percentage terms, algorithms, and historical allowed amounts have distinct meanings; a missing value is not zero.

Does one billing code mean one price?

The published files label 70551 as an HCPCS code. An existence filter finds services carrying that code without multiplying charge rows by sibling code entries. The query counts service and charge occurrences separately for each file:

knitr::kable(DBI::dbGetQuery(con, "
  WITH matched AS (
    SELECT s.file_id, s.service_id
    FROM service AS s
    WHERE EXISTS (
      SELECT 1 FROM service_code AS sc
      WHERE sc.file_id = s.file_id AND sc.service_id = s.service_id
        AND sc.code_type = 'HCPCS' AND sc.code = '70551'
    )
  )
  SELECT mf.hospital_name, count(DISTINCT matched.service_id) AS service_entries,
         count(ch.charge_id) AS charge_contexts
  FROM matched
  JOIN mrf_file AS mf ON mf.file_id = matched.file_id
  JOIN charge AS ch
    ON ch.file_id = matched.file_id AND ch.service_id = matched.service_id
  GROUP BY mf.file_id, mf.hospital_name
  ORDER BY mf.file_id
"))
hospital_name service_entries charge_contexts
Aspirus Wausau Hospital 4 7
Aspirus Eagle River Hospital 4 6
Aspirus Divine Savior Hospital 4 7

Each file has four service entries with this code, and those entries contain multiple charge contexts. A few Wausau rows show why the context matters:

knitr::kable(DBI::dbGetQuery(con, "
  SELECT s.service_id, ch.charge_id, ch.setting, ch.billing_class,
         ch.gross_charge, ch.discounted_cash,
         (SELECT count(*) FROM payer_charge AS p
          WHERE p.file_id = ch.file_id AND p.service_id = ch.service_id
            AND p.charge_id = ch.charge_id) AS payer_terms
  FROM service AS s
  JOIN charge AS ch
    ON ch.file_id = s.file_id AND ch.service_id = s.service_id
  WHERE s.file_id = 1 AND s.service_id IN (11219, 370817)
    AND EXISTS (
      SELECT 1 FROM service_code AS sc
      WHERE sc.file_id = s.file_id AND sc.service_id = s.service_id
        AND sc.code_type = 'HCPCS' AND sc.code = '70551'
    )
  ORDER BY s.service_id, ch.charge_id
"))
service_id charge_id setting billing_class gross_charge discounted_cash payer_terms
11219 1 both facility 4558 2962.7 0
370817 1 outpatient facility NA NA 19
370817 2 both professional NA NA 10

The selected records include facility and professional contexts. Some report gross and cash amounts, while others report payer-specific terms with those fields missing. They are not alternative prices for one automatically interchangeable service. Even if two hospitals report the same code or description, setting, billing class, modifiers, payer/plan terms, and source context can differ. Combining every code with every charge and payer child can also create unintended row multiplication; choose a question’s grain and join on complete source-relative keys.

What this snapshot can and cannot say

These three files demonstrate that a relational database makes large, nested disclosures searchable and lets us distinguish records, contexts, and pricing forms. The observations describe the published source entries captured here, not normalized services, resolved payer identities, utilization-weighted averages, hospital efficiency, insurer-only payments, or patient-specific costs. Source update dates are 2026-04-01; the inventory was retrieved on 2026-12-02. Later publisher files can change, and the selected trio is not the entire Aspirus system. The package’s SHA-256 values help identify these supplied bytes, but a digest is not an extraction decision or compliance certificate.

To adapt the workflow, select different location-name rows from inventory, download their mrf-url values, inspect each source, then pass their paths to mrf_parse() in the order you want reflected by file_id. Inspect source_file and diagnostic before analysis. Keep the persistent database in your chosen working directory for future queries. For complete field meanings and relationships, use the data-model guide; for a smaller first run, use Getting Started with cmsmrf.