[R8] Deactivate patient method in service class

This commit is contained in:
Mirna Gama 2024-01-10 16:53:15 -03:00 committed by Mirna Gama
parent 7c37127366
commit d8704c1fcf
2 changed files with 30 additions and 0 deletions

View File

@ -140,4 +140,26 @@ public class PatientServiceImpl implements PatientService {
return patient;
}
/**
* Deactivates an existing patient record by provided id
*
* @param id Long that represents the patient's unique identifier
*
* @return The deactivated patient if successful, or throws an
* EntityNotFoundException if it is non-existent.
* @throws EntityNotFoundException When patient with id provided is non-existent
*/
@Override
public Patient deactivatePatient(Long id) throws EntityNotFoundException {
Patient patient = findPatientById.execute(id);
if (patient == null) {
throw new EntityNotFoundException();
}
patient.setActive(false);
return savePatient.execute(patient);
}
}

View File

@ -49,4 +49,12 @@ public interface PatientService {
* @return The updated patient if successful, or null if there is an error.
*/
public Patient updatePatient(PatientUpdatedDataDTO patientUpdatedDataDTO);
/**
* Deactivates an existing patient record by provided id
* @param id Long that represents the patient's unique identifier
*
* @return The deactivated patient if successful, or null if there is an error.
*/
public Patient deactivatePatient(Long id);
}