Repository navigation
Search each alternative of a choice element - #2950
Merged
Merged
Conversation
A search parameter whose expression is a choice element, such as Observation.effective, failed because the choice has no single type. Each alternative the parameter type allows is now searched, and those it does not allow, such as Timing for a date, are skipped.
|
johngrimes
marked this pull request as ready for review
November 23, 2026 03:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This change makes a search parameter whose expression is a choice element, such as
Observation.effectivein thedateparameter, search each alternative of the choice that the parameter type allows, and combine the results with OR. Previously the search failed withCannot determine FHIR type for expression: Observation.effective, because the column builder requires a single FHIR type and an unresolved choice has none.Each allowed alternative is selected with
ofTypeand goes through the same path as any other expression, soObservation?date=2020now searcheseffectiveDateTime,effectiveInstantandeffectivePeriod. With the:notmodifier the negated filters of the alternatives are combined with AND, so that a resource matches only if no alternative holds the value.The same applies to every parameter in the default registry whose expression is a bare choice element. Besides the
dateparameter of Observation, DiagnosticReport, Immunization and Procedure, the following no longer fail:ChargeItem?occurrence,ServiceRequest?occurrence,MedicationStatement?effectiveandMedicationAdministration?effective-timeCarePlan?activity-date,Specimen?collected,Media?createdandDetectedIssue?identifiedMessageHeader?eventandMessageDefinition?event(token,Codingoruri)Consent?source-reference(theAttachmentalternative is skipped)RiskAssessment?probability(theRangealternative is skipped)This assumes the rule for #2913 is to skip a type that the parameter type does not allow, rather than fail. An alternative of that kind is skipped, for example
TimingforObservation.effective,stringforImmunization.occurrence, andstring,AgeandRangeforProcedure.performed. A resource that holds only such an alternative does not match. If no alternative of a choice is allowed, the search fails with anInvalidSearchParameterException;PlanDefinition?definition(canonicaloruri, against a reference parameter) now fails in this way. Failing on a disallowed alternative instead would make everyObservation?datesearch fail onTiming, so I don't think that rule is workable here. This change does not alter how disallowed types are handled outside of choice elements, which is the subject of #2913.Some gaps remain:
Timingis not supported, although R4 lists it as a target of date search.system|codesyntax cannot be used onMessageHeader?eventandMessageDefinition?event, because theurialternative rejects it. This failed before this change as well.:noton such a parameter (for exampleObservation?combo-code:not) matches resources that hold the value in one of the expressions. This predates this change, and I have left it alone because it overlaps with search_to_column rejects Observation?value-quantity with InvalidSearchParameterException (SampledData) #2913.The tests search Observation, DiagnosticReport, Immunization, Procedure, MessageHeader and CarePlan through the default registry, with a resource for each alternative.
Resolves #2914.