private void AddPatientAddress(PatientAddressDto patientAddressDto, Patient patient)
        {
            var addressType         = _mappingHelper.MapLookupField <PatientAddressType> (patientAddressDto.PatientAddressType);
            var countyAreaLookup    = _mappingHelper.MapLookupField <CountyArea> (patientAddressDto.CountyArea);
            var stateProvinceLookup = _mappingHelper.MapLookupField <StateProvince> (patientAddressDto.StateProvince);
            var countryLookup       = _mappingHelper.MapLookupField <Country> (patientAddressDto.Country);

            var address = new AddressBuilder()
                          .WithFirstStreetAddress(patientAddressDto.FirstStreetAddress)
                          .WithSecondStreetAddress(patientAddressDto.SecondStreetAddress)
                          .WithCityName(patientAddressDto.CityName)
                          .WithCountyArea(countyAreaLookup)
                          .WithStateProvince(stateProvinceLookup)
                          .WithCountry(countryLookup)
                          .WithPostalCode(
                string.IsNullOrWhiteSpace(patientAddressDto.PostalCode) ? null : new PostalCode(patientAddressDto.PostalCode))
                          .Build();

            var patientAddress = new PatientAddressBuilder()
                                 .WithPatientAddressType(addressType)
                                 .WithAddress(address)
                                 .WithConfidentialIndicator(patientAddressDto.ConfidentialIndicator)
                                 .WithYearsOfStayNumber(patientAddressDto.YearsOfStayNumber)
                                 .Build();

            patient.AddAddress(patientAddress);
        }
Example #2
0
        private void BuildAlbertSmithPatient()
        {
            PersonName name = new PersonNameBuilder()
                              .WithFirst("Albert")
                              .WithLast("Smith")
                              .Build();
            PatientProfile profile = new PatientProfileBuilder()
                                     .WithBirthDate(DateTime.Parse("5/10/1971"))
                                     .WithPatientGender(MaleGender)
                                     .Build();

            AlbertSmithPatient = new Patient(SafeHarborAgency, name, profile);
            AlbertSmithPatient.UpdateUniqueIdentifier("albertsmith");

            var address = new AddressBuilder()
                          .WithFirstStreetAddress("14235 South St")
                          .WithCityName("Baltimore")
                          .WithPostalCode(new PostalCode("21075"))
                          .WithStateProvince(MarylandStateProvince)
                          .Build();

            PatientAddress albertSmithAddress = new PatientAddressBuilder()
                                                .WithPatientAddressType(HomePatientAddressType)
                                                .WithAddress(address)
                                                .Build();

            AlbertSmithPatient.AddAddress(albertSmithAddress);

            AlbertSmithPatient.AddPhoneNumber(new PatientPhone(HomePatientPhoneType, "555-255-5454"));

            var patientRace = new PatientRace(WhiteRace);

            AlbertSmithPatient.AddPatientRace(patientRace);
            AlbertSmithPatient.SetPrimaryRace(WhiteRace);

            AlbertSmithPatient.AddAlias(new PatientAlias(NicknamePatientAliasType, "Al-bear"));

            AlbertSmithPatient.AddPatientDisability(new PatientDisability(DeafDisability));

            Session.SaveOrUpdate(AlbertSmithPatient);
        }
Example #3
0
        public void AddAddress_GivenDuplicate_ValidationFailureEventIsRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var eventRaised = false;
                DomainEvent.Register <RuleViolationEvent>(p => eventRaised = true);

                var agencyMock = new Mock <Agency>();
                var name       = new PersonNameBuilder()
                                 .WithFirst("Albert")
                                 .WithLast("Smith");

                var address = new AddressBuilder()
                              .WithFirstStreetAddress("123 Test Street")
                              .WithCityName("Testville")
                              .WithStateProvince(new StateProvince())
                              .WithPostalCode(new PostalCode("12345"))
                              .Build();

                var patientAddress = new PatientAddressBuilder()
                                     .WithPatientAddressType(new PatientAddressType())
                                     .WithAddress(address)
                                     .Build();

                var patient = new Patient(agencyMock.Object, name, new PatientProfileBuilder().Build());
                patient.AddAddress(patientAddress);

                // Exercise
                patient.AddAddress(patientAddress);

                // Verify
                Assert.IsTrue(eventRaised);
            }
        }