finalizare 1.0
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.QuerriesMedicalHistories;
|
||||
|
||||
public class QuerriesMedicalHistoriesHandler(IMedicalHistoryRepository medicalHistoryRepository)
|
||||
{
|
||||
public async Task<BaseResponse> HandleGetAll(CancellationToken token)
|
||||
{
|
||||
var documents = await medicalHistoryRepository.GetAllAsync(token);
|
||||
if (documents.Any())
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Retrieved medical histories",
|
||||
Data = documents.ToList()
|
||||
};
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NoContent,
|
||||
Message = "Medical histories not found",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> HandleGet(Guid id, CancellationToken token)
|
||||
{
|
||||
var medicalHistory = await medicalHistoryRepository.GetByIdAsync(id, token);
|
||||
if (medicalHistory != null)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Medical history successfully retrieved",
|
||||
Data = medicalHistory
|
||||
};
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Medical history not found in system.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> HandleGetByPatientId(Guid patientId, CancellationToken token)
|
||||
{
|
||||
var medicalHistory = await medicalHistoryRepository.GetByPatientIdAsync(patientId, token);
|
||||
if (medicalHistory != null)
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Medical history successfully retrieved",
|
||||
Data = medicalHistory
|
||||
};
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Medical history not found in system.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user