Image
Build
Connect & operate
Design & teams
Start hereScope a build in one callBring a spec, a wireframe, or a paragraph. You leave with an architecture, a timeline, and a number.Request a scoping call
AI software
LLM & data systems
Vibe coding
Ready to ship?Put AI where the work isAgents, RAG, and private LLMs wired into the systems your team already uses — not a chatbot bolted to a homepage.Discuss an AI project
Domain firstWe learn your workflow before we model itRegulated, operational, or high-volume — the constraints belong in the schema, not in a training doc.Talk about your domain
Eric Lamanna
Author
Shipping a HIPAA Compliant AI Document Pipeline With FHIR Writeback — featured image
11/24/2026

Shipping a HIPAA Compliant AI Document Pipeline With FHIR Writeback

A HIPAA-compliant AI document pipeline is a short list of boundaries, redaction steps, and audit hooks wrapped around a model that is allowed to touch very little. The parts that make it work are not the LLM.

Every stage carries its own threat model and its own BAA question: intake, OCR, PHI detection and redaction, structured extraction, FHIR writeback. Treating them as one undifferentiated AI system is how a six-figure build becomes a breach report, and the 2024 Change Healthcare incident, which eventually reached 192.7 million individuals, is the backdrop any security committee is reading when they review your design.

The BAA Boundary Is the First Design Decision

The first production decision is drawing the line that separates systems covered by a signed Business Associate Agreement from everything else. Inside the line sits object storage for raw documents, OCR, PHI detection, redaction, the LLM endpoint, the FHIR client, and any logging that captures prompts or outputs. Outside sits developer laptops, Slack, source control, and any observability tool that was not bought with PHI in mind.

The commercial BAA list matters more than the model list. AWS covers most of its stack but not all services; Azure OpenAI and GCP Vertex AI both sign BAAs for specific endpoints under regional constraints. If a buyer cannot point to the executed BAA and the exact service tier, that vendor should not see decrypted PHI. Teams retrofitting an existing SaaS often bolt an LLM onto the product and discover the boundary later; the saner path is closer to the approach in retrofitting a SaaS with AI agents, where the boundary is drawn before the model is chosen.

OCR and the First Point of PHI Exposure

OCR is where faxed or scanned source material becomes machine-readable text. It is also where PHI first lands on a system that can be queried, scanned, or misrouted. The stage needs a BAA-covered OCR engine (Textract, Document AI, or an in-cluster model), encryption of the uploaded object at rest, and TLS 1.2 or higher on every transport hop. The HHS Office for Civil Rights proposed in January 2025 to drop the Security Rule's "addressable" designation and expressly require NIST-approved encryption at 256-bit strength, which effectively removes the grey area teams have been using to argue about cost.

Two operational details matter more than the engine choice. First, object keys and filenames must not contain PHI; a patient name in an S3 key is a disclosure the audit log will not catch. Second, raw originals and extracted text belong in separate buckets with different retention policies, so a redaction bug cannot silently expose the originals to the LLM path. OCR output goes to the redactor; originals sit untouched until a reviewer requests them.

Gloved hands feeding a clinical document into a scanner with a redaction overlay covering patient details.
Cloud PHI De-identification Tools: Precision vs Recall on Radiology Reports
Cloud PHI De-identification Tools: Precision vs Recall on Radiology ReportsGCP Healthcare API: 55.3%; Azure Health De-ID Service: 70.4%; AWS Comprehend Medical: 73.6%; Fine-tuned transformer (paper): 96.2%Precision →Recall →12341GCP Healthcare API2Azure Health De-ID Service3AWS Comprehend Medical4Fine-tuned transformer (paper)
Higher and to the right is better; recall below ~80 means PHI leaks past the redactor. Source: arXiv 2511.04079, 2025

PHI Detection and Redaction Before the Model Sees It

PHI redaction on OCR output is the stage most buyers underestimate. HIPAA's Safe Harbor method at 45 CFR 164.514(b)(2) lists 18 categories of identifiers that have to be removed before data stops being PHI: names, geographic subdivisions smaller than a state, dates, record numbers, biometric identifiers, full-face photographs, and more. A production redactor is a pipeline, not a regex pass: a clinical NER model (Presidio, AWS Comprehend Medical, or a tuned open model) for ambiguous spans, deterministic rules for the structured ones, and a confidence floor that routes uncertain spans to human review rather than past the model.

The crosswalk between redacted tokens and the original spans belongs in a separate encrypted store, tied to the document's audit record. That is what lets a downstream FHIR Observation carry the real patient identifier when an authorized caller requests the rehydrated output, without any intermediate service seeing it. NIST's AI 600-1 Generative AI Profile catalogues why the LLM step is not the right place to trust with raw identifiers: prompt injection, data leakage through logs, and inference-time memorisation are all documented risks.

What a Healthcare Breach Actually Looks Like on the Books
10.9
Avg healthcare breach cost
USD millions
213
Days to discover a breach
days (healthcare mean)
1.8
Savings with security AI + automation
USD millions per incident
292
Days to resolve stolen-credential breach
days
IBM's healthcare-sector figures explain why every control in the pipeline earns its keep. Source: IBM, 2024

Structured Extraction Without Letting the Model Write to Epic

The extraction stage converts redacted clinical text into structured fields that map to FHIR resources: Patient, Condition, Observation, MedicationStatement, DocumentReference. The model returns JSON validated against a schema that matches your US Core profile, with per-field confidence scores. Anything below the confidence floor goes to a reviewer queue, not to the EHR.

For a narrow extraction task — ICD-10 codes, lab values, medication names — a small language model fine-tuned on in-house examples often outperforms a frontier model and costs an order of magnitude less per document. The reasoning is spelled out under small language models for document classification. Frontier models still earn a role for messy, free-text summaries where the schema is loose.

The model never speaks FHIR directly. Its JSON output lands in an intermediate validation layer that re-runs the redaction crosswalk, checks required fields, and only then calls the FHIR client. Letting an LLM hold write credentials to an EHR is how a pilot turns into a compliance rescue project six months later.

FHIR Writeback and What It Actually Requires

FHIR writeback is where the pipeline stops being a toy. The Cures Act Final Rule requires certified EHRs to expose standardized HL7 FHIR APIs, which is what makes this architecture tractable at all. In practice, each EHR enforces its own SMART on FHIR OAuth flow, its own app registration process, and its own interpretation of US Core. Epic and Oracle Health both support FHIR R4, but every integration will spend budget on the differences.

Writeback needs four things a demo pipeline does not. Idempotency keys on every POST so a retry does not double-create an Observation. US Core profile validation against the receiving EHR's version, which can lag the published spec by a release. A dead letter queue for FHIR errors the EHR returns asynchronously. And an app-level map of which resources a given customer's EHR actually accepts for writes, because the read surface is usually broader than the write surface.

Scope and cost conversations for this stage live closer to the figures in Epic EHR API integration cost than to a generic API integration estimate.

Epic FHIR Integration: Cost Ranges by Phase and Scope
Epic FHIR Integration: Cost Ranges by Phase and ScopeDiscovery & pathway selection: $5k; Additional site go-live (each): $5k; First production site: $10k; Security & compliance: $10k; Sandbox development: $40k; Read-only FHIR (all in): $65k; Complex multi-pathway (write + HL7 v2): $150kDiscovery & pathwayselection$5k–$15kAdditional sitego-live (each)$5k–$15kFirst production site$10k–$25kSecurity & compliance$10k–$30kSandbox development$40k–$120kRead-only FHIR (allin)$65k–$150kComplex multi-pathway(write + HL7 v2)$150k–$300k
Each bar is the published low-to-high quote for that scope in USD thousands. Source: Arkenea, 2026

Audit Trail, Encryption, and the Teeth Behind It

HIPAA Security Rule obligations attach to the whole pipeline, not just the LLM. Every PHI read, model call, structured output, and FHIR write needs an immutable log entry that ties the action to a user, a document, a confidence score, and, where applicable, a reviewer. Six years of retention is the standard baseline. Logs themselves are PHI, so they inherit the same encryption and access rules as the data they describe.

Encryption at rest and in transit is straightforward with managed KMS. In use is harder: enclaves (AWS Nitro, Azure Confidential Computing) are worth the operational cost where the LLM runs on a BAA-covered endpoint but the provider still controls the host. IBM's 2024 report put the average healthcare breach at $9.77 million, a rank the industry has held since 2011, which frames how the civil monetary penalty tiers stack up next to the incident cost itself.

What This Architecture Costs You and What It Buys

The pipeline above is slower to ship and costlier to operate than a naive PDF-to-GPT workflow. A reviewer queue, a redaction crosswalk, FHIR validation, and immutable audit all add real engineering time, and the frontier model becomes the cheapest line item rather than the hero. That is the trade. What a buyer gets is an architecture that survives an OCR review, a BAA audit, and a frontier-model vendor change without a rebuild. For healthcare document AI, that is usually the version worth paying for.

Author
Eric Lamanna
Eric Lamanna is a Digital Sales Manager with a strong passion for software and website development, AI, automation, and cybersecurity. With a background in multimedia design and years of hands-on experience in tech-driven sales, Eric thrives at the intersection of innovation and strategy—helping businesses grow through smart, scalable solutions. He specializes in streamlining workflows, improving digital security, and guiding clients through the fast-changing landscape of technology. Known for building strong, lasting relationships, Eric is committed to delivering results that make a meaningful difference. He holds a degree in multimedia design from Olympic College and lives in Denver, Colorado, with his wife and children.