Skip to content

Commit

Permalink
Update equality
Browse files Browse the repository at this point in the history
  • Loading branch information
atuonufure committed Jan 15, 2024
1 parent 564ed45 commit 1f08f79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fhirpathpy/engine/invocations/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ def equality(ctx, x, y):
if len(x) != len(y):
return False

return util.parse_value(x[0]) == util.parse_value(y[0])
a = util.parse_value(x[0])
b = util.parse_value(y[0])

if isinstance(a, nodes.FP_Quantity) and isinstance(b, nodes.FP_Quantity):
y_unit = getattr(b, 'unit', None)
if y_unit in nodes.FP_Quantity.mapUCUMCodeToTimeUnits.values():
return a.deep_equal(b)

return a == b


def normalize_string(s):
Expand Down
11 changes: 11 additions & 0 deletions fhirpathpy/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ class FP_Quantity(FP_Type):
"'ms'": "'ms'",
}

mapUCUMCodeToTimeUnits = {
"'a'": "year",
"'mo'": "month",
"'wk'": "week",
"'d'": "day",
"'h'": "hour",
"'min'": "minute",
"'s'": "second",
"'ms'": "millisecond",
}

"""
A map of the UCUM units that must be paired with integer values when doing arithmetic.
"""
Expand Down

0 comments on commit 1f08f79

Please sign in to comment.