# Load HL7 v2 messages into Apache Iceberg for Databricks analytics

**HL7 v2 feeds (ADT, ORU, DFT) become queryable Iceberg tables that
Databricks reads through Unity Catalog — one row per message, PHI
flagged and masked before landing, no interface engine required for
the analytical copy.** Lakewright detects HL7 by the MSH segment
structure and derives columns from segment fields.

## How does HL7 detection work?
The `MSH|^~\&` header identifies the format and its delimiters; the
message type (ADT^A01, ORU^R01, DFT^P03) routes the domain — ADT/ORU
to clinical, DFT/BAR to billing. Segments flatten to columns
(patient class, event type, sending facility) per message.

## What about PHI?
PID segment fields (name, MRN, DOB) are flagged at scan; approved
plans mask or key-hash them at load. The raw message never lands.

## The steps
```bash
lakewright scan  /interfaces/adt-archive
lakewright approve plans/adt_feed.plan.yaml
lakewright load  plans/adt_feed.plan.yaml --rest $CATALOG
```

## FAQ
**Does this replace my interface engine?** No — it lands the
analytical copy your interface engine was never built to serve.
**FHIR too?** Yes — FHIR NDJSON bulk exports are detected by
resourceType and land the same way.
