Stef Heyenrath
Stef Heyenrath

Reputation: 9860

HL7-Fhir : Nested (child) resources and _include supported/allowed in read result from a single resource

This page describes the simple read.

However it's not clear to me if _include (web-page) is supported (see chapter 2.2.4.1 Include Paths) and if nested resource(s) can also be returned ?

So is the following request :
https://example.com/MedicationOrder/5?_include=MedicationOrder.medication valid ?

And should the json-response be like:

{
  "resourceType": "MedicationOrder",
  "id": "5",
  "detail" : "abc",
  "medication":
  {
      "resourceType": "Medication",
      "id": "example",
      "otherDetails": "xyz"
  }
}

Upvotes: 1

Views: 724

Answers (1)

Grahame Grieve
Grahame Grieve

Reputation: 3586

_include is only supported as part of a search. So

https://example.com/MedicationOrder/5?_include=MedicationOrder.medication

is not valid. This is:

https://example.com/MedicationOrder?_id=5&_include=MedicationOrder:medication

Then you get back a bundle with the MedicationOrder and the medication, if there is one.

What you call 'nested resources' - do you mean contained resources? - well, if there are contained resources in the MedicationOrder, they they are always returned with it - they are part of it. But they don't appear in the medication as you show in the example above. Instead:

{
  "resourceType": "MedicationOrder",
  "id": "5",
  "detail" : "abc",
  "medication": { 
    "reference" : "#m1"
  },
  "contained": [
    {
      "resourceType": "Medication",
      "id": "m1",
      "otherDetails": "xyz"
    }
  ]
}

Upvotes: 2

Related Questions