private void btnfhirSearchPatient_Click(object sender, EventArgs e) { String strLastName = txtLastName.Text.ToString().TrimEnd(); String strFirstName = txtFirstName.Text.ToString().TrimEnd(); Hl7.Fhir.Rest.FhirClient client = new Hl7.Fhir.Rest.FhirClient(_fhirServerUrl); client.OnBeforeRequest += Client_OnBeforeRequest; client.PreferredFormat = Hl7.Fhir.Rest.ResourceFormat.Json; List <string> paramsList = new List <string>(); if (string.IsNullOrEmpty(strLastName) == false) { paramsList.Add("family=" + strLastName); } if (string.IsNullOrEmpty(strFirstName) == false) { paramsList.Add("given=" + strFirstName); } var bundle = client.Search <Hl7.Fhir.Model.Patient>(paramsList.ToArray()); txtPatientResponse.Text = new FhirJsonSerializer().SerializeToString(bundle); }
private void SearchPatients() { //Regular search by patient family and given name WorkingMessage(); listCandidates.Items.Clear(); string FHIR_EndPoint = this.txtFHIREndpoint.Text.ToString(); var client = new Hl7.Fhir.Rest.FhirClient(FHIR_EndPoint); try { string family = txtFamilyName.Text.ToString(); string given = txtGivenName.Text.ToString(); var p = new Hl7.Fhir.Rest.SearchParams(); p.Add("family", family); if (given != "") { p.Add("given", given); } var results = client.Search <Patient>(p); this.UseWaitCursor = false; lblErrorMessage.Text = ""; while (results != null) { if (results.Total == 0) { lblErrorMessage.Text = "No patients found"; } btnShowDevices.Enabled = true; foreach (var entry in results.Entry) { var Pat = (Patient)entry.Resource; string Fam = Pat.Name[0].Family; string Giv = Pat.Name[0].GivenElement[0].ToString(); string ideS = Pat.Identifier[0].System; string ideV = Pat.Identifier[0].Value; string Content = Fam + " " + Giv + " (" + ideS + "-" + ideV + ")"; ListViewItem l = new ListViewItem(); l.Text = Content; l.Tag = entry.Resource.Id; listCandidates.Items.Add(l); } // get the next page of results results = client.Continue(results); } } catch (Exception err) { lblErrorMessage.Text = "Error:" + err.Message.ToString(); } if (lblErrorMessage.Text != "") { lblErrorMessage.Visible = true; } }
static void Main(string[] args) { //The fhir server end point address //string ServiceRootUrl = "https://api-v5-stu3.hspconsortium.org/MX1STU3/open"; string ServiceRootUrl = "http://PyroHealth.net/test/stu3/fhir"; //Create a client to send to the server at a given endpoint. var FhirClient = new Hl7.Fhir.Rest.FhirClient(ServiceRootUrl); // increase timeouts since the server might be powered down FhirClient.Timeout = (60 * 1000); Console.WriteLine("Press any key to send to server: " + ServiceRootUrl); Console.WriteLine(); Console.ReadKey(); try { //Attempt to send the resource to the server endpoint Hl7.Fhir.Model.Bundle ReturnedSearchBundle = FhirClient.Search <Hl7.Fhir.Model.Patient>(new string[] { "family=Fhirman" }); Console.WriteLine(string.Format("Found: {0} Fhirman patients.", ReturnedSearchBundle.Total.ToString())); Console.WriteLine("Their logical IDs are:"); foreach (var Entry in ReturnedSearchBundle.Entry) { Console.WriteLine("ID: " + Entry.Resource.Id); } Console.WriteLine(); } catch (Hl7.Fhir.Rest.FhirOperationException FhirOpExec) { //Process any Fhir Errors returned as OperationOutcome resource Console.WriteLine(); Console.WriteLine("An error message: " + FhirOpExec.Message); Console.WriteLine(); string xml = Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(FhirOpExec.Outcome); XDocument xDoc = XDocument.Parse(xml); Console.WriteLine(xDoc.ToString()); } catch (Exception GeneralException) { Console.WriteLine(); Console.WriteLine("An error message: " + GeneralException.Message); Console.WriteLine(); } Console.WriteLine("Press any key to end."); Console.ReadKey(); }
public List <Patient> SearchPatients(string searchString) { var patientResults = new List <Patient>(); Hl7.Fhir.Rest.FhirClient fhirClient = FhirClientManager.CreateClientConnection(Configuration); fhirClient = FhirClientManager.CreateClientConnection(Configuration); Hl7.Fhir.Model.Bundle ReturnedSearchBundle = fhirClient.Search <Hl7.Fhir.Model.Patient>(new string[] { $"name={searchString}" }); foreach (var resource in ReturnedSearchBundle.Entry) { patientResults.Add((Patient)resource.Resource); } return(patientResults); }
public List <Prescription> FindMedication(string patientId) { var prescriptionResults = new List <Prescription>(); Hl7.Fhir.Rest.FhirClient fhirClient = FhirClientManager.CreateClientConnection(Configuration); fhirClient = FhirClientManager.CreateClientConnection(Configuration); Hl7.Fhir.Model.Bundle ReturnedSearchBundle = fhirClient.Search <Hl7.Fhir.Model.MedicationRequest>(new string[] { $"patient={patientId}" }); foreach (var resource in ReturnedSearchBundle.Entry) { var prescription = (Prescription)resource.Resource; prescriptionResults.Add(prescription); } return(prescriptionResults); }
public List <Diagnosis> FindDiagnosis(string patientId) { var diagnosticResults = new List <Diagnosis>(); Hl7.Fhir.Rest.FhirClient fhirClient = FhirClientManager.CreateClientConnection(Configuration); fhirClient = FhirClientManager.CreateClientConnection(Configuration); Hl7.Fhir.Model.Bundle ReturnedSearchBundle = fhirClient.Search <Hl7.Fhir.Model.DiagnosticReport>(new string[] { $"patient={patientId}" }); foreach (var resource in ReturnedSearchBundle.Entry) { var diagnosticReport = (DiagnosticReport)resource.Resource; foreach (var item in diagnosticReport.Contained) { diagnosticResults.Add((Diagnosis)item); } } return(diagnosticResults); }
static Hl7.Fhir.Model.Bundle GetPatient() { var baseUrl = "https://testapp.hospitalitaliano.org.ar/masterfile-federacion-service/fhir"; var client = new Hl7.Fhir.Rest.FhirClient(baseUrl); client.OnBeforeRequest += OnBeforeRequestFhirServer; client.OnAfterResponse += OnAfterResponseFhirServer; Hl7.Fhir.Model.Bundle ret = null; try { var qp = new Hl7.Fhir.Rest.SearchParams(); qp.Add("identifier", "http://www.msal.gov.ar|2222222"); ret = client.Search <Hl7.Fhir.Model.Patient>(qp); } catch (Exception ex) { Log.Error(ex.ToString()); } return(ret); }
private void SearchDevices(string PatientId) { WorkingMessage(); //Empty the device list listDevices.Items.Clear(); //My FHIR Endpoint string FHIR_EndPoint = this.txtFHIREndpoint.Text.ToString(); //Connection var client = new Hl7.Fhir.Rest.FhirClient(FHIR_EndPoint); try { //Find the device related to my patient var p = new Hl7.Fhir.Rest.SearchParams(); //p.Add("subject", PatientId); p.Add("patient", PatientId); var results = client.Search <Device>(p); this.UseWaitCursor = false; lblErrorMessage.Text = ""; while (results != null) { if (results.Total == 0) { lblErrorMessage.Text = "No devices found"; } //Traverse the bundle with results foreach (var entry in results.Entry) { //One Device found! var Device = (Device)entry.Resource; string Content = ""; //Fill the content to add to the list with all the device data //Just in case the UDICarrier info is not present, we show just Manufacturer and Identifier if (Device.UdiCarrier.Count > 0) { Content = Device.UdiCarrier[0].CarrierHRF + " - " + Device.UdiCarrier[0].DeviceIdentifier + " - " + Device.Manufacturer; } else { if (Device.Identifier.Count > 0) { Content = Device.Identifier[0].System + "-" + Device.Identifier[0].Value + " -" + Device.Manufacturer; } else { Content = Device.Manufacturer + " ( No Identifiers )"; } } Content = Content + Device.Type.Coding[0].Display + '-' + Device.Patient.Display; listDevices.Items.Add(Content); } // get the next page of results results = client.Continue(results); } } catch (Exception err) { lblErrorMessage.Text = "Error:" + err.Message.ToString(); } if (lblErrorMessage.Text != "") { lblErrorMessage.Visible = true; } }