private static async Task RuleDataAsync(FhirRest.FhirR4Client fhirClient) { var srchParams = new SearchParams() .Where("title=All Labs") .LimitTo(10) .SummaryOnly() .OrderBy("title", SortOrder.Descending); var bundle = fhirClient.Search <FhirModel4.List>(srchParams); var list = bundle.Entry.FirstOrDefault()?.Resource as FhirModel4.List; if (list != null) { var listResource = fhirClient.Read <FhirModel4.List>(FhirRest.ResourceIdentity.Build("List", list.Id)); Console.WriteLine($"List Summary Narrative: {listResource.Text.Div}"); var tasks = new List <Task <FhirModel4.Patient> >(); foreach (var entryComponent in listResource.Entry) { var resourceReference = entryComponent.Item; tasks.Add(fhirClient.ReadAsync <FhirModel4.Patient>(resourceReference.Url)); } await Task.WhenAll(tasks); foreach (var task in tasks) { var patient = task.Result; Console.WriteLine( $"NAME: {patient.Name[ 0 ].Given.FirstOrDefault()} {patient.Name[ 0 ].Family.FirstOrDefault()}"); } } }
private static void FetchClaims(FhirRest.FhirR4Client fhirClient, string [] query) { var result = fhirClient.Search <FhirModel4.Claim>(query, null, 50); Console.WriteLine($"total claims = " + result.Total); while (result != null) { foreach (var e in result.Entry) { var claim = (FhirModel4.Claim)e.Resource; var diagnosis = (claim.Diagnosis.FirstOrDefault()?.Diagnosis as FhirModel.CodeableConcept)?.Coding.FirstOrDefault()?.Code; Console.WriteLine( $"Claim Diagnosis: { diagnosis }"); var service = (claim.Item.FirstOrDefault()?.ProductOrService as FhirModel.CodeableConcept)?.Coding.FirstOrDefault()?.Code; Console.WriteLine($"Service: { service }"); var extension = claim.GetExtensions("http://careevolution.com/fhirextensions#claim-status").FirstOrDefault(); var status = ((FhirModel.CodeableConcept)extension?.Value)?.Coding.FirstOrDefault()?.Display; Console.WriteLine( $"Claim Status: {status}"); } Console.WriteLine("Fetching more results..."); result = fhirClient.Continue(result); } Console.WriteLine("No more claims."); }
private static List <FhirModel4.Patient> GetPatients(FhirRest.FhirR4Client fhirClient, string family) { var srch = new FhirRest.SearchParams() .Where($"family={family}") .LimitTo(20) .SummaryOnly() .OrderBy("birthdate", FhirRest.SortOrder.Descending); var bundle = fhirClient.Search <FhirModel4.Patient>(srch); return(bundle.Entry.Select(b => b.Resource as FhirModel4.Patient).ToList()); }
private static void FetchDiagnosticReports(FhirRest.FhirR4Client fhirClient, string[] query) { var result = fhirClient.Search <FhirModel4.DiagnosticReport>(query, null, 50); Console.WriteLine($"total reports = " + result.Total); while (result != null) { foreach (var e in result.Entry) { var report = (FhirModel4.DiagnosticReport)e.Resource; Console.WriteLine($"Report LastUpdated: {report.Meta.LastUpdated}"); Console.WriteLine($"Report Status: {report.Status}"); Console.WriteLine($"Report Category: {report.Category.FirstOrDefault()?.Coding.FirstOrDefault()?.Display}"); var observations = report.Result; foreach (var resourceReference in observations) { var resource = fhirClient.Read <FhirModel4.Observation>(resourceReference.Url); Console.WriteLine($"Observation date: {resource.Effective}"); if (resource.Value is FhirModel.Quantity) { var value = (FhirModel.Quantity)resource.Value; Console.WriteLine($"Observation value: {value.Value}"); Console.WriteLine($"Observation units: {value.Unit}"); } else { Console.WriteLine($"Observation value: {(( FhirString )resource.Value ).Value}"); } } } Console.WriteLine("Fetching more results..."); result = fhirClient.Continue(result); } Console.WriteLine("No more reports."); }