
Initial Release
An AI-powered FHIR assistant built with LangGraph multi-agent architecture, featuring RAG knowledge retrieval and InterSystems IRIS integration.
User Input
↓
Router Agent (LangGraph task classification)
↓
RAG Retrieval (FAISS / IRIS Vector Search)
↓
┌─────────────────────────────────────────────────────────────┐
│ Expert │ Query │ Mapping │ Bundle │ Validation │ IRIS │
└─────────────────────────────────────────────────────────────┘
↓
Return Result
| Component | Technology |
|---|---|
| Framework | FastAPI + LangGraph |
| LLM | OpenAI-compatible API (OpenAI, DeepSeek, etc.) |
| Vector Database | FAISS (local) or IRIS Vector Search |
| Embedding | sentence-transformers/all-MiniLM-L6-v2 (384 dims) |
| Frontend | Vanilla HTML/CSS/JS |
| Package Manager | uv |
Prerequisites:
Steps:
.env file:cp .env.example .env
.env file:# Edit .env file
OPENAI_API_KEY=sk-your-api-key-here
docker compose up -d
Wait for services to be ready:
Note: After starting Docker, please wait a moment. The vector database needs to be initialized on first startup. Port 8000 will become accessible once initialization is complete. You can monitor the progress with
docker compose logs -f.
Access the application:
| URL | Description |
|---|---|
| http://localhost:8000 | Chat Interface |
| http://localhost:8000/docs | Swagger API Docs |
| http://localhost:52773/csp/sys/UtilHome.csp | IRIS Management Portal |
Features:
Useful commands:
# View logs docker compose logs -fStop all services
docker compose down
Rebuild and restart
docker compose up -d --build
Prerequisites:
Installation:
cd ai-fhir-copilot
uv sync
Configuration:
Edit .env file or configure via Settings page:
# LLM Configuration OPENAI_API_KEY=your-api-key OPENAI_BASE_URL=https://api.openai.com/v1 MODEL_NAME=gpt-4oVector Store (faiss or iris)
VECTOR_STORE_TYPE=faiss
IRIS Configuration
IRIS_HOST=http://localhost:52773 IRIS_NAMESPACE=USER IRIS_FHIR_PATH=/fhir/r4 IRIS_USERNAME=_SYSTEM IRIS_PASSWORD=SYS IRIS_SQL_PORT=1972
Start:
uv run main.py
Access:
| URL | Description |
|---|---|
| http://localhost:8000 | Chat Interface |
| http://localhost:8000/docs | Swagger API Docs |
Click the gear icon (⚙) in the header to open Settings.
Note: All settings take effect immediately after saving. No restart required.
| Setting | Description | Default |
|---|---|---|
| API Key | OpenAI-compatible API key | - |
| Base URL | API endpoint | https://api.openai.com/v1 |
| Model Name | Model to use | gpt-4o |
Supported LLM providers:
https://api.openai.com/v1https://api.deepseek.comhttps://openrouter.ai/api/v1| Setting | Description | Default |
|---|---|---|
| Vector Store Type | FAISS (local) or IRIS (database) | faiss |
| Setting | Description | Default |
|---|---|---|
| Host | IRIS web server URL | http://localhost:52773 |
| FHIR Path | FHIR REST API path | /fhir/r4 |
| SQL Port | IRIS superserver port | 1972 |
| Username | IRIS username | _SYSTEM |
| Password | IRIS password | SYS |
ai-fhir-copilot/
├── app.py # FastAPI application entry point
├── main.py # Startup script with auto vector index build
├── config.py # Pydantic settings management
├── pyproject.toml # Project dependencies
│
├── Dockerfile # IRIS FHIR server image
├── Dockerfile.app # AI Copilot application image
├── docker-compose.yml # Docker Compose orchestration
├── .env.example # Environment variables template
│
├── graph/
│ └── fhir_graph.py # LangGraph state machine (router → rag → agent → END)
│
├── agents/
│ ├── state.py # Shared TypedDict state definition
│ ├── router_agent.py # Task classification
│ ├── rag_agent.py # RAG context retrieval
│ ├── expert_agent.py # FHIR specification Q&A
│ ├── query_agent.py # Natural language → FHIR Search
│ ├── mapping_agent.py # JSON → FHIR resource conversion
│ ├── bundle_agent.py # FHIR Bundle generation
│ ├── validation_agent.py # FHIR resource validation
│ └── iris_agent.py # IRIS CRUD operations
│
├── services/
│ ├── llm_service.py # LLM wrapper (dynamic settings)
│ ├── rag_service.py # FAISS / IRIS vector store
│ └── iris_service.py # IRIS REST API client
│
├── api/
│ ├── copilot.py # POST /api/copilot endpoint
│ └── settings.py # Settings API endpoints
│
├── knowledge/
│ └── fhir_docs/ # FHIR specification documents (7 files)
│
├── static/
│ └── index.html # Frontend with settings modal
└── scripts/
└── build_vectorstore.py # Rebuild vector index script
POST /api/copilot Content-Type: application/json
{"question": "Your question here"}
Response:
{
"task_type": "expert|query|mapping|bundle|validation|iris",
"result": "Response text with optional JSON data"
}
Note: If API key is not configured, returns a prompt to configure it in Settings.
# Get current settings GET /api/settingsUpdate settings (applied immediately)
POST /api/settings Content-Type: application/json
{ "openai_api_key": "sk-...", "openai_base_url": "https://api.openai.com/v1", "model_name": "gpt-4o", "vector_store_type": "faiss", "iris_host": "http://localhost:52773", "iris_sql_port": 1972, "iris_username": "_SYSTEM", "iris_password": "SYS" }
# Rebuild vector store
POST /api/vectorstore/rebuild
FHIR Q&A:
curl -X POST http://localhost:8000/api/copilot \
-H "Content-Type: application/json" \
-d '{"question": "What is the FHIR Observation resource?"}'
FHIR Query:
curl -X POST http://localhost:8000/api/copilot \
-H "Content-Type: application/json" \
-d '{"question": "Find diabetic patients in the last 30 days"}'
Data Mapping:
curl -X POST http://localhost:8000/api/copilot \
-H "Content-Type: application/json" \
-d '{"question": "{\"name\":\"John\",\"gender\":\"male\"}"}'
Bundle Generation:
curl -X POST http://localhost:8000/api/copilot \
-H "Content-Type: application/json" \
-d '{"question": "Create a diabetic patient admission record"}'
Full integration with InterSystems IRIS FHIR server.
| Operation | Description | Example |
|---|---|---|
search_resource |
Search with FHIR parameters | Patient?name=Smith |
get_resource |
Read by resource ID | Patient/123 |
create_resource |
Create new resource | POST Patient JSON |
update_resource |
Update existing resource | PUT Patient/123 |
delete_resource |
Delete resource | DELETE Patient/123 |
execute_bundle |
Transaction bundle | POST Bundle JSON |
MIT