public void InvokeExpandExistingValueSet() { var client = new FhirClient(testEndpoint); var vs = client.ExpandValueSet(ResourceIdentity.Build("ValueSet","administrative-gender")); Assert.IsTrue(vs.Expansion.Contains.Any()); }
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>(); } }
// 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"; } }
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; } }
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"); }
public TimelineManager(string apiBaseUrl) { var client = new FhirClient(new Uri(apiBaseUrl)); _patientManager = new PatientManager(client); _timelineBuilder = new TimelineBuilder(client); }
public static void AssertContentLocationPresentAndValid(FhirClient client) { if (String.IsNullOrEmpty(client.LastResponseDetails.ContentLocation)) TestResult.Fail("Mandatory Content-Location header missing"); AssertContentLocationValidIfPresent(client); }
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)); }
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); }
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())); }
public AllergyIntolerance(string fhirServer) { if (String.IsNullOrEmpty(fhirServer)) throw new Exception("Invalid URL passed to AllergyIntolerance Constructor"); fhirClient = new FhirClient(fhirServer); }
public AllergyIntolerance(string fhirServer, ApplicationUserManager userManager, IAuthenticationManager authManager) { if(String.IsNullOrEmpty(fhirServer)) throw new Exception("Invalid URL passed to AllergyIntolerance Constructor"); fhirClient = new FhirClient(fhirServer); this.userManager = userManager; this.authManager = authManager; }
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); }
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/"); }
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()); }
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); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); var entry = client.Conformance(); Assert.IsNotNull(entry); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, entry.Rest[0].Mode.Value); Assert.AreEqual(HttpStatusCode.OK.ToString(), client.LastResult.Status); }
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)); }
public static void AssertSuccess(FhirClient client, Action action) { try { action(); } catch (FhirOperationException foe) { TestResult.Fail(foe, String.Format("Call failed (http result {0})", client.LastResponseDetails.Result)); } }
[TestMethod, Ignore] //Server throws error: Access violation at address 000000000129D56C in module 'FHIRServer.exe'. Read of address 0000000000000000 public void InvokeTestPatientGetEverything() { var client = new FhirClient(testEndpoint); var start = new FhirDateTime(2014,11,1); var end = new FhirDateTime(2015,1,1); var par = new Parameters().Add("start", start).Add("end", end); var bundle = (Bundle)client.InstanceOperation(ResourceIdentity.Build("Patient", "1"), "everything", par); Assert.IsTrue(bundle.Entry.Any()); var bundle2 = client.FetchPatientRecord(ResourceIdentity.Build("Patient","1"), start, end); Assert.IsTrue(bundle2.Entry.Any()); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); Conformance c = client.Conformance().Resource; Assert.IsNotNull(c); Assert.AreEqual("HL7Connect", c.Software.Name); Assert.AreEqual(Conformance.RestfulConformanceMode.Server, c.Rest[0].Mode.Value); Assert.AreEqual(ContentType.XML_CONTENT_HEADER, client.LastResponseDetails.ContentType.ToLower()); Assert.AreEqual(HttpStatusCode.OK, client.LastResponseDetails.Result); }
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); }
public async Task GivenAValidBundleWithForbiddenUser_WhenSubmittingATransaction_ThenOperationOutcomeWithForbiddenStatusIsReturned() { FhirClient tempClient = Client.CreateClientForUser(TestUsers.ReadOnlyUser, TestApplications.NativeClient); var requestBundle = Samples.GetJsonSample("Bundle-TransactionWithValidBundleEntry"); var fhirException = await Assert.ThrowsAsync <FhirException>(async() => await tempClient.PostBundleAsync(requestBundle.ToPoco <Bundle>())); Assert.Equal(HttpStatusCode.Forbidden, fhirException.StatusCode); string[] expectedDiagnostics = { "Transaction failed on 'POST' for the requested url '/Patient'.", "Authorization failed." }; IssueType[] expectedCodeType = { OperationOutcome.IssueType.Processing, OperationOutcome.IssueType.Forbidden }; ValidateOperationOutcome(expectedDiagnostics, expectedCodeType, fhirException.OperationOutcome); }
public static void AssertContentLocationValidIfPresent(FhirClient client) { if (!String.IsNullOrEmpty(client.LastResponseDetails.ContentLocation)) { var rl = new ResourceLocation(client.LastResponseDetails.ContentLocation); if (rl.Id == null) TestResult.Fail("Content-Location does not have an id in it"); if (rl.VersionId == null) TestResult.Fail("Content-Location is not a version-specific url"); } }
public void TestRefresh() { var client = new FhirClient(testEndpoint); var result = client.Read <Patient>("Patient/example"); var orig = result.Name[0].FamilyElement[0].Value; result.Name[0].FamilyElement[0].Value = "overwritten name"; result = client.Refresh(result); Assert.AreEqual(orig, result.Name[0].FamilyElement[0].Value); }
public void InvokeValidateCodeWithVS() { var client = new FhirClient(FhirClientTests.TerminologyEndpoint); var coding = new Coding("http://snomed.info/sct", "4322002"); var vs = client.Read <ValueSet>("ValueSet/c80-facilitycodes"); Assert.IsNotNull(vs); var result = client.ValidateCode(valueSet: vs, coding: coding); Assert.IsTrue(result.Result?.Value == true); }
public static void Connectathon6(string url) { FhirClient client = getClient(url); TestRunner tester = new TestRunner(client, LogTest); Console.WriteLine("Running tests for CONNECTATHON 6 (may 2014)"); // Track 1 tester.Run("CR01", "CR04", "HI01", "SE01", "SE03", "SE04"); // Track 2 tester.Run("QU01", "QU02", "QU03", "QU04"); }
public static void AssertLocationPresentAndValid(FhirClient client) { if (String.IsNullOrEmpty(client.LastResponseDetails.Location)) TestResult.Fail("Mandatory Location header missing"); var rl = new ResourceLocation(client.LastResponseDetails.Location); if(rl.Id == null) TestResult.Fail("Location does not have an id in it"); if (rl.VersionId == null) TestResult.Fail("Location is not a version-specific url"); }
public void ExternalServiceValidateCodeTest() { var client = new FhirClient("http://ontoserver.csiro.au/dstu2_1"); var svc = new ExternalTerminologyService(client); // Do common tests for service testService(svc); // Any good external service should be able to handle this one var result = svc.ValidateCode("http://hl7.org/fhir/ValueSet/substance-code", code: "1166006", system: "http://snomed.info/sct"); Assert.True(result.Success); }
public static void AssertValidBundleContentTypePresent(FhirClient client) { AssertContentTypePresent(client); if (!ContentType.IsValidBundleContentType(client.LastResponseDetails.ContentType)) { TestResult.Fail("expected Atom xml or json bundle content type, but received " + client.LastResponseDetails.ContentType); } if (client.LastResponseDetails.CharacterEncoding != Encoding.UTF8) { TestResult.Fail("content type does not specify UTF8"); } }
public async Task GivenAValidBundleWithUnauthorizedUser_WhenSubmittingATransaction_ThenOperationOutcomeWithUnAuthorizedStatusIsReturned() { FhirClient tempClient = Client.CreateClientForClientApplication(TestApplications.WrongAudienceClient); var requestBundle = Samples.GetJsonSample("Bundle-TransactionWithValidBundleEntry"); var fhirException = await Assert.ThrowsAsync <FhirException>(async() => await tempClient.PostBundleAsync(requestBundle.ToPoco <Bundle>())); Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode); string[] expectedDiagnostics = { "Authentication failed." }; IssueType[] expectedCodeType = { OperationOutcome.IssueType.Login }; ValidateOperationOutcome(expectedDiagnostics, expectedCodeType, fhirException.OperationOutcome); }
public ActionResult MedicalHistory(string ID) { SearchViewModel m = new SearchViewModel(); List <ConditionViewModel> conditionList = new List <ConditionViewModel>(); var client = new FhirClient("http://fhirtest.uhn.ca/baseDstu1"); //search patients based on patientID clicked Bundle resultsPatients = client.Search <Patient>(new string[] { "_id=" + ID }); //gets patient based on ID foreach (var entry in resultsPatients.Entries) { ResourceEntry <Patient> patient = (ResourceEntry <Patient>)entry; m = getPatientInfo(patient); } Bundle resultsConditions = client.Search <Condition>(new string[] { "subject=" + ID }); foreach (var entry in resultsConditions.Entries) { ConditionViewModel conditions = new ConditionViewModel(); ResourceEntry <Condition> condition = (ResourceEntry <Condition>)entry; if (condition.Resource.Code != null) { conditions.ConditionName = condition.Resource.Code.Text; } else { conditions.ConditionName = "Unknown"; } if (condition.Resource.Onset != null) { conditions.Date = (condition.Resource.Onset as Date).Value; } else { conditions.Date = "Unknown"; } m.ConditionsCount++; conditionList.Add(conditions); } m.Conditions = conditionList; patients.Add(m); return(View(patients)); }
private IList <PatientProfile> GetPendingPatients() { List <PatientProfile> listPending = new List <PatientProfile>(); try { MongoDBWrapper dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress); List <SessionQueue> pendingSessionList = dbwrapper.GetPendingPatients(); FhirClient client = new FhirClient(sparkEndpointAddress); foreach (var pending in pendingSessionList) { string sparkAddress = sparkEndpointAddress.ToString() + "/Patient/" + pending.SparkReference; Patient pendingPatient = (Patient)client.Get(sparkAddress); PatientProfile patientProfile = new PatientProfile(pendingPatient, true); patientProfile.SessionID = pending._id; patientProfile.LocalNoID = pending.LocalReference; patientProfile.NoIDStatus = pending.ApprovalStatus; patientProfile.NoIDType = pending.PatientStatus; patientProfile.CheckinDateTime = FHIRUtilities.DateTimeToFHIRString(pending.SubmitDate); listPending.Add(patientProfile); } /* * string gtDateFormat = "gt" + FHIRUtilities.DateToFHIRString(DateTime.UtcNow.AddDays(-2)); * client.PreferredFormat = ResourceFormat.Json; * Uri uriTwoDays = new Uri(sparkEndpointAddress.ToString() + "/Patient?_lastUpdated=" + gtDateFormat); * Bundle patientBundle = (Bundle)client.Get(uriTwoDays); * foreach (Bundle.EntryComponent entry in patientBundle.Entry) * { * string ptURL = entry.FullUrl.ToString().Replace("http://localhost:49911/fhir", sparkEndpointAddress.ToString()); * Patient pt = (Patient)client.Get(ptURL); * if (pt.Meta.Extension.Count > 0) * { * Extension ext = pt.Meta.Extension[0]; * if (ext.Value.ToString().ToLower().Contains("pending") == true) * { * PatientProfile patientProfile = new PatientProfile(pt, false); * listPending.Add(patientProfile); * } * } * } */ } catch (Exception ex) { throw ex; } return(listPending); }
public void FhirVersionIsChecked() { var testEndpointDSTU2 = new Uri("http://spark-dstu2.furore.com/fhir"); var testEndpointDSTU1 = new Uri("http://spark.furore.com/fhir"); var testEndpointDSTU12 = new Uri("http://fhirtest.uhn.ca/baseDstu1"); var testEndpointDSTU22 = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var testEndpointDSTU23 = new Uri("http://fhir3.healthintersections.com.au/open"); var client = new FhirClient(testEndpointDSTU1); client.ParserSettings.AllowUnrecognizedEnums = true; Conformance p; try { client = new FhirClient(testEndpointDSTU23, verifyFhirVersion: true); client.ParserSettings.AllowUnrecognizedEnums = true; p = client.Conformance(); } catch (NotSupportedException) { //Client uses 1.0.1, server states 1.0.0-7104 } client = new FhirClient(testEndpointDSTU23); client.ParserSettings.AllowUnrecognizedEnums = true; // p = client.Conformance(); // The STU3 server conformance resource is now called CapabilityStatement. //client = new FhirClient(testEndpointDSTU2); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); //client = new FhirClient(testEndpointDSTU22, verifyFhirVersion:true); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); client = new FhirClient(testEndpointDSTU12); client.ParserSettings.AllowUnrecognizedEnums = true; try { p = client.Conformance(); Assert.Fail("Getting DSTU1 data using DSTU2 parsers should have failed"); } catch (Exception) { // OK } }
public void Search() { // an endpoint that is known to support compression FhirClient client = new FhirClient("http://sqlonfhir-dstu2.azurewebsites.net/fhir"); // testEndpoint); Bundle result; client.CompressRequestBody = true; client.OnBeforeRequest += Compression_OnBeforeRequestGZip; client.OnAfterResponse += Client_OnAfterResponse; result = client.Search <DiagnosticReport>(); client.OnAfterResponse -= Client_OnAfterResponse; Assert.IsNotNull(result); Assert.IsTrue(result.Entry.Count() > 10, "Test should use testdata with more than 10 reports"); client.OnBeforeRequest -= Compression_OnBeforeRequestZipOrDeflate; client.OnBeforeRequest += Compression_OnBeforeRequestZipOrDeflate; result = client.Search <DiagnosticReport>(pageSize: 10); Assert.IsNotNull(result); Assert.IsTrue(result.Entry.Count <= 10); client.OnBeforeRequest -= Compression_OnBeforeRequestGZip; var withSubject = result.Entry.ByResourceType <DiagnosticReport>().FirstOrDefault(dr => dr.Subject != null); Assert.IsNotNull(withSubject, "Test should use testdata with a report with a subject"); ResourceIdentity ri = withSubject.ResourceIdentity(); // TODO: The include on Grahame's server doesn't currently work //result = client.SearchById<DiagnosticReport>(ri.Id, // includes: new string[] { "DiagnosticReport:subject" }); //Assert.IsNotNull(result); //Assert.AreEqual(2, result.Entry.Count); // should have subject too //Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType == // typeof(DiagnosticReport).GetCollectionName())); //Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType == // typeof(Patient).GetCollectionName())); client.OnBeforeRequest += Compression_OnBeforeRequestDeflate; result = client.Search <Patient>(new string[] { "name=Chalmers", "name=Peter" }); Assert.IsNotNull(result); Assert.IsTrue(result.Entry.Count > 0); }
public void TestReceiveErrorStatusWithHtmlIsHandled() { var client = new FhirClient("http://spark.furore.com/"); // an address that returns Status 500 with HTML in its body try { var pat = client.Read <Patient>("Patient/1"); Assert.Fail("Failed to throw an Exception on status 500"); } catch (FhirOperationException fe) { // Expected exception happened if (fe.Status != HttpStatusCode.InternalServerError) { Assert.Fail("Server response of 500 did not result in FhirOperationException with status 500."); } if (client.LastResult == null) { Assert.Fail("LastResult not set in error case."); } if (client.LastResult.Status != "500") { Assert.Fail("LastResult.Status is not 500."); } if (!fe.Message.Contains("a valid FHIR xml/json body type was expected") && !fe.Message.Contains("not recognized as either xml or json")) { Assert.Fail("Failed to recognize invalid body contents"); } // Check that LastResult is of type OperationOutcome and properly filled. OperationOutcome operationOutcome = client.LastBodyAsResource as OperationOutcome; Assert.IsNotNull(operationOutcome, "Returned resource is not an OperationOutcome"); Assert.IsTrue(operationOutcome.Issue.Count > 0, "OperationOutcome does not contain an issue"); Assert.IsTrue(operationOutcome.Issue[0].Severity == OperationOutcome.IssueSeverity.Error, "OperationOutcome is not of severity 'error'"); string message = operationOutcome.Issue[0].Diagnostics; if (!message.Contains("a valid FHIR xml/json body type was expected") && !message.Contains("not recognized as either xml or json")) { Assert.Fail("Failed to carry error message over into OperationOutcome"); } } catch (Exception) { Assert.Fail("Failed to throw FhirOperationException on status 500"); } }
// // GET: /Patient/ public ActionResult Index(string ID) { try { SearchViewModel m = new SearchViewModel(); var client = new FhirClient("http://fhirtest.uhn.ca/baseDstu1"); //search patients based on patientID clicked Bundle resultsPatients = client.Search <Patient>(new string[] { "_id=" + ID }); //gets patient based on ID foreach (var entry in resultsPatients.Entries) { ResourceEntry <Patient> patient = (ResourceEntry <Patient>)entry; m = getPatientInfo(patient); } Bundle resultsAllergies = client.Search <AllergyIntolerance>(new string[] { "subject=" + ID }); foreach (var entry in resultsAllergies.Entries) { m.AllergiesCount++; } Bundle resultsMedications = client.Search <MedicationPrescription>(new string[] { "patient._id=" + ID }); foreach (var entry in resultsMedications.Entries) { m.MedicationCount++; } Bundle resultsConditions = client.Search <Condition>(new string[] { "subject=" + ID }); foreach (var entry in resultsConditions.Entries) { m.ConditionsCount++; } Bundle resultsDevices = client.Search <Device>(new string[] { "patient._id=" + ID }); foreach (var entry in resultsDevices.Entries) { m.DevicesCount++; } patients.Add(m); return(View(patients)); } catch { return(RedirectToAction("Index", "Home")); } }
public Procedure GetProcedureWithBodySite(FhirClient fhirClient) { Procedure procedure = new Procedure { Status = EventStatus.Completed, Subject = new ResourceReference("Patient/example"), BodySite = new List <CodeableConcept> { new CodeableConcept("http://snomed.info/sct", "272676008", "sample") } }; return(fhirClient.Create(procedure)); }
static void TestExpand() { //var json = new WebClient().DownloadString("https://r4.ontoserver.csiro.au/fhir/ValueSet/$expand?url=http://snomed.info/sct?fhir_vs=ecl/%3C394658006"); // http://snomed.info/sct?fhir_vs=ecl%2F%3C394658006&count=1000&activeOnly=true var client = new FhirClient( "https://r4.ontoserver.csiro.au/fhir/"); var p = new Parameters() .Add("url", new FhirUri("http://snomed.info/sct?fhir_vs=ecl/<394658006")) .Add("count", new Integer(1000)) .Add("activeOnly", new FhirBoolean(true)); var result = client.TypeOperation <ValueSet>("expand", p, true); }
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); }
public static void AssertFail(FhirClient client, Action action, HttpStatusCode? expected = null) { try { action(); TestResult.Fail("Unexpected success result (" + client.LastResponseDetails.Result + ")"); } catch (FhirOperationException) { if (expected != null && client.LastResponseDetails.Result != expected) TestResult.Fail(String.Format("Expected http result {0} but got {1}", expected, client.LastResponseDetails.Result)); } }
public void FallbackServiceValidateCodeTest() { var client = new FhirClient("http://ontoserver.csiro.au/dstu2_1"); var external = new ExternalTerminologyService(client); var local = new LocalTerminologyService(_resolver); var svc = new FallbackTerminologyService(local, external); testService(svc); // Now, this should fall back var result = svc.ValidateCode("http://hl7.org/fhir/ValueSet/substance-code", code: "1166006", system: "http://snomed.info/sct"); Assert.True(result.Success); }
private static FhirClient OpenFhirClient() { string PatURL = "http://hackathon.siim.org/fhir/"; var client = new FhirClient(PatURL) { PreferredFormat = ResourceFormat.Json }; client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { e.RawRequest.Headers.Add("apikey", apikey); //requires environment variable to match }; return(client); }
public FhirClient ConfigureBasicClient(string endpoint) { FhirClient fhirClient = new FhirClient(endpoint) { PreferredFormat = ResourceFormat.Json, UseFormatParam = true }; fhirClient.OnBeforeRequest += delegate(object sender, BeforeRequestEventArgs e) { e.RawRequest.Headers.Add(HttpRequestHeader.Accept, "*/*"); }; return(fhirClient); }
//{ // Patient patient = await GetPatientsHttpClient(); // // Amend the Encounter returned from comversion // return patient; //} public static Patient GetPatientFromPyroAPI(string id) { var client = new FhirClient("https://pyrowebapi.azurewebsites.net/fhir"); // Live client = new FhirClient("http://localhost:8888/fhir"); // client. Bundle bundle = client.Search <Patient>(new string[] { $"identifier=" + id }); return(bundle.Entry.First().Resource as Patient); }
static void Main(string[] args) { try { // Create fhir client https://<your box name>.aidbox.app var client = new FhirClient("https://tutorial.aidbox.app"); // Currently Aidbox doesn't support XML format // We need explicitly set it to JSON client.PreferredFormat = ResourceFormat.Json; // Subscribe OnBeforeRequest in order to set authorization header client.OnBeforeRequest += Client_OnBeforeRequest; // Create sample resource var patient = new Patient { Name = new List <HumanName> { new HumanName { Given = new List <string> { "John" }, Family = "Doe" } } }; // Create sample resource in box var newPatient = client.Create(patient); // Show identifier of newly created patient Console.WriteLine("New patient: {0}", newPatient.Id); // Read newly created patient from server var readPatient = client.Read <Patient>("Patient/" + newPatient.Id); // Show it id, given name and family Console.WriteLine("Read patient: {0} {1} {2}", readPatient.Id, readPatient.Name[0].Given.First(), readPatient.Name[0].Family); } catch (Exception e) { // Show error is something go wrong Console.WriteLine("Something go wrong: {0}", e); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
IEnumerator SendData(int weight, string postfix) { yield return(new WaitForSeconds(0.1f)); var client = new FhirClient("http://hapi.fhir.org/baseR4"); Debug.Log("TOAN111: DEVICEINFO:" + DEVICEINFO.ID.STR); Device device = client.Read <Device>("http://hapi.fhir.org/baseR4/Device/" + DEVICEINFO.ID.STR); if (device != null) { Debug.Log("TOAN113: DEVICEINFO:" + DEVICEINFO.ID.STR); //Quantity quantityValue = new Quantity(); Quantity quantityValue; if (device.Property.Count > 0 && device.Property[0].ValueQuantity.Count > 0) { quantityValue = device.Property[0].ValueQuantity[0]; } else { quantityValue = new Quantity(); } quantityValue.Value = (decimal)(weight * 0.005f); quantityValue.System = ("http://unitsofmeasure.org"); quantityValue.Code = postfix; Coding weightCoding = new Coding("http://loinc.org", "29463-7", "Body Weight"); Device.PropertyComponent weightProperty = new Device.PropertyComponent(); CodeableConcept code = new CodeableConcept(); code.Coding.Add(weightCoding); weightProperty.Type = code; weightProperty.ValueQuantity.Add(quantityValue); if (device.Property.Count == 0) { device.Property.Add(weightProperty); } else { device.Property[0] = weightProperty; } var result = client.Update(device); TW.I.AddWarning("", "Updated ID " + result.Id); } else { Debug.Log("TOAN112: DEVICEINFO:" + DEVICEINFO.ID.STR); } }
public void InvokeTestPatientGetEverything() { var client = new FhirClient(testEndpoint); var start = new FhirDateTime(2014, 11, 1); var end = new FhirDateTime(2015, 1, 1); var par = new Parameters().Add("start", start).Add("end", end); var bundle = (Bundle)client.InstanceOperation(ResourceIdentity.Build("Patient", "example"), "everything", par); Assert.IsTrue(bundle.Entry.Any()); var bundle2 = client.FetchPatientRecord(ResourceIdentity.Build("Patient", "example"), start, end); Assert.IsTrue(bundle2.Entry.Any()); }
public ActionResult SavePatient(PatientEdit patient) { var conn = new FhirClient("http://localhost:8080/baseR4"); conn.PreferredFormat = ResourceFormat.Json; Patient patientNew = conn.Read <Patient>("Patient/" + patient.id); patientNew.Name[0].Family = patient.surname; patientNew.BirthDate = patient.birthDate; patientNew.MaritalStatus.Text = patient.mStatus; conn.Update(patientNew); return(View()); }
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); }
private int loadDeathTable(FhirClient iClient, List <Patient> iPatients) { int result = 0; foreach (Patient p in iPatients) { // check to see if patient is deceased if ((FhirBoolean)p.Deceased == new FhirBoolean()) { ; } } return(result); }
public ActionResult <Bundle> GetPatients() { var settings = new FhirClientSettings { Timeout = 10, PreferredFormat = ResourceFormat.Json, VerifyFhirVersion = true, PreferredReturn = Prefer.ReturnMinimal }; var client = new FhirClient("http://fhir.healthintersections.com.au/open", settings); Bundle results = client.Search <Patient>(new string[] { "family:exact=Eve" }); return(results); }
public DomainResource GetConditionToSearchViaContent(FhirClient fhirClient) { var condition = new Condition { Text = new Narrative { Status = Narrative.NarrativeStatus.Generated, Div = "<div xmlns=\"http://www.w3.org/1999/xhtml\">bone</div>" }, ClinicalStatus = Condition.ConditionClinicalStatusCodes.Active, Subject = new ResourceReference("Patient/example") }; return(fhirClient.Create(condition)); }
public void FetchConformance() { FhirClient client = new FhirClient(testEndpoint); var entry = client.Conformance(); var c = entry.Resource; Assert.IsNotNull(c); // Assert.AreEqual("Spark.Service", c.Software.Name); // This is only for ewout's server Assert.AreEqual(Conformance.RestfulConformanceMode.Server, c.Rest[0].Mode.Value); Assert.AreEqual(HttpStatusCode.OK, client.LastResponseDetails.Result); // Does't currently work on Grahame's server Assert.AreEqual(ContentType.XML_CONTENT_HEADER, client.LastResponseDetails.ContentType.ToLower()); }
private void Form2_Load(object sender, EventArgs e) { var patientId = _patientId; var observationCode = _observationCode; var client = new FhirClient(" https://dhew.wales.nhs.uk/hapi-fhir-jpaserver-example/baseDstu3"); Bundle observationBundle = client.Search <Observation>(new string[] { $"patient={patientId}", $"code=http://wrrs.wales.nhs.uk|{observationCode}" }); // call the method to draw the graph... ChartObservations(observationBundle); }
public void ReadRelativeAsync() { FhirClient client = new FhirClient(testEndpoint); var loc = client.ReadAsync <Location>(new Uri("Location/1", UriKind.Relative)).Result; Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Resource.Address.City); var ri = ResourceIdentity.Build(testEndpoint, "Location", "1"); loc = client.ReadAsync <Location>(ri).Result; Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Resource.Address.City); }
public void ReadCallsHookedEvents() { FhirClient client = new FhirClient(testEndpoint); bool hitBeforeRequest = false; bool hitAfterRequest = false; client.OnBeforeRequest += (o, p) => hitBeforeRequest = true; client.OnAfterResponse += (o, p) => hitAfterRequest = true; var loc = client.Read("Patient/1"); Assert.IsTrue(hitBeforeRequest); Assert.IsTrue(hitAfterRequest); }
// When button 2 is clikced, create patient private void button2_Click(object sender, EventArgs e) { // Edit status text createPatientStatus.Text = "Creating..."; // Set FHIR endpoint and create client var endpoint = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var client = new FhirClient(endpoint); // Create new patient birthdate and name var pat = new Patient() {BirthDate = birthDate.Text, Name= new List<HumanName>()}; pat.Name.Add(HumanName.ForFamily(lastName.Text).WithGiven(givenName.Text)); // Upload to server //client.ReturnFullResource = true; client.Create(pat); createPatientStatus.Text = "Created!"; }
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; } }