customeragent-api / HEALTHCARE_IMPLEMENTATION_PLAN.md
anasraza526's picture
Clean deploy to Hugging Face
ac90985

πŸ₯ Healthcare Chatbot – Implementation Flow (Dynamic & CPU-Optimized)

High-Level Runtime Flow

  1. Message Intake: Socket.IO/API -> chat_messages -> chat_sessions
  2. Context Resolution: context_service.py (Patient context + session memory)
  3. Medical Intent Detection: intent_classifier.py (Symptom, Info, Safety, Casual, Non-medical)
  4. Dynamic Risk Scoring: risk_engine.py (Score 0.0-1.0) -> Updates patient context
  5. Dataset Routing: dataset_router.py (Weighted routing, e.g. SymCAT/MedQuAD)
  6. Hybrid Retrieval: retrieval_engine.py (BM25 + FAISS + Cached Embeddings)
  7. Safety & Compliance: safety_guard.py (No diagnosis, Prescriptions, Dosage; Add Disclaimers)
  8. Response Composition: response_composer.py (Template vs LLM)
  9. Delivery: Socket.IO -> storage -> feedback loop

Component Mapping

Existing Component New Role
ai_engine.py Medical Orchestrator Wrapper
FAISS Primary Medical Retrieval
BM25 Clinical Term Matching
Unanswered Questions Human-in-the-loop
Gemini Last-resort Synthesis

Optimization

  • CPU-Only: No heavy local LLMs (use APIs or efficient retrieval)
  • Async: Non-blocking calls
  • Caching: Embeddings and frequent responses

πŸ“Š Dataset & Knowledge Strategy

Dataset Purpose Notes
MedQuAD Medical Q&A pairs Covers diseases like flu, diabetes, cardiovascular; used for evidence-based responses
SymCAT Symptom-to-Disease mapping Helps chatbot compute risk score, suggest next questions, and verify symptom consistency
HealthTap Professional health advice Used to improve natural phrasing and context-aware responses
WHO / CDC Guidelines & Escalation Provides authoritative references for high-risk symptoms and emergency protocols
ICD-10 Codes Disease Taxonomy Standardized identifiers for internal mapping & consistent terminology

Next Steps

  1. Implement medical_orchestrator.py (Core Brain)
  2. Implement risk_engine.py with dynamic formulas
  3. Add patient_context DB migration
  4. Create healthcare-safe response templates
  5. Build symptom stepper UI