Skip to content
DEXPRADEXPRA home

Article · Applied AI

How AI Agents Access Patient Records Through FHIR

SMART defines three subjects and an agent is none of them. What a record actually sees when a model asks it a question, and why the answer is usually one service account doing everything.

DEXPRA · · 17 min read

The decision that is made before the model

An agent that reads a patient record is usually discussed as a model problem. Which model, what context window, how the retrieval is chunked, whether the summary can be trusted. All of that is downstream of a decision taken earlier and somewhere else, normally by whoever filled in a client registration form, and it is the decision that determines what the agent can reach, what the hospital can prove afterwards, and whether anybody can answer the question an auditor will eventually ask.

The decision is which kind of thing the agent is. OAuth has a vocabulary for this and healthcare has a profile of it, and neither has a word for an agent. An agent is a client, not a user, and the record it is talking to was built to tell those two apart.

The three SMART scope subjects, and why an autonomous agent is none of themThree panels side by side, one for each scope prefix SMART App Launch defines. The patient slash prefix reaches one patient’s record: the patient authorizes it at an authorization screen, the token carries a patient in context set at launch, and it reaches data about that one patient and no other. The user slash prefix reaches whatever that user can see: the signed-in clinician authorizes it at launch, the token carries a human identity the server already knows, and it reaches everything their own account reaches and no more. The system slash prefix reaches whatever the client was pre-authorized for: nobody authorizes it at run time and an administrator did so once, the token carries a client identity with no human in it at all, and it reaches the set an administrator registered in advance. A navy band beneath the three panels states that an agent is a client rather than a user, that the grammar has no fourth prefix for it, and that every deployment therefore borrows one of the three.SMART APP LAUNCH 2.2 · THE THREE SCOPE SUBJECTSpatient/One patient’s recordWHO AUTHORIZESThe patient, at anauthorization screenTOKEN CARRIESA patient in context, set atlaunchREACHESData about that one patientand no otheruser/Whatever that user can seeWHO AUTHORIZESThe signed-in clinician, atlaunchTOKEN CARRIESA human identity the serveralready knowsREACHESEverything their own accountreaches, and no moresystem/Whatever the client waspre-authorized forWHO AUTHORIZESNobody, at run time. Anadministrator, onceTOKEN CARRIESA client identity. No human init at allREACHESThe set an administratorregistered in advanceAND THE ONE THE GRAMMAR DOES NOT HAVEAn agent is a client, not a user. There is no fourth prefix for it.So every deployment borrows one of the three, and which one it borrows decides what the serversees and what the audit log can name.
Three prefixes, three different answers to "who is asking". An agent has to borrow one of them.

Three subjects, and an agent is none of them

SMART App Launch defines the authorization layer almost every FHIR server in the United States exposes, because the certification criterion requires it. Its scope grammar begins with one of exactly three prefixes, and they are not three levels of the same thing. They are three different claims about who is at the other end of the connection.

patient/ is a single patient in context, chosen at launch. user/ is, in the specification’s own words, data available to the signed-in user rather than data about them, which means the ceiling is whatever that person’s own account already reaches. system/ is for the case the spec describes as having no user in the loop: a client authenticates with a signed assertion, gets a token, and the only consent that ever happened was an administrator registering it.

Two sentences in that specification do more work than the grammar does. The first: scopes allow a client to request the delegation of a specific set of access rights, and such rights are always limited by underlying system policies and permissions. The second, with the exclamation mark the authors put on it: the scopes ultimately granted by the authorization server may differ from the scopes requested by the client. A scope is a ceiling, not a grant. Asking for more does not produce more, and a client that assumes it got what it asked for is a client that will fail in production on a patient whose record is restricted.

An autonomous agent fits none of the three cleanly. It is software, so it is not a user. It acts because a person asked, so it is not unattended. It persists across sessions and acts when nobody is watching, so it is not an app in a clinician’s hands. Every deployment resolves this by borrowing one of the three, and the choice is made early, quietly, and almost always for operational reasons rather than for the reason that will matter later.

What a scope can actually narrow

The second half of a scope is the part people think they control. It is narrower than it looks.

The four parts of a SMART v2 scope string, taken apart one segment at a timeThe scope patient slash Observation dot r s question mark category equals laboratory, drawn large in a monospace face with a bracket under each of its four parts. The first part, patient, is the subject: whose data and in whose name, one of patient, user or system, fixed by how the client authenticated rather than by what it asks for. The second, Observation, is the resource type, one FHIR type or an asterisk for all of them, and the widest granularity most servers offer. The third, r s, is the set of interactions, a subset of the letters c r u d s in that order, here read and search with no create, update or delete. The fourth, question mark category equals laboratory, is a search parameter filter added in SMART 2.2 that binds only where the server implements it. A note at the foot records that the authorization server may grant less than was asked for and never grants more than the underlying account already has.SMART APP LAUNCH 2.2 · SCOPE SYNTAX V2 WITH A SEARCH PARAMETER FILTERpatientObservationrs?category=laboratory/.SUBJECTRESOURCE TYPEINTERACTIONSFILTERSUBJECTWhose data, and in whose name. patient, user or system. Fixed by how the clientauthenticated, not by what it asks for.RESOURCE TYPEOne FHIR type, or * for all of them. This is the widest granularity most servers offer.INTERACTIONSA subset of c r u d s, in that order. Here: read and search. No create, no update, nodelete.FILTERA search parameter narrowing the set. Added in SMART 2.2. Only binds where the serverimplements it.None of it is a grant. The authorization server may return fewer scopes than were asked for, and no scopereaches data the underlying account cannot already see.
Four segments, three of which are constrained by somebody other than whoever typed the string.

The letters after the dot are a subset of cruds, in that order, and each maps to specific FHIR interactions rather than to a general permission. c is type-level create. r is instance-level read, vread and history. u is instance-level update and patch. d is instance-level delete. s is type-level and system-level search and history.

The consequence that catches people is that r on its own is close to useless. An instance read needs an id, and a client that has not searched does not have one. Search is what finds things, so the real minimum for an agent that explores a chart is .rs, and a scope review that waves through read-only access has approved the ability to enumerate.

SMART 2.2 added a query-string filter, so patient/Observation.rs?category=laboratory is a legal scope that reaches lab results and not the social-history answers filed in the same resource type. This is the only general mechanism for sub-resource granularity, and its coverage is thin on purpose: US Core requires a certifying server to support three category filters on Condition and five on Observation, and names them as the ones the HTI-1 final rule requires. Nothing else has a required filter. patient/DocumentReference.rs is every note, including the psychiatry note and the social work note, and there is no standard scope that is less than that.

Build one and read what it reaches. The warnings underneath are the specification’s, not ours.

BUILD A SCOPE

Four decisions, and the reach of the result underneath. Every line below is from SMART App Launch 2.2, US Core or the certification criterion, not from an opinion about them.

1 · SUBJECT
3 · INTERACTIONS

THE SCOPE

patient/Observation.rs

WHAT IT REACHES

one patient in context: every result, vital sign, score and social-history answer for that person.

WHAT TO KNOW

  • A CEILING, NOT A GRANTThe authorization server may return fewer scopes than were asked for, and the spec says so outright. No scope reaches data the underlying account cannot already see.
Every string this produces is a legal SMART 2.2 scope. The notes under it are from the specification, US Core, and the certification criterion.

The bridge, and the token that cannot cross it

Most agents do not speak FHIR. They call tools, and something behind the tool speaks FHIR. In 2026 that something is increasingly an MCP server, and the Model Context Protocol has an authorization specification with a position on exactly this arrangement.

The specification makes an MCP server an OAuth 2.1 resource server. Clients must implement RFC 8707 resource indicators and send a resource parameter naming the server the token is for. Servers must validate that a token was issued for them as the intended audience, must only accept tokens valid for their own resources, and must not accept or transit any other token. Then the sentence that decides the architecture: if the MCP server calls an upstream API, the token used there is a separate token issued by the upstream authorization server, and the MCP server must not pass through the token it received.

Token passthrough against the two-audience bridge between an agent and a FHIR serverTwo rows, each showing an agent client, an MCP server and a FHIR server joined by arrows. In the upper row, labeled what gets built first and marked forbidden, one token is used on both hops: it is issued for the MCP server and then presented again to the FHIR server, where its audience is wrong. The second arrow is struck through. The MCP specification says a server must not pass through the token it received and must only accept tokens issued for itself. In the lower row, labeled what conforms and marked two audiences, the first hop carries token A with the MCP server as its audience and the second hop carries token B with the FHIR server as its audience, issued to the MCP server acting as its own OAuth client. Token B is issued to the MCP server rather than to the clinician, so nothing in it names the person at the keyboard unless the bridge is built to carry that across.MCP AUTHORIZATION · ACCESS TOKEN PRIVILEGE RESTRICTIONWHAT GETS BUILT FIRST✕ forbiddenAgent clientHolds the user’ssessionMCP serverRelays the callFHIR serverTrusts the bearertoken Aaudience: theMCP servertoken A againwrong audienceThe MCP specification: a server MUST NOT pass through the token it received, and MUST only accepttokens issued for itself.WHAT CONFORMS✓ two audiencesAgent clientHolds the user’ssessionMCP serverIts own OAuthclient upstreamFHIR serverValidates its ownaudiencetoken Aaudience: theMCP servertoken Baudience: theFHIR serverToken B is issued to the MCP server, not to the clinician. Nothing in it names the person at the keyboardunless the bridge is built to carry that.
The first arrangement is the one that gets built. The second is the one the specification describes, and it has a consequence.

That rule is right and the reason for it is good: a token replayed at a service it was not issued for is the confused deputy problem, and audience binding is the mitigation. But follow it through in a hospital. The clinician authorizes the agent. The agent gets a token for the MCP server. The MCP server, forbidden from forwarding it, authenticates to the FHIR server as itself, which in practice means SMART Backend Services: a signed JWT assertion, the client credentials grant, system/ scopes, and a token the profile says should expire within five minutes.

The record now sees one client. Not the agent, and not the clinician behind the agent. It sees a service account holding the union of everything an administrator pre-authorized, doing a thing, at a time. Break-the-glass, consent directives, the narrower permissions on a trainee’s account and every sensitive-category rule are all evaluated against an identity that is not the one that asked.

Four topologies, and the same five questions

There are four shapes this takes in practice. They are not a maturity ladder, and the first is the right answer whenever it fits.

PICK A TOPOLOGY

Four ways to connect an agent to a record, and the same five questions asked of each. They are not a ladder: the first is the best answer whenever it fits.

A SMART app launched by a clinician, holding that session’s token.

HOW THE TOKEN IS OBTAINED

Ordinary SMART App Launch. The clinician launches from the EHR or signs in standalone, approves the scopes at an authorization screen, and the app holds an access token tied to that person, refreshed while the session lasts.

WHAT THE FHIR SERVER SEES

A human. The token resolves to a user the server already knows, with the permissions that account already has, and `fhirUser` identifies them.

WHAT THE AUDIT RECORD HOLDS

Everything. The user is in the request, the app is in the request, and an audit record can name both, which is the arrangement every existing access-review process was designed around.

WHAT IT COSTS

The agent cannot act when nobody is signed in. There is no overnight run, no queue drain and no cohort pass. The ceiling is also the clinician’s own permissions, which is correct and is sometimes not enough.

WHEN IT IS THE RIGHT ANSWER

The work is in a clinician’s hands and in their moment: drafting a reply, summarizing the chart in front of them, answering a question they asked. If this fits, use it. It is the only topology where the attribution problem does not arise.

The same five questions asked of each. The differences that matter are in the last three answers, not the first two.

Delegation, if anyone implemented it

There is a standard for the thing the third topology is missing, and it is twenty-five years of OAuth thinking old. RFC 8693 defines token exchange: a client presents a subject_token representing the party on whose behalf the request is made, optionally an actor_token representing the acting party, and receives a token that carries both. The act claim expresses that delegation has occurred and identifies the actor.

The RFC also draws the distinction this problem needs. Under impersonation, the agent is given all the rights of the user and is indistinguishable from them in that context. Under delegation, the agent keeps its own identity and the user has delegated some rights to it. Only the second is auditable, because only the second leaves two names in the token. There is even a may_act claim, which states in advance that one party is authorized to become the actor for another.

Almost nobody in healthcare implements it. SMART does not profile token exchange, so there is no conformance statement to point a vendor at, no row in a certification test, and no way to specify it in a procurement document except by writing the specification yourself. The work most likely to close this is elsewhere: SMART Permission Tickets, discussed in the Argonaut and US Core session at FHIR DevDays in 2026, aim at portable pre-verified permission grants a client can present at any participating endpoint. That is a different problem with an overlapping shape, and it is the thing to watch.

In the meantime the gap is a procurement question rather than an engineering one. Nothing will require a vendor to offer delegated tokens, so the only mechanism that produces them is customers asking.

Read is certified. Write is not.

The read path an agent uses is a standard. §170.315(g)(10) requires FHIR R4.0.1, the US Core profiles matched to the USCDI version in force, SMART App Launch, token introspection, refresh tokens valid for at least three months for confidential apps, and Bulk Data with the group export operation. A health system can hold its vendor to all of it.

The write path is not a standard, and the criterion says so in as many words: these services specifically exclude write capabilities. Nothing an agent does that changes the record is inside the certified surface. Every create and every update is a bilateral arrangement, enabled per customer, scoped to the resource types that vendor chose to expose, on terms that are commercial rather than regulatory.

What the certification criterion does and does not reach
ReadWrite
Covered by §170.315(g)(10)Yes. Single patient and population, to the USCDI in force.No. Explicitly excluded from the criterion.
Scope vocabularyRequired scopes listed in US Core, including the eight category filters.No required scopes. Whether a write scope exists is a vendor decision.
What you can hold a vendor toCertification, real-world testing, the information blocking rules.A contract, and whatever the app review program decided.
What this does to an agentA portable read path that works the same way across estates.A per-vendor integration, re-done for each one, with its own review.

This is the single most load-bearing fact for anyone planning an agent that does something rather than says something. The demo where it drafts a note and files it is the demo. The production version of that is a negotiation, per vendor, per customer, and it is on the critical path.

Naming the actor in the record

Suppose the write happens. Who does the record say did it?

Which FHIR R4 elements may name a Device, and which cannotA five-row table. Observation dot performer, defined as who was responsible for asserting the observed value as true, may not reference a Device. Observation dot device may, but it names the instrument that generated the data rather than the party that asserted it. DocumentReference dot author may reference a Device outright. Provenance dot agent dot who may, and records who took part in producing the resource and in what role. AuditEvent dot agent dot who may, and its requestor flag says who initiated the event. A note at the foot records that the only element that asks the question you want answered about an AI-produced observation is the one element that cannot answer it, and that HL7’s AI Transparency implementation guide works around this with the alternate-reference extension.FHIR R4 · MAY THIS ELEMENT REFERENCE A DEVICE?ELEMENTDEVICEWHAT THE ELEMENT MEANSObservation.performer✕ noWho was responsible for asserting the observed valueas true. No Device.Observation.device✓ yesThe device used to generate the data. An instrument,not an author.DocumentReference.author✓ yesWho authored the document. A Device may be namedoutright.Provenance.agent.who✓ yesWho took part in producing the resource, and in whatrole.AuditEvent.agent.who✓ yesWho took part in the event, with requestor saying whoinitiated it.The one element that asks the question you want answered about an AI-produced observation is the oneelement that cannot answer it. HL7’s AI Transparency guide works around it with the alternate-referenceextension, and says so in its own source.
Four of the five can name a Device. The one that cannot is the one defined as asking who asserted the value.

FHIR R4 is mostly ready for this. AuditEvent.agent.who, Provenance.agent.who and DocumentReference.author may all reference a Device, so an AI can be named as the author of a note and as a participant in an event. The gap is in one place and it is a conspicuous one: Observation.performer is defined as who was responsible for asserting the observed value as true, which is precisely the question, and its reference list has no Device in it.

HL7 is working the problem. AI Transparency on FHIR, sponsored by the EHR work group and balloted in January 2026, defines an AIProvenance profile requiring at least one agent whose who resolves to an AIDevice, allowing human agents beside it, fixing the reason to the AIAST security label for artificial-intelligence-asserted content, and slicing the entity list so the model card and the input prompt are both carried as references. There is an AIconfidence extension for the probability, usable at resource or element level.

It is worth knowing two things about it. The guide is a continuous build and not an authorized publication, so it is something to design toward rather than conform to. And its own first example runs straight into the performer gap: the source carries a note saying the element cannot hold a Device, and falls back to the alternate-reference extension. The data model is not quite ready for an author that is not a person, and the people fixing it have found that out in the first file.

The audit log is where the action survives

Six months after an agent reads a chart, the only account of what happened is in an audit record. The question will not be a general one. It will be whether this specific patient’s record was accessed on this specific day, by whom, and why, and it will arrive from a privacy officer with a complaint in front of them.

IHE Basic Audit Log Patterns profiles FHIR AuditEvent for exactly this, with patterns for each RESTful interaction and separate patterns for the SAML and OAuth security token cases and for a consent decision. The important structural property is that AuditEvent.agent repeats, and each agent carries a requestor flag saying whether that party initiated the event. One record can name the clinician, the application, and the organization, and say which of them started it.

Which means the data model has been ready for agent attribution for years, and the thing that defeats it is upstream: if the token that reached the FHIR server carried only a client identity, there is no second agent to write. The audit record is complete, correct, and silent on the only question anyone will ask. The answer then lives in the agent platform’s own logs, which is a different system, with a different retention period, a different access control list and a different auditor.

If you are stuck in that position, BALP has a slot for the join and it is worth using rather than inventing a header. The query pattern defines an entity slice typed XrequestId, for a cross-system request identifier, so one logical transaction can be followed across logs belonging to different systems. Write the same value beside the user in the agent platform’s log and the reconstruction becomes a documented two-step procedure. Then have somebody who was not on the project actually perform it, on a real day and a real patient, because a correlation id that has never answered a question is a design intention rather than a control.

What a FHIR AuditEvent can name, and what it names when the token carries only a clientOn the left, an AuditEvent as the data model allows it: three agents, the clinician with requestor true, the application and the organization with requestor false. On the right, the same AuditEvent when the token that reached the FHIR server carried only a client identity: one agent, the client application, and an empty slot where the second agent would be. Below it, a dashed join labeled XrequestId, the BALP entity for a cross-system request identifier, leads to the agent platform's own log, which holds the user and is a different system with a different retention period, access control list and auditor.THE DATA MODEL IS READY. THE TOKEN DEFEATS ITWHAT AUDITEVENT CAN HOLDWHAT IT GETS FROM A CLIENT-ONLY TOKENAuditEventAGENTREQUESTORClinicianTRUEApplicationFALSEOrganizationFALSEAuditEventAGENTREQUESTORClient applicationTRUENO SECOND AGENT TO WRITEOne record names all three and says which of themstarted it.The token named only the client. The record iscomplete, correct, and silent on who asked.BALP ENTITY: XrequestIdAGENT PLATFORM LOGuser = the clinician · same request idA different system, with a different retentionperiod, a different access control list and adifferent auditor.
The data model can name three agents. A client-only token gives it one.

The data is also the instruction channel

One more thing changes when the client is a model rather than a program. A program that fetches a note and a model that reads one are doing different things, because the note can address the model.

The best evidence available is narrower than the headline it usually gets, and the narrowness matters. A JAMA Network Open study published in December 2025 ran three lightweight commercial models across twelve clinical scenarios and found injected instructions followed in 94.4% of evaluations at turn four, 102 of 108, with two of the three models at 100%. The injections were inserted into the user queries, not into retrieved chart content, so this is a measurement of whether these models follow instructions that reach them rather than a measurement of indirect injection through a record. It is the right number to quote and the wrong number to round up.

The structural point stands either way. An agent with read access to free text has an input channel that it cannot distinguish from its own instructions, and a patient-portal message, a scanned referral and an outside note all reach it through that channel. The defense is not better instructions. It is that the scope on the token is the one boundary the model has no ability to argue with: a token that cannot write cannot be talked into writing.

This is also why a tool definition is not a control. MCP lets a server annotate a tool with behavioral hints, and the specification is blunt about their standing: clients must consider tool annotations untrusted unless they come from trusted servers. A tool marked read-only is a label. A .rs scope is an enforcement point, in a different process, that the model never sees.

Where an instruction in a chart meets the only boundary that holdsA path from left to right. Free text from a patient-portal message, a scanned referral and an outside note flows into the model, which cannot tell the note's text from its own instructions. The model calls a tool; a tool marked read-only is only a label, untrusted unless the server is. The call then meets the scope on the token, highlighted, enforced in a different process the model never sees: a token that cannot write cannot be talked into writing.THE NOTE CAN ADDRESS THE MODEL. IT CANNOT ADDRESS THE SCOPEPatient-portal messageScanned referralOutside noteFREE TEXT IN THE RECORDMODELTOOL CALL“READ-ONLY”TOKEN SCOPE.rsCannot tell thenote’s text from itsown instructions.A tool markedread-only is a label.Untrusted unlessthe server is.Enforced in adifferent process. Atoken that cannotwrite cannot betalked into writing.
The note can talk to the model. Only the scope stops the write.

What to settle before anything connects

Six questions. If the answers are not written down somewhere, the integration has made the choices anyway.

  • Which subject, and why not the one above it. If the answer to "why not a user token" is that the service account was easier to register, the attribution gap was bought for convenience and nobody priced it.
  • What the scope string is, in full. Written out, with the filters. user/*.cruds is shorter to type than the right answer and the difference is invisible until someone reads a log.
  • Whether a human identity crosses the bridge, and how. Token exchange, a signed assertion of your own, or a correlation id logged at both ends. Those are the three answers. "It is in the application logs" is the fourth and it is the one that fails an audit.
  • What the audit record will say. Write the AuditEvent you expect, before building, and check it answers the privacy officer’s question rather than the engineer’s.
  • Whether anything writes, and under whose name. If it writes, the attribution question is now a clinical safety question and the certified surface does not cover it.
  • What the token can still reach when the model is wrong. Assume the instructions came from the chart. The scope is the answer, and it is the only one that holds.

None of this is about the model, and none of it gets easier by choosing a better one. The hard part is in the same place it has always been: between the systems, in the part where a field means two different things and nobody owns the join.

Questions about something here?

Ask about an article, a white paper or a tool, or tell us what you would like covered next.

Get in touch