Skip to content

Repository files navigation

πŸ₯ CuraLink - Smart Hospital Bed Management System

A comprehensive IoT-enabled hospital bed occupancy management system with real-time hardware integration, ML-powered predictions, and intelligent dashboard monitoring for efficient healthcare resource management.

πŸ₯ System Components

1. Smart Bed Monitoring Hardware

  • ESP8266-based intelligent bed monitoring
  • Temperature and weight-based occupancy detection
  • RFID staff verification system
  • Real-time status indication via LCD and LED
  • Automated cleaning status management

2. Real-time Dashboard

  • Modern React-based web interface
  • Real-time bed status monitoring
  • Staff authentication and access control
  • Comprehensive bed management features

πŸš€ Features

  • πŸ”§ Hardware Integration

    • ESP8266 + MLX90614 temperature sensor + FSR pressure sensor
    • Real-time occupancy detection with body heat and weight sensing
    • 12-second connection timeout with automatic offline detection
    • Hardware status logging (online/offline transitions)
    • Temperature and pressure data display on dashboard
  • πŸ“Š Smart Dashboard

    • Real-time bed status with color-coded indicators
    • Ward-wise organization (ICU, Maternity, General)
    • Advanced filtering system (Available, Occupied, Unoccupied, Cleaning, By Ward)
    • Supervisor override system with persistent state management
    • Patient assignment with 6-digit ID validation and 30-minute timer
    • Responsive design with collapsible ward sections
    • Status summary cards with counts by type
  • πŸ“ˆ Analytics & History

    • Recent changes display (limited to 5 entries with "View All" option)
    • Full history page with statistics and comprehensive logging
    • Hardware connection status tracking in history
    • ML-powered hourly patient predictions (26 expected patients)
    • Real-time status change notifications
  • πŸ” Security & Authentication

    • Firebase Authentication with persistent login
    • Supervisor override with dual authentication (Employee ID + Password)
    • Comprehensive audit logging with timestamps and staff IDs
    • Secure real-time database with Firebase rules
  • 🎨 User Experience

    • Modern TailwindCSS styling with consistent color scheme
    • Smooth animations and hover effects
    • Navbar with Dashboard, Analytics, and Logs navigation
    • Auto-scroll to top on page navigation
    • Compact sensor data display for space efficiency

πŸ› οΈ Tech Stack

  • Frontend: React 18 + Vite + TailwindCSS
  • Database: Firebase Realtime Database + Authentication
  • Hardware: ESP8266 + MLX90614 (Temperature) + FSR (Pressure)
  • Backend: Python Flask + scikit-learn (ML Predictions)
  • State Management: React Context API + Firebase Listeners
  • Deployment: Node.js environment with real-time synchronization

πŸ“Š Bed Status Types

  • 🟒 Unoccupied - Patient assigned but temporarily away from bed
  • πŸ”΄ Occupied - Patient currently on the bed
  • 🟠 Occupied (Cleaning) - Patient on bed that requires cleaning
  • 🟑 Unoccupied (Cleaning) - Empty bed that needs cleaning
  • ⚫ Unassigned - Bed available for new patient assignment
  • πŸ”˜ Hardware Offline - ESP8266 sensor disconnected (Bed 1 only)

πŸ₯ Ward Classifications

  • πŸ”΄ ICU Ward - Intensive Care Unit beds with hardware integration for Bed 1
  • πŸ’› Maternity Ward - Maternity and obstetrics beds with custom status tracking
  • πŸ”΅ General Ward - Standard patient care beds with automated cleaning status

πŸ“š Documentation

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Firebase project with Realtime Database enabled

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd bed-occupancy-management
  2. Install dependencies

    npm install
  3. Firebase Setup

    • Create a new Firebase project at Firebase Console
    • Enable Authentication with Email/Password provider
    • Enable Realtime Database in test mode
    • Get your Firebase configuration from Project Settings
  4. Configure Firebase

    • Open src/firebase/config.js
    • Replace the placeholder values with your actual Firebase config:
    const firebaseConfig = {
      apiKey: "your-actual-api-key",
      authDomain: "your-project-id.firebaseapp.com",
      databaseURL: "https://your-project-id-default-rtdb.firebaseio.com/",
      projectId: "your-project-id",
      storageBucket: "your-project-id.appspot.com",
      messagingSenderId: "your-messaging-sender-id",
      appId: "your-app-id"
    };
  5. Start the development server

    npm run dev
  6. Open your browser Navigate to http://localhost:5173

πŸ“ Project Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Analytics.jsx        # Analytics and predictions page
β”‚   β”œβ”€β”€ BedCard.jsx          # Individual bed status card with hardware integration
β”‚   β”œβ”€β”€ Dashboard.jsx        # Main dashboard with filtering and ward management
β”‚   β”œβ”€β”€ FullHistory.jsx      # Complete history page with statistics
β”‚   β”œβ”€β”€ HistoryTable.jsx     # Recent changes table component
β”‚   β”œβ”€β”€ LoginPage.jsx        # Authentication page
β”‚   β”œβ”€β”€ Navbar.jsx           # Navigation bar with Dashboard/Analytics/Logs
β”‚   └── PredictionBox.jsx    # ML prediction display component
β”œβ”€β”€ contexts/
β”‚   └── AuthContext.jsx      # Authentication context with persistent login
β”œβ”€β”€ firebase/
β”‚   β”œβ”€β”€ bedManager.js        # Bed status management and logging functions
β”‚   β”œβ”€β”€ config.js            # Firebase configuration
β”‚   β”œβ”€β”€ seedData.js          # Sample data seeding utilities
β”‚   └── statusResolver.js    # Status resolution and validation
β”œβ”€β”€ services/
β”‚   └── PredictionService.js # ML prediction API integration
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ bedUtils.js          # Bed status utilities and color mappings
β”‚   β”œβ”€β”€ hardwareBed.js       # ESP8266 hardware integration and monitoring
β”‚   └── statusMapping.js     # Status conversion and mapping utilities
β”œβ”€β”€ App.jsx                  # Main app with navigation routing
β”œβ”€β”€ main.jsx                 # App entry point
└── index.css                # TailwindCSS imports and custom styles
backend/
β”œβ”€β”€ app.py                   # Flask ML prediction server
β”œβ”€β”€ ml_model.pkl             # Trained scikit-learn model
└── requirements.txt         # Python dependencies
hardware/
β”œβ”€β”€ ESP8266 Code/
β”‚   β”œβ”€β”€ code.cpp            # Main ESP8266 firmware with sensor integration
β”‚   └── hardware_only_code.cpp # Hardware-only version
└── Schematic/
    β”œβ”€β”€ Curalink.fzz        # Fritzing schematic file
    └── Curalink_schematic.png # Circuit diagram

πŸ”₯ Firebase Database Structure

{
  "beds": {
    "bed1": {
      "status": "unoccupied",
      "lastUpdate": "2025-09-02T14:00:00",
      "assignedNurse": "",
      "cleaningStaff": ""
    },
    "bed2": {
      "status": "occupied",
      "lastUpdate": "2025-09-02T13:30:00",
      "assignedNurse": "NURSE45",
      "cleaningStaff": ""
    }
  },
  "history": {
    "entry1": {
      "bedId": "bed1",
      "status": "occupied",
      "assignedNurse": "NURSE45",
      "cleaningStaff": "",
      "timestamp": "2025-09-02T14:00:00"
    }
  }
}

🎯 Usage

First Time Setup

  1. Create an account or sign in using the login page
  2. Seed sample data by clicking the "Seed Sample Data" button when prompted
  3. Explore the dashboard to see bed statuses and statistics

Managing Beds

  • View bed status in color-coded cards organized by ward with real-time updates
  • Filter beds using the priority-ordered dropdown: All β†’ Available β†’ Occupied β†’ Unoccupied β†’ Cleaning
  • Filter by ward (ICU, Maternity, General) with collapsible sections
  • Assign patients with 6-digit ID validation and 30-minute auto-expiration timer
  • Monitor hardware - Bed 1 shows live temperature, pressure, and connection status
  • View recent changes (last 5) with "View All Changes" button for complete history
  • Navigate between Dashboard, Analytics, and Logs using the top navigation

Hardware Integration (Bed 1)

  • Real-time monitoring with ESP8266 + MLX90614 temperature + FSR pressure sensors
  • Connection status - Shows "🟒 Connected" or "πŸ”΄ Hardware Not Connected"
  • Sensor data display - Temperature (Β°C) and pressure values with detection indicators
  • Automatic offline detection - 12-second timeout with "Hardware Offline" status
  • Status logging - All hardware connect/disconnect events logged in history

πŸ” Supervisor Override

The system includes a secure supervisor override feature for authorized personnel:

Valid Supervisor Credentials:

  • Employee ID: 220306 or 130506
  • Password: admin@123

Features:

  • Always-visible supervisor override buttons on every bed
  • Employee ID must be exactly 6 digits
  • Real-time validation with error messages
  • Comprehensive audit logging with Employee ID and timestamp
  • Manual bed status changes for emergency situations

Status Changes

All status changes are automatically:

  • βœ… Saved to Firebase Realtime Database
  • βœ… Logged in the history table
  • βœ… Updated across all connected clients in real-time

πŸ”§ Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint

🚧 Development Notes

Sample Data

The app includes a seedData.js file that provides:

  • 6 sample beds across 3 wards:
    • ICU Ward (Beds 1-2): Bed 1 with hardware integration
    • Maternity Ward (Beds 3-4): Standard monitoring
    • General Ward (Beds 5-6): Standard monitoring
  • Automatic status synchronization for hardware-integrated bed
  • Sample history entries with timestamps
  • Easy data seeding function for testing

Real-time Updates

The dashboard uses Firebase Realtime Database listeners to provide:

  • Instant updates across all connected clients
  • Automatic synchronization of bed status changes
  • Live history updates

Authentication

  • Simple email/password authentication
  • Persistent login state
  • Secure access to dashboard features

πŸ”’ Security Considerations

For production deployment:

  1. Configure Firebase Security Rules
  2. Enable Firebase App Check
  3. Set up proper CORS policies
  4. Use environment variables for sensitive config
  5. Implement proper user roles and permissions

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ License

This project is licensed under the MIT License.

πŸ†˜ Troubleshooting

Common Issues

  1. Firebase connection errors

    • Verify your Firebase config is correct
    • Check if Realtime Database is enabled
    • Ensure authentication is set up
  2. Build errors

    • Clear node_modules and reinstall
    • Check Node.js version compatibility
  3. CSS not loading

    • Verify TailwindCSS configuration
    • Check PostCSS config is correct

Support

If you encounter any issues, please check the console for error messages and ensure all Firebase services are properly configured.

About

A real-time IoT-enabled hospital bed occupancy management dashboard built with React, Firebase, and ESP8266 hardware integration. Features automated sensor-based bed monitoring, ML-powered patient flow predictions, supervisor overrides, and comprehensive history tracking for efficient hospital resource management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages