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

Not Equal and Not Equivalent clause coverage calculation handling #291

Merged
merged 7 commits into from
Dec 15, 2023

Conversation

elsaperelli
Copy link
Contributor

Summary

#287 contains CMS69 which includes a !~ (not equivalent) operation in the CQL that has some undesirable coverage calculation behavior due to the way Not Equivalent and Not Equal operations are translated from CQL to ELM json. This PR provides a workaround so that Not Equivalent and Not Equal clauses behave like Equal and Equivalent clauses.

New behavior

Before, in order to reach 100% clause coverage with CMS69, test cases where BMIEncounter.class WAS equivalent to 'virtual' AND where BMIEncounter.class was NOT equivalent to 'virtual' needed to be provided. This behavior did not match the clause coverage highlighting where only the not equivalent test case was needed for the clause to be highlighted as covered. Now, the coverage calculation matches the coverage highlighting. For CMS69 to reach 100% clause coverage, ONLY a test case where BMIEncounter.class is NOT equivalent (!~) to 'virtual' is needed.

Code changes

  • ClauseResultsHelpers.ts - a workaround was added to for this specific case in findAllLocalIdsInStatement so that the result of the equal or equivalent is now the result of the not.

Testing guidance

  • npm run check
  • npm run cli -- detailed -m <path-to-CMS69> --patients-directory <path-to-CMS69-patients-directory> --trust-meta-profile true --debug on the master branch with the test cases provided in the should result in 96% clause coverage.
  • Switch to this branch and run the same command. This should result in 96.2% clause coverage, showing that the !~ clause is now included in the calculation.
  • Another good way to test this would to be to npm link this branch to fqm-testify to play around with different test cases.

Copy link

github-actions bot commented Dec 5, 2023

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
86.39% (+0.02% 🔼)
2373/2747
🟡 Branches
73.77% (+0.1% 🔼)
2208/2993
🟢 Functions 88.89% 424/477
🟢 Lines
86.72% (+0.02% 🔼)
2293/2644

Test suite run success

451 tests passing in 31 suites.

Report generated by 🧪jest coverage report action from ceb446f

Copy link
Contributor

@hossenlopp hossenlopp left a comment

Choose a reason for hiding this comment

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

Just needs some unit testing.

// If so, we will want to treat this as a 'Not Equivalent' or 'Not Equal' expression which we can do so
// by mapping the 'Equal' or 'Equivalent' clause localId to that of the 'Not' clause
if (statement.operand) {
if (statement.operand.type === 'Equivalent' || statement.operand.type === 'Equal') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole set of logic could use a test case. It's one of the few things in here that isn't tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! I added a unit test for the !~...however, I do not think I am able to add a unit test for the != logic at the moment since an update to the translator will be coming soon that puts a localId on the Equal expression (but it doesn't right now). Am I correct in this? @birick1 may have additional insight as well

Copy link
Contributor

@hossenlopp hossenlopp 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 and added test covers most of this.

@hossenlopp hossenlopp self-requested a review December 12, 2023 19:30
Copy link
Contributor

@hossenlopp hossenlopp left a comment

Choose a reason for hiding this comment

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

Regression test shows some changes that were unexpected.

src/calculation/ClauseResultsHelpers.ts Show resolved Hide resolved
@hossenlopp hossenlopp self-requested a review December 13, 2023 15:37
src/calculation/ClauseResultsHelpers.ts Outdated Show resolved Hide resolved
src/calculation/ClauseResultsHelpers.ts Outdated Show resolved Hide resolved
@hossenlopp hossenlopp self-requested a review December 14, 2023 16:51
Copy link
Contributor

@hossenlopp hossenlopp left a comment

Choose a reason for hiding this comment

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

New tests are looking good

@hossenlopp hossenlopp merged commit a37ab3c into master Dec 15, 2023
5 checks passed
@hossenlopp hossenlopp deleted the cms-69-issue branch December 15, 2023 18:07
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