Exemplo n.º 1
0
        public void WithVersion()
        {
            var identity    = new ResourceIdentity("http://localhost/some/sub/path/fhir/Patient/B256/");
            var newIdentity = identity.WithVersion("3141");

            Assert.AreEqual("B256", newIdentity.Id);
            Assert.AreEqual("3141", newIdentity.VersionId);

            identity    = new ResourceIdentity("http://localhost/some/sub/path/fhir/Organization/3/_history/X98");
            newIdentity = identity.WithVersion("3141");

            Assert.AreEqual("3", newIdentity.Id);
            Assert.AreEqual("3141", newIdentity.VersionId);

            identity    = new ResourceIdentity("Organization/3");
            newIdentity = identity.WithVersion("3141");
            Assert.AreEqual("3", newIdentity.Id);
            Assert.AreEqual("3141", newIdentity.VersionId);

            identity    = new ResourceIdentity("Organization/3/_history/X98");
            newIdentity = identity.WithVersion("3141");
            Assert.AreEqual("3", newIdentity.Id);
            Assert.AreEqual("3141", newIdentity.VersionId);

            var identity2 = identity.WithoutVersion();

            Assert.AreEqual("Organization/3", identity2.ToString());
        }
Exemplo n.º 2
0
        public void UsingResourceIdentity()
        {
            ResourceIdentity ri = ResourceIdentity.Build(
                new Uri("http://sqlonfhir.azurewebsites.net/fhir"),
                "Patient", "45", "1");

            Trace.WriteLine(ri.WithoutVersion().OriginalString);
        }
Exemplo n.º 3
0
        public void CreateAndFullRepresentation()
        {
            FhirClient client = new FhirClient(testEndpoint);

            client.ReturnFullResource = true;       // which is also the default

            var pat             = client.Read <Patient>("Patient/example");
            ResourceIdentity ri = pat.ResourceIdentity().WithBase(client.Endpoint);

            pat.Id = null;
            pat.Identifier.Clear();
            var patC = client.Create <Patient>(pat);

            Assert.IsNotNull(patC);

            client.ReturnFullResource = false;
            patC = client.Create <Patient>(pat);

            Assert.IsNull(patC);

            if (client.LastBody != null)
            {
                var returned = client.LastBodyAsResource;
                Assert.IsTrue(returned is OperationOutcome);
            }

            // Now validate this resource
            client.ReturnFullResource = true;       // which is also the default
            Parameters p = new Parameters();

            //  p.Add("mode", new FhirString("create"));
            p.Add("resource", pat);
            OperationOutcome ooI = (OperationOutcome)client.InstanceOperation(ri.WithoutVersion(), "validate", p);

            Assert.IsNotNull(ooI);
        }