RestRepository ANDs multiple codes of a retrieve terminology filter (should be OR): silent empty results with inline codes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with cqf-fhir-utility/.../repository/RestRepository.kt and trace how its flattened parameter lists reach IQuery.where(Map). Use the provided FHIR R4 reproduction with two inline terminology codes, and confirm that multiple values for one key become comma-separated OR values while separate same-key entries retain AND semantics. Add or update a query-building test that verifies the generated request and confirms an Observation matching either code is retrieved.
Written by the indexing model from the issue text.
Description
Summary
RestRepository.search(..., Multimap<String, List<IQueryParameterType>>, ...) flattens each inner list into repeated query parameters, which FHIR search reads as AND. The retrieve provider builds terminology filters as code -> [c1, c2, ...] meaning OR. With two or more inline codes, a CQL retrieve against a remote server silently returns nothing — no error, the expression just evaluates to an empty list / false.
Where
cqf-fhir-utility/.../repository/RestRepository.kt (present in 4.15.0 and on main as of 4.17.0):
for (key in searchParameters.keySet()) {
val flattenLists = searchParameters.get(key).flatMap { obj -> obj!! }.toMutableList()
params[key] = flattenLists
}
...
op = op.where(searchParameters) // IQuery.where(Map<String, List<IQueryParameterType>>)
IQuery.where(Map) emits one key=value per list element, so code -> [loinc|4548-4, loinc|17856-6] becomes
Observation?code=http://loinc.org|4548-4&code=http://loinc.org|17856-6 (AND) instead of
Observation?code=http://loinc.org|4548-4,http://loinc.org|17856-6 (OR).
Repro
RetrieveSettings:TERMINOLOGY_FILTER_MODE.USE_INLINE_CODES,SEARCH_FILTER_MODE.USE_SEARCH_PARAMETERS.- Data repository:
RestRepository(client)pointing at any FHIR R4 server (reproduced on HAPI FHIR 8.4 and on Google Cloud Healthcare API). - Library:
define "HbA1c": [Observation: "HbA1c"]where the ValueSet has two codes; the subject has one Observation with either code. - Result: empty list. Expected: the Observation.
USE_VALUE_SET_URL (code:in) is not a workaround on servers without :in support (Healthcare API answers 400).
Suggested fix
Keep each inner list as a single comma-joined parameter (OR) and keep separate entries for the same key as separate parameters (AND), e.g. build the query with TokenOrListParam or join the values before calling where. We run this as a wrapper today and can open a PR if that approach is acceptable.
Related, smaller
- Long inline code lists produce GET request lines over common server limits (8 KB on Tomcat); falling back to
POST <type>/_searchabove a size threshold avoids 400s. IQuery.usingStyle(SearchStyleEnum.POST)combined withbyUrl(...)still sends GET in HAPI's generic client, which makes that fallback easy to get wrong.
- Dominant language
- Java
- Stars
- 52
- Forks
- 46
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cqframework/clinical-reasoning
-
Provide a supported public API to get CQL results (and optionally MeasureDef data) from R4 measure evaluationPossibly taken @c-schuler claimed this 5 days ago. Openenhancement
cqframework/clinical-reasoning#1150 · 1 assignee ·
Maintainers usually reply within 1 day
-
R4 PlanDefinition/$apply: two requests from the same ActivityDefinition still get the same id, and one is dropped when the CarePlan is written to JSON (follow-up to #779)Possibly taken @dhes claimed this 34 days ago. Open
Difficulty 4/5 1-2 days Newbie friendliness 35/100
cqframework/clinical-reasoning#1137 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 43/100
cqframework/clinical-reasoning#1133 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 40/100
cqframework/clinical-reasoning#1132 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
cqframework/clinical-reasoning#1128 · 1 comment ·
Maintainers usually reply within 1 day
All issues in cqframework/clinical-reasoning
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#3672 ·
Maintainers usually reply within 1 day
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eclipse-edc/IdentityHub#1296 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
cloudfoundry/uaa#4194 ·
Maintainers usually reply within 1 day
-
area: ui priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
tetsuji16/microProject#1721 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days