Skip to content

Graduation training project at Banque Misr. Our team developed a backend Hospital Management System using Spring Boot, with secure role-based access, doctor & patient management, pharmacy & medicine modules, appointment scheduling, and prescription handling. The system also includes extensive unit/integration tests, Docker support, and logging.

Notifications You must be signed in to change notification settings

IsraaXx/Hospital-System-Backend

Repository files navigation

🏥 Hospital Management System (Spring Boot)

📌 Overview

The Hospital Management System is a secure RESTful backend built with Spring Boot to manage hospital operations including patients, doctors, pharmacies, and administrators.
It implements role-based access control, secure messaging (doctor–patient only), and CRUD features for hospital workflows.


👥 Roles

  • Admin → Manage all accounts (doctor, patient, pharmacy).
  • Doctor → Manage patients, assign prescriptions, message patients.
  • Patient → Register, book appointments, message doctor, buy medicines.
  • Pharmacy → Manage medicine inventory.

✨ Features

  • 🔑 JWT-based authentication & authorization
  • 📅 Appointment booking & management
  • 💊 Prescription and medicine management
  • 💬 Secure doctor–patient messaging (non real-time)
  • 🧾 Medicine orders & pharmacy stock control
  • ⚙️ Role-based access restrictions

🛠 Tech Stack

  • Backend: Spring Boot (Web, JPA, Security, Validation, Lombok)
  • Database: MySQL (H2 for tests)
  • Auth: Spring Security + JWT
  • Build: Maven
  • Testing: JUnit 5 + Mockito
  • Deployment: Docker & Docker Compose

📂 Project Structure

Hospital-System/
│── ERD/                     # ERD diagram
│── logs/                    # Application logs
│── src/
│   ├── main/
│   │   ├── java/com/example/Hospital_System/
│   │   │   ├── config/        # SecurityConfig (Spring Security configuration)
│   │   │   ├── controller/    # REST Controllers
│   │   │   ├── dto/           # Data Transfer Objects
│   │   │   ├── exception/     # Custom exceptions
│   │   │   ├── mapper/        # Entity <-> DTO mappers
│   │   │   ├── model/         # JPA Entities
│   │   │   ├── repository/    # Spring Data JPA Repositories
│   │   │   ├── response/      # Response wrappers (e.g., ErrorResponse)
│   │   │   ├── security/      # JWT filters, utils
│   │   │   ├── service/       # Business logic services
│   │   │   └── HospitalSystemApplication.java
│   │   └── resources/         # application.properties & configs
│   └── test/                  # Unit & Integration tests
│── Dockerfile                 # Docker image config
│── docker-compose.yml         # Multi-service setup
│── pom.xml                    # Maven dependencies

⚙️ Setup & Installation

✅ Prerequisites

  • Java 17+
  • Maven 3+
  • MySQL 8+
  • IDE (IntelliJ IDEA, Eclipse, or VS Code)
  • Docker & Docker Compose (optional for containerization)

1️⃣ Clone the project

git clone https://github.com/IsraaXx/Hospital-System-Backend.git
cd Hospital-System-Backend

2️⃣ Configure Database

src/main/resources/application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/Hospital_System
spring.datasource.username= USERNAME
spring.datasource.password= PASSWORD

3️⃣ Build & Run

mvn clean install
mvn spring-boot:run

📌 API Endpoints

🔑 Authentication

  • POST /auth/register → Register new user
  • POST /auth/login → Login & receive JWT

👨‍⚕️ Doctor

  • GET /doctors/{doctorId}/patients → View all doctor patients
  • POST /doctor/prescriptions → Assign prescription
  • POST /doctors/appointments/follow-up → Add follow up notes
  • GET /doctors/{doctorId}/patients/{patientId}/history → View patient history with that doctor

🧑‍🤝‍🧑 Patient

  • POST /patient/doctors/schedules → get Available Doctor Schedules
  • POST /patient/medicines → get Available Medicines

💊 Pharmacy

  • POST /pharmacy/pharmacy{Id}/medicines → Add medicine
  • GET /pharmacy/pharmacy{Id}/medicines → List medicines
  • GET /pharmacy/pharmacy{Id}/medicines/medicine{Id} → get medicine by id
  • Put /pharmacy/pharmacy{Id}/medicines/medicine{Id} → update medicine by id
  • Patch /pharmacy/pharmacy{Id}/medicines/medicine{Id}/stock → update medicine stock by id
  • Delete /pharmacy/pharmacy{Id}/medicines/medicine{Id} → delete medicine by id

💬 Messaging

  • POST /messages → Send message (doctor ↔ patient only)
  • GET /messages/conversation?userAId=1&userBId=2 → Get conversation

📅 Appointments

  • POST /appointments → Book a new appointment
  • GET /appointments?doctorId={doctorId}&start={startDateTime}&end={endDateTime}→ List a doctor’s appointments in a given time window
  • PATCH /appointments/{appointmentId}/cancel → Cancel an existing appointment

🧪 Testing

Run all unit & integration tests:

mvn test
  • Uses JUnit 5 + Mockito
  • In-memory H2 database for fast testing

🐳 Docker & Deployment

Build Docker Image

docker build -t hospital-system .

Run with Docker Compose

docker-compose up --build

📊 ERD

Hospital ERD

About

Graduation training project at Banque Misr. Our team developed a backend Hospital Management System using Spring Boot, with secure role-based access, doctor & patient management, pharmacy & medicine modules, appointment scheduling, and prescription handling. The system also includes extensive unit/integration tests, Docker support, and logging.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published