-
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
Merged
+98
−10
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -386,13 +386,27 @@ export class ElementDefinition { | |||||||||||||||||||
validationErrors.push( | ||||||||||||||||||||
this.validateIncludes(slicing.rules, ALLOWED_SLICING_RULES, 'slicing.rules') | ||||||||||||||||||||
); | ||||||||||||||||||||
|
||||||||||||||||||||
const isR4 = this.structDef.fhirVersion.startsWith('4.'); | ||||||||||||||||||||
slicing.discriminator?.forEach((d, i) => { | ||||||||||||||||||||
const discriminatorPath = `slicing.discriminator[${i}]`; | ||||||||||||||||||||
validationErrors.push(this.validateRequired(d.type, `${discriminatorPath}.type`)); | ||||||||||||||||||||
validationErrors.push( | ||||||||||||||||||||
this.validateIncludes(d.type, ALLOWED_DISCRIMINATOR_TYPES, `${discriminatorPath}.type`) | ||||||||||||||||||||
); | ||||||||||||||||||||
if (isR4) { | ||||||||||||||||||||
validationErrors.push( | ||||||||||||||||||||
this.validateIncludes(d.type, ALLOWED_DISCRIMINATOR_TYPES, `${discriminatorPath}.type`) | ||||||||||||||||||||
); | ||||||||||||||||||||
} else { | ||||||||||||||||||||
validationErrors.push( | ||||||||||||||||||||
this.validateIncludes(d.type, ALLOWED_DISCRIMINATOR_TYPES_R5, `${discriminatorPath}.type`) | ||||||||||||||||||||
); | ||||||||||||||||||||
if (d.type === 'position' && slicing.ordered !== true) { | ||||||||||||||||||||
validationErrors.push( | ||||||||||||||||||||
new ValidationError( | ||||||||||||||||||||
'Slicing ordering must be true when a position discriminator is used.', | ||||||||||||||||||||
'slicing.ordered' | ||||||||||||||||||||
) | ||||||||||||||||||||
); | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
validationErrors.push(this.validateRequired(d.path, `${discriminatorPath}.path`)); | ||||||||||||||||||||
}); | ||||||||||||||||||||
return validationErrors.filter(e => e); | ||||||||||||||||||||
|
@@ -3076,6 +3090,15 @@ export type ElementDefinitionSlicingDiscriminator = { | |||||||||||||||||||
// Cannot constrain ElementDefinitionSlicingDiscriminator to have these values as a type | ||||||||||||||||||||
// since we want to process other string values, but log an error | ||||||||||||||||||||
const ALLOWED_DISCRIMINATOR_TYPES = ['value', 'exists', 'pattern', 'type', 'profile']; | ||||||||||||||||||||
// R5 introduced the 'position' discriminator | ||||||||||||||||||||
const ALLOWED_DISCRIMINATOR_TYPES_R5 = [ | ||||||||||||||||||||
'value', | ||||||||||||||||||||
'exists', | ||||||||||||||||||||
'pattern', | ||||||||||||||||||||
'type', | ||||||||||||||||||||
'profile', | ||||||||||||||||||||
'position' | ||||||||||||||||||||
]; | ||||||||||||||||||||
Comment on lines
+3094
to
+3101
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
export type ElementDefinitionBase = { | ||||||||||||||||||||
path: string; | ||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 setordered
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...