Skip to content

A discrete-event simulation model to optimize patient flow in the Emergency Department of Sta. Cruz Provincial Hospital, Philippines. Built with Python and SimPy, it analyzes bottlenecks, resource utilization, and waiting times, providing data-driven recommendations for improved efficiency.

License

Notifications You must be signed in to change notification settings

VoxDroid/EDFlowSimulator

Repository files navigation

Emergency Department Flow Simulation - Sta. Cruz Provincial Hospital

This repository contains the final project for optimizing patient flow in the Emergency Department (ED) of Sta. Cruz Provincial Hospital, Sta. Cruz, Laguna, Philippines. Using computational simulation, we model the ED's operations to reduce waiting times, increase throughput, and improve resource utilization. The project was developed as part of CSEL 303 (Computational Science) and CMSC 313 (Human Computer Interaction) courses.

Objectives

  • Minimize patient waiting times and length of stay (LOS), targeting < 30 minutes for critical patients.
  • Maximize throughput to ~180 patients/day at a peak arrival rate of 15 patients/hour.
  • Optimize resource utilization (doctors, nurses, diagnostic equipment) to 70–90%.
  • Identify and mitigate bottlenecks in the ED workflow.

Methodology

The project uses a discrete-event simulation model implemented in Python with the following techniques:

  • Discrete-Event Simulation: Using SimPy to model patient flow (arrival, triage, consultation, diagnostics, treatment, discharge/admission).
  • Queuing Theory: Representing stages as M/M/c queues (e.g., consultation with multiple doctors).
  • Monte Carlo Methods: Sampling stochastic inputs (e.g., arrival rates, service times) from probability distributions.
  • Pseudorandom Number Generation: Using NumPy for realistic variability.
  • Sensitivity Analysis & Optimization: Conducted in Phase 3 to test parameter impacts and optimize resource allocation.

The simulation ran for 1000 iterations over a 24-hour cycle, with a 2-hour warm-up period. Key parameters include:

  • Patient arrival rate: Poisson, 15 patients/hour (peak: 6 PM–12 AM), 12 (night), 10 (day).
  • Resources: 5 doctors (day), 4 (night); 9 nurses (day), 7 (night); 15 beds; 2 X-ray machines (baseline).
  • Patient priority: 20% critical, 30% urgent, 50% non-urgent.

Key Findings

  • Baseline Performance (Phase 2): Throughput of 172.50 patients/day, LOS of 73.55 minutes, with bottlenecks in consultation (17.23 minutes wait) and diagnostics (31.22 minutes wait).
  • Sensitivity Analysis (Phase 3): Throughput peaks at 191.472 patients/day with a peak arrival rate of 15 patients/hour. Adding X-ray machines reduces diagnostics wait from 57.609 minutes (1 X-ray) to 20.468 minutes (3 X-rays).
  • Optimization (Phase 3): Config 3 (5 doctors day, 4 night, 3 X-rays) achieves the best results:
    • Throughput: 195.376 patients/day (exceeding the target).
    • LOS: 48.081 minutes (32% reduction from baseline).
    • Critical patient LOS: 31.0 minutes (slightly above the target of < 30 minutes).
    • Resource utilization: Low at 11.218% (doctors) and 11.231% (X-rays), indicating overcapacity.
  • Recommendations (Phase 4): Adopt Config 3, enhance priority queuing for critical patients, and optimize resource scheduling to improve utilization.

Repository Structure

  • app.py: Main application file for the PyQt6-based GUI.
  • Phase_1.py, Phase_2.py, Phase_3.py, Phase_4.py: Tab implementations for each project phase.
  • Phase_1.md, Phase_2.md, Phase_3.md, Phase_4.md: Documentation for each phase.
  • los_distribution.png, arrival_rate_sensitivity.png, los_heatmap.png, resource_utilization.png, optimization_los.png: Visualizations generated by the simulation.
  • metrics.txt, sensitivity_results.csv, optimization_results.csv: Simulation output files.
  • resources/EDFlowSimulator.png: Application icon.

Setup Instructions

  1. Clone the repository:
    git clone https://github.com/VoxDroid/EDFlowSimulator.git
    cd EDFlowSimulator
    
  2. Create a virtual environment and activate it:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:
    pip install -r requirements.txt 
    python -m pip install briefcase # For briefcase project
    
  4. Run the application:
    briefcase dev
    

Dependencies

  • Python 3.9+
  • SimPy 4.0.1
  • NumPy 1.21.0
  • Pandas 1.3.0
  • Matplotlib 3.4.0
  • PyQt6 (for the GUI)
  • qtawesome (for icons in the GUI)
  • briefcase (for packaging)

Install via:

pip install simpy numpy pandas matplotlib pyqt6 qtawesome
python -m pip install briefcase

Visuals

Key visualizations (generated by the simulation and displayed in the GUI):

  • LOS Distribution by Priority (los_distribution.png): Shows critical patients with shorter stays, but non-urgent patients face delays up to 1200 minutes.
  • Arrival Rate Sensitivity (arrival_rate_sensitivity.png): Throughput peaks at 191.472 patients/day at a peak arrival rate of 15 patients/hour.
  • LOS Heatmap (los_heatmap.png): LOS decreases with more doctors, especially at higher arrival rates.
  • Resource Utilization (resource_utilization.png): Utilization peaks at 32.627% (doctors) and 45.411% (X-rays) at a peak arrival rate of 10 patients/hour.
  • Optimization Results (optimization_los.png): Config 3 achieves the lowest LOS (48.081 minutes) and highest throughput (195.376 patients/day).

Attribution

Developed by @VoxDroid | CSEL 303 & CMSC 313 Final Project | Emergency Department Flow Simulation

About

A discrete-event simulation model to optimize patient flow in the Emergency Department of Sta. Cruz Provincial Hospital, Philippines. Built with Python and SimPy, it analyzes bottlenecks, resource utilization, and waiting times, providing data-driven recommendations for improved efficiency.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages