Skip to content

A Spring Boot-based Emergency Room Management System that prioritizes patient care based on urgency using a priority queue, with a responsive front end and RESTful API integration.

Notifications You must be signed in to change notification settings

PrayasKar/OS_Project

Repository files navigation

Emergency Room Management System

This project is a Spring Boot-based Emergency Room Management System that uses a priority queue to manage patient check-ins based on urgency levels. The front end is designed with HTML, CSS, and JavaScript, while the back end is powered by Java and Spring Boot, utilizing JPA for database interactions.

Overview

The system allows users to:

  • Check in patients with details such as name, date of birth, medical condition, and urgency level.
  • Attend to patients based on the urgency of their condition.
  • View a log of all attended patients.

Features

  • Priority Queue: Patients are attended to based on urgency, ensuring that the most critical cases are handled first.
  • REST API: Provides endpoints for patient check-in, attendance, and viewing the patient log.
  • Spring Boot Integration: Facilitates a robust back end with RESTful services.
  • Responsive Front-End: Designed using HTML, CSS, and JavaScript for an interactive and user-friendly experience.
  • Database Integration: Uses JPA with an in-memory H2 database (or configurable to MySQL) for storing patient information.

Technologies Used

  • Java (Spring Boot)
  • Spring Data JPA
  • HTML5, CSS3, JavaScript
  • Thymeleaf (for template rendering, if needed)
  • PriorityQueue (Java Collection Framework)
  • H2 Database (in-memory, or configurable to MySQL/PostgreSQL)

API Endpoints

  • POST /api/checkin: Check in a new patient.
  • GET /api/attend: Attend the next patient (highest priority).
  • GET /api/log: View the log of all attended patients.

Screenshots

Emergency Room System Screenshot

Explanation for Each Java File

1. EmergencyRoomApplication.java

This is the main class that launches the Spring Boot application. The @SpringBootApplication annotation marks it as the entry point for the Spring framework. When you run this file, it starts the embedded server (Tomcat) and initializes the application context. It enables Spring Boot’s auto-configuration and component scanning. By default, it looks for components in the same package and sub-packages.

2. Patient.java (Model)

This file defines the Patient class, which serves as a model representing the patient data in the system. It includes fields such as id, firstName, lastName, dateOfBirth, medicalCondition, urgency, and timeAttended. The class provides getter and setter methods, and it uses the @Entity annotation to map the class to a table in a database. This model is critical as it represents the core data entity used across the system.

3. PatientRepository.java (Repository)

This is a repository interface for the Patient entity. It extends JpaRepository to provide basic CRUD (Create, Read, Update, Delete) operations and query methods for the patient data. Spring Data JPA automatically implements this interface, making it easier to interact with the database without writing manual queries.

4. PatientController.java (Controller)

This is the controller class that handles HTTP requests from the front end. It uses @RestController to define RESTful API endpoints that interact with the PatientService. The class provides mappings for various routes such as checking in a patient (POST /api/checkin), attending a patient (GET /api/attend), and viewing the patient log (GET /api/log). This class plays a crucial role in the interaction between the front-end client and the back-end logic.

5. PatientService.java (Service)

This service class contains the business logic for the emergency room system. It defines methods such as checkInPatient, attendPatient, and getPatientLog, which are used by the controller to process user requests. The service interacts with the PatientRepository to perform database operations. By keeping the logic here, the code maintains a clean separation between the controller and the core business logic.

6. PatientComparator.java

This class defines the logic for comparing two patients based on their urgency levels. It implements Comparator<Patient> and is used by the priority queue to sort patients, ensuring that those with higher urgency are attended to first. This is a key part of the algorithm that drives the patient attendance order in the system.

About

A Spring Boot-based Emergency Room Management System that prioritizes patient care based on urgency using a priority queue, with a responsive front end and RESTful API integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published