The SmartCare Hospital Chatbot now features role-based intelligence that provides different features and responses based on whether the user is a Patient or Management/Admin.
For: Patients and visitors Focus: Personal assistance, appointments, health information
For: Hospital administrators and staff Focus: Analytics, operations, queue management, reports
- Browse departments
- View available doctors
- Check doctor ratings and experience
- Select appointment slots
Example:
Patient: "Book an appointment"
Bot: Shows departments β Select doctor β Choose time
- Track appointment by phone number
- View appointment details
- See current status (confirmed, waiting, completed)
Example:
Patient: "Check my status"
Bot: "Please provide your phone number"
Patient: "9876543210"
Bot: Shows all appointments with status
NEW FEATURE - Get precise timing information:
- Scheduled appointment time
- Current queue position
- Estimated actual time
- Expected wait duration
Example:
Patient: "What's my estimated time?"
Bot:
"β° Your Appointment Estimate:
π
Date: March 15, 2024
π Scheduled: 10:00 AM
π Queue Position: #3
β±οΈ Estimated Time: 10:30 AM
β Expected Wait: ~30 minutes"
NEW FEATURE - Department-specific guidance:
- What to bring
- How to prepare
- Fasting requirements
- Clothing recommendations
- Timing advice
Example:
Patient: "Precautions for cardiology"
Bot:
"π Precautions for Cardiology:
π©Ί Bring previous ECG/Echo reports
π List of current medications
π« Avoid caffeine 2 hours before
π Wear comfortable, loose clothing
π Fasting may be required for some tests"
Department-Specific Precautions:
- Cardiology: ECG prep, medication list, avoid caffeine
- Neurology: MRI reports, symptom notes, adequate sleep
- Orthopedic: X-rays, comfortable shoes, walking aids
- Pediatrics: Vaccination records, growth chart, comfort toys
- General: ID proof, medical records, insurance
- Search by specialty
- View doctor ratings
- Check experience years
- See availability
- Current wait times by department
- Crowd level indicators
- Best time to visit recommendations
- List all departments
- Floor locations
- Available services
- Best times to visit
- Peak hour warnings
- Tomorrow's forecast
Real-time operational data:
- Total appointments today
- Patients waiting
- Patients in progress
- Completed consultations
- Completion rate
- Department-wise breakdown
Example:
Admin: "Queue statistics"
Bot:
"π Live Queue Statistics:
π
Today's Overview:
β’ Total Appointments: 45
β’ β³ Waiting: 12
β’ π In Progress: 8
β’ β
Completed: 25
π₯ Active Queues by Department:
β’ Cardiology: 5 patients
β’ Neurology: 3 patients
β’ Orthopedic: 4 patients
β‘ Completion Rate: 55.6%"
Comprehensive daily overview:
- Total appointments
- Completion statistics
- No-show rate
- Active departments
- Available doctors
- Average wait time
- System status indicator
Example:
Admin: "Today's summary"
Bot:
"π Today's Summary Report
π
March 15, 2024
π₯ Appointments:
β’ Total: 45
β’ Completed: 25
β’ No-shows: 2
β’ Show Rate: 95.6%
π₯ Operations:
β’ Active Departments: 8
β’ Available Doctors: 15
β’ Avg Wait Time: ~25 min
π‘ Status: π’ Normal"
Performance metrics by department:
- Total appointments per department
- Completion rates
- No-show rates
- Efficiency analysis
Example:
Admin: "Department performance"
Bot:
"π Department Performance Today:
β’ Cardiology:
Total: 15 | Completed: 10 | Rate: 66.7%
β’ Neurology:
Total: 12 | Completed: 8 | Rate: 66.7%
β’ Orthopedic:
Total: 10 | Completed: 5 | Rate: 50.0%"
Staff availability tracking:
- Number of available doctors
- Number of unavailable doctors
- List of currently available doctors
- Department assignments
Example:
Admin: "Doctor availability"
Bot:
"π¨ββοΈ Doctor Availability:
β
Available: 15 doctors
β Unavailable: 3 doctors
Currently Available:
β’ Dr. John Smith - Cardiology
β’ Dr. Sarah Johnson - Neurology
β’ Dr. Mike Brown - Orthopedic"
Priority patient identification:
- Emergency cases
- High-risk patients
- Patients requiring immediate attention
- Appointment times
- Department assignments
Example:
Admin: "High-risk patients"
Bot:
"π¨ High-Risk Patients Today:
Found 3 high-priority cases:
β’ John Doe - Cardiology (10:00 AM)
β’ Jane Smith - Neurology (11:30 AM)
β’ Bob Wilson - Emergency (09:45 AM)
β οΈ These patients require immediate attention.
π‘ Consider prioritizing in queue management."
ML-powered predictions:
- Identify high no-show risk appointments
- Risk percentage for each patient
- Proactive reminder suggestions
Example:
Admin: "No-show predictions"
Bot:
"β οΈ No-Show Risk Analysis:
High-risk appointments: 3/45
β’ Patient A - 10:00 AM (Risk: 65%)
β’ Patient B - 02:30 PM (Risk: 58%)
β’ Patient C - 04:00 PM (Risk: 52%)
π‘ Consider sending reminder SMS to these patients."
Predictive analytics:
- Tomorrow's crowd predictions
- Hour-by-hour forecast
- Peak time identification
- Staffing recommendations
Example:
Admin: "Crowd forecast"
Bot:
"π Crowd Forecast for Tomorrow:
March 16, 2024
π’ 8:00 AM: Low
π‘ 10:00 AM: Medium
π 12:00 PM: High
π‘ 2:00 PM: Medium
π’ 4:00 PM: Low
π‘ Recommendations:
β’ Schedule more staff during peak hours
β’ Prepare for high-volume periods
β’ Consider opening additional counters"
The chatbot automatically detects user role based on:
- Authentication Status: Checks if user is logged in
- User Type: Checks
current_user.is_admin() - Context: Uses session and user data
if current_user.is_authenticated:
if current_user.is_admin():
role = "admin" # Management Mode
else:
role = "patient" # Patient Mode
else:
role = "patient" # Default to Patient Mode| Feature | Patient Mode | Management Mode |
|---|---|---|
| Book Appointments | β Yes | β No |
| Check Status | β Yes (own) | β No |
| Estimated Time | β Yes | β No |
| Precautions | β Yes | β No |
| Find Doctors | β Yes | β Yes |
| Wait Times | β Yes | β Yes |
| Queue Statistics | β No | β Yes |
| Today's Summary | β No | β Yes |
| Dept Performance | β No | β Yes |
| Doctor Availability | β No | β Yes |
| High-Risk Alerts | β No | β Yes |
| No-Show Predictions | β No | β Yes |
| Crowd Forecast | β Limited | β Detailed |
- Login as patient:
test@patient.com/test123 - Open chatbot
- Try these commands:
- "Hello"
- "Book appointment"
- "Check my status"
- "What's my estimated time?"
- "Precautions for cardiology"
- "Find a doctor"
- Login as admin:
admin@hospital.com/admin123 - Open chatbot
- Try these commands:
- "Hello"
- "Queue statistics"
- "Today's summary"
- "High-risk patients"
- "Department performance"
- "Doctor availability"
- "No-show predictions"
- "Crowd forecast"
- β
app/services/chatbot_handlers.py- Patient and Management handlers
- β
app/services/chatbot_service.py- Role-based routing - β
app/routes/chatbot.py- User role detection
class HospitalChatbot:
- process_message() - Main entry point
- _handle_patient_intent() - Route patient requests
- _handle_management_intent() - Route management requests
- _detect_intent() - Role-based intent detection
class PatientHandlers:
- handle_estimated_time() - Appointment timing
- handle_precautions() - Health advice
class ManagementHandlers:
- handle_queue_stats() - Queue analytics
- handle_today_summary() - Daily reports
- handle_high_risk_patients() - Priority alertsβ Personalized assistance for their specific needs β Estimated timing reduces uncertainty β Precautions help them prepare properly β Easy booking process β Status tracking without calling
β Real-time analytics for decision making β Performance metrics for optimization β Risk alerts for proactive management β Predictive insights for planning β Operational efficiency improvements
-
Patient Mode:
- Complete booking through chat
- Payment integration
- Medical history access
- Prescription reminders
- Lab report notifications
-
Management Mode:
- Staff scheduling assistance
- Resource allocation suggestions
- Financial analytics
- Patient satisfaction metrics
- Automated report generation
The role-based chatbot system provides:
β Two distinct modes for different user types β 8 patient features for personal assistance β 7 management features for operations β Automatic role detection based on login β Context-aware responses for each role β Real-time data integration with ML models β Production-ready implementation
This enhancement makes the chatbot more useful and relevant to each user type, improving overall system efficiency and user satisfaction.