Skip to main content
Glama

PyPI Version Stars Downloads

License Python Versions Build Status AI-Assisted Development DOI

Substack Discord

Connect Python pipelines and applications to live FHIR APIs, build and validate structured output, and deliver it through REST, CDS Hooks, CDA, MCP, or LangChain.

Installation

pip install healthchain

Related MCP server: FhirMCP

What HealthChain Does

HealthChain puts a consistent FHIR boundary around your Python code: live data in, your own logic in the middle, and validated FHIR out. Built for research software, healthcare data, and AI teams.

Why HealthChain?

Every healthcare data team rebuilds the same integration layer. Whether your logic is rule-based, a logistic regression, or an agent, it needs authenticated access to real FHIR APIs and a reliable way to turn output into coded FHIR. Pipelines tied to one site's warehouse don't travel, and structural or coding errors may only be discovered downstream.

HealthChain handles that layer so you can focus on your logic and your domain.

  • Live data, not exports — Connect to live FHIR APIs instead of site-specific warehouse queries and stale extracts

  • Keep connection details out of pipeline logic — Load endpoints and credentials from environment-backed configuration

  • Build FHIR with less boilerplate — Use flat, typed helpers instead of manually assembling deeply nested resources

  • Catch errors early — Get structured validation reports with failing field paths and actionable diagnostics

  • Resolve codes instead of guessing them — Map free text through a swappable terminology lookup before building a resource

  • Choose how to deliver the result — Expose output through FHIR REST services, CDS Hooks, SOAP/CDA, MCP, or LangChain

🏆 Recognition & Community

Featured & Presented:

🤝 Pilots & Partnerships

Exploring HealthChain for your product or organization? Get in touch to discuss integrations, pilots, or collaborations, or join our Discord to connect with the community.

Usage Examples

Build a FHIR Service

Expose Multiple FHIR Sources [Docs]

from healthchain.gateway import HealthChainAPI, FHIRGateway
from healthchain.gateway.clients import FHIRAuthConfig
from healthchain.fhir.r4b import Bundle, Patient

# Create a FHIR-connected service
app = HealthChainAPI(title="Multi-EHR Patient Data")

# Credentials are loaded from EPIC_* and CERNER_* environment variables
fhir = FHIRGateway()
fhir.add_source("epic", FHIRAuthConfig.from_env("EPIC").to_connection_string())
fhir.add_source("cerner", FHIRAuthConfig.from_env("CERNER").to_connection_string())

@fhir.aggregate(Patient)
def patient_data(id: str, source: str) -> Bundle:
    """Fetch patient data from any configured FHIR source."""
    bundle = fhir.search(
        Patient,
        {"_id": id},
        source,
        add_provenance=True,
        provenance_tag="healthchain-source",
    )
    return bundle

app.register_gateway(fhir)

# Available at: GET /fhir/aggregate/Patient?id=123&sources=epic&sources=cerner

if __name__ == "__main__":
    app.run(port=8888)

Scaffold with the CLI

Turn a working pipeline into a configurable FHIR service:

healthchain new my-app -t fhir-gateway
cd my-app
healthchain serve

Add your logic in app.py. Use healthchain.yaml to configure FHIR sources and service settings while keeping credentials in environment variables. See the CLI reference for all commands.

Agent and Assistant Workflows

Give an Agent FHIR Tools [Docs]

from healthchain.tools import FHIRToolkit

# One toolkit: build, validate, read, and code FHIR — as typed agent tools
kit = FHIRToolkit(bundle="patient_bundle.json")

kit.as_mcp().run()          # serve to Claude or any MCP client
tools = kit.as_langchain()  # or drop into a LangChain agent

Or serve the tools straight from the terminal:

healthchain mcp --bundle patient_bundle.json

Build with an AI Assistant

Install the HealthChain plugin to give Claude Code or Codex the current API, CLI, and recipes:

# Claude Code
/plugin marketplace add healthchainai/HealthChain
/plugin install healthchain@healthchain

# Codex
codex plugin marketplace add healthchainai/HealthChain
codex plugin add healthchain@healthchain

Or point any assistant at llms.txt for a map of the current API docs.

🛣️ What we're building towards

  • 🔌 Deeper FHIR connectivity — more authentication patterns, write workflows, and real-world examples from pilot deployments

  • 🧪 Broader validation — cover more resource types and value-set bindings, with clearer correction reports and optional server-backed profile validation

  • 🧭 Terminology integrations — connect the TerminologyLookup interface to FHIR terminology servers and licensed vocabularies

  • 🔎 Traceable data movement — carry provenance, validation results, and source errors through transformations and downstream delivery

  • 🧱 Reusable data workflows — strengthen the patterns for moving research extracts, claims, and application data behind consistent FHIR interfaces

🤝 Contributing

🤗 Acknowledgements

This project builds on fhir.resources and CDS Hooks standards developed by HL7 and Boston Children's Hospital.


© 2024–2026 dotimplement ai. HealthChain is an open source project maintained by dotimplement ai.

Available Tools

8 tools
build_resourceA

Build a FHIR resource from flat fields and validate it. Call this instead of writing FHIR JSON by hand — it does the nesting (CodeableConcepts, Dosage) and returns {ok, resource} or {ok: false, issues} to correct. Supported resource_type values: Condition, MedicationStatement, Observation, AllergyIntolerance, Patient. Use a code returned by lookup_code, never an invented one.

Inputs: resource_type (required), code, unit, onset, +12 more.

get_coded_entriesA

Read the coded identity of every resource of a type in the loaded bundle as flat records (code/display/system/status/authored_on/value/unit). Call this first for questions about conditions, medications, allergies, or observations — it resolves medicationReference to the actual Medication for you. Optionally filter by status (e.g. 'active').

Inputs: resource_type (required), status.

get_resourcesA

Get all resources of a type from the loaded bundle as full FHIR JSON. Call this when you need fields the flattened get_coded_entries view doesn't carry.

Inputs: resource_type (required).

list_codesA

List every code in the local terminology catalog, optionally filtered to one code system URI. Call this to browse what codes are available (e.g. to build a mention list); use lookup_code to search by name.

Inputs: system.

load_bundleA

Load a FHIR Bundle from a file path or JSON string and make it the working bundle for the read tools. Call this first when given bundle data. Invalid bundles return issues[] locating each problem (e.g. Bundle.entry[2].resource.subject).

Inputs: source (required).

lookup_codeA

Search the terminology catalog for codes matching free text (e.g. 'metoprolol 25', 'type 2 diabetes'). Call this whenever you need a code — use a returned candidate, never invent or recall one. Results are ranked tightest-match-first; optionally restrict to one code system URI.

Inputs: query (required), system.

resolve_referenceA

Resolve a FHIR reference (e.g. 'Patient/123', 'urn:uuid:...') to its target resource within the loaded bundle. For a contained reference ('#med1'), also pass parent_resource_id — the id of the resource the reference appears in.

Inputs: reference (required), parent_resource_id.

validate_resourceA

Validate a FHIR resource (JSON object) against the spec, including required value-set bindings. Call this after constructing or editing FHIR JSON yourself; read issues[] (severity/diagnostics/expression) and correct the resource. Never raises.

Inputs: resource (required), resource_type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clear, distinct purpose: building, validating, loading, retrieving, resolving references, and terminology lookup. No two tools overlap in functionality.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using lowercase and underscores, e.g., build_resource, load_bundle, get_resources, lookup_code. This makes the API predictable.

    Tool Count5/5

    With 8 tools, the set is well-scoped for a FHIR utility server, covering essential operations without being bloated or too sparse.

    Completeness4/5

    The set covers building, validating, loading, and reading FHIR resources, as well as reference resolution and terminology lookup. Minor gaps like missing update/delete tools or limited build resource types prevent a perfect score.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables LLM-based agents to interact with FHIR healthcare data through natural language prompts, providing full CRUD operations on FHIR resources, document processing, and semantic search capabilities.
      13
      102
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables LLMs to securely interact with FHIR healthcare servers and HL7 terminology services. Provides comprehensive healthcare data operations with built-in PHI protection, audit logging, and SMART on FHIR authentication.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Provides seamless integration with FHIR APIs, enabling AI/LLM tools to search, retrieve, and analyze clinical healthcare data with support for SMART-on-FHIR authentication and multiple transport protocols.
      7
      1,026 PyPI
      137
      Apache 2.0
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables LLM-based agents and MCP-compatible clients to query and manipulate FHIR resources through full CRUD tools, with document ingestion, semantic search, LOINC terminology lookup, and OAuth2-authenticated FHIR API integration.
      -