本文整理汇总了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>();
}
}
示例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());
}
示例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));
}
示例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;
}
}
示例5: AssertContentLocationPresentAndValid
public static void AssertContentLocationPresentAndValid(FhirClient client)
{
if (String.IsNullOrEmpty(client.LastResponseDetails.ContentLocation))
TestResult.Fail("Mandatory Content-Location header missing");
AssertContentLocationValidIfPresent(client);
}
示例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";
}
}
示例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");
}
示例8: TimelineManager
public TimelineManager(string apiBaseUrl)
{
var client = new FhirClient(new Uri(apiBaseUrl));
_patientManager = new PatientManager(client);
_timelineBuilder = new TimelineBuilder(client);
}
示例9: AllergyIntolerance
public AllergyIntolerance(string fhirServer)
{
if (String.IsNullOrEmpty(fhirServer))
throw new Exception("Invalid URL passed to AllergyIntolerance Constructor");
fhirClient = new FhirClient(fhirServer);
}
示例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);
}
示例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()));
}
示例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);
}
示例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());
}
示例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);
}
示例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/");
}