FHIR Meets Graph Databases: Exploring Healthcare's Natural Network Structure

CLaiR: Making medical records understandable

About the Clarity Health Project

Clarity Health Project is a 501(c)(3) nonprofit breaking down language barriers in healthcare. We're tackling a $238 billion problem: poor health literacy that affects 73% of rural patients and causes 42% of non-English speakers to avoid care entirely.

Our solution? CLaiR—an AI assistant that translates medical records in 5 languages and explains complex medical terms in plain language. No jargon, no confusion, just clear explanations that help patients understand their health.

Patient after using CLaiR

CLaiR is completely free, HIPAA compliant, and we never sell patient data. We built it for the 25 million Americans facing language barriers and the 46 million in rural areas with limited healthcare access. Because everyone deserves to understand their medical records—not just those who speak medical English fluently.


When we started building CLaiR at Clarity Health Project, something fascinating emerged: FHIR data naturally wants to be a graph.

Think about it—every FHIR resource references other resources. A Patient links to Encounters, which reference Observations, which connect to Medications. It's not tabular data forced into relationships; it's inherently interconnected from the start. As a computer scientist exploring this space, I've been amazed by how perfectly healthcare's complexity maps to graph structures.

Discovering FHIR's Graph Nature

FHIR doesn't just store healthcare data—it models healthcare relationships. Every resource has references pointing to other resources, creating a web of medical information that mirrors how healthcare actually works.

Consider a simple patient encounter:

  • The patient has multiple conditions
  • Each condition may have multiple medications
  • Those medications interact with each other
  • Lab results inform medication dosing
  • Allergies constrain treatment options

In traditional databases, these relationships require complex joins. In FHIR, they're already there as references. When we import FHIR into a graph database like MemGraph, we're not imposing a structure—we're revealing the structure that already exists.

The Exploration Journey

Working with FHIR data in graph databases has been like being an explorer with a new map. Each query reveals connections we hadn't considered:

  • How do medication patterns differ across patient populations?
  • What lab result trends precede medication changes?
  • Which condition combinations lead to the most complex medication regimens?

The beauty is that these aren't predetermined reports—they're explorations we can make in real-time as we learn what questions to ask. Graph traversals let us follow the natural flow of medical relationships without knowing the exact path beforehand.

Bridging Structured and Unstructured Worlds

One fascinating aspect we're exploring is how FHIR acts as a bridge between structured and unstructured medical data. Yes, clinical notes contain rich narrative text, but FHIR's DocumentReference and DiagnosticReport resources provide structure around that narrative.

When a radiologist writes "findings consistent with pneumonia," that text lives within a FHIR DiagnosticReport that links to:

  • The patient (subject reference)
  • The encounter (context reference)
  • The ordering provider (requester reference)
  • Related observations (result references)

This creates a scaffold for understanding narrative text within its clinical context. We're not just processing text in isolation—we're processing it within a network of relationships that inform meaning.

Why Graphs Supercharge LLMs and Agentic Workflows

Here's what really excites me: graph databases aren't just storage—they're thinking tools for AI agents. When LLMs work with graph-structured data, something magical happens.

Traditional context windows force LLMs to process everything linearly. But healthcare doesn't work linearly. A patient's current symptoms might relate to a medication from three years ago, which was prescribed for a condition diagnosed five years ago. In a graph, these connections are immediate and traversable.

Consider how CLaiR's agents navigate patient data:

  • Contextual traversal: Instead of dumping entire medical histories into context, agents follow specific relationship paths relevant to the current query
  • Semantic pruning: Graph relationships help agents ignore irrelevant data, focusing compute on what matters
  • Multi-hop reasoning: Agents can explore "what if" paths through the graph, testing hypotheses about relationships between conditions, medications, and outcomes

The graph becomes the agent's working memory—persistent, queryable, and infinitely more structured than text alone.

LangGraph + MemGraph: Orchestrating Intelligent Workflows

What makes our architecture particularly powerful is how LangGraph orchestrates agentic workflows that leverage MemGraph's relationship structure.

We're exploring patterns where:

  • Agents use graph queries to gather focused context before making decisions
  • Workflow nodes dynamically adjust based on discovered graph relationships
  • Multiple specialized agents collaborate, each querying different aspects of the patient graph
  • Confidence scores from graph traversals inform agent reasoning paths

For example, when explaining a medication interaction, our workflow might:

  1. Query the graph for all medications linked to the patient
  2. Traverse relationships to find potential interactions
  3. Follow edges to related conditions that might influence risk
  4. Gather temporal context about when medications were started/stopped
  5. Synthesize findings into patient-friendly explanations

The declarative nature of LangGraph means we can compose these complex reasoning chains while the graph ensures agents always work with accurate, connected context.

The Art of Medical Entity Resolution

One of the most intellectually interesting challenges we're exploring is entity resolution—understanding when different terms refer to the same medical concept.

Take medications: "Coumadin" and "warfarin" are the same drug (brand vs generic), but discovering these relationships programmatically opens up fascinating questions:

  • How do we weight different naming conventions?
  • When does context determine whether we mean the drug class or specific formulation?
  • How do regional variations in medical terminology affect our understanding?

Rather than seeing this as a problem to solve once and for all, we're treating it as an ongoing exploration. Each new dataset teaches us something about how medical language evolves and varies.

How FHIR Data Powers Graph Intelligence

The convergence of FHIR and graph databases creates something greater than the sum of its parts. FHIR already models healthcare data as interconnected resources—patients link to encounters, which reference observations, which connect to medications. When we import FHIR data into MemGraph, these JSON references transform into traversable graph relationships that LLMs can navigate intelligently.

Take a typical FHIR bundle response:

{
  "resourceType": "Bundle",
  "entry": [
    {
      "resource": {
        "resourceType": "Patient",
        "id": "patient-123",
        "identifier": [{
          "system": "urn:oid:2.16.840.1.113883.4.3.25",
          "value": "E43744"
        }]
      }
    },
    {
      "resource": {
        "resourceType": "Condition",
        "id": "condition-456",
        "subject": {"reference": "Patient/patient-123"},
        "code": {
          "coding": [{
            "system": "http://snomed.info/sct",
            "code": "44054006",
            "display": "Diabetes mellitus type 2"
          }]
        }
      }
    },
    {
      "resource": {
        "resourceType": "MedicationRequest",
        "id": "med-789",
        "subject": {"reference": "Patient/patient-123"},
        "reasonReference": [
          {"reference": "Condition/condition-456"}
        ],
        "medicationCodeableConcept": {
          "coding": [{
            "system": "http://www.nlm.nih.gov/research/umls/rxnorm",
            "code": "6809",
            "display": "Metformin"
          }]
        }
      }
    }
  ]
}

In MemGraph, this becomes:

// Create nodes with FHIR resource properties
CREATE (p:Patient {
  fhir_id: 'patient-123',
  identifier: 'E43744'
})
CREATE (c:Condition {
  fhir_id: 'condition-456',
  snomed: '44054006',
  display: 'Diabetes mellitus type 2'
})
CREATE (m:MedicationRequest {
  fhir_id: 'med-789',
  rxnorm: '6809',
  display: 'Metformin'
})

// Create relationships from FHIR references
CREATE (p)-[:HAS_CONDITION]->(c)
CREATE (m)-[:PRESCRIBED_FOR]->(p)
CREATE (m)-[:TREATS]->(c)

Now complex clinical queries become simple graph traversals:

// Find medications for diabetic patients with high glucose
MATCH (p:Patient)-[:HAS_CONDITION]->(c:Condition)
WHERE c.snomed = '44054006'  // Diabetes
MATCH (p)-[:HAS_OBSERVATION]->(o:Observation)
WHERE o.loinc = '2339-0'  // Glucose
  AND o.value > 200
  AND o.effectiveDateTime > datetime() - duration('P30D')
MATCH (p)<-[:PRESCRIBED_FOR]-(m:MedicationRequest)
RETURN p.identifier,
       collect(m.display) as medications,
       max(o.value) as recent_glucose

Graphs as LLM Reasoning Scaffolds

What's revolutionary is how graphs provide structure for LLM reasoning. Instead of asking an LLM to process thousands of tokens of medical history, we can:

  1. Pre-filter with graph queries: "Find all medications related to this patient's cardiac conditions"
  2. Provide relationship context: "This medication was prescribed BECAUSE OF this condition, monitored BY these lab tests"
  3. Enable causal reasoning: "Follow the path from symptom → diagnosis → treatment → outcome"

The LLM no longer needs to infer relationships from text—the graph makes them explicit. This dramatically improves accuracy and reduces hallucinations because the model works with verified relationships rather than probabilistic associations.

Agentic Memory Through Graph Persistence

In CLaiR, each agent interaction enriches the graph. When an agent identifies a new relationship or clarifies an ambiguity, that knowledge persists in the graph for future agents to leverage.

Consider this workflow:

  • Agent 1 identifies that "Coumadin 5mg daily" in a clinical note refers to an existing MedicationRequest node
  • Agent 2 later encounters "warfarin therapy" and immediately knows it's the same medication through the graph relationship
  • Agent 3 can traverse from the medication to all related lab results (INR values) without re-processing the entire history

This creates a compound learning effect—each agent builds on the work of previous agents through the shared graph structure.

The Patient Access Rule makes this possible at scale. Since 2021, healthcare organizations must provide FHIR-based API access to patient data. Patients can authorize apps like CLaiR to retrieve their complete medical history in standardized FHIR format. We connect via Smart on FHIR, pull the patient's Bundle, and transform it into a queryable graph in seconds.

Smart on FHIR: A Gateway to Discovery

Smart on FHIR has opened up incredible possibilities for exploration. With standardized API access, we can now investigate questions that were impossible to answer just a few years ago.

The combination of structured FHIR resources and narrative text creates a rich dataset for discovery:

  • Lab results provide quantitative anchors for understanding clinical narratives
  • Medication lists offer structured starting points for exploring treatment patterns
  • Clinical notes add the "why" behind the structured "what"

What's particularly exciting is how Smart on FHIR democratizes this exploration. Any approved application can access this wealth of interconnected data (with patient consent), enabling innovations we haven't even imagined yet.

Building in the Open: A Nonprofit's Perspective

As a nonprofit, we have a unique opportunity to explore these technologies without the pressure of immediate monetization. This lets us ask different questions:

  • What patterns emerge when we look at health equity through graph relationships?
  • How do social determinants manifest in the connection patterns between conditions and outcomes?
  • Can graph traversals reveal care gaps that traditional analytics miss?

We're sharing our discoveries as we go, because the real value isn't in keeping secrets—it's in advancing the field together. Every experiment, whether it succeeds or surprises us with unexpected results, adds to our collective understanding of how to use these powerful technologies for good.

Why the Patient Access Rule Changes Everything

Before 2021, getting your medical records meant weeks of paperwork, fees, and often receiving stacks of illegible PDFs. The CMS Patient Access Rule changed the game completely. Now healthcare organizations must provide FHIR API access to patient data, enabling apps to retrieve structured medical records with patient consent.

For CLaiR, this means:

  • Instant access: Patients connect their health system accounts and we immediately pull their FHIR records
  • Structured data: Instead of parsing PDFs, we get JSON with defined schemas
  • Complete history: Access to encounters, labs, medications, allergies—everything since 2016
  • Real-time updates: New test results and visit notes appear as soon as they're available

The rule essentially democratized health data access. Patients own their records and can share them with any app they trust. For underserved populations who often receive care across multiple systems, this consolidated access is revolutionary. A migrant farmworker can instantly share their complete medical history with a new clinic, in their preferred language, without carrying folders of paper records.

The Beauty of Medical Language in Graphs

What fascinates me is how medical language reveals the richness of clinical thinking. When a radiologist writes "findings consistent with pneumonia," they're not being vague—they're precisely communicating probability in a world of uncertainty. When an emergency physician documents "r/o MI," they're creating a hypothesis tree that we can model as graph relationships.

These linguistic patterns aren't obstacles—they're insights into how medical professionals navigate complexity. By representing these patterns in graph structures, we're learning to model clinical reasoning itself.

Our Evolving Exploration

At Clarity Health Project, we're approaching this as an ongoing journey of discovery. We start with common patterns and relationships, then let each new insight guide our next exploration.

Our integration of Smart on FHIR, MemGraph, and LangGraph creates a living laboratory where we can:

  • Test new hypotheses about medical relationships
  • Discover unexpected connections in patient data
  • Experiment with different ways to make complex medical information accessible

Each beta partner teaches us something new. Each patient interaction reveals patterns we hadn't considered. It's not about having all the answers—it's about building systems that help us ask better questions.

Discovering the Unexpected

The most exciting moments come from unexpected discoveries. Graph queries that reveal:

  • Medication combinations we hadn't considered related
  • Temporal patterns in lab results that predict complications
  • Social factors that influence treatment adherence in ways we're just beginning to understand

These aren't just technical achievements—they're glimpses into the hidden structure of healthcare itself. Every graph traversal is an opportunity to learn something that might help a patient understand their health better.

Graph visualization of interconnected medical data

The beauty of healthcare data: Every connection tells a story

The Future We're Building Toward

What excites me most as CTO isn't just what we've built—it's what we're discovering is possible. The combination of FHIR, graph databases, and LLM-powered agents is creating entirely new ways to understand healthcare.

Imagine agents that can:

  • Predict complications by traversing patterns across thousands of similar patient graphs
  • Suggest personalized treatments by finding patients with similar graph signatures who responded well
  • Identify care gaps by comparing a patient's graph to clinical guidelines encoded as graph patterns
  • Explain complex medical situations by walking patients through their own health graph step by step

Real patients don't have simple, linear medical histories. They have rich, interconnected health stories that span providers, conditions, and treatments over time. Graph databases don't simplify this complexity—they embrace it, revealing patterns and connections that help both AI agents and humans understand health in new ways.

At clarityhealthproject.org, CLaiR is our laboratory for these discoveries. We're exploring what becomes possible when you combine FHIR's inherent structure with graph databases as the foundation for intelligent agent workflows.

Why This Matters

For the communities we serve—those facing language barriers, health literacy challenges, and limited healthcare access—these technologies represent more than technical innovation. They represent the possibility of truly understanding their health for the first time.

When a patient can see how their conditions, medications, and lab results connect in a visual graph, abstract medical concepts become concrete relationships. When they can traverse their health history like exploring a map, they gain agency over their own care.

This is the promise of FHIR and graph technologies: not just storing medical data differently, but fundamentally transforming how we understand and interact with health information. We're just beginning to scratch the surface of what's possible, and that's what makes this work so exhilarating.

Join us in this exploration at clarityhealthproject.org. Because the future of healthcare isn't just about better technology—it's about discovering new ways to make health understandable for everyone.