A production-ready healthcare AI system that automates patient intake, risk assessment, clinical explanation, treatment recommendations, drug safety checks, and medical documentation using 6 orchestrated agents and 4 independent microservices.
Clinexa AI solves the clinical triage problem: Emergency Departments (EDs) manually assess 40+ patients with 10-15 minutes per patient, leading to diagnostic errors and treatment delays. Clinexa AI processes complete patient triage in seconds using machine learning, explainable AI, and real healthcare data standards.
Key Characteristics:
- ✅ 6 specialized AI agents (orchestrated A2A architecture)
- ✅ RandomForest ML model (78% accuracy on 1000 synthetic patients)
- ✅ SHAP explainability (shows WHY each decision was made)
- ✅ Real drug safety checks (OpenFDA database integration)
- ✅ HL7 FHIR R4 compliant output (hospital EHR ready)
- ✅ 100% synthetic data (zero PHI, hospital-safe)
- ✅ Production deployed (4 servers on Railway, 24/7 uptime)
- ✅ Published agents (Prompt Opinion marketplace, publicly testable)
Patient Input (Symptoms + Vitals)
↓
[1] Intake Agent → Parses free-text symptoms into structured data
↓
[2] Risk Prediction Agent → ML model predicts LOW/MEDIUM/HIGH (78% accuracy)
↓
[3] XAI Explanation Agent → SHAP explains why (which factors mattered?)
↓
[4] Treatment Agent → Generates evidence-based care recommendations
↓
[5] Drug Safety Agent → Checks for dangerous drug interactions
↓
[6] FHIR Formatter Agent → Produces HL7 FHIR R4 bundles + SOAP notes
↓
Final Output: Risk + Explanation + Treatment Plan + Safety Alerts + Clinical Documents
| Server | Port | Purpose |
|---|---|---|
| FHIR Server | 8001 | Patient data, observations, clinical bundles (HL7 FHIR R4) |
| Drug Safety Server | 8002 | Drug interaction checking, allergy verification (OpenFDA) |
| XAI Server | 8003 | SHAP explainability, feature importance scoring |
| Grok LLM Server | 8004 | Clinical text generation (intake parsing, SOAP notes) |
- Algorithm: RandomForest classifier (100 decision trees)
- Dataset: 1000 synthetic patient records (zero PHI)
- Accuracy: 78% on independent test set
- Cross-Validation: 79.5% ± 4.3% (stratified 5-fold)
- Features: 26 clinical features (demographics, vitals, symptoms, conditions)
- Output: Risk classification (LOW, MEDIUM, HIGH) with confidence scores
- Method: SHAP (SHapley Additive exPlanations) TreeExplainer
- Output: Plain English explanations showing which factors influenced each decision
- Example: "HIGH risk because chest pain (+0.26 impact), Heart Rate 125 (+0.18 impact), age 68 (+0.12 impact)"
- Benefit: Clinicians understand and trust AI decisions
- Drug Interaction Detection: OpenFDA database integration
- Real Example: Warfarin + Aspirin = HIGH bleeding risk (automatically flagged)
- Allergy Checking: Prevents medication allergies
- Real-Time Alerts: Immediate safety notifications before treatment
- HL7 FHIR R4: Industry standard for healthcare data exchange
- SOAP Notes: Clinical documentation format (Subjective, Objective, Assessment, Plan)
- EHR Integration: Direct compatibility with hospital Electronic Health Records (EHRs)
- Zero PHI: 100% synthetic data ensures patient privacy
git clone https://github.com/LaraibKaleem/clinexa-ai.git
cd clinexa-aipython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtpython data/generate_data.py
# Output: synthetic_triage.csv (1000 patients)python phase1_ml/train_model.py
# Output: risk_model.joblib, shap_explainer.joblib, metrics.jsonpython tests/integration_test.py
# Tests 3 synthetic patients through complete 6-agent pipelinepython phase2_mcp/fhir_mcp/fhir_server.py # Port 8001
python phase2_mcp/drug_mcp/drug_server.py # Port 8002
python phase2_mcp/xai_mcp/xai_server.py # Port 8003
python phase2_mcp/grok_mcp/grok_server.py # Port 8004- Python 3.11+
- pip (Python package manager)
- Virtual environment (recommended)
scikit-learn==1.3.0 # Machine Learning algorithms
numpy==1.24.3 # Numerical computations
pandas==2.0.3 # Data manipulation
shap==0.42.3 # Explainability
fastapi==0.104.1 # Web framework for APIs
uvicorn==0.24.0 # ASGI server
joblib==1.3.0 # Model serialization
requests==2.31.0 # HTTP requests
python-dotenv==1.0.0 # Environment variables
pytest==7.4.0 # Testing framework
Install all:
pip install -r requirements.txtclinexa-ai/
├── data/
│ ├── generate_data.py # Generate 1000 synthetic patients
│ └── synthetic_triage.csv # Output: synthetic patient data
│
├── phase1_ml/
│ ├── train_model.py # Train RandomForest ML model
│ └── models/
│ ├── risk_model.joblib
│ ├── shap_explainer.joblib
│ ├── label_encoders.joblib
│ └── metrics.json
│
├── phase2_mcp/
│ ├── fhir_mcp/fhir_server.py # FHIR Server (Port 8001)
│ ├── drug_mcp/drug_server.py # Drug Safety Server (Port 8002)
│ ├── xai_mcp/xai_server.py # XAI Server (Port 8003)
│ └── grok_mcp/grok_server.py # Grok LLM Server (Port 8004)
│
├── phase3_agents/
│ └── orchestrator.py # 6-agent pipeline orchestrator
│
├── tests/
│ └── integration_test.py # End-to-end testing
│
├── .env # Environment variables
├── README.md # This file
├── requirements.txt # Python dependencies
└── LICENSE
from phase3_agents.orchestrator import run_clinexa_pipeline
patient = {
"patient_id": "TEST-001",
"intake_text": "Severe chest pain and trouble breathing",
"age": 68,
"gender": "male",
"vitals": {
"hr": 125,
"sbp": 185,
"dbp": 110,
"temp": 38.9,
"spo2": 91,
"rr": 26
},
"symptoms": ["chest_pain", "shortness_of_breath", "palpitations"],
"conditions": ["heart_disease", "hypertension"],
"medications": ["warfarin", "aspirin"],
"allergies": [],
"pain_scale": 9
}
result = run_clinexa_pipeline(patient)# Health check
curl http://localhost:8001/health
# Check drug interactions
curl -X POST http://localhost:8002/drug-check \
-H "Content-Type: application/json" \
-d '{"medications": ["warfarin", "aspirin"]}'
# Get SHAP explanation
curl -X POST http://localhost:8003/explain \
-H "Content-Type: application/json" \
-d '{"features": [68, 0, 125, 185, 110, ...]}'
# Generate clinical text
curl -X POST http://localhost:8004/generate \
-H "Content-Type: application/json" \
-d '{"prompt": "Parse patient symptoms: chest pain and fever"}'pytest tests/ -vpython tests/integration_test.py| Metric | Value |
|---|---|
| Accuracy | 78% on 200 test patients |
| Cross-Validation | 79.5% ± 4.3% (5-fold) |
| Precision (HIGH risk) | 85% |
| Recall (HIGH risk) | 90% |
| Training Time | < 1 second (1000 patients) |
Processing 3 synthetic patients end-to-end:
Patient 1 (SYN-10001):
✓ Risk prediction: HIGH (73% confidence)
✓ SHAP explanation: Generated
✓ Drug alert: Warfarin + Aspirin (HIGH risk) — Bleeding detected
✓ FHIR bundle: Created
✓ SOAP note: Generated
Patient 2 (SYN-10002):
✓ Risk prediction: MEDIUM (46% confidence)
✓ FHIR bundle: Created
✓ SOAP note: Generated
Patient 3 (SYN-10003):
✓ Risk prediction: HIGH (55% confidence)
✓ FHIR bundle: Created
✓ SOAP note: Generated
Overall: 100% SUCCESS — All systems operational
python phase2_mcp/fhir_mcp/fhir_server.py &
python phase2_mcp/drug_mcp/drug_server.py &
python phase2_mcp/xai_mcp/xai_server.py &
python phase2_mcp/grok_mcp/grok_server.py &- FHIR Server: https://fhir-production-mcp.up.railway.app
- Drug Safety Server: https://drug-production-mcp.up.railway.app
- XAI Server: https://xai-production-mcp.up.railway.app
- Grok LLM Server: https://grok-production-mcp.up.railway.app
https://app.promptopinion.ai/marketplace/agent/019e149e-25f8-7797-b3bd-5525db2ba27c
Create .env file:
GROK_API_KEY=your-xai-api-key-here
FLASK_ENV=production
LOG_LEVEL=INFO
✅ 100% Synthetic Data — All patient records are completely synthetic ✅ No Real Patients — Zero real medical data ✅ HIPAA (Health Insurance Portability and Accountability Act) Compliant — No privacy violations ✅ Hospital Safe — Can be used for demos and testing in clinical settings
Contributions welcome! Please:
- Fork repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
git clone https://github.com/your-username/clinexa-ai.git
cd clinexa-ai
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python tests/integration_test.pyIf you use Clinexa AI in your research, please cite:
@software{clinexa_ai_2026,
title={Clinexa AI: Multi-Agent Clinical Triage System},
author={Kaleem, Laraib},
year={2026},
url={https://github.com/LaraibKaleem/clinexa-ai},
version={1.0.0}
}
---
## Acknowledgments
- **Scikit-learn** — Machine Learning algorithms
- **SHAP** — Explainability framework
- **FastAPI** — Web framework
- **Railway** — Cloud deployment
- **OpenFDA** — Drug interaction database
- **HL7 FHIR** — Healthcare data standards
- **Prompt Opinion** — AI marketplace
- Open-source community
---
## Disclaimer
**This is a research and educational project.** It is designed for demonstration and learning purposes using 100% synthetic data. It is NOT intended for use in actual clinical settings without proper regulatory approval (FDA clearance, clinical validation, etc.).
Clinexa AI demonstrates proof-of-concept for multi-agent healthcare AI but should NOT be used to make real clinical decisions without qualified medical professionals and appropriate regulatory oversight.
---
Built with ❤️ for healthcare innovation
Last updated: May 2026
<!-- # Clinexa AI — Multi-Agent Clinical Triage System
## Elevator Pitch
6 AI agents that work like a hospital team —
from patient intake to FHIR output — in seconds.
---
## What It Does
A patient describes their symptoms.
Clinexa AI sends them through 6 agents:
1. Intake Agent — reads symptoms, structures them
2. Risk Agent — predicts LOW / MEDIUM / HIGH risk
3. XAI Agent — explains WHY using SHAP
4. Treatment Agent — recommends care plan
5. Drug Safety Agent — checks medication conflicts
6. FHIR Agent — produces HL7 R4 clinical report
---
## Tech Stack
- Python 3.11
- FastAPI — MCP servers
- Scikit-learn — RandomForest ML model
- SHAP — Explainable AI
- xAI Grok — LLM for clinical text
- HL7 FHIR R4 — clinical output standard
- MCP + A2A — agent communication
- Prompt Opinion — deployment platform
---
## Project Structure
clinexai/
├── requirements.txt
├── README.md
├── .env
├── data/
│ ├── generate_data.py
│ └── synthetic_triage.csv
├── phase1_ml/
│ ├── train_model.py
│ └── models/
├── phase2_mcp/
│ ├── fhir_mcp/fhir_server.py
│ ├── drug_mcp/drug_server.py
│ ├── xai_mcp/xai_server.py
│ └── grok_mcp/grok_server.py
├── phase3_agents/
│ └── orchestrator.py
├── phase4_deploy/
│ └── prompt_opinion_config.py
├── phase5_demo/
│ └── demo_script.txt
└── tests/
└── integration_test.py
---
## How To Run
### Step 1 — Install packages
```bash
pip install -r requirements.txt
python data/generate_data.pypython phase1_ml/train_model.pypython tests/integration_test.pyOpen 4 terminals in VS Code:
# Terminal 1
python phase2_mcp/fhir_mcp/fhir_server.py
# Terminal 2
python phase2_mcp/drug_mcp/drug_server.py
# Terminal 3
python phase2_mcp/xai_mcp/xai_server.py
# Terminal 4
python phase2_mcp/grok_mcp/grok_server.pypython phase3_agents/orchestrator.pycurl -X POST http://localhost:8000/triage \
-H "Content-Type: application/json" \
-d "{
\"patient_id\": \"SYN-10001\",
\"intake_text\": \"Severe chest pain and trouble breathing\",
\"age\": 68,
\"gender\": \"male\",
\"vitals\": {\"hr\": 125, \"sbp\": 185, \"dbp\": 110,
\"temp\": 38.9, \"spo2\": 91, \"rr\": 26},
\"symptoms\": [\"chest_pain\", \"shortness_of_breath\"],
\"medications\": [\"warfarin\", \"aspirin\"],
\"comorbidity\": \"heart_disease\",
\"pain_scale\": 9
}"LLM + ML + SHAP combined. Not rule-based — genuinely intelligent.
Faster triage. Catches drug interactions. Auto-generates clinical documentation. Explains every decision.
FHIR R4 compliant output. Synthetic data only — zero PHI. Built on open standards — MCP, A2A, FHIR. Runs on Prompt Opinion platform.
- All data is synthetic
- Zero real patient information
- FHIR bundles tagged as synthetic
- No PHI stored or transmitted
Agents Assemble — Healthcare AI Endgame Submission Deadline: May 12, 2026 Platform: Prompt Opinion Marketplace
--!>