diff --git a/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByDoctorAndDateUseCase.java b/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByDoctorAndDateUseCase.java new file mode 100644 index 0000000..d629f1d --- /dev/null +++ b/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByDoctorAndDateUseCase.java @@ -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); + } +} diff --git a/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByPatientAndDateUseCase.java b/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByPatientAndDateUseCase.java new file mode 100644 index 0000000..301cdfc --- /dev/null +++ b/src/main/java/com/mirna/hospitalmanagementapi/application/usecase/consultation/FindConsultationByPatientAndDateUseCase.java @@ -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); + } +}