Java console application for CMPS347 Data Structures at Beirut Arab University. It simulates hospital reception and treatment waiting lines. Educational project only — not for real medical decisions.
The program uses two custom data structures, both built with our own linked nodes (no Java collection classes):
- ArrivalQueue — a first-in, first-out (FIFO) queue. New patients join at the rear and the first arrival moves next.
- TreatmentPriorityQueue — a sorted linked priority queue. Smaller priority numbers represent higher urgency (1 = critical, 5 = non-urgent). Patients with equal priority keep the order in which they joined the treatment queue.
HospitalSystem.moveNextToTriage() connects both structures: it dequeues the next arrival and enqueues that patient in the treatment queue. treatNext() removes the highest-priority waiting patient.
- Register patients with ID, name, age, reason for visit, and urgency level
- Search or delete a patient by ID in either queue
- Display both queues and their current sizes
- Move patients from reception into the treatment priority queue
- Treat the most urgent patient first
- Reject invalid patient data and duplicate IDs currently in either queue
| File | Purpose |
|---|---|
Patient.java |
Patient data and priority descriptions |
ArrivalNode.java, ArrivalQueue.java |
FIFO arrival queue |
TriageNode.java, TreatmentPriorityQueue.java |
Sorted priority queue |
HospitalSystem.java |
Coordinates both queues |
Main.java |
Console menu and program entry point |
Requires a Java Development Kit (JDK 8 or later). In a terminal, from the repository folder:
javac *.java
java MainIn Eclipse, create a Java Project, add the eight .java classes to the default package under src, and run Main.java as a Java Application.
The optional TestRunner.java class checks both custom queues and the workflow that connects them. Run it after compiling:
java TestRunnerThe runner prints the number of passing and failing checks and exits with an error if a check fails. Start the interactive menu with java Main.
- Register patient 101 with priority 4.
- Register patient 102 with priority 1.
- Choose the menu option to move each patient to treatment.
- Display the treatment queue: patient 102 appears before 101.
- Treat the next patient: patient 102 is treated first.
Let n be the number of patients in the relevant queue.
| Operation | Arrival queue | Treatment queue |
|---|---|---|
Insert (enqueue) |
O(1) | O(n) |
| Search by ID | O(n) | O(n) |
| Delete by ID | O(n) | O(n) |
Remove from front (dequeue) |
O(1) | O(1) |
| Display | O(n) | O(n) |
Test an empty queue, missing ID, duplicate ID, and equal-priority patients. Records exist in memory only and are lost when the program closes. The priority is manually entered for demonstration, not determined through clinical assessment.