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

Support code caret rules in ValueSets #249

Merged
merged 5 commits into from
Jan 8, 2024

Conversation

mint-thompson
Copy link
Collaborator

Fixes #236 and completes task CIMPL-1165.

A ValueSet can use caret rules with a code path to set values on included or excluded concepts. The typical use of this is to set a designation, but other elements may also appear. Elements outside of a concept are still unsupported and require the creation of an Instance.

A ValueSet can use caret rules with a code path to set values on
included or excluded concepts. The typical use of this is to set a
designation, but other elements may also appear. Elements outside of a
concept are still unsupported and require the creation of an Instance.
@cmoesel cmoesel requested review from cmoesel and jafeltra November 1, 2023 20:03
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.

I really like the re-use of code. That made this much simpler!

I would like to see one change regarding the ordering of exported rules. Here's a ValueSet JSON to test with if you'd like:
ValueSet-VSWithConceptCaretRules.json

@@ -693,7 +695,7 @@ describe('CaretValueRuleExtractor', () => {
})
);
expect(loggerSpy.getLastMessage('error')).toMatch(
'Value in CodeSytem testCS at concept testConcept for element property[0] is empty. No caret value rule will be created.'
'Value in CodeSystem testCS at concept testConcept for element property[0] is empty. No caret value rule will be created.'
Copy link
Member

Choose a reason for hiding this comment

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

Whoops! Good catch!

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.

This makes sense to me! I didn't notice anything further.

@mint-thompson
Copy link
Collaborator Author

It turns out there are a bunch of issues with ValueSetConceptComponentRule.toFSH that need to be addressed in SUSHI before this PR can be completed correctly. So, this PR is on hold until those updates are available.

The SUSHI dependency is updated to 3.6.0, which supports including the
system in the path array. This is needed for rules on ValueSets. Add the
system to the path array when extracting caret rules on ValueSet concept
components. Caret rules on CodeSystem concepts don't need a system, but
still need the leading # as a separator.

Add optimizer that reorders rules on ValueSets so that concept rules are
grouped with their corresponding caret rules.

Update other tests for Invariants, ValueSets, and ConceptRules based on
other changes included in SUSHI 3.6.0.
Resolve URLs on caret rules after resolving URLs on ValueSet components
so that the caret rules will be able to use aliases that were created
when resolving the components.

Create new arrays to assign to path array when extracting caret rules on
concepts. This avoids the possibility of inadvertantly modifying
multiple rules with a single operation that mutates the path array.
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 tested out the organization of the rules when exporting value sets, and it looks good to me. I just had one question about a commented out test.

// ' valueset http://fhir.food-pyramid.org/FoodPyramidGuide/ValueSets/DeliciousVS'
// ].join(EOL);
// expect(result).toEqual(expectedResult);
// });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason this test is commented out now?

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 looks good! I only have two minor requests:

  • Either uncomment or remove the commented out test that Julia noted
  • Add a few more codes to the test case that I commented on

After that, I think we're good! I tested manually as well and confirmed it is working as expected.

Comment on lines 23 to 26
zooConcepts.concepts = [
new fshtypes.FshCode('bear', 'http://example.org/zoo'),
new fshtypes.FshCode('pelican', 'http://example.org/zoo')
];
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to add a couple of codes that won't have caret rules too -- just to confirm that we're not dropping those. (I don't think we are, but I think it's a good thing to have a test case for).

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.

Looks good to me!

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.

It's good! Let's get this merged!

@mint-thompson mint-thompson merged commit 225d702 into master Jan 8, 2024
14 checks passed
@mint-thompson mint-thompson deleted the cimpl-1165-value-set-concept-rules branch January 8, 2024 16:02
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.

Support FSH 3.0 Concept Rules for Value Sets
3 participants