예제 #1
0
        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()}");
                }
            }
        }
예제 #2
0
        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.");
        }
예제 #3
0
        private static void PatientData(FhirRest.FhirR4Client fhirClient)
        {
            // search for patient as we don't have a patient ID
            var patients = GetPatients(fhirClient, "JEPPESEN");

            if (!patients.Any())
            {
                return;
            }

            var patientResource = fhirClient.Read <FhirModel4.Patient>(FhirRest.ResourceIdentity.Build("Patient", patients.FirstOrDefault()?.Id));

            Console.WriteLine($" patient name =" + patientResource.Name.FirstOrDefault());
            Console.WriteLine($" patient birthdate =" + patientResource.BirthDate);
            Console.WriteLine($" patient gender =" + patientResource.Gender);

            var query = new string[] { $"patient._id={patientResource.Id}" };

            FetchClaims(fhirClient, query);

            FetchDiagnosticReports(fhirClient, query);
        }