Skip to content

Commit cb95ae9

Browse files
ruscodercursoragent
andcommitted
Fix is_true regression for ResourceNode-wrapped booleans.
Revert `is True` to `== True` in is_true so iif/all treat mid-pipeline ResourceNode conditions correctly after the 2.2.1 ruff cleanup. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 779f157 commit cb95ae9

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

fhirpathpy/engine/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def is_nullable(x):
6060

6161

6262
def is_true(x):
63-
return x is True or isinstance(x, list) and len(x) == 1 and x[0] is True
63+
# Use == not is: mid-pipeline values are often ResourceNode wrappers; __eq__
64+
# compares .data, while `is True` does not (see fhirpathpy 2.2.1 regression).
65+
return x == True or isinstance(x, list) and len(x) == 1 and x[0] == True # noqa: E712
6466

6567

6668
def arraify(x, instead_none=None):

tests/cases/5.1_existence.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ tests:
117117
expression: (0|1|2|3).all($this = $index)
118118
result: [true]
119119

120+
- desc: '** all with boolean field criterium (all true)'
121+
expression: Functions.coll1.colltrue.attr.all($this)
122+
result: [true]
123+
124+
- desc: '** all with boolean field criterium (contains false)'
125+
expression: Functions.coll1.collwithfalse.attr.all($this)
126+
result: [false]
127+
120128

121129
- desc: '5.1.5. allTrue() : boolean'
122130
# Takes a collection of boolean values and returns

tests/cases/5.5_conversion.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ tests:
3838
expression: Functions.iif(false, 'a')
3939
result: []
4040

41+
- desc: '** iif with boolean field as criterium (true)'
42+
expression: Functions.iif(attrtrue, 'a', 'b')
43+
result: ['a']
44+
45+
- desc: '** iif with boolean field as criterium (false)'
46+
expression: Functions.iif(attrfalse, 'a', 'b')
47+
result: ['b']
48+
4149
- desc: '5.5.2. toInteger() : integer'
4250
# If the input collection contains a single item, this functio# n will return a single integer if:
4351
# the item in the input collection is an integer

0 commit comments

Comments
 (0)