当前位置: 首页>>代码示例>>C#>>正文


C# FhirClient.Read方法代码示例

本文整理汇总了C#中FhirClient.Read方法的典型用法代码示例。如果您正苦于以下问题:C# FhirClient.Read方法的具体用法?C# FhirClient.Read怎么用?C# FhirClient.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FhirClient的用法示例。


在下文中一共展示了FhirClient.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMedicationDataForPatientAsync

        public static async Task<List<Medication>> GetMedicationDataForPatientAsync(string patientId, FhirClient client)
        {
            var mySearch = new SearchParams();
            mySearch.Parameters.Add(new Tuple<string, string>("patient", patientId));

            try
            {
                //Query the fhir server with search parameters, we will retrieve a bundle
                var searchResultResponse = await Task.Run(() => client.Search<Hl7.Fhir.Model.MedicationOrder>(mySearch));
                //There is an array of "entries" that can return. Get a list of all the entries.
                return
                    searchResultResponse
                        .Entry
                            .AsParallel() //as parallel since we are making network requests
                            .Select(entry =>
                            {
                                var medOrders = client.Read<MedicationOrder>("MedicationOrder/" + entry.Resource.Id);
                                var safeCast = (medOrders?.Medication as ResourceReference)?.Reference;
                                if (string.IsNullOrWhiteSpace(safeCast)) return null;
                                return client.Read<Medication>(safeCast);
                            })
                            .Where(a => a != null)
                            .ToList(); //tolist to force the queries to occur now
            }
            catch (AggregateException e)
            {
                throw e.Flatten();
            }
            catch (FhirOperationException)
            {
                // if we have issues we likely got a 404 and thus have no medication orders...
                return new List<Medication>();
            }
        }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:34,代码来源:EhrBase.cs

示例2: Read

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

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

            string version = new ResourceIdentity(loc.SelfLink).VersionId;
            Assert.IsNotNull(version);
            string id = new ResourceIdentity(loc.Id).Id;
            Assert.AreEqual("1", id);

            try
            {
                var random = client.Read(new Uri("Location/45qq54", UriKind.Relative));
                Assert.Fail();
            }
            catch (FhirOperationException)
            {
                Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.NotFound);
            }

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

            var loc3 = client.Read<Location>(loc.SelfLink);
            Assert.IsNotNull(loc3);
            Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc),
                            FhirSerializer.SerializeBundleEntryToJson(loc3));        
        }
开发者ID:peterswallow,项目名称:fhir-net-api,代码行数:33,代码来源:FhirClientTests.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            var client = new FhirClient("http://spark.furore.com/fhir");

            var patient = client.Read<Patient>("Patient/1");
            lblFirstPatient.Text = String.Concat("Identifier : ", patient.Resource.Identifier.First<Identifier>().Value);

            var obeservation = client.Read<Patient>("Patient/1");
            lblFirstObservation.Text = String.Concat("Identifier : ", obeservation.Resource.Identifier.First<Identifier>().Value);

            //pat.Resource.Name.Add(HumanName.ForFamily("Kramer")
            //     .WithGiven("Ewout"));
            //client.Update<Patient>(pat);
        }
开发者ID:Ebeid,项目名称:CS440,代码行数:14,代码来源:Default.aspx.cs

示例4: GetMedicationDetails

        public async static Task<Tuple<List<Medication>, Hl7.Fhir.Model.Patient>> GetMedicationDetails(string id, ApplicationUserManager userManager)
        {
            Tuple<List<Medication>, Hl7.Fhir.Model.Patient> tup;
            using (var dbcontext = new ApplicationDbContext())
            {
                // Should be FhirID
                var user = await userManager.FindByIdAsync(id);
                if (user == null)
                {
                    return null;
                }

                var client = new FhirClient(Constants.HapiFhirServerBase);
                if (string.IsNullOrWhiteSpace(user.FhirPatientId))
                {
                    var result = client.Create(new Hl7.Fhir.Model.Patient() { });
                    user.FhirPatientId = result.Id;
                    await userManager.UpdateAsync(user);
                }
                var patient = client.Read<Hl7.Fhir.Model.Patient>(Constants.PatientBaseUrl + user.FhirPatientId);
                tup= new Tuple<List<Medication>, Patient>(await EhrBase.GetMedicationDataForPatientAsync(user.FhirPatientId, client), patient);
                return tup;
            }

        }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:25,代码来源:EhrBase.cs

示例5: ReadWithFormat

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

            client.UseFormatParam = true;
            client.PreferredFormat = ResourceFormat.Json;

            var loc = client.Read<Patient>("Patient/1");
            Assert.IsNotNull(loc);
        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:10,代码来源:FhirClientTests.cs

示例6: InvokeExpandParameterValueSet

        public void InvokeExpandParameterValueSet()
        {
            var client = new FhirClient(testEndpoint);

            var vs = client.Read<ValueSet>("ValueSet/administrative-gender");

            var vsX = client.ExpandValueSet(vs);

            Assert.IsTrue(vs.Expansion.Contains.Any());
        }
开发者ID:012345789,项目名称:fhir-net-api,代码行数:10,代码来源:OperationsTests.cs

示例7: ReadWithFormat

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

            client.UseFormatParam = true;
            client.PreferredFormat = ResourceFormat.Json;

            var loc = client.Read("Patient/1");

            Assert.AreEqual(ResourceFormat.Json, ContentType.GetResourceFormatFromContentType(client.LastResponseDetails.ContentType));
        }
开发者ID:wdebeau1,项目名称:fhir-net-api,代码行数:11,代码来源:FhirClientTests.cs

示例8: ClientForPPT

        public void ClientForPPT()
        {
            var client = new FhirClient(new Uri("http://hl7connect.healthintersections.com.au/svc/fhir/patient/"));

            // Note patient is a ResourceEntry<Patient>, not a Patient
            var patEntry = client.Read<Patient>("1");
            var pat = patEntry.Resource;

            pat.Name.Add(HumanName.ForFamily("Kramer").WithGiven("Ewout"));

            client.Update<Patient>(patEntry);
        }
开发者ID:avontd2868,项目名称:vista-novo-fhir,代码行数:12,代码来源:FhirClientTests.cs

示例9: CreateEditDelete

        public void CreateEditDelete()
        {
            var furore = new Organization
            {
                Name = "Furore",
                Identifier = new List<Identifier> { new Identifier("http://hl7.org/test/1", "3141") },
                Telecom = new List<Contact> { new Contact { System = Contact.ContactSystem.Phone, Value = "+31-20-3467171" } }
            };

            FhirClient client = new FhirClient(testEndpoint);
            var tags = new List<Tag> { new Tag("http://nu.nl/testname", Tag.FHIRTAGNS, "TestCreateEditDelete") };

            var fe = client.Create(furore,tags);

            Assert.IsNotNull(furore);
            Assert.IsNotNull(fe);
            Assert.IsNotNull(fe.Id);
            Assert.IsNotNull(fe.SelfLink);
            Assert.AreNotEqual(fe.Id,fe.SelfLink);
            Assert.IsNotNull(fe.Tags);
            Assert.AreEqual(1, fe.Tags.Count());
            Assert.AreEqual(fe.Tags.First(), tags[0]);
            createdTestOrganization = fe.Id;

            fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592"));

            var fe2 = client.Update(fe);

            Assert.IsNotNull(fe2);
            Assert.AreEqual(fe.Id, fe2.Id);
            Assert.AreNotEqual(fe.SelfLink, fe2.SelfLink);
            Assert.IsNotNull(fe2.Tags);
            Assert.AreEqual(1, fe2.Tags.Count());
            Assert.AreEqual(fe2.Tags.First(), tags[0]);

            client.Delete(fe2.Id);

            try
            {
                fe = client.Read<Organization>(ResourceLocation.GetIdFromResourceId(fe.Id));
                Assert.Fail();
            }
            catch
            {
                Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.Gone);
            }

            Assert.IsNull(fe);
        }
开发者ID:vista-novo,项目名称:fhir,代码行数:49,代码来源:FhirClientTests.cs

示例10: Read

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

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

            Assert.AreEqual("1", loc.Id);
            Assert.IsNotNull(loc.Meta.VersionId);

            var loc2 = client.Read<Location>(ResourceIdentity.Build("Location", "1", loc.Meta.VersionId));
            Assert.IsNotNull(loc2);
            Assert.AreEqual(loc2.Id, loc.Id);
            Assert.AreEqual(loc2.Meta.VersionId, loc.Meta.VersionId);

            try
            {
                var random = client.Read<Location>(new Uri("Location/45qq54", UriKind.Relative));
                Assert.Fail();
            }
            catch (FhirOperationException)
            {
                Assert.AreEqual(HttpStatusCode.NotFound.ToString(), client.LastResult.Status);
            }

            var loc3 = client.Read<Location>(ResourceIdentity.Build("Location", "1", loc.Meta.VersionId));
            Assert.IsNotNull(loc3);
            Assert.AreEqual(FhirSerializer.SerializeResourceToJson(loc),
                            FhirSerializer.SerializeResourceToJson(loc3));

            var loc4 = client.Read<Location>(loc.ResourceIdentity());
            Assert.IsNotNull(loc4);
            Assert.AreEqual(FhirSerializer.SerializeResourceToJson(loc),
                            FhirSerializer.SerializeResourceToJson(loc4));
        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:36,代码来源:FhirClientTests.cs

示例11: LoadConformanceResourceByUrl

        public Hl7.Fhir.Model.Resource LoadConformanceResourceByUrl(string url)
        {
            if (url == null) throw Error.ArgumentNull("identifier");

            var id = new ResourceIdentity(url);

            var client = new FhirClient(id.BaseUri);
            client.Timeout = 5000;  //ms

            try
            {
                return client.Read<Resource>(id);
            }
            catch(FhirOperationException)
            {
                return null;
            }            
        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:18,代码来源:WebArtifactSource.cs

示例12: btnStart_Click

        private void btnStart_Click(object sender, EventArgs e)
        {
            // Choose your preferred FHIR server or add your own
            // More at http://wiki.hl7.org/index.php?title=Publicly_Available_FHIR_Servers_for_testing

            //var client = new FhirClient("http://fhir2.healthintersections.com.au/open");
            var client = new FhirClient("http://spark.furore.com/fhir");
            //var client = new FhirClient("http://fhirtest.uhn.ca/baseDstu2");
            //var client = new FhirClient("https://fhir-open-api-dstu2.smarthealthit.org/");

            try
            {
                var obs = client.Read<Observation>("Observation/example");

                txtDisplay.Text = "Observation read, id: " + obs.Id;
            }
            catch (Exception err)
            {
                txtError.Lines = new string[] { "An error has occurred:", err.Message };
            }
        }
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:21,代码来源:Form1.cs

示例13: ReadResourceArtifact

        public Model.Resource ReadResourceArtifact(Uri artifactId)
        {
            if (artifactId == null) throw Error.ArgumentNull("artifactId");
            if (!artifactId.IsAbsoluteUri) Error.Argument("artifactId", "Uri must be absolute");

            var id = new ResourceIdentity(artifactId);

            var client = new FhirClient(id.Endpoint);
            client.Timeout = 5000;  //ms

            try
            {
                var artifactEntry = client.Read(id);

                return artifactEntry != null ? artifactEntry.Resource : null;
            }
            catch
            {
                return null;
            }
            
        }
开发者ID:wdebeau1,项目名称:fhir-net-api,代码行数:22,代码来源:WebArtifactSource.cs

示例14: CallsCallbacks

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

            bool calledBefore=false;
            HttpStatusCode? status=null;
            byte[] body = null;
            byte[] bodyOut = null;

            client.OnBeforeRequest += (sender, e) =>
                {
                    calledBefore = true;
                    bodyOut = e.Body;
                };

            client.OnAfterResponse += (sender, e) =>
                {
                    body = e.Body;
                    status = e.RawResponse.StatusCode;
                };

            var pat = client.Read<Patient>("Patient/1");
            Assert.IsTrue(calledBefore);
            Assert.IsNotNull(status);
            Assert.IsNotNull(body);

            var bodyText = HttpToEntryExtensions.DecodeBody(body, Encoding.UTF8);

            Assert.IsTrue(bodyText.Contains("<Patient"));

            calledBefore = false;
            client.Create(pat);
            Assert.IsTrue(calledBefore);
            Assert.IsNotNull(bodyOut);

            bodyText = HttpToEntryExtensions.DecodeBody(body, Encoding.UTF8);
            Assert.IsTrue(bodyText.Contains("<Patient"));

        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:39,代码来源:FhirClientTests.cs

示例15: ManipulateMeta

        public void ManipulateMeta()
        {
           FhirClient client = new FhirClient(testEndpoint);
           var pat = FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\TestPatient.xml"));
           var key = new Random().Next();
           pat.Id = "NetApiMetaTestPatient" + key;

           var meta = new Meta();
           meta.ProfileElement.Add(new FhirUri("http://someserver.org/fhir/Profile/XYZ1-" + key));
           meta.Security.Add(new Coding("http://mysystem.com/sec", "1234-" + key));
           meta.Tag.Add(new Coding("http://mysystem.com/tag", "sometag1-" + key));
           pat.Meta = meta;

          //Before we begin, ensure that our new tags are not actually used when doing System Meta()
          var wsm = client.Meta();
          Assert.IsFalse(wsm.Meta.Profile.Contains("http://someserver.org/fhir/Profile/XYZ1-" + key));
          Assert.IsFalse(wsm.Meta.Security.Select(c => c.Code + "@" + c.System).Contains("1234-" + key + "@http://mysystem.com/sec"));
          Assert.IsFalse(wsm.Meta.Tag.Select(c => c.Code + "@" + c.System).Contains("sometag1-" + key + "@http://mysystem.com/tag"));

          Assert.IsFalse(wsm.Meta.Profile.Contains("http://someserver.org/fhir/Profile/XYZ2-" + key));
          Assert.IsFalse(wsm.Meta.Security.Select(c => c.Code + "@" + c.System).Contains("5678-" + key + "@http://mysystem.com/sec"));
          Assert.IsFalse(wsm.Meta.Tag.Select(c => c.Code + "@" + c.System).Contains("sometag2-" + key + "@http://mysystem.com/tag"));


          // First, create a patient with the first set of meta
          var pat2 = client.Create(pat);
          var loc = pat2.ResourceIdentity(testEndpoint);          

          // Meta should be present on created patient
          verifyMeta(pat2.Meta, false,key);

          // Should be present when doing instance Meta()
          var par = client.Meta(loc);
          verifyMeta(par.Meta, false,key);

          // Should be present when doing type Meta()
          par = client.Meta(ResourceType.Patient);
          verifyMeta(par.Meta, false,key);

          // Should be present when doing System Meta()
          par = client.Meta();
          verifyMeta(par.Meta, false,key);

          // Now add some additional meta to the patient

          var newMeta = new Meta();
          newMeta.ProfileElement.Add(new FhirUri("http://someserver.org/fhir/Profile/XYZ2-" + key));
          newMeta.Security.Add(new Coding("http://mysystem.com/sec", "5678-" + key));
          newMeta.Tag.Add(new Coding("http://mysystem.com/tag", "sometag2-" + key));       

          
          client.AddMeta(loc, newMeta);
          var pat3 = client.Read<Patient>(loc);

          // New and old meta should be present on instance
          verifyMeta(pat3.Meta, true, key);

          // New and old meta should be present on Meta()
          par = client.Meta(loc);
          verifyMeta(par.Meta, true, key);

          // New and old meta should be present when doing type Meta()
          par = client.Meta(ResourceType.Patient);
          verifyMeta(par.Meta, true, key);

          // New and old meta should be present when doing system Meta()
          par = client.Meta();
          verifyMeta(par.Meta, true, key);

          // Now, remove those new meta tags
          client.DeleteMeta(loc, newMeta);

          // Should no longer be present on instance
          var pat4 = client.Read<Patient>(loc);
          verifyMeta(pat4.Meta, false, key);

          // Should no longer be present when doing instance Meta()
          par = client.Meta(loc);
          verifyMeta(par.Meta, false, key);

          // Should no longer be present when doing type Meta()
          par = client.Meta(ResourceType.Patient);
          verifyMeta(par.Meta, false, key);

          // clear out the client that we created, no point keeping it around
          client.Delete(pat4);

          // Should no longer be present when doing System Meta()
          par = client.Meta();
          verifyMeta(par.Meta, false, key);
        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:91,代码来源:FhirClientTests.cs


注:本文中的FhirClient.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。