public void WhenResourceRead()
        {
            var createdModelOnTheServer = _fhirClient.Create(_observation);
            var domainResource          = _fhirClient.Read <DomainResource>($"{_observation.GetType().Name}/{createdModelOnTheServer.Id}");

            Assert.NotNull(domainResource);
            AssertHelper.CheckStatusCode(HttpStatusCode.OK, _fhirClient.LastResult.Status);
        }
Ejemplo n.º 2
0
        public static void SearchThenAssertResult(FhirClient client, DomainResource resource, SearchParams searchParams)
        {
            Bundle.EntryComponent entry = null;

            // Retry because depending on how the server is implemented, there could be a slight lag between when an object is created and when it's indexed and available for search.
            int retryCount = 0;

            while (retryCount < 5)
            {
                var bundle = client.Search(searchParams, resource.GetType().Name);

                Assert.NotNull(bundle);

                while (bundle.NextLink != null)
                {
                    // Find the resource from the bundle
                    entry = bundle.FindEntry($"{client.Endpoint}{resource.GetType().Name}/{resource.Id}").FirstOrDefault();

                    if (entry != null)
                    {
                        break;
                    }

                    bundle = client.Continue(bundle);
                }

                if (entry == null)
                {
                    // Find the resource from the bundle
                    entry = bundle.FindEntry($"{client.Endpoint}{resource.GetType().Name}/{resource.Id}").FirstOrDefault();
                }

                if (entry != null)
                {
                    break;
                }

                Thread.Sleep(2000);
                retryCount++;
            }

            Assert.NotNull(entry);
            AssertHelper.CheckStatusCode(HttpStatusCode.OK, client.LastResult.Status);
        }
Ejemplo n.º 3
0
        public static String GetUrl(this DomainResource domainResource)
        {
            switch (domainResource)
            {
            case StructureDefinition sDef:
                return(sDef.Url);

            case CodeSystem codeSys:
                return(codeSys.Url);

            case ValueSet valueSet:
                return(valueSet.Url);

            default:
                throw new NotImplementedException($"Can not get value on unimplemented type {domainResource.GetType().Name}");
            }
        }
Ejemplo n.º 4
0
        public static FHIRVersion?GetFhirVersion(this DomainResource domainResource)
        {
            switch (domainResource)
            {
            case StructureDefinition sDef:
                return(sDef.FhirVersion);

            case CodeSystem codeSys:
            case ValueSet valueSet:
                return(null);

            default:
                throw new NotImplementedException($"Can not get value on unimplemented type {domainResource.GetType().Name}");
            }
        }