A Patient Priority Management System developed as a Data Structures and Algorithms (DSA) project, aimed at prioritizing patient care based on illness severity, age, and other criteria. This project simulates a hospital's patient management and room allocation system, utilizing multiple data structures to efficiently manage patient flow, room vacancies, and patient data.
In healthcare facilities, managing patient priority and room allocation can be a challenging task, especially during high-demand times. This project addresses this by developing a Patient Priority Management System that:
- Prioritizes patients based on severity, age, and arrival time.
- Allocates rooms based on availability and proximity.
- Provides patient search capabilities by unique ID and condition.
This project leverages multiple data structures to ensure optimal efficiency and response times for each feature.
- Patient Prioritization: Patients are sorted and retrieved based on severity, age, and arrival time using a min-heap priority queue.
- Room Allocation: Rooms are allocated based on vacancy and shortest path using graph traversal.
- Search by ID or Condition: Enables quick search of patients by their unique ID or condition using a Binary Search Tree.
- Manage Same-Severity Patients: Lists patients with the same severity, ordered by arrival time.
- Patient Log: Maintains a record of admitted and discharged patients.
-
Min-Heap Priority Queue
- Purpose: Manages patient priority based on severity, age, and arrival time.
- Implementation: Python's
heapq
library, with patients stored in a list and sorted by custom comparison operators.
-
Graph (Adjacency List)
- Purpose: Represents hospital rooms and corridors, with nodes as rooms and edges as corridors.
- Implementation:
RoomNode
objects store room connections and vacancies. Shortest path is found using Dijkstra’s algorithm.
-
Binary Search Tree (BST)
- Purpose: Stores patients by unique ID for efficient searching.
- Implementation: Standard BST structure with patient nodes containing IDs for fast retrieval and lookup.
-
add_patient(self, patient)
- Description: Adds a new patient to the priority queue.
- Returns: None
-
admit_patient(self, patient)
- Description: Finds the nearest vacant room from "Reception" and assigns it to the patient.
- Returns: None
-
discharge_patient(self, room_id)
- Description: Frees a room and removes the patient from the priority queue.
- Returns: None
-
find_nearest_vacant_room(self, start_room_id)
- Description: Uses Dijkstra's algorithm to find the nearest vacant room from the starting point.
- Returns:
RoomNode
(nearest vacant room)
-
remove_patient(self, patient_id)
- Description: Removes a patient from the priority queue.
- Returns: None
-
display_patients_in_priority_order(self)
- Description: Prints all patients in the priority queue in ascending order.
- Returns: None
-
room_assigned(self)
- Description: Displays the current room assignments and vacancy status.
- Returns: None
add_patient(self, patient)
: O(log n) - Insertion in a min-heap requires maintaining heap order.admit_patient(self, patient)
: O(E + V log V) - Uses Dijkstra's algorithm to find the nearest vacant room, where V is the number of rooms and E is the number of corridors.discharge_patient(self, room_id)
: O(n) - Rebuilds the heap after removing a patient, requiring traversal of all patients in the priority queue.find_nearest_vacant_room(self, start_room_id)
: O(E + V log V) - Dijkstra's algorithm for finding the shortest path to a vacant room.remove_patient(self, patient_id)
: O(n) - Searches and rebuilds the heap after removing a patient by ID.display_patients_in_priority_order(self)
: O(n log n) - Displays patients in priority order, requiring sorting of the min-heap.room_assigned(self)
: O(V) - Traverses the list of rooms to display assignments, where V is the number of rooms.
This project is licensed under the MIT License - see the LICENSE file for details.