Example #1
0
        private void initialize()
        {
            id         = "sprink" + new Random().Next().ToString();
            location   = "Patient/" + id;
            CreateDate = DateTimeOffset.Now;

            Patient patient = DemoData.GetDemoPatient();
            ResourceEntry <Patient> entry;

            entry = client.Create <Patient>(patient, id, null, true);
            Versions.Add(entry.SelfLink);

            entry.Resource.Telecom.Add(new Contact()
            {
                System = Contact.ContactSystem.Email, Value = "*****@*****.**"
            });

            entry = client.Update <Patient>(entry, refresh: true);
            Versions.Add(entry.SelfLink);

            entry = client.Update <Patient>(entry, refresh: true);
            Versions.Add(entry.SelfLink);

            client.Delete(location);
        }
Example #2
0
        public void ValidateCreateResource()
        {
            Patient patient = DemoData.GetDemoPatient();

            OperationOutcome oo;

            if (!client.TryValidateCreate(patient, out oo, null))
            {
                TestResult.Fail("Validation incorrectly reported failure.");
            }
        }
Example #3
0
        public void ValidateUpdateResource()
        {
            Patient patient = DemoData.GetDemoPatient();
            ResourceEntry <Patient> result = client.Create <Patient>(patient);

            OperationOutcome oo;

            if (!client.TryValidateUpdate(result, out oo))
            {
                TestResult.Fail("Validation incorrectly reported failure.");
            }
        }
Example #4
0
        public void TestTagsOnCreateAndRead()
        {
            var tags = new List <Tag>()
            {
                new Tag(NUTAG, Tag.FHIRTAGSCHEME_GENERAL, "readTagTest")
            };
            var patient = DemoData.GetDemoPatient();

            HttpTests.AssertSuccess(client, () => latest = client.Create(patient, tags, true));

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

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

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

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

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

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

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

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

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

            original = latest;
        }
Example #5
0
        public void ValidateInvalidCreateResource()
        {
            Patient patient = DemoData.GetDemoPatient();

            patient.Identifier = new List <Identifier> {
                new Identifier {
                    System = new Uri("urn:oid:hallo")
                }
            };

            OperationOutcome oo;

            if (!client.TryValidateCreate(patient, out oo, null))
            {
                TestResult.Fail("Validation incorrectly reported failure.");
            }
        }
        private Uri tryCreatePatient(FhirClient client, ResourceFormat formatIn, string id = null)
        {
            client.PreferredFormat = formatIn;
            ResourceEntry <Patient> created = null;

            Patient demopat = DemoData.GetDemoPatient();

            if (id == null)
            {
                HttpTests.AssertSuccess(client, () => created = client.Create <Patient>(demopat));
            }
            else
            {
                HttpTests.AssertSuccess(client, () => created = client.Create <Patient>(demopat, id));

                var ep = new RestUrl(client.Endpoint);
                if (!ep.IsEndpointFor(created.Id))
                {
                    TestResult.Fail("Location of created resource is not located within server endpoint");
                }

                var rl = new ResourceIdentity(created.Id);
                if (rl.Id != id)
                {
                    TestResult.Fail("Server refused to honor client-assigned id");
                }
            }

            HttpTests.AssertLocationPresentAndValid(client);

            // Create bevat geen response content meer. Terecht verwijderd?:
            // EK: Niet helemaal, er is weliswaar geen data meer gereturned, maar de headers (id, versie, modified) worden
            // nog wel geupdate
            HttpTests.AssertContentLocationValidIfPresent(client);

            return(created.SelfLink);
        }