You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our case, we have a scenario where we want to retrieve all FHIR MedicationRequest resources which does not have any associated FHIR MedicationDispense events (/resources).
Is there a way in FHIR Query to use modifiers on '_revinclude' or '_include' to achieve above requirement?
Appreciate any guidance on this please.
The text was updated successfully, but these errors were encountered:
First of all implementers would be the right person to answer this. But as a fallback mechanism you can use some thing like this as below. I just referenced firely as server.
private static async Task CallWithoutReference()
{
var fhirServerUrl = "https://server.fire.ly/";
var client = new FhirClient(fhirServerUrl);
//1. Fetch MedicationRequests with their associated MedicationDispense resources
var bundleWithDispenses = await client.SearchAsync<MedicationRequest>(new string[] {"_revinclude=MedicationDispense:medicationrequest" });
var medicationRequestWithDispenses = bundleWithDispenses?.Entry.Where(e => e.Resource is MedicationRequest).Select(e => e.Resource as MedicationRequest).ToList();
//2. Fetch all medication request
var allMedicationRequest = new List<MedicationRequest>();
Bundle bundle;
var nextPageUrl = "MedicationRequest";
do
{
bundle = await client.SearchAsync<MedicationRequest>(new string[]{$"_page=1&url={nextPageUrl}"});
allMedicationRequest.AddRange(bundle.Entry.Where(e => e.Resource is MedicationRequest).Select(e => e.Resource as MedicationRequest));
nextPageUrl = bundle.NextLink?.ToString();
}while(nextPageUrl != null);
//3. Filter now from those who have dispenses
var dispenseIds = medicationRequestWithDispenses?.Select(req => req?.Id).ToHashSet();
var medicationRequestWithoutDispenses = allMedicationRequest.Where(req => !dispenseIds.Contains(req.Id)).ToList();
foreach (var req in medicationRequestWithoutDispenses)
{
Console.WriteLine($"MedicationRequest without Dispense: {req.Id}");
}
}`
Question
In our case, we have a scenario where we want to retrieve all FHIR MedicationRequest resources which does not have any associated FHIR MedicationDispense events (/resources).
Is there a way in FHIR Query to use modifiers on '_revinclude' or '_include' to achieve above requirement?
Appreciate any guidance on this please.
The text was updated successfully, but these errors were encountered: