DV_PROPORTION.is_integral in OPTs and validation rules

Hi all, I’m working on testing a server, and found for DV_PROPORTION a constraint for “is_integral” ends up in the OPT: https://github.com/ehrbase/ehrbase/blob/develop/tests/robot/_resources/test_data_sets/valid_templates/minimal/minimal_action_2.opt#L247-L273

By the spec, “is_integral” is a function, not a field, so that constraint looks strange there. Is that a bug of the modeling tools?

Looking at the spec definition for is_integral(), the description is a little confusing: “True if the numerator and denominator values are integers, i.e. if precision is 0.”

For that to make sense, I think when ‘precision’ is mentioned, is the precision of each numerator and denominator, not the precision of the DV_PROPORTION. But if that’s referring to the DV_PROPORTION.precision, for that function definition, we need to consider numerator, denominator, precision, type and the validation rules, because are all related. The way I think that should be wirtten is:

if precision is 0, then numerator, denominator and type should be integer, integer, [fraction or integer fraction] to comply with the validation rules (I didn’t include ‘percentage’ because I think we could have values like 33.5%).

What do you think?

And everything is interlinked because of the validation rules:

  • precision = 0 implies is_integral
  • is_integral implies (numerator.floor = numerator and denominator.floor = denominator)
  • (type = pk_fraction or type = pk_integer_fraction) implies is_integral

Testing Marand’s implementation, I see they also use is_integral as a field for validation:

"Invalid value at /content[openEHR-EHR-ACTION.minimal_2.v1,'Minimal 2']/description[at0001,'Arbol']/items[at0002,'Proportion']/value/is_integral, expected: not true, actual: true"

Should all functions in the RM be treated as fields for validation?

I would say better to not do that, as there are times values are derived from actual attributes or compossed from several ones. This is something you probably cannot do with xml schema (probably is feasible with schematron or rules)