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);
        }
        public void CreatePatientWithExtension()
        {
            Patient selena = Utils.NewPatient("Gomez", "Selena");

            selena.AddAddress("Cornett", "Amanda", "United States", "Texas", "Grand Prairie");

            Uri qualifier = new Uri("http://hl7.org/fhir/Profile/iso-21090#qualifier");

            selena.Contact[0].Name.AddExtension(qualifier, new Code("AC"));

            ResourceEntry <Patient> entry = client.Create(selena, null, false);
            string id = entry.GetBasicId();

            //entry = null;
            entry = client.Read <Patient>(entry.GetBasicId());

            var extensions = entry.Resource.Contact[0].Name.GetExtensions(qualifier);

            if (extensions == null || extensions.Count() == 0)
            {
                TestResult.Fail("Extensions have disappeared on resource " + Location);
            }

            if (!extensions.Any(ext => ext.Value is Code && ((Code)ext.Value).Value == "AC"))
            {
                TestResult.Fail("Resource extension was not persisted on created resource " + entry.GetBasicId());
            }
        }
Пример #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);
            }
        }
Пример #4
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);
        }