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


C# FhirClient类代码示例

本文整理汇总了C#中FhirClient的典型用法代码示例。如果您正苦于以下问题:C# FhirClient类的具体用法?C# FhirClient怎么用?C# FhirClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FhirClient类属于命名空间,在下文中一共展示了FhirClient类的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: InvokeExpandExistingValueSet

 public void InvokeExpandExistingValueSet()
 {
     var client = new FhirClient(testEndpoint);
     var vs = client.ExpandValueSet(ResourceIdentity.Build("ValueSet","administrative-gender"));
     
     Assert.IsTrue(vs.Expansion.Contains.Any());
 }
开发者ID:012345789,项目名称:fhir-net-api,代码行数:7,代码来源:OperationsTests.cs

示例3: 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

示例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: AssertContentLocationPresentAndValid

        public static void AssertContentLocationPresentAndValid(FhirClient client)
        {
            if (String.IsNullOrEmpty(client.LastResponseDetails.ContentLocation))
                TestResult.Fail("Mandatory Content-Location header missing");

            AssertContentLocationValidIfPresent(client);
        }
开发者ID:nagyistoce,项目名称:furore-sprinkler,代码行数:7,代码来源:HttpTests.cs

示例6: btnSearchPatient_Click

        // When btnSearchPatient is clicked, search patient
        private void btnSearchPatient_Click(object sender, EventArgs e)
        {
            // Edit status text
            searchStatus.Text = "Searching...";
            
            // Set FHIR endpoint and create client
            var endpoint = new Uri("http://fhirtest.uhn.ca/baseDstu2");
            var client = new FhirClient(endpoint);

            // Search endpoint with a family name, input from searchFamName
            var query = new string[] { "family=" + searchFamName.Text };
            Bundle result = client.Search<Patient>(query);

            // Edit status text
            searchStatus.Text = "Got " + result.Entry.Count() + " records!";
            
            // Clear results labels
            label1.Text = "";
            label2.Text = "";

            // For every patient in the result, add name and ID to a label
            foreach (var entry in result.Entry)
            {
                Patient p = (Patient)entry.Resource;
                label1.Text = label1.Text + p.Id + "\r\n";
                label2.Text = label2.Text + p.BirthDate + "\r\n";
            }
        }
开发者ID:nagyistoce,项目名称:JawboneToFHIRMapper,代码行数:29,代码来源:Form1.cs

示例7: Register

        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if(ModelState.IsValid)
            {
                var client = new FhirClient(Constants.HapiFhirServerBase);
                var fhirResult = client.Create(new Hl7.Fhir.Model.Patient() { });
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FhirPatientId = fhirResult.Id };
                var result = await UserManager.CreateAsync(user, model.Password);
                if(result.Succeeded)
                {
                    await UserManager.AddToRolesAsync(user.Id, Enum.GetName(typeof(AccountLevel), model.Account_Level));
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }
            // If we got this far, something failed, redisplay form
            return View(viewName: "Register");
        }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:26,代码来源:RegisterController.cs

示例8: TimelineManager

        public TimelineManager(string apiBaseUrl)
        {
            var client = new FhirClient(new Uri(apiBaseUrl));

            _patientManager = new PatientManager(client);
            _timelineBuilder = new TimelineBuilder(client);
        }
开发者ID:nagyistoce,项目名称:PatientTimelineFhir,代码行数:7,代码来源:TimelineManager.cs

示例9: AllergyIntolerance

        public AllergyIntolerance(string fhirServer)
        {
            if (String.IsNullOrEmpty(fhirServer))
                throw new Exception("Invalid URL passed to AllergyIntolerance Constructor");

            fhirClient = new FhirClient(fhirServer);
           
        }
开发者ID:EhrgoHealth,项目名称:CS6440,代码行数:8,代码来源:AllergyIntolerance.cs

示例10: InvokeLookupCode

        public void InvokeLookupCode()
        {
            var client = new FhirClient(testEndpoint);
            var expansion = client.ConceptLookup(new Code("male"), new FhirUri("http://hl7.org/fhir/administrative-gender"));

            //Assert.AreEqual("male", expansion.GetSingleValue<FhirString>("name").Value);  // Returns empty currently on Grahame's server
            Assert.AreEqual("Male", expansion.GetSingleValue<FhirString>("display").Value);
        }
开发者ID:012345789,项目名称:fhir-net-api,代码行数:8,代码来源:OperationsTests.cs

示例11: AssertResourceResponseConformsTo

        public static void AssertResourceResponseConformsTo(FhirClient client, ContentType.ResourceFormat format)
        {
            AssertValidResourceContentTypePresent(client);

            var type = client.LastResponseDetails.ContentType;
            if(ContentType.GetResourceFormatFromContentType(type) != format)
               TestResult.Fail(String.Format("{0} is not acceptable when expecting {1}", type, format.ToString()));
        }
开发者ID:nagyistoce,项目名称:furore-sprinkler,代码行数:8,代码来源:HttpTests.cs

示例12: 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

示例13: 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

示例14: InvokeLookupCoding

        public void InvokeLookupCoding()
        {
            var client = new FhirClient(testEndpoint);
            var coding = new Coding("http://hl7.org/fhir/administrative-gender", "male");

            var expansion = client.ConceptLookup(coding);

            Assert.AreEqual("AdministrativeGender", expansion.GetSingleValue<FhirString>("name").Value);
            Assert.AreEqual("Male", expansion.GetSingleValue<FhirString>("display").Value);               
        }
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:10,代码来源:OperationsTests.cs

示例15: 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/");
        }
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:10,代码来源:Form1.cs


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