[R6] Find patients method in patient service class
This commit is contained in:
parent
d6b269f169
commit
3b7437f654
@ -1,11 +1,15 @@
|
||||
package com.mirna.hospitalmanagementapi.application.services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.mirna.hospitalmanagementapi.application.usecase.patient.FindPatientByIdUseCase;
|
||||
import com.mirna.hospitalmanagementapi.application.usecase.patient.FindPatientsUseCase;
|
||||
import com.mirna.hospitalmanagementapi.application.usecase.patient.SavePatientUseCase;
|
||||
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientDTO;
|
||||
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientPublicDataDTO;
|
||||
import com.mirna.hospitalmanagementapi.domain.entities.Patient;
|
||||
import com.mirna.hospitalmanagementapi.domain.services.PatientService;
|
||||
import com.mirna.hospitalmanagementapi.infra.handlers.EntityNotFoundErrorHandler;
|
||||
@ -29,6 +33,9 @@ public class PatientServiceImpl implements PatientService {
|
||||
@Autowired
|
||||
private FindPatientByIdUseCase findPatientById;
|
||||
|
||||
@Autowired
|
||||
private FindPatientsUseCase findPatients;
|
||||
|
||||
/**
|
||||
* Adds a new patient to the database.
|
||||
*
|
||||
@ -60,4 +67,16 @@ public class PatientServiceImpl implements PatientService {
|
||||
return patient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds patients from the database.
|
||||
*
|
||||
* @param pageable Pagination information, such as size and page number
|
||||
*
|
||||
* @return A paginated sublist containing data transfer objects with patients public information in the repository
|
||||
*/
|
||||
@Override
|
||||
public Page<PatientPublicDataDTO> findPatients(Pageable pageable) {
|
||||
return findPatients.execute(pageable).map(PatientPublicDataDTO::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package com.mirna.hospitalmanagementapi.domain.services;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientDTO;
|
||||
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientPublicDataDTO;
|
||||
import com.mirna.hospitalmanagementapi.domain.entities.Patient;
|
||||
|
||||
/**
|
||||
@ -28,4 +32,13 @@ public interface PatientService {
|
||||
*/
|
||||
public Patient findPatientById(Long id);
|
||||
|
||||
/**
|
||||
* Retrieves a paginated sublist of doctors.
|
||||
*
|
||||
* @param pageable Pagination information, such as size and page number
|
||||
*
|
||||
* @return A paginated sublist containing data transfer objects with patients public information in the repository
|
||||
*/
|
||||
public Page<PatientPublicDataDTO> findPatients(Pageable pageable);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user