FHIR Chat · inspecting contained resource · fhirpath

Stream: fhirpath

Topic: inspecting contained resource


view this post on Zulip Jens Villadsen (Mar 25 2020 at 23:14):

How do I correctly get a hold of a certain (set of) contained resource(s) in an invariant. Lets say I have a Communication resource and the sender is a contained device. In my Invariant, I would like to get access to that particular contained resource. The following does not work (and it aint elegant either): contained.where(id = sender.reference.replace('#',''))

view this post on Zulip Jens Villadsen (Mar 25 2020 at 23:15):

the question is how is that correctly stated using FHIR Path?

view this post on Zulip Lloyd McKenzie (Mar 26 2020 at 04:53):

You should ideally be resolving the references (using .resolve()) rather than relying on foreknowledge that the content will be contained.

view this post on Zulip Jens Villadsen (Mar 26 2020 at 08:40):

How do I inspect the identifier of the device when the example looks like the following?

{
  "sender": {
    "reference": "#1"
  },
  "meta": {
    "profile": [
      "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-message"
    ]
  },
  "status": "completed",
  "medium": [
    {
      "text": "WRITTEN",
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationMode",
          "code": "WRITTEN"
        }
      ]
    }
  ],
  "recipient": [
    {
      "reference": "http://inttest.ehealth.sundhed.dk/trifork-fhir-server/Patient/XXX"
    }
  ],
  "resourceType": "Communication",
  "category": [
    {
      "text": "Besked",
      "coding": [
        {
          "system": "http://ehealth.sundhed.dk/cs/message-category",
          "code": "message"
        }
      ]
    }
  ],
  "contained": [
    {
      "id": "1",
      "resourceType": "Device",
      "identifier": [
        {
          "value": "hello.system"
        }
      ]
    }
  ],
  "payload": [
    {
      "contentString": "Hello world"
    }
  ],
  "sent": "2019-04-03T18:01:10-08:00"
}

sender.resolve() returns the empty set

view this post on Zulip Jens Villadsen (Mar 26 2020 at 08:41):

at least using https://marketplace.visualstudio.com/items?itemName=Yannick-Lagger.vscode-fhir-tools

view this post on Zulip Jose Costa Teixeira (Oct 28 2021 at 20:54):

I have the same need, I guess

view this post on Zulip Jose Costa Teixeira (Oct 28 2021 at 20:55):

I am looking into a contained resource.
This evaluates to true:
contained.first().id=implementation.custodian.reference.substring(1,999)

view this post on Zulip Jose Costa Teixeira (Oct 28 2021 at 20:56):

(as it should) - this means that the first contained resource matches what I want to look for

view this post on Zulip Jose Costa Teixeira (Oct 28 2021 at 20:57):

so why doesn't contained.where(id=implementation.custodian.reference.substring(1,999)) return the first contained resource?

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 22:21):

contained.where(id=%resource.implementation.custodian.reference.substring(1,999)) will probably work

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 22:22):

When you're inside the where clause, the names of the properties you're referencing have to be 'visible' from the node you're on. In this case, the root node of all the contained resources

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 22:36):

%resource allows you to start at the root of the resource that is the 'base' for the current node

view this post on Zulip Jose Costa Teixeira (Oct 29 2021 at 06:21):

It seems that %resource is not implemented in the javascript library that I want to use.

view this post on Zulip Lloyd McKenzie (Oct 29 2021 at 13:05):

@Paul Lynch

view this post on Zulip Brian Postlethwaite (Oct 29 2021 at 23:41):

It is, but you have to set it when calling it.

view this post on Zulip Jose Costa Teixeira (Oct 30 2021 at 08:38):

What does that mean?

view this post on Zulip Brian Postlethwaite (Oct 30 2021 at 09:07):

The code that calls it needs to pass in an array of variables, including this one.

view this post on Zulip Brian Postlethwaite (Oct 30 2021 at 09:12):

Not the part on here that talks about environment variables, use that and add in resource to that array like it has for %a
https://github.com/HL7/fhirpath.js/

view this post on Zulip Jose Costa Teixeira (Oct 31 2021 at 22:20):

thanks. That works


Last updated: Apr 12 2022 at 19:14 UTC