-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix minimum_id algorithm #65
Conversation
I added example files for test cases from the ticket I raised: #62. These appear to pass, which is a good sign. Granted that I'm reading the code too late at night to develop a deep understanding, I'm not fully understand the implementation approach you've taken here. I'd be interested in a narrative description of what steps you intend the algorithm to take because I think that would help me understand it better. Initial observations:
|
Great comments! It will need a few iterations to be quality algorithm, let me go back and try second round of polishing the algorithm/code. |
Short description about the new commit: What the algorithm does:
may be converted to a Hash:
For now this algorithm is "order-unaware". If is easy to change it order-aware. Later we can make it configurable.
|
Remove duplicate
Integrated the recursive minimum_id check into the engine. The previous one (deep_merge) was replaced. |
It doesn't contain a TestScript to test, yet. |
Added some TestScripts for minimumId that uses just fixtures including
These didn't quite work as expected and the logic wasn't giving any hints as to why the unexpected failures, so I started to add some basic error details and ended up fixing a few things while doing that:
Finally, note that rather than try to use the template Jack created for the compare results, I created a minimumId-specific return. Please take a look and let me know what you think. A last thing I'd like to do somewhere as a part of this commit is provide brief documentation of the logic behind our implementation of the minimumId assertion. It is possible that this should live in a FHIR implementation guide eventually, but I think that would be something we tackle in the new year, so I'd probably just put it in the README for simplicity. |
I tested on my end and it looks good. Just added one more test for fun.
Actual resource differed from content in fixture '#{assert.minimumId}'
|
Tried some new wording, see what you think. For each location in the minimumId fixture, there are two failure cases:
Agreed - could be done better, but not a priority now
Agreed. Recommend we avoid setting up a new thing for documentation at this point |
Polished wording; Added minimum_id logic explanation.
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 found "TestScript Engine" and "About the project" were overlapping and merged. Thanks for adding another polish. It looks great! If you think the PR is good, approve and I will merge.
Summary
New algorithm to examine if a FHIR resource is "minimum" of the other FHIR resource
New behavior
Given two FHIR resource instances A and B, A is considered a minimum of B if and only if:
B has all the elements of A, exactly the same element names and values (codes). No consideration of range or pre/post-coordination.
Hierarchies and levels of the elements from A must be the same in B. Otherwise it is considered as different element.
Order doesn’t matter.
Duplication doesn’t matter. If B has two duplicate sets (which isn’t realistically the case of FHIR though), the algorithm stops when it find the first set.
Code changes
Added minimum_id.rb under lib. To be included into assertion.rb after testing.
Testing guidance
ruby lib/testscript_engine/minimum_id.rb