Stream: implementers
Topic: How search on Reference.identifier in STU3
Eric Haas (Jul 15 2018 at 16:24):
For R4 we added this:
"References are also allowed to have an identifier. The modifier :identifier
allows for searching by the identifier rather than the literal reference:
GET [base]/Observation?subject:identifier=http://acme.org/fhir/identifier/mrn|123456
This is a search for all observations that reference a patient by a particular patient MRN. When the :identifier modifier is used, the search value works as a token search.
"
I did not see a way to create custom search modifier using SearchParameter, what is the best way to add this search functionality to a STU3 Implementation Guide. As an Operation?
Grahame Grieve (Jul 16 2018 at 00:39):
I'm not understanding this.. you want to add different functionality to an IG?
Vadim Peretokin (Jul 16 2018 at 07:03):
Hey @Eric Haas, I got it working with a SearchParameter - you'll need to follow the server-specific docs for adding it in
{ "resourceType": "SearchParameter", "id": "observation-context-identifier", "url": "http://hl7.org/fhir/SearchParameter/observation-context-identifier", "name": "Observation.context.identifier Search Parameter", "status": "draft", "experimental": true, "date": "2018-07-11", "publisher": "blah", "purpose": "Need to search Observation.context references by business identifier", "code": "context-identifier", "base": [ "Observation" ], "type": "token", "description": "Search Observation contexts by their business identifier", "expression": "Observation.context.identifier", "target": [ "Patient" ], "modifier": [ "missing" ] }
Then a query like /Observation?context-identifier=my-system|my-code
will work
Michele Mottini (Jul 16 2018 at 14:23):
Can't you already do that with a chained search (even in DSTU2): GET [base]/Observation?subject.dentifier=http://acme.org/fhir/identifier/mrn|123456
Eric Haas (Jul 16 2018 at 17:13):
@Grahame Grieve is not defined in STU3 only showed up in R4, @Michele Mottini This is not the resource identifier but the Reference.identifier element for the Reference Type. @Vadim Peretokin thanks that just might be the answer I was looking for - create my own SearchParameter!
Michele Mottini (Jul 16 2018 at 17:26):
Yes...but shouldn't they be the same? Don't reference.identifier means 'referencing to a resource with this identifier' ?
Eric Haas (Jul 16 2018 at 17:40):
they may be, but not interested in chaining across Resources since the endpoint only has QuestionnaireAnswers or some other resource but no Patient. Although I don't know if this buys you anything. Is, Reference.reference is any more or less opaque than a Reference.identifier from a privacy aspect?
Eric Haas (Jul 16 2018 at 17:40):
assuming the identifier is opaque
Christiaan Knaap (Jul 17 2018 at 08:29):
A key difference is that for the chained version to work, the resource that is referenced to has to be available on the same server.
When searching directly on the identifier value of the Reference element, you don't need the referenced-to resource to be available.
Michele Mottini (Jul 17 2018 at 18:31):
Why does the referenced resource has to be available? I don't see anything in the specs requiring that
Eric Haas (Jul 17 2018 at 19:58):
you can't chain without it. need to access Patient to query the identifiers. If your server only has QuestionnaireAnswers you are out of luck on your query.
Lloyd McKenzie (Jul 17 2018 at 20:50):
That's not strictly true in that if the Patient were contained, you could theoretically chain without supporting the Patient endpoint - but containing Patient would be weird...
Lloyd McKenzie (Jul 17 2018 at 20:50):
Can be relevant when searching Bundles though - because all the data you chain through to could live in the Bundle.
John Moehrke (Jul 18 2018 at 02:43):
I am not sure I am fully clear on where this conversation is ending. There are cases where the element in a Resource (Any). Plus I am told that in the case of a Reference.identifier, I can put a business identifier there even if there is no Resource yet holding that business identifier. For example where Observation.basedOn.identifier holds a HL7 v2 order number; but there is no actual instance of any of the given resource types that exist and hold that business identifier. Thus in this case basedOn.reference is not populated. So how do I search for this?
Eric Haas (Jul 18 2018 at 02:57):
GET [base]/Observation?subject:identifier=http://acme.org/fhir/identifier/mrn|123456
should do the trick in your case since this is querying the Observation.subject directly and not search for a yet to be created Patient resource.
John Moehrke (Jul 18 2018 at 03:00):
okay, that is what I was thinking.... so then I don't understand the subtly of this thread. What is different that makes it not as easy?
Eric Haas (Jul 18 2018 at 03:05):
My initial ask was how to do it in STU3? since the above Query is new for R4. This stream went a little sideways for other use cases.
Is a Reference.reference is any more or less opaque than a Reference.identifier from a privacy aspect?... assuming the identifier is opaque
Grahame Grieve (Jul 18 2018 at 03:06):
you should do it the same way in R3 - just pre-adopt the R4 solution
John Moehrke (Jul 18 2018 at 03:06):
Hm, so one can't do what I asked about in STU3? Didn't know that
John Moehrke (Jul 18 2018 at 03:07):
pre-adopt is fallacy... nice story, but not helpful... ultimately R4 will happen soon enough.
John Moehrke (Jul 18 2018 at 03:08):
As to the Reference.reference vs Reference.identifier.... if both are assigned given pseudorandom identifier mechanism, they are both equal from a Privacy perspective.
Michele Mottini (Jul 18 2018 at 03:08):
I can definitely chain without having a Patient resource implemented. It is just a matter of convert ?subject.identifier=xxx in the appropriate query to the underlying data store - exactly like you would do for ?subject:identifier=xxxxx
John Moehrke (Jul 18 2018 at 03:09):
If the identifiers are issued poorly, which can happen with either URI or identifier, then they are equally bad.
Michele Mottini (Jul 18 2018 at 03:09):
(that is why I'd rather always use the chained syntax - that is already established - instead of adding yet another way to do the same thing)
John Moehrke (Jul 18 2018 at 03:12):
so, given the query problem in STU3 as just outlined, I guess I am now glad I didn't simplify Provenance and AuditEvent until last week... The STU3 flavors were old school (pre STU3) model...
Brian Postlethwaite (Jul 18 2018 at 04:32):
I think there is some confusion here.
The :idenfitier
search modifier is not referring to an identifier value in the referenced resource, its specifying the value in the reference.reference property (which would have been indexed)
This is not a chain, but a property in the resource.
I do however note that there is nothing in this part of the spec that talks about if the reference.identifier was resolved to fill in the reference.reference value.
http://build.fhir.org/search.html#reference
Brian Postlethwaite (Jul 18 2018 at 04:36):
The example in the spec would be searching for observations like this one.
<Observation> <subject> <identifier> <system value="http://acme.org/fhir/identifier/mrn" /> <value value="123456" /> </identifier> </subject> </Observation>
It would not be checking for a chained search to check Observation.subject.identifier= ...
Brian Postlethwaite (Jul 18 2018 at 04:36):
(Haven't implemented this in my R4 test server yet either)
Bob Milius (Aug 21 2020 at 17:48):
I've read through this thread, and admit I'm confused. I can successfully create this resource on http://hapi.fhir.org/baseR4/
<Observation>
<subject>
<identifier>
<system value="http://acme.org/identifier/mrn" />
<value value="000" />
</identifier>
</subject>
</Observation>
(a Patient resource does not exist)
and then I attempt to search for it using
GET http://hapi.fhir.org/baseR4/Observation?subject:identifier=http://acme.org/identifier/mrn|000
but it doesn't find anything. Is this expected behavior?
How would I search for Observation.subject.identifier?
Vassil Peytchev (Aug 21 2020 at 18:51):
This might be completely off, but could an identifier "000" be hitting a strange edge case that breaks the search?
Bob Milius (Aug 21 2020 at 18:59):
Vassil Peytchev said:
This might be completely off, but could an identifier "000" be hitting a strange edge case that breaks the search?
I've used other values (eg 123456) with the same result.
Michele Mottini (Aug 21 2020 at 21:40):
Try asking in #hapi ? This seems something specific to that server - a bug, or it does not support that search
Bob Milius (Feb 25 2021 at 18:37):
Michele Mottini said:
Try asking in #hapi ? This seems something specific to that server - a bug, or it does not support that search
I did ask in #hapi (https://chat.fhir.org/#narrow/stream/179167-hapi/topic/searching.20for.20subject.3Aidentifier) but haven't gotten anywhere so far. Can someone show me a working example on a public server that supports searching for observations based on subject:identifier?
Last updated: Apr 12 2022 at 19:14 UTC