Class DoctorServiceImpl

java.lang.Object
com.mirna.hospitalmanagementapi.application.services.DoctorServiceImpl
All Implemented Interfaces:
DoctorService

@Service public class DoctorServiceImpl extends Object implements DoctorService
This class is an implementation of the DoctorService interface. This class provides methods to perform operations on doctors
Version:
1.0
Author:
Mirna Gama
  • Constructor Details

    • DoctorServiceImpl

      public DoctorServiceImpl()
  • Method Details

    • addDoctor

      public Doctor addDoctor(DoctorDTO doctorDTO)
      Adds a new doctor to the database.
      Specified by:
      addDoctor in interface DoctorService
      Parameters:
      doctorDTO - A data transfer object containing the data for Doctor entity.
      Returns:
      The saved doctor if successful, or null if there is an error.
    • findDoctorById

      public Doctor findDoctorById(Long id) throws jakarta.persistence.EntityNotFoundException
      Finds a stored doctor by id.
      Specified by:
      findDoctorById in interface DoctorService
      Parameters:
      id - A long representing the doctor's unique identifier
      Returns:
      The corresponding doctor if successful, or throws an EntityNotFoundException if it is non-existent.
      Throws:
      jakarta.persistence.EntityNotFoundException - When doctor with id provided is non-existent
    • findDoctors

      public org.springframework.data.domain.Page<DoctorPublicDataDTO> findDoctors(org.springframework.data.domain.Pageable pageable)
      Finds doctors from the database.
      Specified by:
      findDoctors in interface DoctorService
      Parameters:
      pageable - Pagination information, such as size and page number
      Returns:
      A paginated sublist containing data transfer objects with doctors public information in the repository
    • updateDoctor

      public Doctor updateDoctor(DoctorUpdatedDataDTO doctorUpdatedDataDTO) throws jakarta.persistence.EntityNotFoundException
      Updates an existing doctor record
      Specified by:
      updateDoctor in interface DoctorService
      Parameters:
      doctorUpdatedDataDTO - Data transfer object containing the doctor updated data along with their corresponding id
      Returns:
      The updated doctor if successful, or throws an EntityNotFoundException if it is non-existent.
      Throws:
      jakarta.persistence.EntityNotFoundException - When doctor with id provided is non-existent
    • deactivateDoctor

      public Doctor deactivateDoctor(Long id) throws jakarta.persistence.EntityNotFoundException
      Deactivates an existing doctor record by provided id
      Specified by:
      deactivateDoctor in interface DoctorService
      Parameters:
      id - Long that represents the doctor's unique identifier
      Returns:
      The deactivated doctor if successful, or throws an EntityNotFoundException if it is non-existent.
      Throws:
      jakarta.persistence.EntityNotFoundException - When doctor with id provided is non-existent