-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "position" slicing discriminator #1538
base: master
Are you sure you want to change the base?
Conversation
FHIR R5 added "position" as an allowed slice discriminator, where slices are differentiated by their order within a list element. Because a consistent order is necessary for this slicing to be meaningful, emit an error if "ordered" is not set to true for the slicing. Previous versions of FHIR may not use this discriminator. Minor changes to npm-shrinkwrap.json due to issues detected by `npm audit`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense! I tested out the new slicing discriminator in R4 and R5, and it worked as expected!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving this, but I did make a minor suggestion that you can take or leave. And I also started a discussion on an alternate approach to ordered
-- but I'm comfortable with it as-is if that's what other think is best.
if (d.type === 'position' && slicing.ordered !== true) { | ||
validationErrors.push( | ||
new ValidationError( | ||
'Slicing ordering must be true when a position discriminator is used.', | ||
'slicing.ordered' | ||
) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's something to think about: If the user uses a position
discriminator type, should we just set ordered
to true for them? I.e., we know what it should be, so... just do it? Putting the "short" in "shorthand"?
I'm torn on it. I feel like if they don't set the ordered
property themself using a caret rule, then it makes sense to set it for them. But if they had set it themself to the wrong value (false), then I'm not sure if silently setting it to true is the right thing to do...
const ALLOWED_DISCRIMINATOR_TYPES_R5 = [ | ||
'value', | ||
'exists', | ||
'pattern', | ||
'type', | ||
'profile', | ||
'position' | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this, but... it could be:
const ALLOWED_DISCRIMINATOR_TYPES_R5 = [ | |
'value', | |
'exists', | |
'pattern', | |
'type', | |
'profile', | |
'position' | |
]; | |
const ALLOWED_DISCRIMINATOR_TYPES_R5 = [...ALLOWED_DISCRIMINATOR_TYPES, 'position']; |
Description:
FHIR R5 added "position" as an allowed slice discriminator, where slices are differentiated by their order within a list element. Because a consistent order is necessary for this slicing to be meaningful, emit an error if "ordered" is not set to true for the slicing. Previous versions of FHIR may not use this discriminator.
Minor changes to npm-shrinkwrap.json due to issues detected by
npm audit
.Testing Instructions:
Confirm that new tests adequately cover this new feature. Try building projects with R4 and R5 resources using SUSHI, observing that the "position" discriminator can't be used with R4, but can be used with R5. There is also a new error message, so please let me know if you have suggestions for its wording.
Related Issue:
Partially addresses #1391, but does not validate Instances to confirm that slices are provided in the required order when position-based slicing is used.