Ejemplo n.º 1
0
        public void TestBuild()
        {
            var id  = new ResourceIdentity("http://localhost/services/fhir/v012/Patient/3");
            var idb = ResourceIdentity.Build(new Uri("http://localhost/services/fhir/v012"), "Patient", "3");

            Assert.AreEqual("http://localhost/services/fhir/v012/Patient/3", id.ToString());
            Assert.AreEqual(id, idb);

            id  = new ResourceIdentity("Patient/3");
            idb = ResourceIdentity.Build("Patient", "3");
            Assert.AreEqual("Patient/3", id.ToString());
            Assert.AreEqual(id, idb);

            id = ResourceIdentity.Build("Patient", "A100", "H2");
            Assert.AreEqual("Patient/A100/_history/H2", id.ToString());

            id  = new ResourceIdentity("urn:oid:1.2.3.4.5.6");
            idb = ResourceIdentity.Build(UrnType.OID, "1.2.3.4.5.6");
            Assert.AreEqual("urn:oid:1.2.3.4.5.6", id.ToString());
            Assert.AreEqual(id, idb);

            id  = new ResourceIdentity("#myid");
            idb = ResourceIdentity.Build("myid");
            Assert.AreEqual("#myid", id.ToString());
            Assert.AreEqual(id, idb);
        }
Ejemplo n.º 2
0
        public void TestResourceIdentity()
        {
            ResourceIdentity id = new ResourceIdentity("http://localhost/services/fhir/v012/patient/3");

            Assert.AreEqual("http://localhost/services/fhir/v012/patient/3", id.ToString());
            Assert.AreEqual("patient", id.Collection);
        }
Ejemplo n.º 3
0
        public IElementNavigator Resolve(IElementNavigator instance, string reference)
        {
            var identity = new ResourceIdentity(reference);

            if (identity.Form == ResourceIdentityForm.RelativeRestUrl)
            {
                // Relocate the relative url on the base given in the fullUrl of the entry (if applicable)
                var fullUrl = ContextFullUrl(instance);

                if (fullUrl != null)
                {
                    var parentIdentity = new ResourceIdentity(fullUrl);
                    if (parentIdentity.BaseUri != null)
                    {
                        identity = identity.WithBase(parentIdentity.BaseUri);
                    }
                }
            }

            IElementNavigator referencedResource = null;

            if (identity.Form == ResourceIdentityForm.Local || identity.Form == ResourceIdentityForm.AbsoluteRestUrl || identity.Form == ResourceIdentityForm.Urn)
            {
                referencedResource = findUri(instance, identity.ToString());
            }

            return(referencedResource);
        }
Ejemplo n.º 4
0
        public void WithBase()
        {
            var id  = new ResourceIdentity("http://localhost/services/fhir/v012/Patient/3");
            var id1 = id.WithBase("http://nu.nl/fhir");

            Assert.AreEqual("http://nu.nl/fhir/Patient/3", id1.ToString());

            var id2 = new ResourceIdentity("Patient/3").WithBase("http://nu.nl/fhir");

            Assert.AreEqual("http://nu.nl/fhir/Patient/3", id2.ToString());

            var id3 = id2.MakeRelative();

            Assert.AreEqual("Patient/3", id3.ToString());
        }