Skip to content

Incorrect math operations on quantity/numerical literals #2168

Open
@piotrszul

Description

@piotrszul

The results of math operations on quantity literals are incorrect.
e.g.

2.0 'cm' * 2.0 'm' = 0.040 'm2' is not true

Including mix of quantity and decimal/integeer values

FHIR R4 Exclusions

Details

Expected: true but got: null ==> expected: <true> but was: <null>

  • 2.0 'cm' * 2.0 'm' = 0.040 'm2' [** testQuantity9]
  • 4.0 'g' / 2.0 'm' = 2 'g/m' [** testQuantity10]

Math 6 exclusions

Details

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? * ??

  • 2 'kg' * 5 = 10 'kg' [** Can multiply a quantity by a number]
  • 2 * 5 'kg' = 10 'kg' [** Can multiply a number by a quantity]
  • 1 'B' * 2 [** Empty result when one of the operands has a special unit]

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? / ??

  • 1 'B' / 2 [** Empty result when one of the operands has a special unit]

Expected: null but got: [null,null,null,null,1,http://unitsofmeasure.org,1,null,1,null] ==> expected: <null> but was: <[null,null,null,null,1,http://unitsofmeasure.org,1,null,1,null]>

  • 1 'B' + 1 'B' [** Empty result when one of the operands has a special unit]
  • 1 'B' - 1 'B' [** Empty result when one of the operands has a special unit]

Expected: true but got: null ==> expected: <true> but was: <null>

  • 2 'kg' * 5 'm' = 10 'kg.m' [** Can multiply two quantities]

Details

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? / ??

  • 20 'kg' / 5 = 4 'kg' [** Can divide a quantity by a number]
  • 20 / 5 'kg' = 4 '1/kg' [** Can divide a number by a quantity]
  • 3 's' / 3 milliseconds = 1000 [** Allow division of a UCUM duration quantity]

Expected: true but got: null ==> expected: <true> but was: <null>

  • 10 'kg' / 5 'm' = 2 'kg/m' [** Can divide two quantities]

Details

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? + ??

  • 3 '1' + 2 = 5 '1' [** Can add a number to a quantity]
  • 3 + 2 '1' = 5 '1' [** Can add a quantity to a number]

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? - ??

  • 3 - 2 '1' = 1 '1' [** Can subtract a quantity from a number]
  • 3 '1' - 2 = 1 '1' [** Can subtract a number from a quantity]

Details

au.csiro.pathling.errors.InvalidUserInputError: Left and right operands are not comparable: ?? / ??

  • 1 / 3 months [** Empty result when one of the operands is a calendar duration quantity greater than seconds (5)]
  • 1 year / 2 = 6 months [** Can divide a calendar duration quantity by a number]
  • Observation.value / 185 months = 1 [** Can divide System.Quantity (converted from FHIR.Quantity) by System.Quantity]
  • Observation.value / 185 'mo' [** Empty result when one of the operands is a calendar duration quantity greater than seconds (6)]

au.csiro.pathling.errors.InvalidUserInputError: Operands must be comparable

  • 3 month / 2 year = 1 / 8 [** Can divide when both operands are calendar duration quantities]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfhirpathRelated to fhirpath reference implementation

    Type

    Projects

    Status

    Planned

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions