Part of
Enterprise context layer
Architecture

Architecting an Enterprise Context Layer for Protected Healthcare Environments

EHR, clearinghouse and billing system data pass through an orange context layer that applies a field list per task, masks identifiers and logs every retrieval, before a model sees anything.

An enterprise context layer for a protected healthcare environment decides which fields of a patient record an AI agent may read for each task. It decides before any prompt is built. It checks the agent's role and limits the record to the minimum the task needs. It masks identifiers the task can do without, such as the patient's name. It maps clinical terms to standard codes inside your network, and it logs every read. The model gets only those fields, never a connection to your electronic health record (EHR).

The rules it enforces come from HHS, the US Department of Health and Human Services. The HIPAA Privacy Rule applies to covered entities, such as health plans and providers, and to their business associates. It requires them to make reasonable efforts to limit protected health information (PHI) to the minimum necessary for the purpose of each use, disclosure or request (45 CFR 164.502(b)). A search pipeline that drops a patient's whole chart into the prompt to answer a billing question does the opposite, on every call.

What does HIPAA require of an AI agent that reads patient data?

HIPAA does not mention AI agents. It sets requirements for anyone who uses or discloses protected health information, and an agent reading a chart is software doing exactly that. The table lists the provisions an agent pipeline has to meet, in HHS's wording, and the control that meets each one.

RequirementWhat HHS requiresContext layer control
Minimum necessaryLimit PHI to the minimum necessary for the purpose (164.502(b)); identify who needs access to which categories (164.514(d))A list of allowed fields for each task, checked before anything is read
Access controlAllow access only to persons or software programs granted access rights (164.312(a))Each agent has its own identity and role
Unique user identificationAssign a unique name or number to identify and track user identity (164.312(a)(2)(i))The log names the agent and the person it acts for
Audit controlsRecord and examine activity in systems that contain or use ePHI (164.312(b))Every retrieval, refusal and action logged
Activity reviewRegularly review audit logs, access reports and incident reports (164.308(a)(1))A named owner reviews the log on a schedule
Business associatesA party that creates, receives, maintains or transmits PHI for a covered entity is a business associate (160.103)PHI reaches an outside model only under your business associate agreement (BAA) with its provider

Two details change the design. First, the minimum necessary standard does not apply to disclosures to, or requests by, a health care provider for treatment. So it matters most for agents that handle billing, operations, reporting and patient communication, which is where most healthcare automation starts. Second, Section 164.514(d) asks you to name the categories of PHI each class of workforce member needs. An agent is one more class, and the context layer is where you write down its categories and enforce them.

How does a context layer apply minimum necessary to each task?

Access by role usually works per system. A biller can open the billing system, so the biller sees everything in it. Minimum necessary is narrower, because it works per purpose. The context layer keeps a list of allowed fields for each agent task and applies it when it reads the record. The same record then gives each task a different set of fields. Pick a task below.

Minimum necessary, per task
One patient record, four agent tasks. What does each task get to read?
Agent task
Patient nameM. R••••
Date of birth••/••/1958
Medical record numberMRN ••••2291
Phone number(•••) •••-0147
Member ID••••••4410
Next appointment
Claim lines and CPT codes
Diagnosis codes
Remittance reason code
Signed visit note
Medication list
Full medical history
Visible
0
Masked
0
Not retrieved
0

A denial appeal draft sees the claim lines, diagnosis codes, reason code and signed note, with name and member ID masked. A prior authorization packet adds the medication list and member ID. An appointment reminder sees only name, phone and appointment time. A weekly denial report sees codes only.

Illustrative record and masking. Which fields each task may read is set per workflow during scoping.

Masking is a separate step from filtering. A denial appeal draft does not need the patient's name to argue that a provider number was missing. So the layer replaces the name with a placeholder, and the billing system puts the name back only after a biller approves the draft. Our AI solutions for healthcare page shows the same split on a denied claim. The agent sees the claim lines, the reason code and the provider roster, and the full chart is never retrieved.

Where does patient data leak in an AI agent pipeline?

Patient data leaks from an agent pipeline in three places, and each needs its own control.

  • Over-retrieval. A similarity search returns whatever text looks most like the question, from every patient and every note the index holds. The OWASP Top 10 for LLM Applications 2025 lists this as LLM08, vector and embedding weaknesses. Its first prevention step is fine-grained access control, with vector stores that know who may see each item. In healthcare, that means the patient, the task and the field list limit the search. A line in the prompt asking the model to hold back is not enough.
  • Copies that outlive the source. Every embedding, cache, prompt log and fine-tuning set that holds PHI is one more copy to secure. HIPAA gives patients the right to access their records and to have a covered entity amend them (45 CFR 164.524 and 164.526). Correcting the chart does not correct a search index built last month. Fewer copies make both rights easier to honor, so the layer reads from the original systems at the moment of each request where it can.
  • Model calls and outputs. Under HHS's definition, a model provider that receives PHI on your behalf is a business associate, and it needs a business associate agreement with you. Anything the model writes can repeat what it was given. So its output goes to a person or a fixed destination, never straight to a payer or a patient.

The drawing shows where each control sits when the whole pipeline runs inside your own environment.

Reference layout
Where patient data goes when an agent works a task
Tap a numbered hop to see what data crosses it and which control applies.
Your cloud or data center
Sources
EHRnotes, orders
Clearinghouse837, 835 files
Billing systemclaims, payments
Context layer
  1. Agent identity and role checked
  2. Fields limited to the task
  3. Identifiers masked or dropped
  4. Terms mapped to SNOMED CT, RxNorm, ICD‑10‑CM
  5. Retrieval logged
Model
Model you hoststays in your network
External model APIleaves your network, under your BAA
Sign-off
Person approvesbiller or clinician
Action loggedrecord, change, approver
Hop 1: Sources to the context layer
What crosses it
Only the fields on the task's field list, read from the EHR, clearinghouse or billing system at request time where it can, which leaves fewer copies of PHI to secure.
Control
The agent's own identity and role are checked, the field list applies at retrieval (minimum necessary, 45 CFR 164.502(b)) and the retrieval is logged (164.312(b)).
The dashed card is the one call that leaves your network, and it carries only the scoped fields. The model never holds a database connection. It receives one scoped package per task, and the package, the approval and the change are written to the log.

We run the workflows on self-hosted n8n in your cloud or data center, so the workflow, its logs and the patient data it touches stay with you. A call to an outside model carries only the allowed fields, under your own business associate agreement with that provider. The other option is a model you host. Ovidius does not sign business associate agreements. The general pattern, outside healthcare, is in how to build an enterprise context layer.

Mapping clinical terms with UMLS, SNOMED CT and RxNorm

Clinical text says the same thing many ways. A note may say heart attack, MI or myocardial infarction, and a medication list may carry a brand name where the payer rule uses the generic. If the agent has to resolve that itself, it guesses, and the guess lands in an appeal letter or a prior authorization packet.

The context layer translates terms before the prompt is built, using the standard vocabularies the National Library of Medicine (NLM) distributes. The UMLS Metathesaurus brings together terms and codes from vocabularies including CPT, ICD-10-CM, LOINC, RxNorm and SNOMED CT. That lets the layer tie a phrase in a note to the codes a payer rule uses. RxNorm gives normalized names for clinical drugs, built from ingredient, strength and dose form. NLM releases the full RxNorm data set monthly. SNOMED CT links each concept to broader ones through is-a relationships, and to defining details such as the body site affected (the finding site). That lets the layer connect a phrase in a note to the broader condition a payer rule names.

Run the term-mapping service inside your network, against your own copies of the vocabularies, so clinical text never leaves your network to be coded. NLM issues UMLS licenses to individuals, not organizations, so someone on your team holds the license. The model then receives the mapped codes instead of the note text. Codes are shorter, easier to check and carry fewer identifiers. Our guide to mapping business rules into the context layer covers how rules such as payer edits get into the layer.

Audit trails and human sign-off for healthcare agents

The HIPAA Security Rule asks for audit controls that record and examine activity, and for regular review of those records. For an agent, the useful record is one line per step. It shows who the agent acted for, which task it ran, which fields it read and which it was refused. It also shows what the agent produced, who approved it and what changed. With that log, a compliance officer can say who saw a patient's data and why, which is the question an access report has to answer.

Plan human sign-off in the same design. In our healthcare builds, a biller approves anything sent to a payer and a clinician signs off on anything clinical. The agent holds no credential that would let it submit on its own. Enterprise AI governance covers the approval steps, and data governance for AI lists the fields to log for every answer.

A checklist before your first healthcare agent

  1. Pick one workflow outside direct treatment, such as denials that repeat for the same reason, and write down its purpose.
  2. List the fields the task needs, field by field, and mark which can be masked until a person approves.
  3. Give the agent its own identity and role, and record which categories of PHI it needs, as you do for each class of workforce member.
  4. Decide where the model runs: a model you host, or an external API under your own business associate agreement.
  5. Keep PHI out of fine-tuning sets, prompt logs and long-lived indexes unless you have a reason and a control for each copy.
  6. Run the terminology mapping inside your network and pass codes to the model instead of raw note text.
  7. Log every retrieval, refusal, output and approval, and name the person who reviews the log.
  8. Test in staging on test or de-identified claims before the agent touches live records.

If you want to prove the controls on your own data first, an AI pilot runs one workflow in staging before you commit to the build.

Frequently asked questions

Is an enterprise context layer HIPAA compliant?

No architecture is compliant on its own. HIPAA compliance comes from your organization's policies, risk analysis, agreements and safeguards. A context layer gives you specific controls toward it: minimum necessary per task, access control per agent, and audit records of every retrieval and action.

Does the minimum necessary standard apply to AI agents?

Yes, with some exceptions. It applies to uses and disclosures of PHI, and an agent reading PHI is a use. HHS exempts some cases, including disclosures to, or requests by, a health care provider for treatment. So it applies most clearly to billing, operations and reporting agents. Ask your privacy officer how it applies to each workflow.

Can we send patient data to an LLM API?

Only to a provider that has signed a business associate agreement with you. Under HHS's definition, a party that receives or transmits PHI on your behalf is a business associate. The other option is a model you host inside your environment. Either way, send only the fields the task needs, not the whole record.

Should we de-identify data before an agent sees it?

For reporting and analytics, often yes. HHS recognizes two methods. Safe Harbor removes 18 listed identifiers. Under Expert Determination, a qualified expert documents that the risk of re-identification is very small. Tasks that act on one patient, such as an appeal, usually need masked identifiers rather than full de-identification.

Why map clinical terms before the prompt?

Mapping terms first means the model works with standard codes instead of free-text notes. The mapping to SNOMED CT, RxNorm and ICD-10-CM runs inside your network. What the model receives is shorter and carries fewer identifiers, and a fixed step can check it against payer rules instead of the model.

We build healthcare agents for billing, denials, reporting and the front office. They work behind a context layer in your own environment, and a person approves every submission. See the workflows on AI solutions for healthcare, read how the layer works on the enterprise context layer page, or book a discovery call.

More on this topic

Put your first workflow on the board

Answer a few questions about your team and what you want automated, then a senior partner scopes it with you on the call.