Search Clause
The search clause triggers a search operation: a Http(s) call to a FHIR Server. This SHOULD be done using a FHIR client and will always produce a bundle result, which becomes the initial data set for the query clauses that follow it.
A tool implementing FQL, MUST parse the search clause, but is allowed to report that it cannot execute the search query. A Search expression MAY be ignored, just as a FHIR server may ignore these parameters.
Syntax
The search clause, contains a set of filter expressions separated by and
, which are each transformed into a REST parameter.
SearchClause: 'search' SearchExpression RangeClause?
SearchExpression: SearchEquation ( SearchLogicalOp SearchEquation )*
SearchLogicalOp: 'and'
SearchEquation: FieldName SearchEqualityOp StringValue
SearchEqualityOp: '=' | '!=' | '<' | '>'
Performance
Because the REST URL needs to know the resource type, the search operation is a special case that MUST look into other nodes of the syntax tree.
For good performance and reducing bandwidth, The Search operation SHOULD look into the first of each of the following clauses: from
, and using
that come before the first select
clause.
Order
The search operation becomes the data provider for the full query. And thus must be executed first before all other clauses.
All clauses, exect the search
clauses should be (re) executed in order on the resulting data set.
Example
In the following query.
using 'https://example.com/fhir'
from Patient
search name='Chalmers'
take 10
select
name.given,
name.family
The FHIR search operation takes data from the using
clause, the from
clause, the take
clause and the search
clause, producing the following query:
https://example.com/fhir/Patient?name=Chalmers&_count=10