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 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."); }