Skip to content

okturan/Veterinary-Management-System-API

Repository files navigation

Veterinary Management API

Overview

The Veterinary Management API is a backend service designed for managing various aspects of a veterinary clinic.

Getting Started

Prerequisites

  • Java 17
  • Maven
  • PostgreSQL

Start PostgreSQL Server

Create a new db with the following details:

    spring:
      datasource:
        url: jdbc:postgresql://localhost:5432/veterinary_management
        username: postgres
        password: postgres

Fill Mock Data (automatic)

The application includes a DataLoader class that automatically populates the database with mock data upon startup. This class is responsible for creating sample owners, animals, doctors, availabilities, vaccines, and vaccinations, making it easier to test the API without needing to manually enter data.

Project is by default set to:

ddl-auto: create-drop

This ensures each time the application is run there is identical mock data for testing purposes.

Overview

This API includes functionalities for managing owners, animals, doctors, appointments, availabilities, vaccines, and vaccinations.

Features

  • Owner Management: Create, update, delete, and retrieve owners of pets.
  • Animal Management: Manage animals, including their details and associated vaccinations.
  • Doctor Management: Handle doctors' information and their availability for appointments.
  • Appointment Scheduling: Schedule and manage appointments between doctors and animals.
  • Vaccination Tracking: Keep track of vaccinations for animals, including due dates and vaccine details.
  • Availability Management: Manage doctors' availability for appointments.

Technologies Used

  • Spring Boot: A framework for building Java-based web applications.
  • Spring Data JPA: For data persistence and database interactions.
  • PostgreSQL: A relational database management system used for storing data.
  • MapStruct: A code generator for bean mapping.
  • Lombok: To reduce boilerplate code in Java classes.
  • Maven: For project management and build automation.

Veterinary Clinic Database Schema

Veterinary clinic entity-relationship diagram

API Endpoints

Base URL

http://localhost:8080/api

Owners

Create Owner
  • URL: /owners
  • Method: POST
  • Request Body:
    {
      "name": "John Doe",
      "phone": "555-1234",
      "email": "john.doe@example.com",
      "address": "123 Main St",
      "city": "City 1"
    }
Get Owner by ID
  • URL: /owners/{id}
  • Method: GET
Get All Owners
  • URL: /owners
  • Method: GET
  • Query Parameters:
    • name (optional): Filter by name
Update Owner
  • URL: /owners/{id}
  • Method: PUT
  • Request Body:
    {
      "name": "John Doe",
      "phone": "555-1234",
      "email": "john.doe@example.com",
      "address": "123 Main St",
      "city": "City 1"
    }
Delete Owner
  • URL: /owners/{id}
  • Method: DELETE
Add Animal to Owner
  • URL: /owners/{id}/animals
  • Method: POST
  • Request Body:
    {
      "name": "Rex",
      "species": "Dog",
      "breed": "Labrador",
      "gender": "Male",
      "colour": "Black",
      "dateOfBirth": "2020-01-01"
    }

Animals

Create Animal
  • URL: /animals
  • Method: POST
  • Request Body:
    {
      "name": "Rex",
      "species": "Dog",
      "breed": "Labrador",
      "gender": "Male",
      "colour": "Black",
      "dateOfBirth": "2020-01-01"
    }
Get Animal by ID
  • URL: /animals/{id}
  • Method: GET
Get All Animals
  • URL: /animals
  • Method: GET
  • Query Parameters:
    • name (optional): Filter by name
Update Animal
  • URL: /animals/{id}
  • Method: PUT
  • Request Body:
    {
      "name": "Rex",
      "species": "Dog",
      "breed": "Labrador",
      "gender": "Male",
      "colour": "Black",
      "dateOfBirth": "2020-01-01"
    }
Delete Animal
  • URL: /animals/{id}
  • Method: DELETE
Get Vaccinations by Animal ID
  • URL: /animals/{id}/vaccinations
  • Method: GET
Create Vaccination for Animal
  • URL: /animals/{id}/vaccinations
  • Method: POST
  • Request Body:
    {
      "vaccineId": 1,
      "vaccinationDate": "2023-01-01"
    }

Doctors

Create Doctor
  • URL: /doctors
  • Method: POST
  • Request Body:
    {
      "name": "Dr. John Smith",
      "phone": "555-1234",
      "email": "dr.john@example.com",
      "address": "123 Main St",
      "city": "City 1"
    }
Get Doctor by ID
  • URL: /doctors/{id}
  • Method: GET
Get All Doctors
  • URL: /doctors
  • Method: GET
Update Doctor
  • URL: /doctors/{id}
  • Method: PUT
  • Request Body:
    {
      "name": "Dr. John Smith",
      "phone": "555-1234",
      "email": "dr.john@example.com",
      "address": "123 Main St",
      "city": "City 1"
    }
Delete Doctor
  • URL: /doctors/{id}
  • Method: DELETE
Add Availability to Doctor
  • URL: /doctors/{doctorId}/availabilities
  • Method: POST
  • Request Body:
    {
      "date": "2023-12-01"
    }

Appointments

Create Appointment
  • URL: /appointments
  • Method: POST
  • Request Body:
    {
      "doctorId": 1,
      "animalId": 1,
      "appointmentDate": "2023-12-01T14:00:00"
    }
Get Appointment by ID
  • URL: /appointments/{id}
  • Method: GET
Get All Appointments
  • URL: /appointments
  • Method: GET
  • Query Parameters:
    • startDate (optional): Filter by start date
    • endDate (optional): Filter by end date
    • doctorId (optional): Filter by doctor ID
    • animalId (optional): Filter by animal ID
Update Appointment
  • URL: /appointments/{id}
  • Method: PUT
  • Request Body:
    {
      "doctorId": 1,
      "animalId": 1,
      "appointmentDate": "2023-12-01T14:00:00"
    }
Delete Appointment
  • URL: /appointments/{id}
  • Method: DELETE

Availabilities

Create Availability
  • URL: /availabilities
  • Method: POST
  • Request Body:
    {
      "doctorId": 1,
      "date": "2023-12-01"
    }
Get Availability by ID
  • URL: /availabilities/{id}
  • Method: GET
Get All Availabilities
  • URL: /availabilities
  • Method: GET
  • Query Parameters:
    • doctorId (optional): Filter by doctor ID
Update Availability
  • URL: /availabilities/{id}
  • Method: PUT
  • Request Body:
    {
      "doctorId": 1,
      "date": "2023-12-01"
    }
Delete Availability
  • URL: /availabilities/{id}
  • Method: DELETE

Vaccines

Create Vaccine
  • URL: /vaccines
  • Method: POST
  • Request Body:
    {
      "name": "Rabies Vaccine",
      "code": "RV-01",
      "efficacyPeriod": "P1Y"
    }
Get Vaccine by ID
  • URL: /vaccines/{id}
  • Method: GET
Get All Vaccines
  • URL: /vaccines
  • Method: GET
  • Query Parameters:
    • name (optional): Filter by name
Update Vaccine
  • URL: /vaccines/{id}
  • Method: PUT
  • Request Body:
    {
      "name": "Rabies Vaccine",
      "code": "RV-01",
      "efficacyPeriod": "P1Y"
    }
Delete Vaccine
  • URL: /vaccines/{id}
  • Method: DELETE

Vaccinations

Create Vaccination
  • URL: /vaccinations
  • Method: POST
  • Request Body:
    {
      "vaccineId": 1,
      "animalId": 1,
      "vaccinationDate": "2023-01-01"
    }
Get Vaccination by ID
  • URL: /vaccinations/{id}
  • Method: GET
Get All Vaccinations
  • URL: /vaccinations
  • Method: GET
Get Expiring Vaccinations
  • URL: /vaccinations/expiring
  • Method: GET
  • Query Parameters:
    • start (required): Start date for the range
    • end (required): End date for the range
Update Vaccination
  • URL: /vaccinations/{id}
  • Method: PUT
  • Request Body:
    {
      "vaccineId": 1,
      "animalId": 1,
      "vaccinationDate": "2023-01-01"
    }
Delete Vaccination
  • URL: /vaccinations/{id}
  • Method: DELETE

About

A Spring Boot application for managing veterinary services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages