Ejemplo n.º 1
0
        public async Task CanAddPatient()
        {
            //Arrange
            var createPatientVm = new CreatePatientVm {
                Name = "PatientX",
                Age  = 13
            };
            var dbContext = GetDbContext(nameof(CanAddPatient));
            var sut       = new ClinicService(dbContext);

            //Action
            await sut.AddPatientAsync(createPatientVm);

            //Assert
            var eavEntity = await dbContext.Entities
                            .AsNoTracking()
                            .WithAttributes()
                            .SingleAsync();

            eavEntity.Should().NotBeNull();
            eavEntity.EntityType.Should().Be(EntityType.Patient);

            eavEntity.AttributeValues.Should()
            .NotBeNullOrEmpty()
            .And.HaveCount(2);

            var name = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientName).Value;

            name.Should().Be(createPatientVm.Name);

            var age = eavEntity.AttributeValues.Single(x => x.AttributeType == AttributeType.PatientAge).Value;

            age.Should().Be(createPatientVm.Age.ToString());
        }
Ejemplo n.º 2
0
        public Task AddPatientAsync(CreatePatientVm patientDto)
        {
            var patient = new EavEntity {
                Id              = Guid.NewGuid(),
                EntityType      = EntityType.Patient,
                AttributeValues = new List <AttributeValueEntity> {
                    new AttributeValueEntity {
                        AttributeType = AttributeType.PatientName, Value = patientDto.Name
                    },
                    new AttributeValueEntity
                    {
                        AttributeType = AttributeType.PatientAge, Value = patientDto.Age.ToString()
                    },
                }
            };

            _dbContext.Entities.Add(patient);

            return(_dbContext.SaveChangesAsync());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreateNewPatient(CreatePatientVm createPatientVm)
        {
            await _clinicService.AddPatientAsync(createPatientVm);

            return(Ok());
        }