Skip to content
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

Allow caret and insert rules to be applied to concepts within a ValueSet #1315

Merged
merged 8 commits into from
Aug 4, 2023

Conversation

mint-thompson
Copy link
Collaborator

Completes task CIMPL-1130.

Some of the elements within ValueSet.compose.include.concept and ValueSet.compose.exclude.concept can't be reached using the normal concept component rules on a ValueSet. To access those elements, you can now use a caret rule with a path that is a contained concept. Similarly, you can insert a RuleSet at such a path. These rules are similar to the code caret rules and code insert rules used by CodeSystem, but since the concept elements are a flat list, the path has to be exactly once concept long.

A concept component rule with exactly one concept in it establishes a context for an indented rule to appear after it. So, these two rules:

* ZOO#hippo "Hippopotamus"
* ZOO#hippo insert DesignationRules("hipopótamo", #es)

are equivalent to these two rules:

* ZOO#hippo "Hippopotamus"
  * insert DesignationRules("hipopótamo", #es)

The grammar changes to support these rules resulted in some different parser errors in cases where commas are used to list concepts. Additionally, these rules represent a sort of weird case where a rule may set a context, but not itself be indented. Rather than change the set of rules that are allowed to be used in context operations, I added a flag to the context-operation functions so that errors relating to improper indents only get logged once.

Elements within value set concept components can be set by caret value
rules. The concept must already be added to the value set in order to
use it in a caret rule. The concept can be in either the include or
exclude arrays. Concept rules with a single code establish a path
context that can be used by an indented rule that follows it.
Because caret value rules can be applied to concepts, it is also
reasonable to want to apply a rule set containing caret value rules at a
concept. This uses the existing grammar rule for a codeCaretRule, but
only one concept is allowed for the insert rule's path.
@cmoesel cmoesel self-assigned this Jul 27, 2023
Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't as messy as you lead me to believe. That's good!

I do have a few questions and suggestions I'd like you to consider.

Thanks!

src/import/FSHImporter.ts Outdated Show resolved Hide resolved
src/import/FSHImporter.ts Show resolved Hide resolved
src/import/FSHImporter.ts Show resolved Hide resolved
src/import/FSHImporter.ts Outdated Show resolved Hide resolved
src/import/FSHImporter.ts Show resolved Hide resolved
test/import/FSHImporter.ValueSet.test.ts Show resolved Hide resolved
test/import/FSHImporter.context.test.ts Show resolved Hide resolved
The syntax that was used to support listing multiple concepts in a
single rule is removed. Tests related to this syntax are removed.

Add more tests for making sure that rule context is handled properly in
various combinations of rules on a ValueSet.
cmoesel
cmoesel previously approved these changes Aug 1, 2023
Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. This works well and has a great set of tests. I tried it out with all the examples in the balloted spec and they went great!

cmoesel
cmoesel previously approved these changes Aug 2, 2023
Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still good!

Copy link
Collaborator

@jafeltra jafeltra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had one question that could easily just be due to something I missed. Other than that, it looks great and I didn't notice anything else.

Comment on lines +1241 to +1242
/Only one concept may be listed before an insert rule on a ValueSet\..*File: Insert\.fsh.*Line: 3\D*/s
);
Copy link
Collaborator

@jafeltra jafeltra Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question about this case. We log an error if there are multiple concepts listed before the insert rule, but I don't think we log any error if the caret value rule is included after multiple concepts. For example, something like this doesn't log any errors and adds the designation to the hippo concept. Is that expected?

ValueSet: ZooVS
* ZOO#hippo "Hippopotamus"
* ZOO#rhino
* ZOO#hippo ZOO#rhino ^designation.value = "hipopótamo"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang. Yeah, multiple concepts in a VS should trigger an error no matter what. Good find.

@mint-thompson
Copy link
Collaborator Author

@jafeltra thank you for pointing out that case with the caret rule! I've added a test for that and resolved the issue.

Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many times can I approve the same PR? Hopefully this is the last one! (But if not, that is OK).

Copy link
Collaborator

@jafeltra jafeltra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making that update! Looks good to me!

@cmoesel cmoesel merged commit a41dfb1 into master Aug 4, 2023
14 checks passed
@cmoesel cmoesel deleted the cimpl-1130-compose-caret-rule branch August 4, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants