A unified healthcare AI platform featuring three specialized medical agents integrated into a single FastAPI backend and React frontend. This system demonstrates advanced agentic AI concepts through practical healthcare use cases.
Version: 2.0 (Reorganized)
Status: Production Ready
βββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (general_ui/) β
β Patient Intake | Specialist Consultation β
β Clinical Document Processing β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β HTTP/REST
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Unified FastAPI Backend (general_api/) β
β β’ Patient Intake Agent (Reflection Loop) β
β β’ Specialist Consultation Agent (Parallel) β
β β’ Clinical Document Agent (Pipeline+HiL) β
βββββββββββββββββββββββββββββββββββββββββββββββ
This project prioritizes mastering Agentic AI working principles over production infrastructure.
The focus is on agent design patterns (reflection loops, parallel fan-out, human-in-the-loop) and LLM integration rather than enterprise-grade features. Therefore, database connections and persistent server infrastructure are intentionally omitted. This allows you to concentrate on the core concepts: state management, conditional routing, multi-agent coordination, and human approval workflowsβwithout the distraction of database schemas, migrations, or deployment complexity. Once you master these agentic patterns, scaling to production with databases, authentication, and microservices becomes straightforward.
- Reflection Loops: Generator and Critic nodes that iteratively improve output (Patient Intake Agent)
- Supervisor + Parallel Fan-Out: LLM-driven routing and concurrent specialist analysis (Specialist Consultancy Agent)
- Sequential Pipelines with Human-in-the-Loop: Multi-phase workflows with interrupt checkpoints for human review (Clinical Document Agent)
- State Management: How state flows through multi-node graphs and how to use operators to accumulate results
- Conditional Routing: Dynamic decision-making at runtime based on LLM output
- LangGraph: Building stateful multi-agent graphs with complex control flow
- FastAPI: Unified backend API serving multiple agents
- React + TypeScript: Modern frontend with centralized API configuration
- LiteLLM: Provider-agnostic LLM access (OpenAI, Claude, local models, etc.)
- Pydantic: Robust structured output validation from LLMs
- ICD-10-CM Coding: How medical conditions are standardized and coded
- RxNorm (RxCUI): Medication standardization and drug coding
- SOAP Notes: Clinical documentation structure (Subjective, Objective, Assessment, Plan)
- Clinical Workflow: Why human review gates are essential for safety and accuracy
Pattern: Reflection Loop (Generator β Critic)
Entry point for patient symptoms.
Flow:
- Generator Node: Takes patient symptom description, drafts a medical summary
- Critic Node: Reviews the draft for:
- No explicit diagnoses (only differential considerations)
- Professional clinical tone
- No hallucinated facts
- Loop: If rejected, Generator refines based on Critic feedback (max 5 iterations)
- Output: Approved summary with revision history
API Endpoint: POST /basic/analyze
{
"text": "Patient presents with chest pain and shortness of breath..."
}Pattern: Supervisor + Parallel Fan-Out + Aggregator
Medical case routed to multiple specialists simultaneously.
Flow:
- Supervisor Node: LLM reads case, selects top_k relevant specialists from pool of 20
- Parallel Specialist Nodes: All selected specialists analyze the case simultaneously via
SendAPI - Aggregator Node: Synthesizes all assessments into:
- Consensus findings
- Areas of divergence
- Prioritized management plan
API Endpoint: POST /intermediate/analyze
{
"case": "56-year-old patient with elevated troponin...",
"top_k": 5
}Specialist Pool: Cardiologist, Neurologist, Pulmonologist, Gastroenterologist, Rheumatologist, etc.
Pattern: Sequential Pipeline + Human-in-the-Loop
Multi-phase document processing with human approval gate.
Flow:
- Condition Extractor: Extracts conditions from clinical documents
- Medication Extractor: Extracts medications with dosage and route
- Condition Coder: Assigns ICD-10-CM codes
- Medication Coder: Assigns RxNorm codes
- SOAP Drafter: Generates draft SOAP note
- Human Review Gate: Workflow pauses; clinician reviews and edits SOAP note in UI
- Finalization: After approval, final signed SOAP note is created
API Endpoints:
POST /advanced/upload- Upload and process documentsPOST /advanced/approve- Approve SOAP note after human reviewGET /advanced/files- List available documents
HealthCare_agentic_ai/
βββ general_api/ # Unified FastAPI backend
β βββ main.py # FastAPI server with all three agents
β βββ patient_intake_agent.py # Basic Agent
β βββ specialist_consultancy_agent.py # Intermediate Agent
β βββ medical_document_agent.py # Advanced Agent
β βββ tools.py # Shared utilities and tools
β βββ requirements.txt # Python dependencies
β βββ data/ # Document storage
β βββ .env # Environment configuration
β
βββ general_ui/ # React + TypeScript frontend
β βββ src/
β β βββ pages/
β β β βββ PatientIntakePage.tsx # Basic Agent UI
β β β βββ SpecialistConsultationPage.tsx # Intermediate Agent UI
β β β βββ ClinicalDocumentPage.tsx # Advanced Agent UI
β β β βββ HomePage.tsx # Landing page
β β β βββ ...
β β βββ components/ # Shared UI components
β β βββ config/
β β β βββ api.ts # Centralized API configuration
β β βββ App.tsx # Main routing
β βββ package.json
β βββ tailwind.config.js
β βββ .env.local # Frontend environment
β
βββ Archive/ # Previous single-project implementations
β βββ 01_basic_agent/
β βββ 02_intermediate_agent/
β βββ 03_advanced_agent/
β
βββ REORGANIZATION.md # Detailed v2.0 migration guide
βββ README.md # This file
- Python 3.10+
- Node.js 16+
- pip and npm
- LLM API keys (OpenAI, Anthropic, or compatible)
# Navigate to backend
cd general_api
# Create and activate virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
copy .env.example .env
# Edit .env with your LLM API keys and model preferences
# Start API server
python main.py
# API will be available at http://localhost:8001# Navigate to frontend
cd general_ui
# Install dependencies
npm install
# Configure API endpoint
echo "REACT_APP_API_URL=http://localhost:8001" > .env.local
# Start development server
npm start
# UI will open at http://localhost:3000- API Health:
curl http://localhost:8001/health - API Docs: Open http://localhost:8001/docs in browser
- Frontend: Open http://localhost:3000 in browser
For testing the frontend, the following demo credentials are available:
- Username:
[email protected] - Password:
patient123
`
Note: These is demo credential for development and testing only.
GET /health # Global health
GET /basic/health # Patient Intake Agent health
GET /intermediate/health # Specialist Consultancy health
GET /advanced/health # Clinical Document Agent health
POST /basic/analyze
Body: { "text": "patient symptoms..." }
Response: { "final_summary": "...", "history": [...] }
POST /intermediate/analyze
Body: { "case": "medical case...", "top_k": 5 }
Response: {
"case_summary": "...",
"specialist_assessments": [...],
"unified_summary": "...",
"specialists_count": 5
}
GET /advanced/files # List documents
POST /advanced/upload # Upload and process
POST /advanced/process-storage # Process from storage
POST /advanced/approve # Approve SOAP note
Body (approve): { "thread_id": "...", "updated_soap": "..." }
For complete details, visit http://localhost:8001/docs (Swagger UI).
- Single FastAPI server serves all three agents
- Consistent error handling and response formats
- Built-in async/await for concurrent requests
- Swagger documentation auto-generated
- All API endpoints defined in one place (
src/config/api.ts) - No hardcoded URLs scattered across components
- Easy to switch between development/production
- Each agent maintains independent logic
- Common tools and utilities in
tools.py - Shared LLM configuration via environment variables
- Clean separation of concerns
- Workflow pauses at checkpoint for human review
- Clinician can edit intermediate results
- Edited content preserved in final output
- Audit trail of approvals and changes
# Terminal 1 - Backend
cd general_api
source venv/bin/activate # or: venv\Scripts\activate on Windows
python main.py
# Terminal 2 - Frontend
cd general_ui
npm startBackend:
# Edit agent code in general_api/
# Restart API: Ctrl+C and python main.py again
# Check logs in terminal
# API docs auto-update at /docsFrontend:
# Edit React components
# Hot-reload automatically applies changes
# Check console in browser DevTools (F12)- Backend Logs: Check terminal running
python main.py - API Docs: Visit
http://localhost:8001/docs - Browser Console: Open DevTools (F12) β Console tab
- Network Monitoring: DevTools β Network tab to see API calls
# LLM Configuration
LLM_MODEL=gpt-4 # or claude-3-sonnet, etc.
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
# Server Configuration
API_HOST=0.0.0.0
API_PORT=8001
DEBUG=false
# Data Storage
DATA_DIR=/app/dataREACT_APP_API_URL=http://localhost:8001| Issue | Cause | Solution |
|---|---|---|
Connection refused on port 8001 |
Backend not running | Start backend: cd general_api && python main.py |
CORS error in browser |
Backend CORS not configured | Ensure fastapi.middleware.cors.CORSMiddleware is added in main.py |
ModuleNotFoundError |
Missing Python dependencies | cd general_api && pip install -r requirements.txt |
API returns 401/403 |
LLM API key invalid or expired | Check .env file, verify API key with provider |
Frontend shows loading spinner forever |
API unreachable or slow | Check browser Network tab, verify REACT_APP_API_URL |
SOAP note doesn't pause for approval |
Missing interrupt_after in graph |
Verify graph compilation includes interrupt_after=["saga_drafter"] |
- Simplicity: Single endpoint for all agent functionality
- Scalability: Easier to add more agents or features
- Maintenance: Centralized configuration and logging
- Consistency: Same error handling and response format
- Type Safety: Catch errors at compile time
- Developer Experience: IntelliSense and refactoring support
- Component Reusability: Shared Navbar, Sidebar, Footer components
- Modern Tooling: Hot-reload, testing frameworks, bundle optimization
- State Management: Explicit state handling for complex workflows
- Interrupts: Built-in human-in-the-loop support
- Composition: Easy to combine agents into larger systems
- Testing: Deterministic playback and inspection
After working through this system, you will understand:
- How to design stateful multi-agent workflows using LangGraph
- How to build a production-grade API with FastAPI
- How to create a modern frontend with React and TypeScript
- How to safely integrate LLMs into healthcare workflows
- How to implement human-in-the-loop approval processes
- How to handle parallel execution with
SendAPI - How to structure code for maintainability and testing
- Read through each agent implementation in
general_api/ - Trace the data flow from API endpoint to LLM to frontend
- Modify prompts in agents and observe output changes
- Add new specialists to the Specialist Consultancy Agent
- Implement new coding systems (beyond ICD-10 and RxNorm)
- Add database for persistent storage
- Implement user authentication and authorization
- Set up monitoring, logging, and alerting
- Add rate limiting and request validation
- Containerize with Docker and deploy to cloud
- Set up CI/CD pipeline
The entry point for the application with role-based authentication.
Features:
- Email and password authentication
- Remember me functionality with secure localStorage
- Password visibility toggle
- Demo credentials for testing
- Responsive design for mobile and desktop
How to Use:
- Enter email and password from demo credentials section (above)
- Click "Sign In"
- You'll be redirected to Home page
- Remember me checkbox stores credentials for future logins
Dashboard showcasing all three AI agents and quick navigation to their features.
Features:
- Quick access cards for three agents (Basic, Intermediate, Advanced)
- Agent descriptions and capabilities overview
- Health News feed section with latest medical news
- Role-based sidebar navigation
- System status indicator at bottom left
- User profile in top right corner
What You Can Do:
- Browse all available medical AI agents
- View detailed agent descriptions
- Navigate directly to Patient Intake, Specialist Consultation, or Clinical Document processing
- Check latest health news and medical updates
Analyze patient symptoms and generate professional medical summaries using AI-powered reflection loops.
Features:
- Text input area for patient symptoms and medical history
- Real-time AI analysis with Generator-Critic loop
- Iterative improvement of medical summaries (max 5 iterations)
- "How It Works" tutorial snackbar on first visit
- Review of full revision history
- Professional clinical tone validation
- Safety checks preventing explicit diagnosis statements
Workflow:
- Input: Enter patient symptoms, vital signs, and medical history
- Generate: AI creates initial summary
- Critique: AI Critic reviews for accuracy, safety, and professionalism
- Loop: If rejected, Generator refines based on feedback
- Approve: Once approved, summary shown with full history
Example Input:
Patient is a 45-year-old male with a 3-day history of:
- Severe headache (9/10 intensity), photophobia, neck stiffness
- Nausea and one episode of vomiting
- Temperature 38.7Β°C, HR 94
AI Output: Professional summary focusing on differential diagnoses without explicit diagnosis.
Get insights from multiple AI specialists analyzing complex medical cases simultaneously.
Features:
- Complex case input for multi-specialist analysis
- Adjustable specialist count (1-20) via sidebar slider
- Parallel AI specialist processing for fast results
- Specialist Assessment Tabs showing individual specialist opinions
- Unified clinical summary synthesizing all assessments
- Key findings, differential diagnoses, and management plans from each specialist
Available Specialists (20+): Cardiologist, Neurologist, Pulmonologist, Gastroenterologist, Rheumatologist, Endocrinologist, Nephrology, Infectious Disease, Hematology, Oncology, and more...
Workflow:
- Input: Enter complex medical case
- Supervisor: AI selects relevant specialists based on case
- Parallel Analysis: All selected specialists analyze simultaneously
- Synthesis: AI synthesizes consensus, divergence, and disagreements
- Output: Unified recommendations and management plan
Example Case: "68-year-old female with progressive shortness of breath, bilateral leg swelling..."
- Cardiologist: Reviews heart failure indicators
- Nephrologist: Assesses kidney involvement and fluid overload
- Pulmonologist: Evaluates lung congestion and respiratory function
- Unified Plan: Combined differential diagnoses and treatment approach
Process clinical documents with intelligent extraction, medical coding, and human-in-the-loop approval.
Features:
- Multi-format Support: Upload PDF, TXT, or CSV documents
- Intelligent Extraction: Automatically extracts conditions and medications
- Medical Coding:
- ICD-10-CM codes for conditions
- RxNorm codes for medications
- SOAP Generation: Automatic structured clinical note creation
- Visual Pipeline: Real-time progress visualization of 5 processing stages
- Human Review Gate: Built-in approval workflow for clinician verification
- Editable Output: Modify extracted information before finalization
Processing Pipeline (5 Stages):
- π Document Upload - Accept and validate documents
- π₯ Condition Extractor - Identify medical conditions (e.g., "hypothyroidism")
- π Medication Extractor - Extract drugs with dosage and route
- #οΈβ£ Condition Coder - Assign ICD-10-CM codes (e.g., E03.9)
- #οΈβ£ Medication Coder - Assign RxNorm codes (e.g., RxCUI: 196448)
- βοΈ SOAP Drafter - Generate structured clinical note
- ποΈ Human Review - Clinician reviews and approves
Output Information:
Medical Conditions (ICD-10):
| Condition | ICD-10 Code | Status |
|---|---|---|
| Hypothyroidism | E03.9 | β Done |
| Hyperlipidemia | E78.5 | β Done |
| Obesity | E66.9 | β Done |
Medications (RxNorm):
| Medication | Dosage | Route | RxNorm Code |
|---|---|---|---|
| Atorvastatin | 40 MG | Oral | 196448 |
| Lisinopril | 10 MG | Oral | 197497 |
| Levothyroxine | 50 mcg | Oral | 185499 |
SOAP Note Structure:
## SOAP Note
### S (Subjective)
Patient-reported symptoms and concerns...
### O (Objective)
Clinical findings, vital signs, and laboratory results...
### A (Assessment)
Clinical impression with multiple comorbidities...
### P (Plan)
Treatment recommendations and follow-up schedule...
How to Use:
- Click "Upload Files" button
- Select documents (PDF, TXT, or CSV)
- System processes through 5 stages
- Review extracted conditions and medications
- Review SOAP note draft
- Edit if needed
- Click "Approve SOAP Note"
- Final note is ready for medical records
Browse and connect with AI specialist agents available in the system.
Features:
- Interactive specialist directory
- Specialist cards with:
- Profile photo
- Name and specialty
- Years of experience
- Medical institution location
- Email and phone contact
- Current availability status
- Search functionality to find specialists
- Filter by specialty
- Real-time availability indicators:
- π’ Available - Ready for consultation
- π‘ In Consultation - Currently busy
- Status shows time and specialization
Use Case:
- Find specific specialist for second opinion
- Check availability before scheduling
- View expertise and experience
- Contact specialist directly
Manage personal health records and medical history.
Features:
- Patient Dashboard with overview
- Multiple Patient Records:
- Quick access cards for different patients
- Risk level indicators (Critical π΄, High π , Moderate π’)
- Age, condition, and status info
- Detailed Patient Information:
- Full patient demographics
- Age, blood type, vital info
- Last checkup and next appointment dates
- Medical Records Tabs:
- Patient History - Full history record
- Medical Info - Current medications and allergies
- Medical History - Past diagnoses and treatments
- Appointments - Scheduled follow-ups
- Health Conditions Tracking:
- Allergies and sensitivities
- Current conditions
- Medications and dosages
Workflow:
- View all patients in system
- Select patient to view details
- Review medical history and conditions
- Check appointments and follow-ups
- View allergies and important health notes
Manage your personal account information and user profile details.
Features:
- User profile overview with avatar
- Personal Information:
- First Name and Last Name
- Email Address
- Phone Number
- Title/Role (Medical Professional, etc.)
- Address Information:
- Country
- City
- Street Address
- Postal Code
- Edit button for updating profile information
- Role-based access with admin edit functionality
How to Use:
- Click on user avatar in top right corner
- Select "Profile" from menu
- View your personal and address information
- Click "Edit" button to modify information
- Update details and save changes
- Changes are immediately reflected in your profile
Information Displayed:
- Current logged-in user details
- Contact information (Email, Phone)
- Professional role/title
- Location information
- User avatar/profile picture
The application displays real-time status information:
Frontend Status:
- β Active at http://localhost:3000
- Real-time user authentication
- Responsive UI across devices
Backend API Status:
- β Active at http://localhost:8001
- All three agents operational
- Health endpoints monitoring all services
Displayed in UI:
- π’ Green indicator: "All systems online"
- Shows "AI system online" badge
- Real-time availability updates
Using: Patient Intake Agent (Basic)
INPUT:
Patient is a 45-year-old male with 3-day history:
- Severe chest pain (7/10)
- Shortness of breath on exertion
- Mild diaphoresis
- BP: 145/90, HR: 98
PROCESS:
Generator β Creates draft summary
β (Sent for criticism)
Critic β Reviews for accuracy and safety
β (If rejected, feedback sent back)
Generator β Refines based on feedback
β (Repeats max 5 times until approved)
OUTPUT:
"45-year-old patient presents with acute chest pain characterized by...
Vital signs show mild hypertension and tachycardia. Differential
considerations include acute coronary syndrome, pulmonary embolism,
aortic dissection, and musculoskeletal causes. Immediate EKG and
troponin levels recommended..."
Revision History: 2 iterations before approval
Using: Specialist Consultancy Agent (Intermediate)
INPUT:
68-year-old female with:
- Progressive SOB for 2 weeks
- Bilateral leg swelling
- Elevated troponin (6.5)
- Hypertension, diabetes, On metformin, amlodipine
- Exam: JVP elevated, bilateral crackles, pitting edema to knees
- ECG: Sinus tachycardia, LBBB
SPECIALISTS SELECTED (top 5):
1. Cardiologist - Heart failure specialist
2. Nephrologist - Kidney/fluid specialist
3. Pulmonologist - Lung congestion expert
4. Endocrinologist - Diabetes complications
5. Internist - Overall coordination
PARALLEL ANALYSIS:
- Cardiologist: "Consistent with acute decompensated heart failure"
- Nephrologist: "Acute kidney injury complicating cardiac failure"
- Pulmonologist: "Bilateral pulmonary edema secondary to heart failure"
- Endocrinologist: "Diabetes contributing to vascular complications"
UNIFIED OUTPUT:
"Primary diagnosis: Acute decompensated heart failure with secondary
AKI and pulmonary edema. Underlying causes: long-standing hypertension,
diabetes, and possible myocardial infarction. Recommended: ICU admission,
diuretics, ACE inhibitors, cardiology consult, nephrology follow-up..."
Using: Clinical Document Agent (Advanced)
INPUT DOCUMENT:
Clinical note PDF with patient information, symptoms, exam findings,
lab results
AUTOMATED PIPELINE:
1. Document Upload β
2. Condition Extraction β
Found: hypothyroidism, hyperlipidemia, hypertension, anemia
3. Medication Extraction β
Found: Levothyroxine 50mcg daily, Atorvastatin 40mg daily, Lisinopril 10mg daily
4. Condition Coding β
E03.9, E78.5, I10, D50.9
5. Medication Coding β
RxCUI: 185499, 196448, 197497
6. SOAP Drafting β
Complete structured note generated
7. Human Review β³ AWAITING APPROVAL
CLINICIAN REVIEW GATE:
- Reviews SOAP draft
- Edits "Assessment" section to add clinical impression
- Confirms ICD-10 codes are accurate
- Changes one medication dosage
- Clicks "Approve SOAP Note"
FINALIZATION:
β SOAP note saved to medical records
β Ready for filing and insurance claims
Last Updated: March 2026









