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

Automatically set units and precision in rules #391

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

EdwardvanRaak
Copy link
Collaborator

For some testing on mobile implementation for now.

No tests yet

@codecov
Copy link

codecov bot commented Feb 11, 2022

Codecov Report

Merging #391 (9523260) into master (2d166fa) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 9523260 differs from pull request most recent head 8aec62b. Consider uploading reports for the commit 8aec62b to get more accurate results

@@            Coverage Diff            @@
##             master     #391   +/-   ##
=========================================
  Coverage     71.26%   71.26%           
  Complexity     6710     6710           
=========================================
  Files           657      657           
  Lines         22245    22245           
  Branches       3572     3572           
=========================================
  Hits          15853    15853           
  Misses         4698     4698           
  Partials       1694     1694           
Impacted Files Coverage Δ
.../main/java/com/nedap/archie/query/RMPathQuery.java 69.23% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

CAttribute precision = template.getDefinition().itemAtPath(pathOfParent + "/precision");

if (units.getChildren().size() != 1 || precision.getChildren().size() != 1)
return result; // Only fix if there is 1 unit and 1 precision, don't assume anything otherwise
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could split these two checks for more auto-fixing.

Also note that precision.getChildren() contains intervals, and you cannot use those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and you cannot use those.

Not exactly sure what you mean, am I not allowed to do a precision.getChildren().size() != 1?


// Fix units
CString cString = (CString) units.getChildren().get(0);
String assumedUnitValue = cString.getAssumedValue();
Copy link
Collaborator

Choose a reason for hiding this comment

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

assumed value won't work, that's an explicitly set thing in ADL. You need the actual first+only constraint here, need to check if it's not a regular expression (starts+ends with / or ^), and set it.


// Fix precision
CInteger cInteger = (CInteger) units.getChildren().get(0);
long assumedPrecisionValue = cInteger.getAssumedValue();
Copy link
Collaborator

Choose a reason for hiding this comment

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

assumed value won't work, that's an explicitly set thing in ADL. You need the actual first+only constraint here. This constraint will be an Interval<Long>. If interval.isUpperBounded(), you can set precision to -1.
Otherwise, if interval.isUpperIncluded() set it to interval.upper
else set it to interval.upper -1.


private static Map<String, Object> fixDvQuantity(Object rmObject, Archetype archetype, String pathOfParent) {
try {
Map<String, Object> result = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two more todo's:

  • check if actually the magnitude is being set (see the pathOfParent.endsWith contruction elsewhere)
  • if units or precision already have a value, should they be set? You probably do not want to override a value set manually or with a different rule elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check if actually the magnitude is being set (see the pathOfParent.endsWith contruction elsewhere)

I only see .../value in the pathOfParent when these quantities are being set by rule evaluation. Not sure how that would work then, or should I expect a .../value/magnitude path or something.

Base automatically changed from fix_rules_terminology_id to master February 21, 2022 13:03
@EdwardvanRaak EdwardvanRaak changed the base branch from master to fix-rm-path August 18, 2022 14:20
Base automatically changed from fix-rm-path to master August 23, 2022 13:40
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