Cookbook
Runnable patterns for building reusable applications with healthcare data.
Connect live FHIR sources, turn extracts and model output into coded, validated FHIR, and deliver results through standard healthcare and agent interfaces.
Run a recipe
Cookbooks are runnable scripts in the HealthChain repository. Clone the repo to get started:
git clone https://github.com/healthchainai/HealthChain.git
cd HealthChain
uv sync --all-extras # or: pip install healthchain
Each cookbook page states the exact pip install line it needs โ optional capabilities live in extras ([cda], [examples], [sandbox], ...), so you only install what the example uses.
Run any cookbook from the repo root โ e.g. python cookbook/ml_risk_to_fhir.py. Filter by Zero Setup below to find examples that run immediately with no external accounts. Connecting to a live FHIR API? Start with Working with FHIR Sandboxes.
From recipe to reusable application
Cookbooks keep every step visible in one runnable script. Once a pattern fits your use case, move the same logic into an application and choose the interface it needs: FHIR REST, CDS Hooks, CDA, MCP, or LangChain.
# 1. Run a cookbook locally
python cookbook/cds_discharge_summarizer_hf_trf.py
# 2. Scaffold a project
healthchain new my-cds-service -t cds-hooks
cd my-cds-service
# 3. Move your hook logic into app.py, then run with config
healthchain serve
app.run() keeps a standalone recipe easy to execute. When you need a configurable service, healthchain serve reads healthchain.yaml for the service port and FHIR source names while credentials remain in environment variables.
Separate application logic from connection config:
# cookbook โ source configuration lives beside the example
gateway = FHIRGateway()
gateway.add_source("medplum", FHIRAuthConfig.from_env("MEDPLUM").to_connection_string())
app = HealthChainAPI(title="My App", service_type="fhir-gateway")
app.register_gateway(gateway)
app.run(port=8000)
# healthchain.yaml โ service and source names are reusable across environments
service:
type: fhir-gateway
port: 8000
sources:
medplum:
env_prefix: MEDPLUM # credentials stay in .env
# app.py โ keep application logic independent of site credentials
from healthchain.config import AppConfig
from healthchain.gateway import FHIRGateway, HealthChainAPI
config = AppConfig.load()
gateway = FHIRGateway.from_config(config)
app = HealthChainAPI(title="My App")
app.register_gateway(gateway)
Credentials (API keys, client secrets) always stay in .env โ never in healthchain.yaml.
Configuration reference
See the configuration reference for service, FHIR source, and security settings.