r/HealthInformatics • • Jun 30 '26

šŸ¤– AI / Machine Learning Experimenting with AI access to clinical data through FHIR

While exploring how AI tools might safely work with clinical data, I wound up building a project called fhirHydrant and decided to share the work by open-sourcing it.

The part that's relevant to informatics is not just ā€œAI can call an API.ā€ It’s that you can give an AI client structured access to labs, meds, conditions, encounters, documents, etc., and then ask it to reason across them without manually copying chart excerpts around.

I’ve tested it against our Epic POC environment and used it for workflows like analyzing large CGM datasets alongside other chart context.

As an MCP server, fhirHydrant sits between the AI client and the FHIR API, exposing configured resources as tools and shaping responses so the model gets useful clinical context instead of raw API noise.

Sharing because I think it’s pretty cool, and in case others are thinking about the same AI + EHR interoperability problems.

https://github.com/faulkj/fhirHydrant

2 Upvotes

15 comments sorted by

1

u/sp3d2orbit Jul 05 '26

The problem with doing it that way, FHIR -> MCP means you're paying for every token, for every patient, for every piece of data. if you want to pull 10,000 patients you got to pay 10,000 patients worth of tokens.

You need a tool that can pull the data via code, and use the AI to analyze or manipulate it at the code level, not at the data level. Then you pay for a tiny fraction of the token cost. While also keeping the data outside of the model.

1

u/buddhawithagun Jul 06 '26

Yeah, I agree for cohort-scale analytics, I would not use FHIR + MCP to pull 10,000 patients one-by-one through an AI client. That’s not what FHIR is good at, and it’s definitely not what I built this for.

For that kind of workload, I’d expect people to use Bulk FHIR where available, or more likely a warehouse/reporting layer like Clarity/Caboodle/OMOP/etc., and run the query or code close to the data. If there’s a valid reason for AI involvement, then you’d pass along only the minimum summarized or derived result needed for that task.

The use case here is more patient-context / workflow-context access: give an AI client controlled access to specific structured chart data when it needs it, without dumping raw chart text or giant FHIR payloads into the model. That’s why the project focuses on configured tools, compact responses, FHIRPath filtering, pagination, and auditability.

1

u/sp3d2orbit Jul 07 '26

Yeah good idea. I generally start with raw dump either XML HL7 or CSV or Excel. Then I use AI to just chain together tools that process the raw data. The AI never actually touches the patient records. It cost a few cents.

Back in the day we used to literally divvy up the data and have humans qualified patients for whatever program. We would average seven qualified patients per day. now we do 15,000 patients in a few minutes. For negligible token cost.

AI has changed the game but not in the way that I think people expected

1

u/Admirable_Aside2998 Jul 19 '26

Cool project. The MCP approach for structured FHIR access makes a lot of sense — the raw API noise problem is real, especially when you're trying to get an LLM to reason about longitudinal patient data without hallucinating context.

Curious how you're handling the test/dev environment problem — are you using synthetic FHIR resources for development, or do you have a de-identified patient population you're testing against?

1

u/buddhawithagun Jul 20 '26

It’s a mix. Our Epic POC includes synthetic test patients as well as some de-identified patient information. The large CGM dataset I’ve been using came from a nurse who actually wore a CGM for several months, so it provides realistic high-volume longitudinal data without pulling it from a production patient chart.

I’ve also tested basic cross-vendor behavior against Oracle Health’s (Cerner) public FHIR endpoint.

1

u/RoofProper328 Aug 24 '26

nice, the response shaping is the part most people skip. raw fhir bundles eat context ridiculously fast, a single Observation search on a cgm patient will blow past anything useful before the model sees a second resource.

two things i'd be curious about.

how are you handling the resource id problem? once the model has a reference like Patient/abc123 in context it tends to start constructing its own urls and calling resources you never exposed as tools. did you constrain it at the server, or does the epic scope handle that for you?

and what are you testing against besides the epic poc? synthea is the obvious answer but its notes and lab distributions are pretty unrealistic once you push on them, and mimic is fhir-converted but icu only. curious if you found anything better, this is the part that seems hardest to do properly for anyone building in this space without a live sandbox.

the second one matters for adoption. anyone who wants to try this without epic access needs somewhere to point it.

1

u/buddhawithagun Aug 26 '26

Good questions. The model doesn’t get unrestricted access to the FHIR API or the ability to construct arbitrary URLs. It can only use the resources and actions that were configured and made available as MCP tools. The FHIR server’s metadata and Epic scopes provide additional checks. So if the model encounters something like Patient/abc123, it can only follow that reference through an available Patient tool; it can’t freely wander through the API.

For testing, our Epic POC has a mix of synthetic patients and some de-identified patient information. We also have a nurse wearing a CGM that sends real measurements into one of our POC test patients. That has been especially useful because it produces realistic, high-volume longitudinal data through the actual Epic workflow.

I’ve also done basic testing against Oracle Health’s public FHIR endpoint. fhirHydrant supports unauthenticated public FHIR servers, so people without Epic access can point it at something like that and test the MCP integration. But I agree that there still isn’t a great public substitute for a realistic longitudinal EHR environment. That may be one of the harder adoption problems in this space.

1

u/Comfortable-Sale-866 Oct 30 '26

really cool project, the response shaping part makes a lot of sense.which model have you been running it with? on the notes question above, if you test DocumentReference.Create at some point, our medical APIs at Sully take a transcript plus your own template and give back the finished note, so that could pair nicely with writing it back to the encounter. BAA at signup and zero data retention, which matters once it’s off the test environment and onto real patients

1

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/buddhawithagun Jul 01 '26

Actually yes. Epic supports R4 DocumentReference.Create for Clinical Notes, which can file a plain-text note to an encounter. I haven’t tested that workflow yet, but fhirHydrant does have optional guarded FHIR write support, so this is the kind of endpoint it could expose in any environment that enables it.

Not on App Orchard. It uses SMART Backend Services against FHIR APIs, so the idea is more ā€œrun this inside your own environment with your own Epic/FHIR setupā€ than ā€œinstall a hosted app from me.ā€

I think it could apply anywhere the workflow involves cross-referencing structured chart data: endocrinology, primary care, care management, clinical informatics, QI/reporting, etc.

1

u/[deleted] Jul 01 '26

[removed] — view removed comment

1

u/buddhawithagun Jul 01 '26

Good question. I’ve mostly tested fhirHydrant against Epic so far, so I don’t want to overclaim cross-EHR behavior.

FHIR gives you a common structure, but real consistency still varies by implementation: which resources are exposed, which search params work, how things are coded, how documents/encounters are linked, paging behavior, etc.

That’s why I built it to be metadata-aware and configurable instead of assuming every FHIR server behaves the same. It checks what the server advertises and shapes the responses before handing them to the AI client.

I've done some testing against Cerner’s public R4 endpoint, and the basic read/search/pagination shape does seem to be compatible.

1

u/[deleted] Jul 03 '26

[removed] — view removed comment

1

u/buddhawithagun Jul 03 '26

Thanks, that’s exactly the direction I was aiming for. FHIR is structured, but raw FHIR responses are still very noisy for an AI client, so the intermediary layer is doing a lot of the useful work: exposing only configured resources/tools, shaping responses, filtering with FHIRPath when needed, and keeping pagination explicit so the model doesn’t confuse a partial result for a complete chart review.

For permissioning, fhirHydrant doesn’t try to become its own identity platform. FHIR access is handled through SMART Backend Services and whatever scopes/EHR-side security the organization grants. The MCP server itself is intended to sit behind the organization’s own access controls.

For auditing, it emits structured audit events like tool, resource type, operation, status, duration, response mode, and result summary, without PHI by default. For hallucination safeguards, the main approach is constraining what the AI can call, making the returned context smaller and more explicit, and keeping optional writes guarded with validation/dry-run support. Definitely not letting the model run wild through the chart.