Class PatientServiceImpl

java.lang.Object
com.mirna.hospitalmanagementapi.application.services.PatientServiceImpl
All Implemented Interfaces:
PatientService

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

    • PatientServiceImpl

      public PatientServiceImpl()
  • Method Details

    • addPatient

      public Patient addPatient(PatientDTO patientDTO)
      Adds a new patient to the database.
      Specified by:
      addPatient in interface PatientService
      Parameters:
      patientDTO - A data transfer object containing the data for Patient entity.
      Returns:
      The saved patient if successful, or null if there is an error.
    • findPatientById

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

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

      public Patient updatePatient(PatientUpdatedDataDTO patientUpdatedDataDTO)
      Updates an existing patient record
      Specified by:
      updatePatient in interface PatientService
      Parameters:
      patientUpdatedDataDTO - Data transfer object containing the patient updated data along with their corresponding id
      Returns:
      The updated patient if successful, or null if there is an error.