Healthcare RAG Architecture: Building It Safely Under HIPAA
How to design retrieval-augmented generation for healthcare: data sources, FHIR, HIPAA safeguards, permission-aware retrieval, evaluation and FDA limits.
A healthcare RAG architecture is a retrieval-augmented generation system designed for clinical or administrative questions, in which a language model answers using retrieved guidelines, policies or patient records and cites them. The architecture is the same two-pipeline design as any RAG system, but healthcare adds hard requirements: protected health information (PHI) must be secured and accessed only as needed, retrieval must respect who is allowed to see which records, and anything that drifts into clinical recommendations has to be evaluated for safety and, sometimes, for FDA status [2][3][6].
This guide covers the design decisions specific to healthcare. It assumes familiarity with general RAG; if you need the basics, read What Is RAG? and our complete RAG architecture guide. It is general information, not legal or medical advice.
Why RAG fits healthcare
Medical knowledge changes, and models trained months ago miss new guidance. The MIRAGE benchmark study, which tested 41 combinations of medical corpora, retrievers and language models on 7,663 questions, found that its MedRAG toolkit improved the accuracy of six different LLMs by up to 18% over chain-of-thought prompting alone [1]. It also found that combining several medical corpora and retrievers worked best [1].
Just as important, RAG makes answers checkable. A clinician reviewing an AI-drafted summary can click through to the lab result or guideline it cites. That matters for reducing the impact of hallucinations, which are far more serious in a chart than in a chatbot.
Three common healthcare RAG patterns
Pattern | Knowledge source | PHI involved? | Typical users |
|---|---|---|---|
Reference RAG | Clinical guidelines, drug references, internal protocols | No (if the query carries none) | Clinicians, pharmacists |
Administrative RAG | Payer policies, coding rules, prior authorization criteria | Sometimes | Billing and utilization staff |
Patient-record RAG | Notes, labs, medications, imaging reports for one patient | Yes | Clinicians at the point of care |
Each pattern changes the architecture. Reference RAG can run largely like enterprise RAG. Patient-record RAG needs every HIPAA safeguard in the retrieval path, and is the focus of most of this guide.
Data layer: getting clinical data in
Structured data via FHIR. HL7's FHIR (Fast Healthcare Interoperability Resources) is a standard for exchanging healthcare information electronically [5]. Pulling patient data through FHIR APIs gives you consistent structures for patients, encounters, observations and medications, which makes chunking and metadata far easier than scraping documents.
Unstructured notes. Clinical notes carry most of the nuance. Chunk them along their natural sections (history, assessment, plan) and keep the note date, author role and encounter as metadata. See chunking strategies.
Time is a first-class field. "Current medications" depends on dates. Store effective dates on every chunk and let the query pipeline filter or sort by recency.
De-identified corpora for development. HIPAA allows health information to be treated as de-identified either through an expert determination that re-identification risk is very small, or by removing a defined list of identifiers such as names and geographic subdivisions smaller than a state [4]. Building and tuning pipelines on properly de-identified data reduces PHI exposure during development.
Security layer: HIPAA in the retrieval path
The HIPAA Security Rule's technical safeguards translate into concrete RAG requirements [2]:
Safeguard | RAG implementation |
|---|---|
Access control and unique user identification | Every query runs as an identified user (or a uniquely identified service), never a shared account |
Audit controls | Log which chunks were retrieved for which user and query, not just the final answer |
Integrity | Protect indexes from tampering; version documents and embeddings |
Encryption (addressable) | Encrypt indexes, caches and logs that contain ePHI |
Two further principles shape design:
- Minimum necessary. When using or disclosing PHI, covered entities and business associates must make reasonable efforts to limit it to the minimum necessary for the purpose, with exceptions such as disclosures to a provider for treatment [3]. In RAG terms: retrieve only the records relevant to the task, and do not fill the context with an entire chart "just in case."
- Permission-aware retrieval. Apply the user's access rights as a filter inside the search query. A model cannot "un-see" a record that should never have been retrieved.
Also check your vendors. Embedding APIs, vector databases and LLM providers that handle PHI on your behalf are typically business associates, and the required assurances must be documented in a written contract or other written agreement [3].
Regulations are moving. HHS published a final rule modifying the HIPAA Privacy Rule on November 19, 2026, aimed at care coordination, case management and individual access; it takes effect January 19, 2027 [8]. Teams may want to review the new Privacy Rule changes with counsel before finalizing data flows.
Retrieval and generation layer
- Hybrid retrieval. Medical text mixes concepts with exact codes, drug names and abbreviations. Combine vector and keyword search; see hybrid search.
- Reranking. A reranker can improve precision when queries are short and notes are long. See reranking models.
- Context ordering. Models use long contexts unevenly and tend to miss information in the middle [9]. The MIRAGE study observed the same "lost-in-the-middle" effect in medical RAG [1]. Put the most relevant evidence first and keep context tight.
- Answer rules. Require citations for every clinical statement, dates for every result, and an explicit "not found in the record" when evidence is missing.
Safety and regulatory layer
FDA boundaries. FDA's January 2026 guidance on clinical decision support software explains which CDS functions fall outside device regulation, generally software intended for health care professionals that lets them independently review the basis for recommendations, and which do not [6]. A RAG tool that retrieves and cites guidelines for a clinician is designed differently from one that tells patients what to do. Decide the intended use early and document it.
Fairness. Covered entities must not discriminate through patient care decision support tools on the basis of race, color, national origin, sex, age or disability, and must make reasonable efforts to identify and mitigate such risks [7]. Evaluate answer quality across patient groups.
Prompt injection. Referral letters, faxes and patient messages are untrusted input that will be indexed. Treat retrieved text as data, never instructions. See RAG security.
Evaluation for healthcare RAG
Test | What it catches |
|---|---|
Retrieval recall on clinician-labeled questions | Missing the right note or guideline |
Citation accuracy | Statements not supported by the cited source |
Temporal accuracy | Outdated meds or results presented as current |
Permission tests | Records retrieved for users who should not see them |
Subgroup analysis | Quality gaps across patient populations [7] |
Clinician review panel | Clinically unsafe or misleading phrasing |
Benchmarks such as MIRAGE help compare components [1], but they do not replace evaluation on your own documents and workflows.
Frequently asked questions
Is RAG HIPAA compliant?
RAG is an architecture, not a compliance status. A RAG system that handles ePHI must implement the Security Rule's safeguards, such as unique user identification and audit controls [2], follow minimum-necessary principles [3], and have business associate agreements with vendors that handle PHI.
Does RAG improve accuracy on medical questions?
In the MIRAGE benchmark study, the authors' MedRAG toolkit improved six LLMs' accuracy by up to 18% over chain-of-thought prompting [1]. Results depend heavily on corpus quality and retriever choice, so test on your own use case.
Should I use FHIR for healthcare RAG?
FHIR is an HL7 standard for exchanging healthcare information electronically [5]. Using FHIR APIs gives structured, consistently labeled records that are easier to chunk, filter by date and secure than scraped documents.
Is a clinical RAG tool a medical device?
It depends on intended use. FDA's January 2026 CDS guidance explains when decision support software for health care professionals falls outside device regulation and when it does not [6]. Tools aimed at patients, or that analyze images or signals, are more likely to be regulated.
How do I stop a healthcare RAG system from leaking records?
Enforce the user's permissions as a filter during retrieval, retrieve only what the task needs, log retrieved chunks per user, and test with users who should be denied access [2][3].
Sources
- Xiong, G. et al. "Benchmarking Retrieval-Augmented Generation for Medicine." arXiv:2402.13178, 2024. https://arxiv.org/abs/2402.13178
- eCFR. "45 CFR 164.312: Technical safeguards." https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-C/part-164/subpart-C/section-164.312
- eCFR. "45 CFR 164.502: Uses and disclosures of protected health information: General rules." https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-C/part-164/subpart-E/section-164.502
- eCFR. "45 CFR 164.514: Other requirements relating to uses and disclosures of protected health information." https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-C/part-164/subpart-E/section-164.514
- HL7 International. "FHIR Overview." https://hl7.org/fhir/overview.html
- U.S. Food and Drug Administration. "Clinical Decision Support Software." January 2026. https://www.fda.gov/regulatory-information/search-fda-guidance-documents/clinical-decision-support-software
- eCFR. "45 CFR 92.210: Nondiscrimination in the use of patient care decision support tools." https://www.ecfr.gov/current/title-45/subtitle-A/subchapter-A/part-92/subpart-C/section-92.210
- Federal Register. "HIPAA Privacy Rule: Changes To Support Coordinated Care and Individual Engagement and Reduce Regulatory Burdens." November 19, 2026. https://www.federalregister.gov/documents/2026/11/19/2026-23429/hipaa-privacy-rule-changes-to-support-coordinated-care-and-individual-engagement-and-reduce
- Liu, N. et al. "Lost in the Middle: How Language Models Use Long Contexts." arXiv:2307.03172, 2023. https://arxiv.org/abs/2307.03172