FHIR Chat · Searching by a collection of references · implementers

Stream: implementers

Topic: Searching by a collection of references


view this post on Zulip Lloyd McKenzie (Jan 27 2022 at 03:29):

I've got a collection of local references (e.g. Practitioner/1, Practitioner/2, Organization/3, PractitionerRole/4)
I want to define a single search that will retrieve all four resources
Is it possible? If so, how?

view this post on Zulip Paul Church (Jan 27 2022 at 05:01):

write a batch bundle with 4 read operations in it?

view this post on Zulip René Spronk (Jan 27 2022 at 07:31):

A bit whacky perhaps, but on the quick I don't see why theoretically it shouldn't work: GET Resource?_id=Practitioner/1, Practitioner/2, Organization/3, PractitionerRole/4

view this post on Zulip Lloyd McKenzie (Jan 27 2022 at 16:25):

The batch bundle is the only approach I've come up with, but it seems rather inefficient. I don't think searching by _id allows preceding resource names. Though if we could have a search at the 'root' level that could work that way, that'd be ideal...

view this post on Zulip René Spronk (Jan 27 2022 at 16:35):

GET [base]?_type=Practitioner,Organization&_id=1,2,3 or even GET [base]?_id=1,2,3 certainly works, but one would have to assume that all of the logical ids are unique on a server for that to do exactly what it is you'd like to do.

view this post on Zulip John Moehrke (Jan 27 2022 at 16:41):

bulk data pull everything, filter out locally.... You never said you wanted to have a single search return ONLY these. :-)

view this post on Zulip Lloyd McKenzie (Jan 27 2022 at 21:34):

@Rene, ids aren't unique across resource types, so in theory you might get Organization/1 and Practitioner/1 and PractitionerRole/1

view this post on Zulip Lloyd McKenzie (Jan 27 2022 at 21:34):

I definitely want the search to return only those. The use-case is a CDS Hooks pre-fetch.

view this post on Zulip Jabeen Mohammed (Jan 30 2022 at 14:03):

Lloyd McKenzie said:

I definitely want the search to return only those. The use-case is a CDS Hooks pre-fetch.

@Lloyd McKenzie one can create $youroperation with input resource parameters

view this post on Zulip Lloyd McKenzie (Jan 30 2022 at 15:13):

Sure, but that then requires custom support across all servers. It seems to me that there should be a simple search mechanism to retrieve a list of local references without needing a Batch of reads.

view this post on Zulip Josh Mandel (Jan 30 2022 at 17:33):

The batch bundle is the only approach I've come up with, but it seems rather inefficient.

What kind of "efficiency" are you thinking about here? Batch seems to meet your stated requirements neatly.

view this post on Zulip Josh Mandel (Jan 30 2022 at 17:36):

The use-case is a CDS Hooks pre-fetch.

For CDS Hooks pre-fetch, you can have as many individual pre-fetch keys as you require. Why not define distinct pre-fetch keys for each, so you can name them with useful labels and so the EHR can easily return any subset of them?

view this post on Zulip Eric Prud'hommeaux (Jan 30 2022 at 17:41):

Lloyd McKenzie said:

Sure, but that then requires custom support across all servers. It seems to me that there should be a simple search mechanism to retrieve a list of local references without needing a Batch of reads.

I'm pretty ignorant here 'cause i've not dived into the specs, but i'da thunk that the phrase "Batch of reads" nicely describes the desired behavior.

view this post on Zulip Lloyd McKenzie (Jan 30 2022 at 19:28):

What I want to do is, for all draft orders passed in, retrieve the performers (Practitioners, PractitionerRoles, whatever) for all of the orders. I don't know in advance how many orders there will be, so I can't reasonably name a distinct key for each.

view this post on Zulip Jabeen Mohammed (Jan 30 2022 at 20:01):

Lloyd McKenzie said:

What I want to do is, for all draft orders passed in, retrieve the performers (Practitioners, PractitionerRoles, whatever) for all of the orders. I don't know in advance how many orders there will be, so I can't reasonably name a distinct key for each.

@Lloyd McKenzie use case basis store them as bundle resource of type collection. This allow you to search and if you want to additional update that specific bundle. So the when client query they will get most current info.
-- I am trying to learn your use case

view this post on Zulip Lloyd McKenzie (Jan 30 2022 at 20:15):

The use-case is that a set of draft orders are passed to a CDS Hook. The draft orders are not persisted on a server anywhere, so there's no ability to query them using a RESTful server. The draft orders reference who 'performs' each order. I want to define a pre-fetch query that will retrieve the performers for all of the specified orders. I can easily create a comma-delimited list of reference URLs (absolute or relative). But I don't have a way to retrieve the set of resources so referenced in a single query. It needs to be a single query because the prefetch has to drop into a single prefetch variable - I can't have a distinct variable per record because you have to know how many variables you'll have at the outset - and I have no idea how many orders there will be, or how many performers per order.

view this post on Zulip Josh Mandel (Jan 30 2022 at 21:46):

I'm confused about how you are using the CDS hooks prefetch templating syntax. Can you share an example of the input variables that you are using to create a prefetch template? I'm having trouble understanding how the static prefetch template syntax would get access to an array of inputs...

view this post on Zulip Lloyd McKenzie (Jan 30 2022 at 22:26):

The CDS work group has talked about extending the syntax to allow navigating into the passed resource to allow retrieval. (One of the most obvious needs is to be able to retrieve the Medication instances associated with MedicationRequests passed as draft or signed orders.) The problem though is that even if we extend the syntax to allow navigating to the MedicationResource.medication element, there's no effective way to have a search that could use the results :(

view this post on Zulip Josh Mandel (Jan 31 2022 at 01:22):

If we're creating new capabilities, we can think about several options... e.g., an include array in the prefetch template that can take a set of expressions based on the context -- but this is all quite complex. Better, I think, to just let the CDS Service make REST API calls as needed, without prefetch.

view this post on Zulip Lloyd McKenzie (Jan 31 2022 at 03:10):

REST calls by the service are a non-starter in some cases. Plus, the whole point of pre-fetch is to grab the content you need all the time. And needing the medication for a MedicationRequest is an obvious situation where this is going to be needed.

view this post on Zulip Josh Mandel (Feb 03 2022 at 19:53):

I'm hearing this as a new feature request for the CDS Hooks prefetch language. It would be good to capture the use case and some proposed approach(es) to meet it (e.g., suggested semantics and syntax, evaluation of trade-offs).

view this post on Zulip Lloyd McKenzie (Feb 03 2022 at 20:57):

The new feature has been discussed on a couple of CDS calls already - but it was all based on the premise we could tie into the existing search syntax. However, as best as I can determine, we can't. So my first step was to make sure that I'm not missing something. After that, then yes, we'll probably be looking at adding something completely net new in terms of prefetch for CDS Hooks.


Last updated: Apr 12 2022 at 19:14 UTC