FHIR Chat · Contained Resources · shorthand

Stream: shorthand

Topic: Contained Resources


view this post on Zulip Jose Costa Teixeira (Feb 13 2020 at 14:05):

Is there support for contained resources?

view this post on Zulip Chris Moesel (Feb 13 2020 at 14:16):

That's a good question... We don't have tests for that. As you know, contained has type Resource -- so I suspect that maybe SUSHI would only allow you to set fields that are on Resource (if you defined the contained resources inline in the instance). We probably need to come up w/ a syntax that would allow the author to indicate a more specific type (than Resource) when doing that. We also could/should consider allowing authors to define contained resources as separate instances (using Instance: keyword) and then reference them as a contained resource in another instance.

view this post on Zulip Jose Costa Teixeira (Feb 13 2020 at 14:32):

I didn't mean to go as far to allow collaborative work. I was wondering how to reference them since we cannot put Reference(#contained_resource_01)

view this post on Zulip Jose Costa Teixeira (Feb 13 2020 at 14:35):

syntax for declaration - could be a nested syntax?
e.g. everything under the keyword "contained" would be a contained resource.

view this post on Zulip David Pyke (May 28 2020 at 16:37):

I'm trying to add a contained resources with a choice of resources allowed to an extension (because I like being an edge case) and can't find an example of contained resources in FSH or any mention of it in the docs. Can anyone show me a pointer or example as to how that might be done?

view this post on Zulip Chris Moesel (May 28 2020 at 16:52):

Hi @David Pyke. Here's a quick example. Let me know if you were looking for something different:

// First define the instances you want contained as inline instances
Instance: ShirleyTemple
InstanceOf: Patient
Usage: #inline
* name.given = "Shirley"
* name.family = "Temple"

// You could define more the same way...

// Now in your instance that you want to contain it in, assign it to contained
Instance: MyExtension
InstanceOf: SomeExtension
Usage: #example
* contained[0] = ShirleyTemple
// you could add others via contained[1], contained[2], etc

view this post on Zulip David Pyke (May 28 2020 at 16:52):

I meant an example of how to define the extension. Sorry

view this post on Zulip David Pyke (May 28 2020 at 16:53):

Or really, how to define a contained resource in FSH in general

view this post on Zulip Chris Moesel (May 28 2020 at 16:56):

Oh. Do you mean something like this:

Extension: MyExtension
* contained only Condition or Procedure or MedicationOrder

If so, that's how you do it... but it seems that SUSHI might generate the StructureDefinition in a way that the IG Publisher no longer supports. I'm not sure on that though -- so if you run into issues, do let us know. It's something we need to look into.

view this post on Zulip David Pyke (May 28 2020 at 16:59):

THat's exactly what I was looking for. I'll see what the publisher does with it

view this post on Zulip David Pyke (May 28 2020 at 17:06):

I probably should have mentioned it was a sub-extension. I defined it as:

  • extension[subscriber].contained only Patient or Practitioner or RelatedPerson or Organization
    sushi fails with
    error No element found at path extension[subscriber].contained for CEQextension, skipping rule

view this post on Zulip David Pyke (May 28 2020 at 17:17):

extension[subscriber].value[x] only contained didn't work. Not that I expected it to.

view this post on Zulip Nick Freiter (May 28 2020 at 17:21):

I could be missing something here, but does Extension have a contained field on it? I know contained is defined on DomainResource, and therefore most resources, but I didn't think that Extension had a contained.

view this post on Zulip David Pyke (May 28 2020 at 17:26):

It doesn't, it only has value[x]. THat's my problem I'm not sure how to set the value to a contained resource.

view this post on Zulip David Pyke (May 28 2020 at 17:27):

If I'm trying to do the impossible, that might be my problem

view this post on Zulip David Pyke (May 28 2020 at 17:29):

I'm assuming extension[subscriber].value[x] only valueReference([list of Resources]) contained would be something like what I want

view this post on Zulip Vassil Peytchev (May 28 2020 at 17:29):

Are you trying to define a valueReference pointing to a contained resource?

view this post on Zulip David Pyke (May 28 2020 at 17:29):

Yes

view this post on Zulip David Pyke (May 28 2020 at 17:33):

Ultimately, I'm trying to create a subextension that is a contained resource with a choice of 4 different resource options

view this post on Zulip David Pyke (May 28 2020 at 17:33):

How that would be done is the exciting part

view this post on Zulip ryan moehrke (May 28 2020 at 17:43):

If you want a reference to only point to a contained resource, isn't that declared in the aggregation element? https://www.hl7.org/fhir/elementdefinition-definitions.html#ElementDefinition.type.aggregation
But that would mean you couldn't require it on every use of that extension, just on ones you have added in an extension slice to the structureDefinition..

The other terrible idea I had was to add an invariant that requires the reference value to start with "#" but that seems just as unlikely to be usable

view this post on Zulip David Pyke (May 28 2020 at 17:55):

That would work, how do you do that in fsh?

view this post on Zulip David Pyke (May 28 2020 at 17:57):

The heck with this, I'm going to push back and do it as a bundle. I'm sure there's a way to do this but I can't figure it out.

view this post on Zulip ryan moehrke (May 28 2020 at 18:04):

I just used a lot of ^ escaped lines, obviously you would use #contained not #bundled but this is the format:

Profile: PatientSingleAgg
Parent: Patient
Id: PatientSingleAgg
Title: "PatientSingleAgg"
Description: "PatientSingleAgg profile for testing"

view this post on Zulip David Pyke (May 28 2020 at 18:06):

I'll give it a shot and see how sushi and the publisher like that

view this post on Zulip Vassil Peytchev (May 28 2020 at 18:12):

David Pyke said:

The heck with this, I'm going to push back and do it as a bundle. I'm sure there's a way to do this but I can't figure it out.

If it can be done as a bundle, it probably should be done as a bundle. Contained resources are not a "packaging" structure...

view this post on Zulip David Pyke (May 28 2020 at 20:36):

I agree, I was asked to attempt this by Those That Rule. Now that I've tried a bunch of different ways, I'm going to just bundle them

view this post on Zulip Chris Moesel (May 28 2020 at 21:02):

Thanks everyone for working this one out. Sorry I totally misunderstood the question! BTW, @ryan moehrke -- I think yours could be simplified, right? The type is already a reference to an Organization, so I don't think you need to repeat that. You should only need:

* contact.organization ^type.aggregation = #bundled

view this post on Zulip Chris Moesel (May 28 2020 at 21:03):

Unless you were trying to just show how you could restrict the type to only certain types. In that case, I think only would still work and would be simpler than using ^ all the way.

view this post on Zulip ryan moehrke (May 28 2020 at 21:25):

thanks, for my purposes its probably good as-is but it's good to know there's a better way of going about it

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 19:13):

Hello, @Chris Moesel @Jose Costa Teixeira . wondering if you folks have an syntax on "contained". I am creating profile of PractitionerRole and looking for a way to have contained Resource type to be only InsurancePlan with card. 1..*

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 19:14):

so you want to disallow any other contained resources?

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 19:15):

yes

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 19:15):

and how is the relation between insuranceplan and practitionerrole?

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 19:16):

PractitionerRole does not link to InsurancePlan normally..

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 19:21):

insuranceplan own the networks which practionerrole participates

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 19:35):

how do you link? PractitionerRole does not have an attribute that would is a reference to InsurancePlan

view this post on Zulip Saul Kravitz (Dec 16 2020 at 19:44):

Completely off topic: in the Plan-Net IG, we added an extension to provide the reference from a PractitionerRole to a Network (a profile of Organization, owned by a Payer. https://build.fhir.org/ig/HL7/davinci-pdex-plan-net/StructureDefinition-plannet-PractitionerRole.html

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 19:54):

we don't have much information about InsurancePlan resource (were are not the payer) nor we maintained the resource. kind of place holder for downstream system use this and build actual resource (it up to downstream system). this is not reference outside of that specific PractitionerRole.
@Saul Kravitz our system is back-end processing service.

view this post on Zulip Chris Moesel (Dec 16 2020 at 20:18):

Hi @Jabeen Mohammed. I think @Jose Costa Teixeira is concerned because normally a contained resource is referenced from the profile in some way. This reference shows how the contained resource is related to the thing that contains it. A contained resource that is not referenced at all has no formal relationship to the thing containing it. People can guess at the relationship, but you really ought to formalize it. One way to do that, as @Saul Kravitz suggested, is to create an extension that references an InsurancePlan to formally represent the relationship between PractitionerRole and InsurancePlan.

I'm not very familiar w/ this domain, so my suggestion may not be exactly right (semantically), but here is an example of how you might do this with FSH if you wanted to represent a PractitionerRole that "accepts" one or more InsurancePlans (that you want contained):

Extension: AcceptsInsurancePlan
Id: accepts-insurance-plan
* value[x] 1..1
* value[x] only Reference(InsurancePlan)

Profile: MyPractitionerRole
Parent: PractitionerRole
Id: my-practitioner-role
* contained 1..*
* contained only InsurancePlan
* extension contains AcceptsInsurancePlan named accepts 1..*

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 20:23):

yes, i was asking because resources can only be contained in other resources if there is a reference from the resource to the contained resource, or if the contained resource references the container resource.

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 20:24):

if such an extension is created, then the problem is solved

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 20:55):

@Chris Moesel @Jose Costa Teixeira I wish my client client's agree to extension which more of norm. but got find way... hopefully can convince them on extension :grinning_face_with_smiling_eyes:

view this post on Zulip Jabeen Mohammed (Dec 16 2020 at 20:59):

@Chris Moesel thanks for example... :smile:

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 20:59):

A contained resource only makes sense if the parent resource points to it, or if it points to the parent resource

view this post on Zulip Jose Costa Teixeira (Dec 16 2020 at 21:00):

http://build.fhir.org/references.html#contained

view this post on Zulip Jabeen Mohammed (Dec 17 2020 at 03:30):

@Chris Moesel @Jose Costa Teixeira @Saul Kravitz thanks for guys...
I was able to share the comparison "contained" vs "extension" with my clients customers and the winner was "extension".

view this post on Zulip Juan Manuel Caputo (Feb 23 2021 at 10:38):

Hello,
Im building an IG using FHIR Shorthand, and I need to specifiy a resource with acontained resource in it.

I've been doing a reserch and I also asked in this forum on other topic (Implementors), because i didn't know that this stream exists, an until now I found that a contained resource only can be use in the instance of a resource.

¿It's not possible to use in the definition of the resource?

greetins and thanks in advance

view this post on Zulip Nick Freiter (Feb 23 2021 at 13:11):

You can add a contained resource to a Profile of a resource using the ^ syntax. Here is a contrived but simple example:

Instance: ContainedResource
InstanceOf: Observation
* status = #final

Profile: PatientProfile
Parent: Patient
* ^contained[0] = ContainedResource

This will create a StructureDefinition for the PatientProfile, and that StructureDefinition will contain the ContainedResource Observation.

view this post on Zulip Barbro Vessman (Aug 19 2021 at 14:22):

Hello

How can I add info about a contained resource? I'm trying different ways but do not succeed.

* ^contained[+] = List
* ^contained[=].status 1..1 MS
* ^contained[=].status ^short = "current | retired | entered-in-error""

The second and third lines give errors:

  • Assignment rules must include at least one space both before and after the '=' sign
  • The element or path you referenced does not exist: contained[0].status

How can this be expressed?

view this post on Zulip David Pyke (Aug 19 2021 at 14:25):

You add all that data in the contained resource profile and instance definition, not in the parent profile itself.

view this post on Zulip Jean Duteau (Aug 19 2021 at 14:26):

you don't need the '^' unless you mean to add a contained resource to the underlying StructureDefinition. Here's what I do in one of my profiles:

* contained contains BusinessOperation 1..* MS and USAgentAffiliation 0..1 MS and USAgent 0..1 MS
* contained[BusinessOperation] only LabelerBusinessOperation
* contained[USAgentAffiliation] only USAgentAffiliation
* contained[USAgent] only USAgentOrganization

And then in the instance:

* contained[USAgentAffiliation] = SampleLabelerUSAgentAffiliation
* contained[USAgentAffiliation].organization.reference = "#"
* contained[USAgentAffiliation].participatingOrganization.reference = "#usagent"
* contained[USAgent] = SampleLabelerUSAgent
* contained[USAgent].id = "usagent"
* contained[BusinessOperation] = SampleLabelerBusinessOperation
* contained[BusinessOperation].providedBy.reference = "#"

view this post on Zulip Barbro Vessman (Aug 19 2021 at 14:41):

OK, thanks a lot @David Pyke and @Jean Duteau . Great with examples! Same thing with referenced resources then I suppose

view this post on Zulip Catherine Hosage Norman (Jan 12 2022 at 05:17):

What is the correct syntax to specify another profile needs to be used for a contained resource that will be referred to in the file?

Profile: DrugProduct
Parent: MedicinalProductDefinition
Id: pqcmc-DrugProduct
Title: "Drug Product"
Description: "Includes the properties of the drug product, its components and impurities"
// ComponentSubstance is a profile

  • .contained = ComponentSubstance
    // this gave the error: Cannot assign Instance at path contained to element of type Resource. Definition not found for Instance:

  • description ^short = "Drug Product Description"
    // This gave the error: Cannot assign Reference value: Reference(ComponentSubstance). Value does not match element type: Resource
    The last seems closer, but it is not catching on that behind the ComponentSubstance is a parent resource. So is there a way to specify use this profile with the resource?

view this post on Zulip Catherine Hosage Norman (Jan 12 2022 at 05:20):

correction to the last bullet

  • .contained = Reference(ComponentSubstance) not description ^short = "Drug Product Description".

view this post on Zulip Jean Duteau (Jan 12 2022 at 05:46):

Contained is a resource array so you probably need to slice it first and then restrict the slice to a specific profile.

view this post on Zulip Jean Duteau (Jan 12 2022 at 05:48):

If you mean to say that all contained resources have to be of the same type, then the example I gave earlier would work: contained only ComponentSubstance

view this post on Zulip Catherine Hosage Norman (Jan 12 2022 at 16:48):

Bingo! thanks


Last updated: Apr 12 2022 at 19:14 UTC