Weirdcraft
Priority Queues & Heaps2025Advanced Data Structures

Emergency Room Triage Priority Queue Simulator

Hospital emergency room triage intake simulation that dynamically orders and dispatches patients by clinical acuity scores rather than arrival order.

Unique Project Permalink & Local Reference
Local Workspace Origin PathD:\Assignment\Priority Queue\ER_Triage.java
Interactive In-Browser Simulation
Live Working Demo

Live ER Triage Priority Queue Simulator

Dynamic max-heap clinical dispatch matching your Java ER_Triage.java

Severity:
Triage Priority Queue (Top Priority First)5 Waiting
#1

Marcus V.

Severe Chest Trauma

Severity 5
#2

Elena R.

Cardiac Arrhythmia

Severity 5
#3

Sarah L.

Acute Appendicitis

Severity 4
#4

David K.

Moderate Sprain

Severity 2
#5

Tom B.

Mild Laceration

Severity 1
Dispatch Audit Log
No patients dispatched yet.

Project Overview & Architecture

Built to demonstrate the real-world application of the Priority Queue Abstract Data Type. Instead of a First-In-First-Out (FIFO) queue, this simulation ingests patient arrival vectors, parses clinical urgency classifications, and utilizes a binary heap priority queue to ensure critical condition patients are prioritized immediately for medical treatment.

Key Implementation Highlights

  • ✓Custom patient comparator dynamically ranking cases based on medical urgency score and timestamp.
  • ✓Automated intake engine reading patients from structured text inputs and dispatching treatment logs.
  • ✓Demonstrates logarithmic O(log n) insertions and extractions under continuous patient arrivals.

Implementation Source Code

1 File
Emergency Room Triage Priority Queue Simulator Source Codejava
File origin: D:\Assignment\Priority Queue\ER_Triage.java
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import java.io.*;
import java.util.*;

class Patient implements Comparable<Patient> {
    String name;
    int priority;

    public Patient(String name, int priority) {
        this.name = name;
        this.priority = priority;
    }

    @Override
    public int compareTo(Patient other) {
        // Higher numeric priority value indicates higher clinical emergency urgency
        return Integer.compare(other.priority, this.priority);
    }

    @Override
    public String toString() {
        return name + " [Severity: " + priority + "]";
    }
}

public class TriageQueue {
    private PriorityQueue<Patient> heap = new PriorityQueue<>();

    public void enqueue(Patient patient) {
        heap.add(patient);
        System.out.println("Enqueued patient: " + patient);
    }

    public Patient dequeue() {
        if (heap.isEmpty()) {
            System.out.println("No patients currently in triage queue.");
            return null;
        }
        Patient treated = heap.poll();
        System.out.println("Dispatched to Doctor: " + treated);
        return treated;
    }

    public Patient peek() {
        return heap.peek();
    }

    public boolean isEmpty() {
        return heap.isEmpty();
    }

    public void visualize() {
        List<Patient> snapshot = new ArrayList<>(heap);
        Collections.sort(snapshot);
        System.out.println("--- Current Priority Queue Status ---");
        for (Patient p : snapshot) {
            System.out.println(" • " + p);
        }
    }
}
59 linesVerified from local workspace

Technologies & Tools

JavaPriority Queue ADTBinary Heap MechanismComparator InterfaceFile I/O Parsing

Academic Classification

Program / FocusAdvanced Data Structures
Project Timeline2025

More in Data Structures, Algorithms & Small Lab Projects

View all in category
Weirdcraft

The municipal department of curiosities: hand-built games, physics toys, and a gallery that re-hangs itself every midnight.

© 2026 WEIRDCRAFT · Municipal Dept. of Curiosities

Free admission · No trackers · Open all night