public async Task <ActionResult> GetAllPatients()
        {
            var query  = new GetAllPatientsQuery();
            var result = await Mediator.Send(query);

            return(Ok(result));
        }
Beispiel #2
0
        public async Task <ActionResult <AllPatientsReadModel> > GetAll()
        {
            var query = new GetAllPatientsQuery();
            var allDoctorsReadModel = await _getAllPatientsQueryHandler.HandleAsync(query);

            return(Ok(allDoctorsReadModel));
        }
Beispiel #3
0
        public async Task <IReadOnlyList <AllPatientsReadModel> > HandleAsync(GetAllPatientsQuery query,
                                                                              CancellationToken cancellationToken = default)
        {
            var patients = await _readModelData.GetPatientTablesAsync(cancellationToken);

            return(patients.Select(x => new AllPatientsReadModel
            {
                PatientId = x.PatientId,
                Name = x.Name
            }).ToList());
        }
Beispiel #4
0
        public async Task <IEnumerable <PatientDto> > Handle(GetAllPatientsQuery request, CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Entering {nameof(GetAllPatientsQueryHandler)}");

            var patients = await _context.Patient
                           .Paginate(request)
                           .OrderBy(p => p.Surname)
                           .Include(md => md.MedicalDetail)
                           .ToListAsync(cancellationToken);

            return(_mapper.Map <IEnumerable <PatientDto> >(patients));
        }
        public async Task <IEnumerable <PatientModel> > Handle(GetAllPatientsQuery request, CancellationToken cancellationToken)
        {
            var patients = await _repository.GetPatientsAsync();

            return(patients.Select(patient => new PatientModel()
            {
                Id = patient.Id,
                Names = patient.Names,
                Surnames = patient.Surnames,
                Age = patient.Age,
                Birthday = patient.Birthday,
                Allergies = patient.Allergies.Select(a => new AllergyModel()
                {
                    Id = a.Id,
                    Name = a.Name
                })
            }));
        }
Beispiel #6
0
        public async Task PatientsControllerGet_ValidGetAllPatientsQuery_GetsAllPatients()
        {
            var mediatorMock = Substitute.For <IMediator>();
            var loggerMock   = Substitute.For <ILogger <PatientsController> >();
            var patients     = new Fixture().CreateMany <PatientDto>(3).ToList();

            mediatorMock.Send(Arg.Any <GetAllPatientsQuery>()).Returns(patients);
            GetAllPatientsQuery getAllPatientsQuery = new GetAllPatientsQuery();
            var sut = new PatientsController(mediatorMock, loggerMock);

            var result = await sut.Get(getAllPatientsQuery);

            var okResult = result as OkObjectResult;

            Assert.IsNotNull(okResult);
            Assert.That(okResult.StatusCode, Is.EqualTo(200));
            Assert.That((okResult.Value as List <PatientDto>), Is.EquivalentTo(patients));
            await mediatorMock.Received(1).Send(Arg.Any <GetAllPatientsQuery>());

            loggerMock.Received(1);
        }
Beispiel #7
0
        public async Task <IActionResult> Get([FromQuery] GetAllPatientsQuery query)
        {
            _logger.LogInformation($"Entering {nameof(Get)}");

            return(Ok(await _mediator.Send(query)));
        }