Python SDK for healthcare AI

Healthchain

by healthchainai · Apache-2.0 license · ★ 231 on GitHub · updated Nov 13

Healthchain cover

Python SDK for healthcare AI — typed, validated FHIR tools for agents, real-time EHR connectivity, production deployment ✨ 🏥

<!-- mcp-name: io.github.healthchainai/healthchain -->

<div align="center" style="margin-bottom: 1em;">

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/brand/lockup/lockup-stacked-white.png">
  <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/brand/lockup/lockup-stacked-black.png" alt="HealthChain" width="400">
</picture>

<!-- Project Badges -->

[![PyPI Version][pypi-version-badge]][pypi]
[![Stars][stars-badge]][stars]
[![Downloads][downloads-badge]][pypistats]

[![License][license-badge]][license]
[![Python Versions][python-versions-badge]][pypi]
[![Build Status][build-badge]][build]

Overview

[![PyPI Version][pypi-version-badge]][pypi] [![Stars][stars-badge]][stars] [![Downloads][downloads-badge]][pypistats]

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • README.md13.5 KB
Read README.md here
healthchainai/main1 file
README.md
Show the full text267 lines
HealthChain

PyPI Version Stars Downloads

License Python Versions Build Status AI-Assisted Development DOI

Substack Discord

Open infrastructure for healthcare data applications.

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

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.

Epic, Cerner, and other FHIR sources flow through FHIRGateway into one patient record

🔌 Connect to Live FHIR APIs

Connect to Epic, Cerner, Medplum, and other FHIR R4 servers through one interface that handles authentication, source routing, and common FHIR operations.

Getting Started →

Structured output goes through validate_resource, which reports any FHIR issues to correct

🔥 Build and Validate FHIR

Build typed resources without hand-writing deeply nested FHIR. Structured validation identifies failing fields and invalid required codes before delivery.

Getting Started →

FHIRToolkit serves typed FHIR tools to Claude over MCP and to LangChain agents

🤖 Use the Same Tools with Agents

Expose the same build, validate, read, and terminology operations over MCP or LangChain, with structured errors an agent can inspect and correct.

Getting Started →

A patient question plus the live FHIR record produces a grounded answer

💬 Build FHIR-Backed Applications

Use live or local FHIR data in research software, patient-facing applications, analytics, decision support, and AI-assisted workflows.

Getting Started →

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
HealthChain CLI scaffolding and running a FHIR Gateway service

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.

1<!-- mcp-name: io.github.healthchainai/healthchain -->
2 
3<div align="center" style="margin-bottom: 1em;">
4 
5<picture>
6 <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/brand/lockup/lockup-stacked-white.png">
7 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/brand/lockup/lockup-stacked-black.png" alt="HealthChain" width="400">
8</picture>
9 
10<!-- Project Badges -->
11 
12[![PyPI Version][pypi-version-badge]][pypi]
13[![Stars][stars-badge]][stars]
14[![Downloads][downloads-badge]][pypistats]
15 
16[![License][license-badge]][license]
17[![Python Versions][python-versions-badge]][pypi]
18[![Build Status][build-badge]][build]
19[![AI-Assisted Development][ai-badge]][claude-md]
20[![DOI](https://zenodo.org/badge/785158333.svg)](https://doi.org/10.5281/zenodo.20056729)
21 
22[![Substack][substack-badge]][substack]
23[![Discord][discord-badge]][discord]
24 
25</div>
26 
27<h2 align="center" style="border-bottom: none">Open infrastructure for healthcare data applications.</h2>
28 
29<div align="center">
30 
31Connect Python pipelines and applications to live FHIR APIs, build and validate structured output, and deliver it through REST, CDS Hooks, CDA, MCP, or LangChain.
32 
33</div>
34 
35## Installation
36 
37```bash
38pip install healthchain
39```
40 
41## What HealthChain Does
42 
43HealthChain 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.
44 
45<table>
46 <tr>
47 <td width="50%" valign="top">
48 <picture>
49 <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-aggregation-dark.svg">
50 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-aggregation-light.svg" alt="Epic, Cerner, and other FHIR sources flow through FHIRGateway into one patient record" width="100%">
51 </picture>
52 <div align="center">
53 <br>
54 <a href="https://healthchainai.github.io/HealthChain/reference/gateway/gateway/"><strong>🔌 Connect to Live FHIR APIs</strong></a>
55 <br><br>
56 <div>Connect to Epic, Cerner, Medplum, and other FHIR R4 servers through one interface that handles authentication, source routing, and common FHIR operations.</div><br>
57 <a href="https://healthchainai.github.io/HealthChain/cookbook/multi_ehr_aggregation/">Getting Started →</a>
58 <br><br>
59 </div>
60 </td>
61 <td width="50%" valign="top">
62 <picture>
63 <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-fhir-dark.svg">
64 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-fhir-light.svg" alt="Structured output goes through validate_resource, which reports any FHIR issues to correct" width="100%">
65 </picture>
66 <div align="center">
67 <br>
68 <a href="https://healthchainai.github.io/HealthChain/reference/utilities/fhir_helpers/"><strong>🔥 Build and Validate FHIR</strong></a>
69 <br><br>
70 <div>Build typed resources without hand-writing deeply nested FHIR. Structured validation identifies failing fields and invalid required codes before delivery.</div><br>
71 <a href="https://healthchainai.github.io/HealthChain/reference/utilities/fhir_helpers/">Getting Started →</a>
72 <br><br>
73 </div>
74 </td>
75 </tr>
76 <tr>
77 <td width="50%" valign="top">
78 <picture>
79 <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-agent-tools-dark.svg">
80 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-agent-tools-light.svg" alt="FHIRToolkit serves typed FHIR tools to Claude over MCP and to LangChain agents" width="100%">
81 </picture>
82 <div align="center">
83 <br>
84 <a href="https://healthchainai.github.io/HealthChain/reference/utilities/tools/"><strong>🤖 Use the Same Tools with Agents</strong></a>
85 <br><br>
86 <div>Expose the same build, validate, read, and terminology operations over MCP or LangChain, with structured errors an agent can inspect and correct.</div><br>
87 <a href="https://healthchainai.github.io/HealthChain/reference/utilities/tools/">Getting Started →</a>
88 <br><br>
89 </div>
90 </td>
91 <td width="50%" valign="top">
92 <picture>
93 <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-fhir-qa-dark.svg">
94 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/cards/hc-card-fhir-qa-light.svg" alt="A patient question plus the live FHIR record produces a grounded answer" width="100%">
95 </picture>
96 <div align="center">
97 <br>
98 <a href="https://healthchainai.github.io/HealthChain/cookbook/fhir_qa/"><strong>💬 Build FHIR-Backed Applications</strong></a>
99 <br><br>
100 <div>Use live or local FHIR data in research software, patient-facing applications, analytics, decision support, and AI-assisted workflows.</div><br>
101 <a href="https://healthchainai.github.io/HealthChain/cookbook/fhir_qa/">Getting Started →</a>
102 <br><br>
103 </div>
104 </td>
105 </tr>
106</table>
107 
108## Why HealthChain?
109 
110Every 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.
111 
112HealthChain handles that layer so you can focus on your logic and your domain.
113 
114- **Live data, not exports** — Connect to live FHIR APIs instead of site-specific warehouse queries and stale extracts
115- **Keep connection details out of pipeline logic** — Load endpoints and credentials from environment-backed configuration
116- **Build FHIR with less boilerplate** — Use flat, typed helpers instead of manually assembling deeply nested resources
117- **Catch errors early** — Get structured validation reports with failing field paths and actionable diagnostics
118- **Resolve codes instead of guessing them** — Map free text through a swappable terminology lookup before building a resource
119- **Choose how to deliver the result** — Expose output through FHIR REST services, CDS Hooks, SOAP/CDA, MCP, or LangChain
120 
121## 🏆 Recognition & Community
122 
123**Featured & Presented:**
124 
125- Featured in [TLDR AI Newsletter](https://tldr.tech/ai/2025-08-21) (900K+ developers)
126- [Featured by Medplum](https://www.medplum.com/blog/healthchain) for open source integration with Epic
127- Presented at [NHS Python Open Source Conference](https://github.com/nhs-r-community/conference-2024/blob/main/Talks/2024-11-21_jiang-kells_building-healthchain.md) ([watch talk](https://www.youtube.com/watch?v=_ZqlPsDUdSY&t=1967s))
128- [Built from NHS AI deployment experience](https://open.substack.com/pub/jenniferjiangkells/p/healthchain-building-the-tool-i-wish) – read the origin story
129 
130## 🤝 Pilots & Partnerships
131 
132Exploring HealthChain for your product or organization? [Get in touch](mailto:[email protected]) to discuss integrations, pilots, or collaborations, or join our [Discord](https://discord.gg/UQC6uAepUz) to connect with the community.
133 
134## Usage Examples
135 
136### Build a FHIR Service
137 
138#### Expose Multiple FHIR Sources [[Docs](https://healthchainai.github.io/HealthChain/reference/gateway/gateway)]
139 
140```python
141from healthchain.gateway import HealthChainAPI, FHIRGateway
142from healthchain.gateway.clients import FHIRAuthConfig
143from healthchain.fhir.r4b import Bundle, Patient
144 
145# Create a FHIR-connected service
146app = HealthChainAPI(title="Multi-EHR Patient Data")
147 
148# Credentials are loaded from EPIC_* and CERNER_* environment variables
149fhir = FHIRGateway()
150fhir.add_source("epic", FHIRAuthConfig.from_env("EPIC").to_connection_string())
151fhir.add_source("cerner", FHIRAuthConfig.from_env("CERNER").to_connection_string())
152 
153@fhir.aggregate(Patient)
154def patient_data(id: str, source: str) -> Bundle:
155 """Fetch patient data from any configured FHIR source."""
156 bundle = fhir.search(
157 Patient,
158 {"_id": id},
159 source,
160 add_provenance=True,
161 provenance_tag="healthchain-source",
162 )
163 return bundle
164 
165app.register_gateway(fhir)
166 
167# Available at: GET /fhir/aggregate/Patient?id=123&sources=epic&sources=cerner
168 
169if __name__ == "__main__":
170 app.run(port=8888)
171```
172 
173#### Scaffold with the CLI
174 
175Turn a working pipeline into a configurable FHIR service:
176 
177```bash
178healthchain new my-app -t fhir-gateway
179cd my-app
180healthchain serve
181```
182 
183<div align="center">
184 <img src="https://raw.githubusercontent.com/healthchainai/HealthChain/main/docs/assets/images/demo.gif" alt="HealthChain CLI scaffolding and running a FHIR Gateway service" width="700">
185</div>
186 
187Add 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](https://healthchainai.github.io/HealthChain/cli/) for all commands.
188 
189### Agent and Assistant Workflows
190 
191#### Give an Agent FHIR Tools [[Docs](https://healthchainai.github.io/HealthChain/reference/utilities/tools/)]
192 
193```python
194from healthchain.tools import FHIRToolkit
195 
196# One toolkit: build, validate, read, and code FHIR — as typed agent tools
197kit = FHIRToolkit(bundle="patient_bundle.json")
198 
199kit.as_mcp().run() # serve to Claude or any MCP client
200tools = kit.as_langchain() # or drop into a LangChain agent
201```
202 
203Or serve the tools straight from the terminal:
204 
205```bash
206healthchain mcp --bundle patient_bundle.json
207```
208 
209#### Build with an AI Assistant
210 
211Install the HealthChain plugin to give Claude Code or Codex the current API, CLI, and recipes:
212 
213```text
214# Claude Code
215/plugin marketplace add healthchainai/HealthChain
216/plugin install healthchain@healthchain
217 
218# Codex
219codex plugin marketplace add healthchainai/HealthChain
220codex plugin add healthchain@healthchain
221```
222 
223Or point any assistant at [llms.txt](https://healthchainai.github.io/HealthChain/llms.txt) for a map of the current API docs.
224 
225## 🛣️ What we're building towards
226 
227- 🔌 **Deeper FHIR connectivity** — more authentication patterns, write workflows, and real-world examples from pilot deployments
228- 🧪 **Broader validation** — cover more resource types and value-set bindings, with clearer correction reports and optional server-backed profile validation
229- 🧭 **Terminology integrations** — connect the `TerminologyLookup` interface to FHIR terminology servers and licensed vocabularies
230- 🔎 **Traceable data movement** — carry provenance, validation results, and source errors through transformations and downstream delivery
231- 🧱 **Reusable data workflows** — strengthen the patterns for moving research extracts, claims, and application data behind consistent FHIR interfaces
232 
233## 🤝 Contributing
234 
235- **Building research software or working with healthcare data?** [Contribute a cookbook](https://github.com/healthchainai/HealthChain/issues/208) — bring your use case, and I'll personally support you through it
236- Read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines
237- Technical questions and ideas → [GitHub Discussions](https://github.com/healthchainai/HealthChain/discussions)
238- Pilots and partnerships → [email](mailto:[email protected]?subject=HealthChain)
239 
240## 🤗 Acknowledgements
241 
242This project builds on [fhir.resources](https://github.com/nazrulworld/fhir.resources) and [CDS Hooks](https://cds-hooks.org/) standards developed by [HL7](https://www.hl7.org/) and [Boston Children's Hospital](https://www.childrenshospital.org/).
243 
244---
245 
246© 2024–2026 dotimplement ai. HealthChain is an open source project maintained by [dotimplement ai](https://dotimplement.ai).
247 
248<!-- Badge Links -->
249 
250[pypi-version-badge]: https://img.shields.io/pypi/v/healthchain?logo=python&logoColor=white&style=flat-square&color=%23e59875
251[downloads-badge]: https://img.shields.io/pepy/dt/healthchain?style=flat-square&color=%2379a8a9
252[stars-badge]: https://img.shields.io/github/stars/healthchainai/HealthChain?style=flat-square&logo=github&color=BD932F&logoColor=white
253[license-badge]: https://img.shields.io/github/license/healthchainai/HealthChain?style=flat-square&color=%23e59875
254[python-versions-badge]: https://img.shields.io/pypi/pyversions/healthchain?style=flat-square&color=%23eeeeee
255[build-badge]: https://img.shields.io/github/actions/workflow/status/healthchainai/healthchain/ci.yml?branch=main&style=flat-square&color=%2379a8a9
256[discord-badge]: https://img.shields.io/badge/chat-%235965f2?style=flat-square&logo=discord&logoColor=white
257[substack-badge]: https://img.shields.io/badge/Cool_Things_In_HealthTech-%23c094ff?style=flat-square&logo=substack&logoColor=white
258[ai-badge]: https://img.shields.io/badge/AI--dev_friendly-CLAUDE.MD-%23e59875?style=flat-square&logo=anthropic&logoColor=white
259[pypi]: https://pypi.org/project/healthchain/
260[pypistats]: https://pepy.tech/project/healthchain
261[stars]: https://github.com/healthchainai/HealthChain/stargazers
262[license]: https://github.com/healthchainai/HealthChain/blob/main/LICENSE
263[build]: https://github.com/healthchainai/HealthChain/actions?query=branch%3Amain
264[discord]: https://discord.gg/UQC6uAepUz
265[substack]: https://jenniferjiangkells.substack.com/
266[claude-md]: CLAUDE.md
267 
View all files on GitHub →

Details

Updated
Nov 13, 2026
License
Apache-2.0
Stars on the repo
★ 231
Checked
Source
healthchainai/HealthChain ↗
Creator
healthchainai · 1 listing
View creator

Similar MCP servers

See all →
SkillGuides stable API and interface designaddyosmani/agent-skills · by addyosmaniGuides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.★ 98.7k GitHub starsAgentPulls up-to-date, version-specific library docsContext7upstash/context7 · by upstashPulls up-to-date, version-specific library docs and code examples into the prompt so the AI stops inventing old APIs.★ 62.3k GitHub starsSkillHow to use the Adaptyv Bio Foundry API and Python SDKK-Dense-AI/scientific-agent-skills · by K-Dense-AIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.★ 46k GitHub starsSkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillGuides the usage of Gemini Interactions API on GeminiGemini Interactions API Skillgoogle/skills · by googleGuides the usage of Gemini Interactions API on Gemini Enterprise Agent Platform. Use when the user wants to use the stateful, server-managed Interactions API for multi-turn conversations, background execution, streaming, structured output, and function calling on the Agent Platform.★ 20.9k GitHub starsSkillInstall, authenticate, troubleshootGemini Notebook Automationteng-lin/notebooklm-py · by teng-linInstall, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API. Do not use for the generic Gemini API or unrelated content creation.★ 19.6k GitHub stars