How to specify "value" using SearchParameter.expression?


I’m trying to implement search function for FHIR server and have a question.

The Description & Constraints for SearchParameter.expression says “FHIRPath expression that extracts the values”. (SearchParameter - FHIR v4.0.1)
Is there a method to specify the values using SearchParameter.expression without any external logic??

For example, suppose I want to implement search function for “[base]/AllergyIntolerance?code=xxxx”.
The expression of SearchParameter/clinical-code is “AllergyIntolerance.code | AllergyIntolerance.reaction.substance”, which correspond to CodableConcepts, and the type of the SearchParameter is “token”.

As explained in SearchParameter - FHIR v4.0.1, CodeableConcepts may contain text and/or multiple codings, where the codings themselves contain a code and a system.

I suppose “[base]/AllergyIntolerance?code=xxxx” should search for codes and not for systems. Code elements and system elements, however, are both children of Coding elements and look parallel. Is there any definition or description which element is representing the “value” for the parent Coding element?

The token search type allows searching for code alone, code + system or code with no declared system. Details are here: Search - FHIR v4.6.0

In general, it’s best to always search for both code + system because the same code string can exist in multiple systems and mean different things.

1 Like

Thank you for reply.
What I need was fully explained in the url you give.

What confused me was that for the string type search parameter, the expression shows the value (e.g. Patient.​name.​given for “given” search parameter), while for the token type, it only shows the data type (e.g not AllergyIntolerance.code.Coding.code but AllergyIntolerance.​code for “code” search parameter) , and the search section explains what the value is for each data type.

Thank you!