You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problems constraining an element's type in Profile A to a profiled type (Profile B) with child elements that have slices when Profile A's parent has constrained child element's of the element type first
#1555
Open
cmoesel opened this issue
Jan 15, 2025
· 0 comments
This is a tricky one that is best explained via an example.
If you have a profile that constrains a child element of one of its element's that is a complex type (e.g., a Patient profile that constrains meta.lastUpdated):
Profile: BaseParentPatientProfile
Parent: Patient
* meta.lastUpdated MS // force parent to expand all child elements of meta
And you define a profile on that same complex type (e.g., a profile on Meta) that introduces slicing on one of the complex type's children (e.g., slicing on Meta.security) and at least one slice (e.g., Meta.security[ABC]):
And then you define a child profile of the first parent profile that constrains the complex type element to the profile of the the complex element (e.g., a profile of BaseParentPatientProfile that constrains meta to MetaWithABCSecuritySlice) and then reference the slice defined in the complex type's profile (e.g., meta.security[ABC]):
Profile: BrokenPatientProfile
Parent: BaseParentPatientProfile
* meta only MetaWithABCSecuritySlice
* meta.security[ABC] MS
Then SUSHI will fail to find the element corresponding to the slice defined in the complex type's profile:
error No element found at path meta.security[ABC] for FlagRule in BrokenPatientProfile, skipping rule
I think this is because the parent profile (e.g., BaseParentPatientProfile) has to expand all the children of the complex type element (e.g., children of Patient.meta) to apply the constraint on a child element (e.g., Patient.meta.lastUpdated). When the type constraint (e.g., meta only MetaWithABCSecuritySlice) is applied to that element in a child profile, SUSHI does not merge the type's profile elements with the already expanded child elements from the parent profile -- so when it tries to reference a child element from the type's profile in the context of the profile that applied the type, it can't find it.
A potential workaround is to reintroduce the slicing and slices from the complex type profile into the profile that applies the complex type. E.g.:
Profile: WorkaroundPatientProfile
Parent: BaseParentPatientProfile
* meta only MetaWithABCSecuritySlice
* meta.security ^slicing.discriminator.type = #value
* meta.security ^slicing.discriminator.path = "system"
* meta.security ^slicing.rules = #closed
* meta.security ^slicing.description = "Slice on system value"
* meta.security contains ABC 1..1
* meta.security[ABC] MS
This causes some redundancy in the definitions, but I don't think it is harmful as long as the slicing definition and slices are a perfect match to what was in the complex type's profile.
NOTE: I suspect the correct fix for this is that when a type constraint is applied to an element whose children have already been expanded, that type's elements should be merged with the existing expanded elements. I'm not sure how difficult such a merge would be.
The text was updated successfully, but these errors were encountered:
This is a tricky one that is best explained via an example.
If you have a profile that constrains a child element of one of its element's that is a complex type (e.g., a
Patient
profile that constrainsmeta.lastUpdated
):And you define a profile on that same complex type (e.g., a profile on
Meta
) that introduces slicing on one of the complex type's children (e.g., slicing onMeta.security
) and at least one slice (e.g.,Meta.security[ABC]
):And then you define a child profile of the first parent profile that constrains the complex type element to the profile of the the complex element (e.g., a profile of
BaseParentPatientProfile
that constrainsmeta
toMetaWithABCSecuritySlice
) and then reference the slice defined in the complex type's profile (e.g.,meta.security[ABC]
):Then SUSHI will fail to find the element corresponding to the slice defined in the complex type's profile:
I think this is because the parent profile (e.g.,
BaseParentPatientProfile
) has to expand all the children of the complex type element (e.g., children ofPatient.meta
) to apply the constraint on a child element (e.g.,Patient.meta.lastUpdated
). When the type constraint (e.g.,meta only MetaWithABCSecuritySlice
) is applied to that element in a child profile, SUSHI does not merge the type's profile elements with the already expanded child elements from the parent profile -- so when it tries to reference a child element from the type's profile in the context of the profile that applied the type, it can't find it.A potential workaround is to reintroduce the slicing and slices from the complex type profile into the profile that applies the complex type. E.g.:
This causes some redundancy in the definitions, but I don't think it is harmful as long as the slicing definition and slices are a perfect match to what was in the complex type's profile.
Full Example on FSH Online
NOTE: I suspect the correct fix for this is that when a type constraint is applied to an element whose children have already been expanded, that type's elements should be merged with the existing expanded elements. I'm not sure how difficult such a merge would be.
The text was updated successfully, but these errors were encountered: