Python SDK for healthcare AI
Healthchain

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/
Show the full text267 lines
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.
|
🔌 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 → |
🔥 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 → |
|
🤖 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 → |
💬 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:
- Featured in TLDR AI Newsletter (900K+ developers)
- Featured by Medplum for open source integration with Epic
- Presented at NHS Python Open Source Conference (watch talk)
- Built from NHS AI deployment experience – read the origin story
🤝 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
TerminologyLookupinterface 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
- Building research software or working with healthcare data? Contribute a cookbook — bring your use case, and I'll personally support you through it
- Read CONTRIBUTING.md for guidelines
- Technical questions and ideas → GitHub Discussions
- Pilots and partnerships → email
🤗 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://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 | |
| 31 | 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. |
| 32 | |
| 33 | </div> |
| 34 | |
| 35 | ## Installation |
| 36 | |
| 37 | |
| 38 | pip install healthchain |
| 39 | |
| 40 | |
| 41 | ## What HealthChain Does |
| 42 | |
| 43 | 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. |
| 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 | |
| 110 | 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. |
| 111 | |
| 112 | HealthChain 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] (900K+ developers) |
| 126 | [Featured by Medplum] for open source integration with Epic |
| 127 | Presented at [NHS Python Open Source Conference] ([watch talk]) |
| 128 | [Built from NHS AI deployment experience] – read the origin story |
| 129 | |
| 130 | ## 🤝 Pilots & Partnerships |
| 131 | |
| 132 | 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. |
| 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 | |
| 141 | from healthchain.gateway import HealthChainAPI, FHIRGateway |
| 142 | from healthchain.gateway.clients import FHIRAuthConfig |
| 143 | from healthchain.fhir.r4b import Bundle, Patient |
| 144 | |
| 145 | # Create a FHIR-connected service |
| 146 | app = HealthChainAPI(title="Multi-EHR Patient Data") |
| 147 | |
| 148 | # Credentials are loaded from EPIC_* and CERNER_* environment variables |
| 149 | fhir = FHIRGateway() |
| 150 | fhir.add_source("epic", FHIRAuthConfig.from_env("EPIC").to_connection_string()) |
| 151 | fhir.add_source("cerner", FHIRAuthConfig.from_env("CERNER").to_connection_string()) |
| 152 | |
| 153 | @fhir.aggregate(Patient) |
| 154 | def 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 | |
| 165 | app.register_gateway(fhir) |
| 166 | |
| 167 | # Available at: GET /fhir/aggregate/Patient?id=123&sources=epic&sources=cerner |
| 168 | |
| 169 | if __name__ == "__main__": |
| 170 | app.run(port=8888) |
| 171 | |
| 172 | |
| 173 | #### Scaffold with the CLI |
| 174 | |
| 175 | Turn a working pipeline into a configurable FHIR service: |
| 176 | |
| 177 | |
| 178 | healthchain new my-app -t fhir-gateway |
| 179 | cd my-app |
| 180 | healthchain 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 | |
| 187 | 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. |
| 188 | |
| 189 | ### Agent and Assistant Workflows |
| 190 | |
| 191 | #### Give an Agent FHIR Tools [[Docs](https://healthchainai.github.io/HealthChain/reference/utilities/tools/)] |
| 192 | |
| 193 | |
| 194 | from healthchain.tools import FHIRToolkit |
| 195 | |
| 196 | # One toolkit: build, validate, read, and code FHIR — as typed agent tools |
| 197 | kit = FHIRToolkit(bundle="patient_bundle.json") |
| 198 | |
| 199 | kit.as_mcp().run() # serve to Claude or any MCP client |
| 200 | tools = kit.as_langchain() # or drop into a LangChain agent |
| 201 | |
| 202 | |
| 203 | Or serve the tools straight from the terminal: |
| 204 | |
| 205 | |
| 206 | healthchain mcp --bundle patient_bundle.json |
| 207 | |
| 208 | |
| 209 | #### Build with an AI Assistant |
| 210 | |
| 211 | Install the HealthChain plugin to give Claude Code or Codex the current API, CLI, and recipes: |
| 212 | |
| 213 | |
| 214 | # Claude Code |
| 215 | /plugin marketplace add healthchainai/HealthChain |
| 216 | /plugin install healthchain@healthchain |
| 217 | |
| 218 | # Codex |
| 219 | codex plugin marketplace add healthchainai/HealthChain |
| 220 | codex plugin add healthchain@healthchain |
| 221 | |
| 222 | |
| 223 | Or point any assistant at [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] — bring your use case, and I'll personally support you through it |
| 236 | Read [CONTRIBUTING.md] for guidelines |
| 237 | Technical questions and ideas → [GitHub Discussions] |
| 238 | Pilots and partnerships → [email] |
| 239 | |
| 240 | ## 🤗 Acknowledgements |
| 241 | |
| 242 | This project builds on [fhir.resources] and [CDS Hooks] standards developed by [HL7] and [Boston Children's Hospital]. |
| 243 | |
| 244 | |
| 245 | |
| 246 | © 2024–2026 dotimplement ai. HealthChain is an open source project maintained by [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 |
Details
- Updated
- Nov 13, 2026
- License
- Apache-2.0
- Stars on the repo
- ★ 231
- Checked
- Source
- healthchainai/HealthChain ↗
- Creator
- healthchainai · 1 listing
Similar MCP servers
See all →
SkillGuides stable API and interface design
AgentPulls up-to-date, version-specific library docsContext7
SkillHow to use the Adaptyv Bio Foundry API and Python SDK
SkillMaster C/.NET backend development patterns for building
SkillGuides the usage of Gemini Interactions API on GeminiGemini Interactions API Skill
SkillInstall, authenticate, troubleshootGemini Notebook Automation