Skip to contents

Scope and source

This vignette is the authoritative logical relational contract for the cmsmrf Hospital Price Transparency (HPT) JSON v3 database. It defines 16 relations: 12 describing information disclosed in source MRFs and four containing package-generated creation context, attempted-file outcomes, materialized row counts, and processing findings. mrf_inspect() reports a small source overview, while mrf_parse() creates the complete database structure for one or more ordered local sources, populates all approved source fields and relations, records obtainable file-byte SHA-256 fingerprints, and retains consequential processing findings. The extraction engine has completed Stage 4 integrated verification; the final public workflow and release work remain in development.

For a guided first extraction, see Getting Started with cmsmrf. This document remains the reference for complete relation and field definitions.

Two small, independently authored fictional JSON files are bundled at system.file("examples", package = "cmsmrf"): hospital-basic.json introduces the nesting, while hospital-detailed.json exercises all 12 source-derived relations. Both can be inspected individually and processed individually or together through the same extraction path.

The source reference is the CMS JSON schema V3.0.0 and JSON data dictionary v3.0, both at CMS repository commit 6855f04377ec6e87f88798cd618a27a826eebd2a. mrf_specification() returns this reference. The schema defines JSON structure and some conditions; the dictionary explains meanings and additional conditions. Neither specifies the relational tables below. Table names, column names, keys, and positional location/address pairing are package modeling decisions.

Paths use [] for one JSON array element. In each source-derived column table, Source is relative to the relation’s stated source path unless a full path is shown. “Generated” identifies a package-assigned technical key, not a CMS field. “CMS-required” and “conditional” describe source expectations, not future physical NOT NULL constraints. Dictionary-only fields are named explicitly because the pinned schema does not enumerate them.

Relation overview

The four package-generated relations describe the database and processing outcome:

Relation Grain Relationship
database_metadata One row per completed database Standalone database-wide context
source_file One row per attempted input Parent of mrf_file, file_summary, and diagnostic
file_summary One row per successful input and source-derived relation file_id references source_file
diagnostic One row per recorded finding file_id references source_file

The 12 source-derived relations retain the grains of the disclosed JSON:

Parent Direct source-derived children Relationship
mrf_file file_location, file_npi, contract_provision, service, modifier File context and root arrays
service service_drug, service_code, charge Optional drug object, codes, charges
charge charge_modifier, payer_charge Modifier references and payer terms
modifier modifier_payer Payer-specific modifier explanations

source_file establishes attempted-file identity. A source_file row has zero or one corresponding materialized mrf_file row. mrf_file.file_id is both its PK and an FK to source_file.file_id; its existing children keep their parent FKs. charge_modifier.modifier_id has a separate, conditional reference to modifier only when its code identifies exactly one root definition. The other processing relations do not create direct links to source-derived records. The complete hierarchy is shown below; column definitions and precise relationship conditions follow.

Logical relational model: four package-generated relations and twelve source-derived relations.
Logical relational model: four package-generated relations and twelve source-derived relations.

The root arrays location_name[] and hospital_address[] feed one file_location relation by position. This follows the dictionary’s description of corresponding locations and addresses; the JSON schema itself does not enforce equal lengths or declare a link between the arrays. No source key associates a service with a location or NPI, a code with one particular charge within its service, a contract provision with one payer term, or a modifier payer explanation with one payer charge. Labels and repeated values are not substitute keys.

Relational conventions

All relation and column names are lowercase snake_case. source_file.file_id is the authoritative compact positive INTEGER assigned by input order, starting at 1 for every attempted input, even after an earlier failure. The same file_id occurs in every applicable source-derived relation, including for a single input file. Other *_id keys are compact positive INTEGER positions starting at 1 within the stated source array and parent key; diagnostic_id is positive and scoped within its file. location_id is the shared position in the two paired root arrays. A repeated value still receives its own positional key. These keys identify source occurrences or findings within one extraction, not stable real-world hospitals, services, codes, payers, plans, or contracts. Reordering inputs or array elements can change IDs.

Each relation below states its primary key (PK), where applicable, and foreign keys (FKs). Keys are separate columns rather than concatenated strings. Logical types are INTEGER for compact technical keys, BIGINT for potentially large file sizes and row counts, TEXT for JSON and metadata strings, BOOLEAN for JSON booleans, NUMERIC for JSON numbers, DATE for the package-controlled reference date, and TIMESTAMP for a package-generated creation instant. The current DuckDB implementation uses VARCHAR for TEXT, TIMESTAMPTZ for the creation instant, and ordinary double-precision DOUBLE for numeric fields. last_updated_on and allowed_amount_count remain TEXT to preserve disclosed strings. A present numeric value that cannot be converted to a finite number is stored as NULL with a source-positioned diagnostic; absent optional values do not generate conversion findings. The dictionary generally expects positive numeric values, but this document does not implement compliance validation.

An absent optional source scalar is represented as NULL, never an invented zero or empty string. A source-derived row exists when its source object or array position exists; an absent optional array or object yields zero rows in its relation. All 16 relations retain their defined columns and relationships even when empty. One or many inputs use the same structure, types, keys, and missingness rules; only row populations change. A completed database has one metadata row and one source_file row per attempted input. The pinned schema requires nonempty standard_charge_information[], code_information[], and standard_charges[], and nonempty optional arrays when supplied. The extractor assumes the supported source structure; it does not repair fundamentally irregular input or distinguish explicit JSON null from omission in the relational output.

Package-generated processing information

These relations describe the result of a single extraction undertaking, potentially involving several inputs. They are generated by cmsmrf, not fields in a hospital’s JSON. They support interpretation after the original R session and source files are gone. The model does not define a historical ingestion system, a compliance certification, or processing mechanics.

database_metadata

Grain: Exactly one row per completed database. PK/FK: None; the singleton invariant does not require an artificial ID. Every field is expected to be populated in a completed database.

Column Type Origin Requiredness Meaning
created_at TIMESTAMP Package creation event Expected Unambiguous database creation instant in UTC
package_version TEXT Installed cmsmrf version Expected Version used to produce the database
specification_family TEXT mrf_specification()$family Expected Supported CMS specification family
specification_format TEXT mrf_specification()$format Expected Supported source format
schema_version TEXT mrf_specification()$schema_version Expected Referenced CMS schema version
dictionary_version TEXT mrf_specification()$dictionary_version Expected Referenced CMS data dictionary version
reference_date DATE mrf_specification()$reference_date Expected Package-defined specification reference date
repository_url TEXT mrf_specification()$repository_url Expected CMS specification repository URL
repository_commit TEXT mrf_specification()$repository_commit Expected Referenced CMS repository commit
schema_url TEXT mrf_specification()$schema_url Expected Referenced CMS schema URL
dictionary_url TEXT mrf_specification()$dictionary_url Expected Referenced CMS dictionary URL

created_at is an instant rather than a local wall-clock time; the current DuckDB implementation stores it as TIMESTAMPTZ. reference_date is a package-controlled date, unlike source-text mrf_file.last_updated_on. The persisted reference allows the database to explain its governing package and specification without a separate installation. It records no user, host, R session, filesystem path, run history, or execution duration.

source_file

Grain: One row per attempted input file, including an attempt that fails. PK: file_id. The filename and terminal status are expected for each recorded attempt; size and digest may be NULL when unobtainable.

Column Type Origin Requiredness Meaning
file_id INTEGER Package-assigned input order Key One-based attempted-file position, never reassigned after a preceding failure
file_name TEXT Supplied file basename Expected Filename only, without directory or filesystem path; not unique
file_size_bytes BIGINT Supplied file bytes Nullable if unobtainable Size of original supplied file in bytes
sha256 TEXT Supplied file bytes Nullable if unobtainable Conventional hexadecimal SHA-256 content digest
status TEXT Processing outcome Expected Terminal success or failed

The digest identifies byte-for-byte content, not parsed rows or normalized JSON, hospital identity, or CMS conformance. It is neither a key nor a deduplication instruction; two attempted inputs with the same filename or digest still have distinct file_id values. The extractor hashes the supplied local file directly before its file-specific transaction, so a fingerprint remains available even if parsing later fails and rolls back. sha256 remains NULL when the fingerprint cannot be obtained; if extraction otherwise succeeds, a concise provenance finding explains that gap without discarding usable rows. An inaccessible file receives the ordinary failure finding rather than a duplicate provenance finding. The operation assumes the supplied file does not change between hashing and extraction; it does not lock or recheck it. success means the approved extraction operation completed, possibly with recoverable findings; failed means meaningful extraction did not complete. Neither status certifies compliance or perfect source values. Each file is processed in its own transaction; a failed attempt retains its source_file row and failure diagnostic, but leaves no source-derived rows or successful-file summaries. Previously successful files remain available, and later inputs continue when the database remains usable. Database-level failures that prevent safe continuation raise an R error.

file_summary

Grain: One row per successfully processed file and source-derived relation. PK: (file_id, relation_name). FK: file_id → source_file. Each successful file has exactly 12 rows, one for each relation listed below, including relations with zero materialized rows. Failed attempts have no summary rows.

Column Type Origin Requiredness Meaning
file_id INTEGER source_file.file_id Key Successfully processed input
relation_name TEXT One of the 12 source relation names Key Counted relation
row_count BIGINT Materialized rows for this file Expected, nonnegative Actual row count; zero is meaningful

The relation_name domain is exactly mrf_file, file_location, file_npi, contract_provision, service, service_drug, service_code, charge, charge_modifier, payer_charge, modifier, and modifier_payer. For example, a successful file with no contract provisions has relation_name = "contract_provision" and row_count = 0. An absent row for a failed file must not be interpreted as a zero count. Counts are of actual materialized occurrences, not unique real-world entities, expected source records, completeness, or conformance. The current extractor calculates each count from the corresponding materialized relation.

diagnostic

Grain: One recorded consequential processing finding for one attempted file. PK: (file_id, diagnostic_id). FK: file_id → source_file. Findings may accompany successful or failed attempts; none is required solely because an optional source field is absent.

Column Type Origin Requiredness Meaning
file_id INTEGER source_file.file_id Key Attempted input
diagnostic_id INTEGER Package-assigned within file Key Positive finding position within file_id, not severity
source_path TEXT Relevant JSON instance path Nullable Source object, array element, or field involved, when locatable
message TEXT Package finding Expected Human-readable finding and relevant consequence

An instance path uses periods and one-based bracket indices, such as standard_charge_information[152].standard_charges[2].payers_information[5].standard_charge_dollar. This differs from the generic [] source paths in the definitions below. source_path is NULL for file-wide findings or when no specific location can reasonably be determined. The extractor records failed numeric conversions at their field paths while retaining the affected records, and reports unequal location/address arrays while retaining unmatched positions. It records one finding per unresolved modifier code and reason within a file, with a representative reference path and occurrence count; the original references remain in charge_modifier. A successful extraction with an unavailable fingerprint records one file-wide provenance finding. Failed files retain a file-wide failure explanation after rollback; intermediate findings from an unsuccessful transaction do not survive. Diagnostic IDs restart within each file. A successful file may have an empty diagnostic relation. This means only that no circumstances produced a finding under the implemented behavior; it does not certify CMS schema or dictionary conformance, regulatory compliance, exhaustive checking, or analytical accuracy. This model does not define severity, codes, categories, timestamps, occurrence counts, or a validation engine.

File and hospital context

mrf_file

Grain: Zero or one materialized JSON root per attempted source MRF. Source path: root object. PK and FK: file_id → source_file.file_id. The source_file row exists for the attempt even when no root can be materialized.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Input-file position
hospital_name TEXT hospital_name CMS-required Disclosed legal hospital name
last_updated_on TEXT last_updated_on CMS-required Source update date string; CMS expects YYYY-MM-DD
declared_version TEXT version CMS-required Source-declared template version; not proof of conformance
license_state TEXT license_information.state CMS-required Reported licensure state
license_number TEXT license_information.license_number Optional Reported license number
attestation_text TEXT attestation.attestation CMS-required Published statement; schema expects its specified text
confirm_attestation BOOLEAN attestation.confirm_attestation CMS-required Disclosed Boolean, including FALSE if reported
attester_name TEXT attestation.attester_name CMS-required Named attester
financial_aid_policy TEXT financial_aid_policy Optional; dictionary-only Policy description or URL

Licensure and attestation are one-to-one root objects and are represented as columns here. Their CMS-required fields are source expectations, not a separate validation checklist; values that can be projected remain nullable if absent. financial_aid_policy is defined by the dictionary but is not a named property in the pinned schema.

file_location

Grain: One reported position across root location_name[] and hospital_address[]. Source paths: both root arrays. PK: (file_id, location_id). FK: file_id → mrf_file.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
location_id INTEGER Generated from array position Key One-based shared position
location_name TEXT location_name[location_id] Nullable when unmatched Disclosed location name at this position
hospital_address TEXT hospital_address[location_id] Nullable when unmatched Disclosed physical address at this position

Both source arrays are CMS-required and nonempty under the schema. The approved positional interpretation pairs their first values, second values, and so on. The relation has a row for every position through the longer array; an absent counterpart is NULL, so unequal lengths do not discard information. For example, three names and two addresses produce a third row with a name and missing address. This representation does not assert that unequal arrays conform to CMS requirements. The current extractor records one file-wide observation when array lengths differ and preserves every position. No link to a particular NPI, service, charge, or payer term is inferred.

file_npi

Grain: One reported type 2 organizational NPI occurrence. Source path: type_2_npi[]. PK: (file_id, npi_id). FK: file_id → mrf_file.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
npi_id INTEGER Generated from array position Key NPI occurrence position
type_2_npi TEXT Array element CMS-required array member Disclosed NPI; text preserves leading zeros

The schema requires a nonempty NPI array, but supplies no NPI-to-location or NPI-to-service key.

contract_provision

Grain: One root general contract provision object. Source path: general_contract_provisions[] (dictionary-only optional array). PK: (file_id, provision_id). FK: file_id → mrf_file.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
provision_id INTEGER Generated from array position Key Provision occurrence position
payer_name TEXT payer_name Optional Payer label, if supplied
plan_name TEXT plan_name Optional Plan label, if supplied
provisions TEXT provisions Dictionary-required within object Disclosed aggregate or claim-level provision

The dictionary permits provisions for specific payer/plan labels or across plans. A matching label does not create a source FK to payer_charge or prove that a provision applies to each charge for that payer. The pinned schema does not enumerate this optional root array or its fields.

Services, codes, and drugs

service

Grain: One service disclosure object. Source path: standard_charge_information[]. PK: (file_id, service_id). FK: file_id → mrf_file.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated from array position Key Service occurrence position
description TEXT description CMS-required Disclosed item or service description

Repeated descriptions and billing codes do not make separate source disclosures interchangeable services.

service_drug

Grain: Zero or one drug-information object per service. Source path: standard_charge_information[].drug_information. PK and FK: (file_id, service_id) → service.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated Key Parent service
drug_unit NUMERIC unit CMS-required within object Reported drug unit value
drug_type TEXT type CMS-required within object Schema-listed unit type

Keep this relation separate. Its row distinguishes a supplied but imperfect drug object from an absent object; flattening these fields into service would lose that distinction. The schema conditionally requires drug information when a service has an NDC code. A present unit that cannot be converted to a finite number becomes NULL with a field-path diagnostic while the drug row remains.

service_code

Grain: One billing or accounting code occurrence within a service. Source path: standard_charge_information[].code_information[]. PK: (file_id, service_id, code_id). FK: (file_id, service_id) → service.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated Key Parent service
code_id INTEGER Generated from array position Key Code occurrence position
code TEXT code CMS-required Disclosed billing or accounting code
code_type TEXT type CMS-required Schema-listed coding system

Codes belong to their service. The source does not identify which particular charge or payer term a code within that service selects; joining every code to every charge would invent separate disclosed prices.

Charge contexts and payer terms

charge

Grain: One standard-charge context within a service. Source path: standard_charge_information[].standard_charges[]. PK: (file_id, service_id, charge_id). FK: (file_id, service_id) → service.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated Key Parent service
charge_id INTEGER Generated from array position Key Charge occurrence position
setting TEXT setting CMS-required inpatient, outpatient, or both
gross_charge NUMERIC gross_charge Optional Undiscounted chargemaster amount
discounted_cash NUMERIC discounted_cash Optional Cash-paying individual’s charge
minimum NUMERIC minimum Conditional De-identified minimum negotiated dollar charge
maximum NUMERIC maximum Conditional De-identified maximum negotiated dollar charge
additional_generic_notes TEXT additional_generic_notes Optional Source note at charge scope
billing_class TEXT billing_class Optional; dictionary-only Billing class at charge scope

At least one gross, cash, or payer-specific negotiated charge form is expected for a charge context. If a nested payer term has a negotiated dollar amount, the schema requires both bounds. They summarize dollar charges and do not identify the payer at an extreme. billing_class is a dictionary-defined charge field with recommended values professional, facility, and both; the pinned schema does not enumerate it. Gross, cash, and bounds remain at charge scope rather than being copied into each payer term.

charge_modifier

Grain: One modifier-code reference occurrence within a charge. Source path: standard_charge_information[].standard_charges[].modifier_code[]. PK: (file_id, service_id, charge_id, modifier_ref_id). FK: (file_id, service_id, charge_id) → charge.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated Key Parent service
charge_id INTEGER Generated Key Parent charge
modifier_ref_id INTEGER Generated from array position Key Reference occurrence position
modifier_code TEXT Array element CMS-required array member Disclosed modifier code
modifier_id INTEGER Resolved from unique code match Nullable FK Root modifier position, if unambiguous

modifier_id may reference (file_id, modifier_id) in modifier only when exactly one root modifier object in the file reports that code. It stays NULL if no definition matches or several match. The current extractor retains every original reference and records a concise file-scoped finding for each unresolved code and reason, with a representative source path; repeated equivalent references do not produce duplicate findings. A resolved definition does not calculate an adjustment or prove that its optional setting applies. The source schema does not enforce uniqueness of root modifier codes.

payer_charge

Grain: One payer/plan negotiated term within a charge. Source path: standard_charge_information[].standard_charges[].payers_information[]. PK: (file_id, service_id, charge_id, payer_id). FK: (file_id, service_id, charge_id) → charge.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
service_id INTEGER Generated Key Parent service
charge_id INTEGER Generated Key Parent charge
payer_id INTEGER Generated from array position Key Payer-term occurrence position
payer_name TEXT payer_name CMS-required Disclosed payer label
plan_name TEXT plan_name CMS-required Disclosed plan label
methodology TEXT methodology CMS-required Contract method named by CMS
standard_charge_dollar NUMERIC standard_charge_dollar Conditional Negotiated dollar amount
standard_charge_percentage NUMERIC standard_charge_percentage Conditional Negotiated percentage, e.g. 70.5 for 70.5%
standard_charge_algorithm TEXT standard_charge_algorithm Conditional Disclosed algorithm or formula
median_amount NUMERIC median_amount Conditional Historical median total allowed amount
percentile_10_amount NUMERIC 10th_percentile Conditional Historical 10th-percentile total allowed amount
percentile_90_amount NUMERIC 90th_percentile Conditional Historical 90th-percentile total allowed amount
allowed_amount_count TEXT count Conditional Remittance count or category, preserved as text
additional_payer_notes TEXT additional_payer_notes Conditional Disclosed payer note

At least one of the three negotiated charge forms must be reported for a payer term; multiple forms may coexist. The model does not prefer one, convert a percentage or algorithm to dollars, or interpret an absent amount as zero. The five CMS methodology values are case rate, fee schedule, percent of total billed charges, per diem, and other; other calls for an explanatory payer note.

The median and percentiles summarize historical total allowed amounts, not negotiated prices or future estimates. A percentage or algorithm calls for count and, unless that count is "0", all three statistics. The count source is a string: "0", "1 through 10", or digits for 11 or more. It cannot always be treated as a numeric count. When count is "0", the schema specifically requires additional_payer_notes, while the dictionary permits explanation in either payer-specific or generic notes. Both note fields are retained; the discrepancy is not silently resolved. A negotiated dollar term calls for the charge-level de-identified bounds.

Modifier descriptions

modifier

Grain: One root modifier definition. Source path: modifier_information[] (optional root array). PK: (file_id, modifier_id). FK: file_id → mrf_file.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
modifier_id INTEGER Generated from array position Key Modifier occurrence position
modifier_code TEXT code CMS-required Disclosed modifier code
description TEXT description CMS-required Common modifier name
setting TEXT setting Optional Setting where modifier applies

The relational name modifier_code aligns with charge_modifier.modifier_code; the source field remains modifier_information[].code. Neither the schema nor a repeated code value establishes a unique modifier definition.

modifier_payer

Grain: One payer/plan explanation within a modifier definition. Source path: modifier_information[].modifier_payer_information[]. PK: (file_id, modifier_id, modifier_payer_id). FK: (file_id, modifier_id) → modifier.

Column Type Source Requiredness Meaning
file_id INTEGER Generated Key Parent file
modifier_id INTEGER Generated Key Parent modifier
modifier_payer_id INTEGER Generated from array position Key Explanation occurrence position
payer_name TEXT payer_name CMS-required Disclosed payer label
plan_name TEXT plan_name CMS-required Disclosed plan label
description TEXT description CMS-required Explanation of how modifier may change a charge

Matching labels do not create a key to payer_charge or assert an amount for a specific service. The pinned schema requires a nonempty modifier_payer_information[] array within each root modifier object.

Interpretation and limits

This model preserves source scopes rather than manufacturing identities or comparable prices. A charge’s minimum and maximum are de-identified negotiated-dollar bounds, not payer rates. gross_charge and discounted_cash have different meanings from negotiated dollar, percentage, and algorithm terms. The allowed-amount statistics summarize historical remittances; allowed_amount_count may be categorical. Setting, billing class, code type, drug unit/type, methodology, modifiers, and notes qualify interpretation. A code, description, payer name, or plan name is never a cross-file identity key.

The dictionary permits hospital-created attributes beyond its named fields. This contract includes its named optional financial_aid_policy, general_contract_provisions, and billing_class, but does not claim to interpret all extensions. The schema leaves these three attributes unenumerated. The supported CMS structure is the input contract; unknown fields outside this model can ordinarily be ignored, while an unprocessable source structure receives an ordinary extraction failure. Unequal location/address arrays retain unmatched positions, and missing or ambiguous modifier definitions leave the original reference unlinked with a finding. No comprehensive structural validation or repair is implied.

The current extractor creates all 16 relations with physical DuckDB types and keys for one or many inputs and populates every approved source field and relation when supplied. An empty optional relation or NULL optional value may reflect source absence; a conversion finding identifies a present numeric value that could not be stored as a finite DOUBLE. Historical median and percentile allowed amounts remain separate from negotiated price forms, and allowed_amount_count remains source text. mrf_inspect() reports source facts independently of extraction; file_summary counts rows actually materialized for each successful file, including zero counts. source_file.sha256 records obtainable file-byte fingerprints, and diagnostic records only encountered consequential findings. The logical contract and shared diagram remain the authority for the intended database.

The projected JSON reader sets its maximum_object_size from the supplied file’s bytes plus 1,024 and rejects a bound above 4,294,967,295 bytes. This is an implementation guard, not evidence that every smaller root is processable. A bounded local exercise processed two single-root sources of about 161 MB and 212 MB together; memory and disk requirements depend on source structure and environment, and substantially larger or differently shaped sources remain unexamined. Local sources are assumed unchanged during hashing and parsing. Final public workflow documentation and release verification remain for later stages.