Skip to contents

Create the documented 16-table database and populate the approved source-derived model from one or more local Hospital Price Transparency JSON v3 files in the supplied order. Extraction completion does not establish CMS compliance. The package's initial public workflow and release remain in development.

Usage

mrf_parse(path, output, quiet = FALSE)

Arguments

path

Nonempty ordered character vector of local JSON file paths. Each entry is an attempted file, including inaccessible or repeated paths.

output

Path for a new, persistent DuckDB database. An existing file is never overwritten; its parent directory must exist.

quiet

Set to TRUE to suppress start and outcome messages.

Value

Invisibly, the normalized output database path when the operation completes, including when individual attempted files failed.

Details

The database has all 16 relations and columns in the data model. Extraction populates the approved source fields and relations, including contract provisions, modifier definitions and references, notes, billing class, and historical allowed-amount statistics. One database_metadata row describes the operation. Each input receives its one-based position as file_id, even after an earlier failed attempt; repeated paths are separate attempts. source_file records each attempted filename, available byte size, SHA-256 of its supplied bytes when obtainable, and terminal status. The fingerprint is retained even if extraction fails; it is neither a record key nor a deduplication instruction. An unavailable fingerprint remains NULL and does not block otherwise usable extraction. Supplied files are assumed to remain unchanged during processing. Every successful file has 12 file_summary rows with actual materialized counts, including zeros. Failed files have no summaries.

Numeric fields use ordinary DOUBLE conversion. A present value that cannot be converted to a finite number is stored as NULL, with a source-positioned diagnostic; other usable information is retained. Missing optional values do not generate conversion diagnostics. Unequal location-name and address arrays are paired through the longer array, with a NULL counterpart and a file-wide observation. Unresolved modifier references and unavailable fingerprints also produce concise findings. A successful file can have no diagnostic rows; that does not certify CMS conformance. Each file is processed in its own transaction. On a genuine file-specific failure, that file has a failed source row and diagnostic but no partial source rows or summaries; processing continues with later inputs when the database remains usable. Earlier completed files remain available. A completed operation returns its database path even if some or all attempted files failed. Inspect source_file and diagnostic for individual outcomes. Database-level failures that prevent safe continuation still raise an error. The projected DuckDB JSON reader sets its object-size bound from the source byte size and refuses a bound above 4,294,967,295 bytes. This guard does not establish that every smaller file can be processed; memory and disk needs depend on its structure and the operating environment.

Reopen a completed result with DBI::dbConnect(duckdb::duckdb(), dbdir = output, read_only = TRUE) and disconnect it with DBI::dbDisconnect(). The database does not depend on the original R return value or source file after extraction.

See also

mrf_example() for a complete executable bundled-source workflow, and the data model for relation and field definitions.