Stream: implementers
Topic: Search reference by id with multiple targets
Christiaan Knaap (Oct 09 2017 at 12:27):
I seek clarification to this part of the spec (http://www.hl7.org/implement/standards/fhir/search.html#reference):
Some references are allowed to point to more than one type of resource; e.g. subject : Reference(Patient|Group|Device|..). In these cases, multiple resources may have the same logical identifier. Servers SHOULD reject a search where the logical id refers to more than one matching resource across different types."
The search parameter general-practitioner on Patient is such a parameter, it may reference Organization and Practitioner.
Let's assume a FHIR Server with the following data, and a few searches on it.
- Practitioner/1
- Practitioner/2, with no patient linking to it
- Organization/1, with no patient linking to it.
- Organization/2, with name="SomeCorp"
- Patient/pat1, with general-practitioner=Practitioner/1
- Patient/pat2, with general-practitioner=Organization/2
Search nr1: /Patient?general-practitioner=1
If I read the text, I assume this is valid, since the logical id '1' happens to refer to only 1 resource, being Practitioner/1.
Search nr2: /Patient?general-practitioner=2
I assume this should be rejected, since the logical id '2' refers to both Practitioner/2 and Organization/2. Even though Practioner/2 is never linked to.
Search nr3: /Patient?general-practitioner.name=SomeCorp
This does not involve a logical id, but is - within the above data - equivalent to Search nr2. Is it valid?
Now I have a few problems:
1. The first search is valid, the second is not, but I could not tell the difference beforehand
2. The validity of search nr3 is not clear to me.
3. This is - at least in our implementation of Vonk - not very efficient, since this issue could happen some levels deep inside a chained search, and we do not execute all the subqueries separately.
I would be in favour of a narrowing it further like this:
"Some references are allowed to point to more than one type of resource; e.g. subject : Reference(Patient|Group|Device|..). In these cases, multiple resources may have the same logical identifier and thus Servers SHOULD reject a search if it does not specify the resourcetype (either in the url, or in the type modifier). If a client wished to search for more than one type, it can use the choice construct to do so."
Jason Walonoski (Oct 10 2017 at 11:53):
My 2 cents... nr2 should be legal. It is a search after all...
Last updated: Apr 12 2022 at 19:14 UTC