Stream: shorthand
Topic: Extension in Profile in Extension
Jill Doty (May 19 2020 at 21:31):
I've defined a profile with an extension (ReferenceWithPeriod)
Extension: ReferencePeriod
Title: "Reference Period"
Id: reference-period
* value[x] only Period
Profile: ReferenceWithPeriod
Parent: Reference
Title: "Reference with Period"
Id: reference-with-period
* extension contains ReferencePeriod named period 1..1
I'd like to define an extension using that profile, and set the value of the original period extension. I'm struggling to find syntax that doesn't cause an error - any advice is appreciated.
Below are some of the options that don't work... (attempted one at a time)
Extension: FixedStartReference
Title: "FixedStartReference"
Id: fixed-start-reference
* value[x] only ReferenceWithPeriod
* value[x].extension[period].start = "2020-01-01"
* value[x].valuePeriod.start = "2020-01-01"
* value[x].period.start = "2020-01-01"
Nick Freiter (May 20 2020 at 12:49):
What you are trying to do should be possible, and I explain the syntax below, but up front I want to warn you that it seems like you have found a bug specific to Reference unfortunately, so the syntax I explain should work, but doesn't in this case.
The syntax you would want in this case looks more like this:
Extension: FixedStartReference
Title: "FixedStartReference"
Id: fixed-start-reference
* value[x] only ReferenceWithPeriod
* valueReference.extension[period].valuePeriod.start = "2020-01-01"
Once a value[x]
element has been constrained to only one choice, you use the syntax valueDataType
, where DataType is the capitalized name of the data type that the choice has been constrained to. We do it this way, because this is how the data would be represented on an actual instance of a FHIR resource. Note that we do not do valueReferenceWithPeriod
, because ReferenceWithPeriod
is just a profile of Reference
, the underlying datatype is still Reference
. Then you had the right idea to next access extension[period]
. But keep in mind that at this point we are accessing the ReferencePeriod
extension, which does not have a start
on it. The ReferencePeriod
extension has a value[x]
constrained to Period, and the Period has a start. So we access that as valuePeriod.start
. Then the full path becomes the one shown above.
Nick Freiter (May 20 2020 at 12:50):
Again though, my example will still not work. I've replicated your example with other datatypes, and it does work. It is just in the case of Reference that things break down, so this is definitely a bug, which we will work to fix soon. Thanks for the find!
Nick Freiter (May 20 2020 at 13:00):
Here is the issue where we will be tracking this: https://github.com/FHIR/sushi/issues/451
Last updated: Apr 12 2022 at 19:14 UTC