FHIR Chat · Query for logical and literal references? · implementers

Stream: implementers

Topic: Query for logical and literal references?


view this post on Zulip Håkan MacLean (Feb 14 2022 at 11:23):

I've tried searching the threads on this topic but haven't found a definite answer. Let's say you want to create an Observation about a Patient that does not yet exist in the FHIR Server. All you have a is some logical reference to it. The Observation could then for example look like this:

{
 "resourceType": "Observation 1",
 "subject": {
     "identifier": {
        "system": "uri:patient",
        "value": "someUUID"
      }
    }
}

Then how do we query for this? This thread indicates we should do Observation?subject:Identifier=uri:patient:someUUID, but other posts have suggested we do: Observation?subject.Identifier=uri:patient:someUUID. I didn't find much guidance on the page about logical references. Not sure where in the FHIR standard the mention of using ':' is mentioned?

Furthermore, once this Patient has been created in a FHIR server, so for example:

{
 "resourceType": "Patient",
 "id": 123
 "identifier": {
     "system": "uri:patient",
      "value": "someUUID"
  }
  "name": "Hakan"
}

And someone then creates an Observation with a literal reference:

{
 "resourceType": "Observation 2",
  "subject": {
     "reference": "Patient/123"
    }
}

I would ideally like to perform a query that fetches both of these two Observations. What would be the correct FHIR syntax for this?

view this post on Zulip Rik Smithies (Feb 14 2022 at 11:51):

This may not be answering your question, but it is unusual to create observations for patients that don't exist. Do you have a strong requirement to do it this way around?
FHIR is designed primarily to work on literal references. Logical ones tend to be to things that exist outside of FHIR and so may never be queryable (using FHIR).
If the patient data is coming along soon (e.g. later in the session), is it not possible to add it first? Or if the patient data is never coming along (because it is not going to be on that server, or will not be in FHIR and so the logical reference will always remain logical and never be referenceable), then you cannot reliably query it.
By the way your 2 queries look the same to me.

view this post on Zulip Håkan MacLean (Feb 14 2022 at 13:05):

Rik Smithies said:

Do you have a strong requirement to do it this way around?

Unfortunately yes. It might be data coming from partners where we will never even have the Patient object.

By the way your 2 queries look the same to me.

One is subject:Identifier and the other subject.Identifier, which seems to have been the topic of a lot of debate (see links in original post).

view this post on Zulip Rik Smithies (Feb 14 2022 at 13:48):

hi I think you may want to create a patient object as a proxy for the "real" one. You can use the external, non-referenceable identifier, but also have a local FHIR id.
Basically, if you have no patient object, then there is no query.
And if you do have a patient object, there is no harm in assigning a FHIR id and using it. All created resources will have one anyway.
Some servers can search for identifiers on the same server (but the FHIR id can also so that), but in general, there is no way to know what server that patient exists on, so this is not reliable.

view this post on Zulip Lloyd McKenzie (Feb 14 2022 at 15:36):

Note that the ':identifier' qualifier is lower-case.
There's no way with a single query to retrieve both boy 'identifier' and by formal reference. You'll need to exercise two queries. (In general, once the Patient exists, you'd want to update your original Observation to have an explicit Reference.reference, as you can't chain or include based on Reference.identifier.

view this post on Zulip Håkan MacLean (Feb 14 2022 at 15:41):

Lloyd McKenzie said:

Note that the ':identifier' qualifier is lower-case.

Right. But I'm still a bit unsure about when the ':' syntax is appropriate and when to use '.'? Can I read about it somewhere?

In general, once the Patient exists, you'd want to update your original Observation to have an explicit Reference.reference, as you can't chain or include based on Reference.identifier.

Interesting. What type of consequences should such changes have to the original Observation have? A new versionId?

view this post on Zulip Lloyd McKenzie (Feb 14 2022 at 15:43):

You use ':' when you're using one of the modifiers (:identifier, :text, :in, etc.). You use '.' when you're chaining - so referring to a search parameter within the scope of the resource you're currently searching on.

Updating Observation would cause meta.version to change.


Last updated: Apr 12 2022 at 19:14 UTC