FHIR Chat · Contained Resources · implementers

Stream: implementers

Topic: Contained Resources


view this post on Zulip Paul Barry (May 24 2016 at 22:36):

We are using transaction bundles to persist medicationDispense resources and all associated resources - organization, patient, dispenser. We'd like to link the MedicationDispense to the AuthorisingPrescription (MedicationOrder) if it exists. However if it doesn't exist we'd need to store the prescribing data somewhere but we wouldn't have enough information to create independent resources so I was thinking of using 'contained' resources. How would I put this logic in the transaction e.g. if AuthorisingPrescription exist then link else use contained resources

view this post on Zulip Paul Barry (May 25 2016 at 03:17):

We have since found in the spec the following statement on contained resources:
*Contained resources SHALL NOT contain additional contained resources*
This means we wouldn't be able to 'contain' the Prescriber within the MedicationOrder that is contained within the MedicationDispense. So we have a problem. How will we store the following data against our MedicationDispense resource?
Prescriber number
prescriber first name
prescriber last name
practice name
practice address
practice phone number
Creating a profile doesn't feel right?

view this post on Zulip Gaute Brakstad (May 25 2016 at 07:02):

Next you have a rule that says:

view this post on Zulip Gaute Brakstad (May 25 2016 at 07:02):

A contained resource SHALL only be included in a resource if something in that resource (potentially another contained resource) has a reference to it

view this post on Zulip Gaute Brakstad (May 25 2016 at 07:13):

we had some discussion internally in our company around this in a similar case. What we ended up with was following is not allowed:
<Composition xmlns="http://hl7.org/fhir">
<extension>...</extension>
<text>...</text>
<contained>
<Organization>
<contained>
<Organization>
<id value="org2"/>
</Organization>
</contained>
<id value="org1"/>
<partOf>
<reference value="#org2" />
</partOf>
</Organization>
</contained>
<information>
<custodian>
<reference value="#org1" />
</custodian>
<information>
</Composition>

While following is correct:
<Composition xmlns="http://hl7.org/fhir">
<extension>...</extension>
<text>...</text>
<contained>
<Organization>
<id value="org1"/>
<partOf>
<reference value="#org2" />
</partOf>
</Organization>¨
</contained>
<contained>
<Organization>
<id value="org2"/>
</Organization>
</contained>
<information>
<custodian>
<reference value="#org1" />
</custodian>
<information>
</Composition>

This is to make sure you only have to look one place for your contained resources. Basicly its the "master" resource that have all the contain

view this post on Zulip Paul Barry (May 25 2016 at 10:33):

@Gaute Brakstad Thanks for your response. I am not sure your solution works for my scenario. The organisation is only referenced by the prescriber and the prescriber can only be referenced by medicationOrder so how can I not go two deep?

view this post on Zulip Gaute Brakstad (May 25 2016 at 12:03):

<MedicationDispense xmlns="http://hl7.org/fhir">
<contained>
<MedicationOrder>
<id>order1</id>
<prescriber>
<reference value="#practitioner1" />
</prescriber>
</MedicationOrder>
</contained>
<contained>
<Practitioner>
<id>practitioner1</id>
</Practitioner>
</contained>
<authorizingPrescription>
<reference value="#order1" />
</authorizingPrescription>

</MedicationDispense>

view this post on Zulip Gaute Brakstad (May 25 2016 at 12:04):

Is it something like this you want to achive?

view this post on Zulip Yunwei Wang (May 25 2016 at 14:23):

@Paul Barry Just for curiosity, in which situation you have a MedicalDispense instance w/o MedicationOrder (so you have to create contained resource)?

view this post on Zulip Igor Sirkovich (May 25 2016 at 15:53):

We used the same solution as Gaute did: have all the contained resources under the MedicationDispense. Then each of these contained resources can reference any other contained resource

view this post on Zulip Grahame Grieve (May 25 2016 at 21:34):

yes that's the intent

view this post on Zulip Paul Barry (May 25 2016 at 22:19):

@Yunwei Wang Sometimes Pharmacies are connected to the system but the Prescribing systems are not. If the patient presents at the pharmacy they will submit details about the prescriber as well as their own dispensing information

view this post on Zulip Paul Barry (May 25 2016 at 22:26):

@Gaute Brakstad yes this is what we are trying to achieve. I see you have put the contained Practitioner inline with the contained MedicationOrder even though it is reference by the MedicationOrder (as opposed to the MedicationDispense). I wasn't sure if this was correct. Thanks for clarifying

view this post on Zulip Andrew Ross (Jun 03 2016 at 14:45):

A Bundle is not allowed to have contained resources, right?

view this post on Zulip Andrew Ross (Jun 03 2016 at 14:45):

because it inherits from Resource as opposed to DomainResource

view this post on Zulip Andrew Ross (Jun 03 2016 at 14:46):

but the resources referenced in Bundle.entry each *can* have their own contained resources, right?

view this post on Zulip Andrew Ross (Jun 03 2016 at 14:46):

(but it wouldn't be possible for a resource in one entry to reference something contained in another)

view this post on Zulip Andrew Ross (Jun 03 2016 at 14:47):

we're building a FHIR client library that might encapsulate looking up contained resources and we just want to make sure we're looking in the right place

view this post on Zulip Mirjam Baltus (Jun 03 2016 at 15:05):

Correct.
For which language/platform are you building the library?

view this post on Zulip Andrew Ross (Jun 03 2016 at 15:12):

Ruby

view this post on Zulip Andrew Ross (Jun 03 2016 at 15:12):

we're working with MITRE / FHIR crucible

view this post on Zulip Andrew Ross (Jun 03 2016 at 15:13):

they already have them published open source, we're just working on extending it to handle more use-cases

view this post on Zulip Igor Sirkovich (Jun 03 2016 at 20:43):

I've just found that if I try to validate a bundle with resources, which have contained resources on Grahame's server at fhir3.healthintersections.com.au/open/, I get an error that local references have to start with "#", but actually, all my local references start with "#". If I extract any resources from this bundle and try to validate on the same server , it passes the validation. @Grahame Grieve, could you please look at this issue when you have time?

view this post on Zulip Grahame Grieve (Jun 05 2016 at 12:01):

Igor, can you send me the bundle please

view this post on Zulip Igor Sirkovich (Jun 06 2016 at 14:32):

medicationdispensebundle.json

view this post on Zulip Igor Sirkovich (Jun 06 2016 at 14:35):

@Grahame Grieve , the bundle is attached above. I've simplified it, so it has only one MedicationDispense resource in it with a few data elements and a few references to contained resources.

view this post on Zulip Igor Sirkovich (Jun 06 2016 at 14:38):

The errors I get are of type: "SHALL have a local reference if the resource is provided inline (url: Medication561127; ids: ) () reference.startsWith('#').not() or (reference.substring(1).trace('url') in %resource.contained.id.trace('ids'))"

If I run the same resource with all its contained resources spearately (not part of a bundle), I get "All OK".

view this post on Zulip Grahame Grieve (Jun 07 2016 at 00:42):

ok I'll look

view this post on Zulip Igor Sirkovich (Jun 09 2016 at 19:06):

Thank you @Grahame Grieve

view this post on Zulip David Hay (Jun 25 2018 at 22:24):

Can a contained resource claim conformance to a profile? I don't see why not...

view this post on Zulip Grahame Grieve (Jun 26 2018 at 03:22):

yes

view this post on Zulip Raheel Sayeed (Jul 19 2018 at 15:44):

I have a similar question about contained resources, related to QuestionnaireResponse and Questionnaire.

1. Questionnaire is unique enough to exist as a contained resource in QuestionnaireResponse.

2. Questionnaire has a contained resource ValueSet, that Quesionnaire.item.options references.

So: QuestionnaireResponse contains Questionnaire contains ValueSet

However, when the resource is created: all contained resources are within the parent resource
QuestionnaireResponse.contained: [
1. Questionnaire
2. ValueSet
]

Is this an expected behavior? The Questionnaire.item.options have to be redirected to the contained of parent resource and not its own contained set?

example: https://raw.githubusercontent.com/raheelsayeed/fhirpromis/master/QuestionnaireResponse_contained.json

view this post on Zulip Pascal Pfiffner (Jul 19 2018 at 15:58):

Contained resources cannot themselves contain resources, see http://build.fhir.org/references.html#contained
You simply stick them all in the parent resource and reference them with "#id", as you're already doing.

view this post on Zulip Raheel Sayeed (Jul 19 2018 at 16:07):

Contained resources cannot themselves contain resources, see http://build.fhir.org/references.html#contained
You simply stick them all in the parent resource and reference them with "#id", as you're already doing.

Yep, thats what I figured, this is corrected at the server! Nice.

view this post on Zulip Lloyd McKenzie (Jul 19 2018 at 17:35):

Corrected at the server? If you found a server that accepts a contained resource within a contained resource and fixes it for you, you're very lucky - as your inbound instance wasn't conformant and (in most environments) would have been rejected.


Last updated: Apr 12 2022 at 19:14 UTC