Are we optimizing hospital resources with intelligence? Yes!
This project was built during a hackathon focused on healthcare optimization and real-time resource allocation. The goal was to demonstrate how AI can improve hospital bed management and patient forecasting in a fast-paced environment.
Smart Bed AI is a system designed to forecast patient admissions, allocate available beds using optimization techniques, and provide a web-based dashboard for hospital staff to manage wards, simulate patient flow, and react to changing conditions.
A live demo can be accessed at smart-bed-ai (replace with real URL when deployed). The demo allows users to log in, view current bed allocations, forecasted demand, and run simulations.
- Forecasting: Historical admission data is fed into a forecaster (likely using ML or time-series models) located in
backend/engine/forecaster.py. - Allocation: A Mixed Integer Linear Program (MILP) in
backend/engine/milp_allocator.pydetermines optimal bed assignments given predicted demand and ward constraints. - Backend: FastAPI-based service defined in
backend/main.pywith routers handling allocation, forecasting, patients, wards, and more. - Frontend: React with Vite (
src/) presents dashboards, controls, and simulation views. - WebSocket: Real-time updates are pushed via WebSocket to client dashboards.
- Backend: Python, FastAPI, Pydantic, SQLAlchemy (presumably), uvicorn
- Optimization: MILP solver (could be OR-Tools or similar)
- Frontend: TypeScript, React, Vite, TailwindCSS or custom UI components
- Database: SQLite/PostgreSQL (check
backend/database.pyfor config) - Testing: Pytest for backend (
test_beds_api.py, others); likely Jest for frontend
- Clone repo:
git clone <repo-url> - Navigate to backend:
cd backendand create a virtualenv:python -m venv venvthensource venv/bin/activate. - Install dependencies:
pip install -r requirements.txt. - Initialize database:
python seed.pyor run migration scripts. - Start backend server:
uvicorn main:app --reload. - Open another terminal for frontend:
cd ../srcand runnpm install && npm run dev. - Visit
http://localhost:3000(or appropriate port) to access the UI.
- Cannot connect to database: Verify
DATABASE_URLin environment orbackend/database.pysettings. - Port conflicts: Ensure backend and frontend ports (8000 and 3000) are free.
- Dependency issues: Run
pip install --upgrade -r requirements.txtandnpm audit fix.
The application supports a demo mode where sample data is preloaded and user actions are sandboxed. Enable by setting DEMO_MODE=true in the environment before starting the backend.
Use the web UI to:
- Start/stop patient simulation
- Adjust forecast parameters
- Reset bed allocations
- View historical trends
backend/ # Python API and logic
engine/ # Forecasting and allocation engines
routers/ # FastAPI route handlers
scripts/ # utility scripts
models.py # data models
database.py # DB configuration
main.py # FastAPI application
src/ # Frontend React application
components/ # UI components and views
lib/ # shared utilities
index.html # main HTML entry
package.json # frontend dependencies
DATABASE_URL- connection string for the databaseDEMO_MODE- enable demo data and sandbox environmentSECRET_KEY- application secret for signing tokensPORT- backend server portFRONTEND_URL- allowed origins for CORS
- Backend:
pytestfrom the project root. Seetest_beds_api.pyandtest_quick_add.py. - Frontend:
npm run testinsidesrcif tests exist.
- Forecast generation: <500ms per run
- Allocation solver: <1s for typical ward sizes
- API response: <200ms for read operations
- Each ward has a hard bed count limit
- Patients cannot be double-assigned
- Forecasting models must use only past data
A nurse logs into the dashboard on a busy morning. She views the forecast, which predicts a surge of admissions in the next 24 hours. Using the simulator, she tests reallocating beds from less-critical wards. The MILP engine suggests an optimal layout, and she approves it. Real-time updates push to all staff screens as patients are admitted, keeping everyone informed.
- M Tanusree Reddy
- Nihal DR
- P Devesh Reddy
Thank you for checking out Smart Bed AI! Enhance hospital care with intelligent resource management.