Stream: implementers
Topic: Reference Search - Observation Encounter period start/end
Matthew Koch (Apr 30 2018 at 14:38):
Hi all,
I'm looking for some guidance on constructing a RESTFul URL to search for Observations
based on a number of criteria, namely a reference to the Encounter
resource (period.start
and period.end
) through the context
attribute.
For example, I believe the following is considered valid as a search based on Encounter.status
:
Observation?context:Encounter.status=finished
However, I am having trouble figuring out the correct way to structure a query wherein I want to filter the results based on the context (Encounter) as well as the date period of said Encounter:
Observation?context:Encounter.period.start=2006-06-27T00:00:00-06:00
I've tried the above on the https://sandbox.hspconsortium.org sandbox and it always comes back as an invalid parameter chain. I'm sure it's because I've structured it incorrectly. Any help is greatly appreciated!
Lloyd McKenzie (Apr 30 2018 at 15:23):
You can't search by paths, you can only use defined (or custom) search parameters. There are no search parameters for start or end on Encounter, just a search for 'date' which will match on any date that falls between start and end. So what you want is something like this: Observation?context:Encounter.status=finished&context:Encounter.date=le2006-06-30&context:Encounter.date=ge2006-06-20
Note that the only reason this works is because Observation is only allowed a maximum of one context because chaining filters are independent of each other.
Matthew Koch (Apr 30 2018 at 17:19):
You can't search by paths, you can only use defined (or custom) search parameters. There are no search parameters for start or end on Encounter, just a search for 'date' which will match on any date that falls between start and end. So what you want is something like this: Observation?context:Encounter.status=finished&context:Encounter.date=le2006-06-30&context:Encounter.date=ge2006-06-20
Note that the only reason this works is because Observation is only allowed a maximum of one context because chaining filters are independent of each other.
Interesting, so the date parameter on Encounter translates to the period start/end dates?
Lloyd McKenzie (Apr 30 2018 at 18:27):
When you search on a 'date' parameter that's mapped to a Period, it matches on any resource whose period overlaps with the period represented by the search value. (Because technically all date and dateTime values are themselves intervals, whether it's a whole day down to just being a whole second.
Matthew Koch (Apr 30 2018 at 20:17):
I see. The only part that confuses me is that period is not mentioned anywhere in your example GET call - it appears that it implicitly refers to it instead of explicitly.
Lloyd McKenzie (Apr 30 2018 at 20:30):
The Encounter 'date' search parameter refers to Encounter.period
Lloyd McKenzie (Apr 30 2018 at 20:30):
(so that's your linkage)
Last updated: Apr 12 2022 at 19:14 UTC