public void Read()
        {
            FhirClient client = new FhirClient(testEndpoint);

            var loc = client.Read<Location>("1");
            Assert.IsNotNull(loc);
            Assert.AreEqual("Den Burg", loc.Resource.Address.City);

            string version = new ResourceLocation(loc.SelfLink).VersionId;               
            Assert.AreEqual("1", version);

            string id = new ResourceLocation(loc.Id).Id;
            Assert.AreEqual("1", id);

            try
            {
                var random = client.Read<Location>("45qq54");
                Assert.Fail();
            }
            catch (FhirOperationException)
            {
                Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.NotFound);
            }

            var loc2 = client.VRead<Location>("1", version);
            Assert.IsNotNull(loc2);
            Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc),
                            FhirSerializer.SerializeBundleEntryToJson(loc2));

            var loc3 = client.Fetch<Location>(loc.SelfLink);
            Assert.IsNotNull(loc3);
            Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc),
                            FhirSerializer.SerializeBundleEntryToJson(loc3));

        }
Exemplo n.º 2
0
        public void TryReadUnknownResourceType()
        {
            ResourceLocation rl = new ResourceLocation(client.Endpoint);

            rl.Collection = "thisreallywondexist";
            rl.Id         = "1";

            HttpTests.AssertFail(client, () => client.Fetch <Patient>(rl.ToUri()), HttpStatusCode.NotFound);
        }
Exemplo n.º 3
0
        public void TestTagsOnCreateAndRead()
        {
            var tags = new List <Tag>()
            {
                new Tag(NUTAG, Tag.FHIRTAGNS, "readTagTest")
            };

            HttpTests.AssertSuccess(client, () => latest = client.Create <Patient>(DemoData.GetDemoPatient(), tags));

            if (latest.Tags == null)
            {
                TestResult.Fail("create did not return any tags");
            }

            var nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);

            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("create did not return specified tag");
            }

            var read = client.Fetch <Patient>(latest.Id);

            if (read.Tags == null)
            {
                TestResult.Fail("read did not return any tags");
            }
            nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);
            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("read did not return specified tag");
            }

            var vread = client.Fetch <Patient>(latest.SelfLink);

            if (vread.Tags == null)
            {
                TestResult.Fail("vread did not return any tags");
            }
            nutags = latest.Tags.FindByTerm(NUTAG, Tag.FHIRTAGNS);
            if (nutags.Count() != 1 || nutags.First().Label != "readTagTest")
            {
                TestResult.Fail("vread did not return specified tag");
            }

            original = latest;
        }
Exemplo n.º 4
0
        public void Read()
        {
            FhirClient client = new FhirClient(testEndpoint);

            var loc = client.Read <Location>("1");

            Assert.IsNotNull(loc);
            Assert.AreEqual("Den Burg", loc.Resource.Address.City);

            string version = new ResourceLocation(loc.SelfLink).VersionId;

            Assert.AreEqual("1", version);

            string id = new ResourceLocation(loc.Id).Id;

            Assert.AreEqual("1", id);

            try
            {
                var random = client.Read <Location>("45qq54");
                Assert.Fail();
            }
            catch (FhirOperationException)
            {
                Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.NotFound);
            }

            var loc2 = client.VRead <Location>("1", version);

            Assert.IsNotNull(loc2);
            Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc),
                            FhirSerializer.SerializeBundleEntryToJson(loc2));

            var loc3 = client.Fetch <Location>(loc.SelfLink);

            Assert.IsNotNull(loc3);
            Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc),
                            FhirSerializer.SerializeBundleEntryToJson(loc3));
        }