Class PatientServiceImpl
java.lang.Object
com.mirna.hospitalmanagementapi.application.services.PatientServiceImpl
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPatient(PatientDTO patientDTO) Adds a new patient to the database.Deactivates an existing patient record by provided idfindPatientById(Long id) Finds a stored patient by id.org.springframework.data.domain.Page<PatientPublicDataDTO>findPatients(org.springframework.data.domain.Pageable pageable) Finds patients from the database.updatePatient(PatientUpdatedDataDTO patientUpdatedDataDTO) Updates an existing patient record
-
Constructor Details
-
PatientServiceImpl
public PatientServiceImpl()
-
-
Method Details
-
addPatient
Adds a new patient to the database.- Specified by:
addPatientin interfacePatientService- 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
Finds a stored patient by id.- Specified by:
findPatientByIdin interfacePatientService- 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:
findPatientsin interfacePatientService- 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
Updates an existing patient record- Specified by:
updatePatientin interfacePatientService- 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.
-
deactivatePatient
Deactivates an existing patient record by provided id- Specified by:
deactivatePatientin interfacePatientService- Parameters:
id- Long that represents the patient's unique identifier- Returns:
- The deactivated patient if successful, or throws an EntityNotFoundException if it is non-existent.
- Throws:
jakarta.persistence.EntityNotFoundException- When patient with id provided is non-existent
-