Skip to content

Commit 427b1f0

Browse files
committed
Fix runtime error when there is a decimal in context
1 parent 60d668d commit 427b1f0

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

fhirpathpy/engine/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ def __eq__(self, value):
839839
return self.data == value
840840

841841
def __hash__(self):
842-
data_hash = hash(json.dumps(self.data, sort_keys=True))
842+
data_hash = hash(json.dumps(self.data, sort_keys=True, default=str))
843843
path_hash = hash(self.path)
844844
return hash((data_hash, path_hash))
845845

tests/test_context.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from fhirpathpy import evaluate as fhirpath
2+
from decimal import Decimal
3+
4+
5+
def use_decimal_in_context_test():
6+
assert fhirpath(
7+
{},
8+
"%QuestionnaireResponse.repeat(item).where(linkId='blood-pressure-systolic').answer.valueQuantity",
9+
{
10+
"QuestionnaireResponse": {
11+
"resourceType": "QuestionnaireResponse",
12+
"item": [
13+
{
14+
"answer": [{"valueQuantity": {"value": Decimal(120)}}],
15+
"linkId": "blood-pressure-systolic",
16+
}
17+
],
18+
}
19+
},
20+
) == [{"value": Decimal(120)}]

0 commit comments

Comments
 (0)