Stream: shorthand
Topic: Adding an extension to a Bundle?
Brian Kaney (Feb 09 2022 at 15:49):
I have looked at this several times and feel like this should work. What am I missing?
Instance: single-gaps-open-indv-report
InstanceOf: Bundle
Usage: #example
* type = #document
* extension[+].url = "my-extension"
* extension[=].valueBoolean = true
Error:
error Cannot read properties of undefined (reading '0')
Line: 5
error Cannot read properties of undefined (reading '0')
Line: 6
Brian Kaney (Feb 09 2022 at 15:55):
Ah, Bundle is Resource, not DomainResource... so I guess we can't add extensions to Bundle resource?
Josh Mandel (Feb 09 2022 at 15:55):
This is subtle :-) Bundle inherits from the FHIR Resource type rather than the DomainResource type.
Josh Mandel (Feb 09 2022 at 15:55):
The usual trick is to add extensions to bundle.meta
Brian Kaney (Feb 09 2022 at 15:56):
Okay, I was thinking of that, thanks!
Josh Mandel (Feb 09 2022 at 15:56):
I can see some opportunities to improve the sushi error message here ;-)
Chris Moesel (Feb 09 2022 at 16:28):
Yeah, it's odd that this is the error message you get. We must have some code that is trying to do something fancy w/ extension
-- because if you change your FSH to use a name other than extension
, you get a much better error message. E.g.,
* foo[+].url = "my-extension"
results in:
error The element or path you referenced does not exist: foo.url
Line: 5
Chris Moesel (Feb 09 2022 at 16:36):
Also, there is a single-line syntax for setting extensions like this. If the extension is defined in the same project, you can do::
* meta.extension[MyExtensionName].valueBoolean = true
If the extension is from FHIR core or a dependency IG, you need to use the canonical URL:
* meta.extension[http://example.org/my-extension].valueBoolean = true
Last updated: Apr 12 2022 at 19:14 UTC