Repository navigation
Done
Labels
Bunsen_lineAffects the Bunsen-based encoders line (v10.0.0 and earlier)PoF_lineAffects the Parquet on FHIR line (#2367)bugSomething isn't working
Description
Summary
search_to_column raises on the standard value-quantity search parameter of Observation, so no filter column is produced. The error is about the SampledData branch of the parameter's expression, which the FHIR specification marks as not used in search.
Environment
- Pathling 10.0.0 (PyPI; Python 3.11, PySpark 4.0.5) and current
main(11.0.0-SNAPSHOT build; Python 3.9) - FHIR R4, Python library API
How it was found
Reproduced while reviewing this issue.
Steps to reproduce
from pathling import PathlingContext
pc = PathlingContext.create(enable_terminology=False)
pc.search_to_column("Observation", "value-quantity=5.4")Actual behaviour (observed)
The call raises before any data is read:
py4j.protocol.Py4JJavaError: An error occurred while calling o87.searchToColumn.
: au.csiro.pathling.search.InvalidSearchParameterException: FHIR type 'SampledData' is not valid for search parameter type 'QUANTITY'. Allowed types: [QUANTITY]
Stack trace (10.0.0)
Traceback (most recent call last):
File "repro.py", line 5, in <module>
pc.search_to_column("Observation", "value-quantity=5.4")
File ".../pathling/context.py", line 865, in search
jcolumn = self._jpc.searchToColumn(resource_type, search_expression)
...
py4j.protocol.Py4JJavaError: An error occurred while calling o87.searchToColumn.
: au.csiro.pathling.search.InvalidSearchParameterException: FHIR type 'SampledData' is not valid for search parameter type 'QUANTITY'. Allowed types: [QUANTITY]
at au.csiro.pathling.search.SearchColumnBuilder.getFilterForType(SearchColumnBuilder.java:361)
at au.csiro.pathling.search.SearchColumnBuilder.buildExpressionFilter(SearchColumnBuilder.java:336)
at au.csiro.pathling.search.SearchColumnBuilder.lambda$buildCriterionFilter$2(SearchColumnBuilder.java:273)
... (java.util.stream frames)
at au.csiro.pathling.search.SearchColumnBuilder.buildCriterionFilter(SearchColumnBuilder.java:274)
at au.csiro.pathling.search.SearchColumnBuilder.lambda$fromSearch$0(SearchColumnBuilder.java:175)
... (java.util.stream frames)
at au.csiro.pathling.search.SearchColumnBuilder.fromSearch(SearchColumnBuilder.java:176)
at au.csiro.pathling.search.SearchColumnBuilder.fromQueryString(SearchColumnBuilder.java:195)
at au.csiro.pathling.library.PathlingContext.searchToColumn(PathlingContext.java:951)
... (reflection and py4j frames)
On main the exception and frames are the same, with the SearchColumnBuilder line numbers shifted (363, 338, 275, 276) and PathlingContext.java:959.
Expected behaviour (from the specification, not verified end to end because the failure occurs first)
The call returns a filter column. Per the FHIR R4 quantity search rules:
- The parameter's expression is
(Observation.value as Quantity) | (Observation.value as SampledData), and the specification listsSampledDataas "Not used in search". - An Observation with a
valueQuantityof 5.4 should match. - An Observation whose value is a
SampledDatashould never match and should not cause an error.
Example that should match:
{
"resourceType": "Observation",
"id": "example",
"status": "final",
"code": { "text": "dose" },
"valueQuantity": { "value": 5.4, "system": "http://unitsofmeasure.org", "code": "mg" }
}Optional
- Suspected cause (hypothesis, from reading the source): The search validates every type in the union expression against the parameter type, and
SampledDatahas no search semantics, so it is rejected. A type the specification marks as not used in search should contribute no matches, not an error. - Scope: Not investigated.
- Workaround: Not investigated.
- Suggested acceptance tests:
value-quantity=5.4returns a column without raising.- Applied to the example above, it selects that Observation.
- Applied to an Observation whose value is a
SampledData, it excludes it without error.
Related: #1986 (Support for FHIR Search API queries)
Metadata
Metadata
Assignees
Labels
Bunsen_lineAffects the Bunsen-based encoders line (v10.0.0 and earlier)PoF_lineAffects the Parquet on FHIR line (#2367)bugSomething isn't working
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]Quantity search fails on SampledData for value-quantity[/-][+]search_to_column rejects Observation?value-quantity with InvalidSearchParameterException (SampledData)[/+]piotrszul commentedon Nov 24, 2026
I checked the fix from #2953 (Skip search expressions of a type the parameter does not allow), on
release/11.0.0at 4de8ad6 (11.0.0-SNAPSHOT, Python 3.11.13, Java 21.0.3, Spark 4.0.5).Fixed: the snippet in this issue no longer fails, and
Observation?value-quantitymatchesvalueQuantityvalues. TheSampledDataexpression is skipped, which is correct: R4 marks SampledData as not used in search. A sweep of the bundled R4 registry found 30 parameters that mix an allowed expression with a disallowed one fixed in the same way, and none newly broken.Two things this fix does not cover, now tracked separately:
component-value-quantityandcombo-value-quantitynow get past the error in this issue, but fail on an Observation with more than one component. The same failure affectsValueSet?contexton 10.0.0, so it predates Skip search expressions of a type the parameter does not allow #2953.context-quantitynow skipsRangevalues instead of failing. R4 does define quantity search against a Range, so a resource whose context is a Range is silently not matched. Skip search expressions of a type the parameter does not allow #2953 documents this as a limitation.