Esempio n. 1
0
        public void TestConstructFailedWithPlaceOfDeath()
        {
            var birthPlaceExtension = this.m_serviceManager.CreateInjected <BirthPlaceExtension>();
            var birthPlace          = new Place
            {
                Addresses = new List <EntityAddress>
                {
                    new EntityAddress(AddressUseKeys.HomeAddress, "25 Tindale Crt", "Hamilton", "Ontario", "Canada", "L9K 6C7")
                },
                Names = new List <EntityName>
                {
                    new EntityName(NameUseKeys.Search, "25 Tindale Crt, Hamilton, Ontario, Canada, L9K 6C7")
                }
            };

            var patient = new SanteDB.Core.Model.Roles.Patient
            {
                Relationships = new List <EntityRelationship>
                {
                    new EntityRelationship(EntityRelationshipTypeKeys.PlaceOfDeath, birthPlace)
                }
            };

            var constructedBirthPlace = birthPlaceExtension.Construct(patient).ToArray();

            Assert.IsNotNull(constructedBirthPlace);
            Assert.IsFalse(constructedBirthPlace.Any());
        }
Esempio n. 2
0
        public void TestBirthPlaceExtensionConstructValidRoleBirthPlace()
        {
            var birthPlaceExtension = this.m_serviceManager.CreateInjected <BirthPlaceExtension>();
            var birthPlace          = new Place
            {
                Addresses = new List <EntityAddress>
                {
                    new EntityAddress(AddressUseKeys.HomeAddress, "25 Tindale Crt", "Hamilton", "Ontario", "Canada", "L9K 6C7")
                },
                Names = new List <EntityName>
                {
                    new EntityName(NameUseKeys.Search, "25 Tindale Crt, Hamilton, Ontario, Canada, L9K 6C7")
                }
            };

            var patient = new SanteDB.Core.Model.Roles.Patient
            {
                Relationships = new List <EntityRelationship>
                {
                    new EntityRelationship(EntityRelationshipTypeKeys.Birthplace, birthPlace)
                }
            };

            var constructedBirthPlace = birthPlaceExtension.Construct(patient).ToArray();

            Assert.IsTrue(constructedBirthPlace.Any());

            var extension = constructedBirthPlace.FirstOrDefault();

            Assert.NotNull(extension);
            Assert.IsInstanceOf <Address>(extension.Value);

            var address = extension.Value as Address;

            Assert.NotNull(address);
            Assert.IsTrue(address.Line.Any());
            Assert.AreEqual("25 Tindale Crt", address.Line.Single());
            Assert.AreEqual("Hamilton", address.City);
            Assert.AreEqual("Canada", address.Country);
            Assert.AreEqual("L9K 6C7", address.PostalCode);
            Assert.AreEqual("Ontario", address.State);
            Assert.AreEqual("25 Tindale Crt, Hamilton, Ontario, Canada, L9K 6C7", address.Text);
        }
Esempio n. 3
0
        public void TestParseWithAddressUpdatedText()
        {
            var      birthPlaceExtension = this.m_serviceManager.CreateInjected <BirthPlaceExtension>();
            var      location            = TestUtil.GetFhirMessage("CreateLocation") as Location;
            Resource actual;

            TestUtil.CreateAuthority("TEST", "1.2.3.4", "http://santedb.org/fhir/test", "TEST_HARNESS", this.AUTH);
            using (TestUtil.AuthenticateFhir("TEST_HARNESS", this.AUTH))
            {
                var locationResourceHandler = FhirResourceHandlerUtil.GetResourceHandler(ResourceType.Location);
                actual = locationResourceHandler.Create(location, TransactionMode.Commit);

                location.Address.Text = "321 New Street, Hamilton, Ontario, Canada";

                var extensionFortest = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthPlace", location.Address);
                var patient          = new SanteDB.Core.Model.Roles.Patient();

                Assert.Throws <KeyNotFoundException>(() => birthPlaceExtension.Parse(extensionFortest, patient));
            }
        }
Esempio n. 4
0
        public void TestParseAddress()
        {
            var      birthPlaceExtension = this.m_serviceManager.CreateInjected <BirthPlaceExtension>();
            var      location            = TestUtil.GetFhirMessage("CreateLocation") as Location;
            Resource actual;

            TestUtil.CreateAuthority("TEST", "1.2.3.4", "http://santedb.org/fhir/test", "TEST_HARNESS", this.AUTH);
            using (TestUtil.AuthenticateFhir("TEST_HARNESS", this.AUTH))
            {
                var locationResourceHandler = FhirResourceHandlerUtil.GetResourceHandler(ResourceType.Location);
                actual = locationResourceHandler.Create(location, TransactionMode.Commit);

                var extensionForTest = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthPlace", location.Address);
                var patient          = new SanteDB.Core.Model.Roles.Patient();

                birthPlaceExtension.Parse(extensionForTest, patient);

                Assert.IsNotNull(patient.Relationships);
                Assert.IsTrue(patient.Relationships.Count() == 1);
                Assert.IsInstanceOf <Place>(patient.Relationships.Single().TargetEntity);
                Assert.IsTrue(patient.Relationships.Single().RelationshipTypeKey == EntityRelationshipTypeKeys.Birthplace);
            }
        }