[R9] Find consultation by doctor or patient and date use case classes

This commit is contained in:
Mirna Gama 2024-01-13 17:29:02 -03:00 committed by Mirna Gama
parent 7ba358eb58
commit b0fc5bf648
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package com.mirna.hospitalmanagementapi.application.usecase.consultation;
import java.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.mirna.hospitalmanagementapi.domain.entities.Consultation;
import com.mirna.hospitalmanagementapi.domain.repositories.ConsultationRepository;
/**
* This class is used to execute the findConsultationByDoctorAndDate method from consultation repository
*
* @author Mirna Gama
* @version 1.0
*/
@Component
public class FindConsultationByDoctorAndDateUseCase {
@Autowired
private ConsultationRepository consultationRepository;
/**
* Executes the findConsultationByDoctorAndDate method from Doctor repository
*
* @param doctorId The doctor's id from the consultation
* @param consultationDate The date of the consultation
* @return The corresponding consultation if successful, or null if it is non-existent
*
*/
public Consultation execute(Long doctorId, LocalDateTime consultationDate) {
return this.consultationRepository.findConsultationByDoctorAndDate(doctorId, consultationDate);
}
}

View File

@ -0,0 +1,34 @@
package com.mirna.hospitalmanagementapi.application.usecase.consultation;
import java.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.mirna.hospitalmanagementapi.domain.entities.Consultation;
import com.mirna.hospitalmanagementapi.domain.repositories.ConsultationRepository;
/**
* This class is used to execute the findConsultationByPatientAndDate method from consultation repository
*
* @author Mirna Gama
* @version 1.0
*/
@Component
public class FindConsultationByPatientAndDateUseCase {
@Autowired
private ConsultationRepository consultationRepository;
/**
* Executes the findConsultationByPatientAndDate method from Doctor repository
*
* @param patientId The patient's id from the consultation
* @param consultationDate The date of the consultation
* @return The corresponding consultation if successful, or null if it is non-existent
*
*/
public Consultation execute(Long patientId, LocalDateTime consultationDate) {
return this.consultationRepository.findConsultationByPatientAndDate(patientId, consultationDate);
}
}