Skip to content

DeibydBarragan/eps-spring-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPS SPRING BOOT REST-API

Hi, mi name is Deibyd and this is my project to manage patients, doctors and appointments of an EPS.

Prerequisite

You have to install these tools

Features and Functionalities

  • Get a list of the appointments, patients and doctors from the database and their information
  • Create new appointments, patients and doctors in a PostgreSQL database
  • Update appointments, patients and doctors
  • Delete appointments, patients and doctors
  • Filter appointments by patient's cedula and doctor's cedula and filter by speciality

Tech Stack

Data model

Data model

Installation and running

1. Clone this repo by running the following commands

git clone https://github.com/DeibydBarragan/eps-spring-rest-api.git

2. Then, go to the root folder and install the dependencies

cd eps-spring-rest-api

mvn clean install

3. Configure the application.properties file in eps-spring-rest-api/src/main/resources/application.properties with these values

spring.datasource.url = *YOUR POSTGRESQL DATABASE URL*
spring.datasource.username = *YOUR POSTGRESQL DATABASE USERNAME*
spring.datasource.password = *YOUR POSTGRESQL DATABASE PASSWORD*
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql = true

4. Then, go to the root folder and run the following command

mvn spring-boot:run

now you can test the API with Postman or another client with this url http://localhost:8080/api

5. Then, in another terminal go to the root folder and run the following

cd webui

npm install

6. Add a .env.local file with the following

NEXT_PUBLIC_API_URL=http://localhost:8080/api

7. Now run the following command

npm run dev

Then go to http://localhost:3000 and use the frontend app

Build and run the backend API with Docker

To execute the backend app (with the postgreSQL database) in a docker container:

  1. Make sure you have docker installed on your system

  2. Configure the application.properties file in eps-spring-rest-api/src/main/resources/application.properties exactly like this

    spring.datasource.url = ${DATABASE_URL}
    spring.datasource.username = ${DATABASE_USERNAME}
    spring.datasource.password = ${DATABASE_PASSWORD}
    spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
    spring.jpa.hibernate.ddl-auto = update
    spring.jpa.show-sql = true
    
  3. Open the root directory in the terminal and run the following

    mvn clean package
  4. Then execute the following command

    docker-compose build java_app
    
  5. Then run the following command:

    docker compose up
    

Now you can use the api from http://localhost:8080/api and the database from http://localhost:5432

Build and run the frontend APP with Docker

To execute the frontend app in a docker container:

  1. Make sure you have docker installed on your system, also make sure that you have the backend API running and the .env.local file configured with the port of the backend API

  2. Open the webui root directory in the terminal

  3. Execute the following command

    docker build -t eps-client-api .
    
  4. Then run the following command:

    docker run --env-file=./.env.local -p 3000:3000 eps-client-api:latest
    

Now you can use the frontend app in http://localhost:3000

How to use the backend API?

Patients API

Create a patient

Endpoint: POST /api/patients

Body example
{
  "name": "Deibyd Santiago",
  "lastname": "Barragán Gaitán",
  "cedula": 1069445930,
  "age": 19,
  "email": "deibydbarragan@hotmail.com",
  "phone": 3134828849
}
Example
postPatient.mp4

Update a patient

Endpoint: PUT /api/patients/{id}

Params
  • id (required): patient id.
Body

Use the same fields as creating a patient.

Example
updatePatient.mp4

Delete a patient

Endpoint: DELETE /api/patients/{id}

Params
  • id (required): patient id.
Example
deletePatient.mp4

Get and paginate patients

Endpoint: GET /api/patients

Query params
  • size (optional): limit the number of patients in every page.
  • page (optional): bring patients of a specific page.
Example
getAndPaginatePatients.mp4

Doctors API

Create a doctor

Endpoint: POST /api/doctors

Body example
{
  "name": "Pablo",
  "lastname": "Casas MejĂ­a",
  "cedula": 221345443,
  "specialty": "CardiologĂ­a",
  "office": 205,
  "email": "pablomejia@hotmail.com",
  "phone": 3134828849
}
Example
postDoctor.mp4

Update a doctor

Endpoint: PUT /api/doctors/{id}

Params
  • id (required): doctor id.
Body

Use the same fields as creating a doctor

Example
updateDoctor.mp4

Delete a doctor

Endpoint: DELETE /api/doctors/{id}

Params
  • id (required): patient id.
Example
deleteDoctor.mp4

Get all doctors without pagination and filter them by speciality

Endpoint: GET /api/doctors/all

Query params
  • specialty (optional): value must between 0 and 7. Filter doctors by their speciality.
Example
AllDoctorsAndFilterBySpecialty.mp4

Get and paginate doctors

Endpoint: GET /api/doctors

Query params
  • size (optional): limit the number of doctors in every page.
  • page (optional): bring doctors of a specific page.
Example
getAndPaginateDoctors.mp4

Appointments API

Create an appointment

Endpoint: POST /api/appointments

Body example
{
    "patientId": 4,
    "doctorId": 2,
    "date": "2023-09-15T06:30:00.0"
}
  • date (required): It must be a date in 'YYYY-MM-DDTHH:MM:SS.0' format. The time must be in 24 hours and 30 minutes format and the date must be in the future.
Example
postAppointment.mp4

Update an appointment

Endpoint: PUT /api/appointments/{id}

Params
  • id (required): appointment id.
Body

Use the same fields as creating an appointment.

Example
updateAppointment.mp4

Delete an appointment

Endpoint: DELETE /api/appointments/{id}

Params
  • id (required): appointment id.
Example
deleteAppointment.mp4

Get appointments by patient's cedula

Endpoint: GET /api/appointments/patient/{cedula}

Params
  • cedula (required): patient's cedula.
Example
getByPatientCedula.mp4

Get appointments by doctor's cedula

Endpoint: GET /api/appointments/doctor/{cedula}

Params
  • cedula (required): doctor's cedula.
Example
getByDoctorCedula.mp4

Get and paginate appointments

Endpoint: GET /api/appointments

Query params
  • specialty (optional): Get appointments by specialty.
Example (getting and paginating)
getAndPaginateAppointments.mp4
Example (filtering appointments)
filterAppointmentsBySpecialty.mp4

How to use the frontend API?

For patients

patients.mp4

For doctors

doctors.mp4

For appointments

appointments.mp4

Additionally, this project uses:

For Backend

For frontend

About

This is a Spring REST API project to manage doctors, patients and appointments of an EPS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages