FHIR Search: Combo Search Parameters
HAPI FHIR and Smile CDR define a special type of SearchParameter called a Combo Search Index Parameter that is used to index a combination of parameters together in a single database table. For example, consider the following search:
http://localhost:8000/Patient
By default, the search above relies on separate index tables to manage the family name, gender, and birthdate parameters. This generally works well, but can lead to performance issues if each of these parameters individually returns a large number of records (as would likely be the case for the family and gender parameters above in a large FHIR repository).
Using a Combo Search Index Parameter avoids unnecessary database joining by combining (denormalizing) all of the above values into a single database table for indexing and searching. Optionally, Smile CDR can also enforce uniqueness for the values of the parameters. See Unique Combo Search Index Parameters below for more information.
Note that Combo Search Index Parameters are a different concept from the FHIR Composite Search Parameter type.
FHIR Composite Search Index Parameters use a single parameter in a REST search URL to express multiple values where the values are closely related within the resource (e.g. the component code and component value within an Observation).
HAPI FHIR / Smile CDR Combo Index Search Parameters use multiple parameters in a REST search URL to express unrelated search parameters that are intended to be used together.
Both of these concepts are defined using a SearchParameter resource with a type of composite, however the latter uses an sp-unique
extension to mark it as a combo search parameter.
There are limited number of Search Parameter types that can be used in composite and combo Search Parameters. For more details see Support for Component Types.
The following example shows a sample Non-unique Combo Index Search parameter and it assumes that you have already created the 3 individual SearchParameter resources based on the Patient resource's properties being used here (family
, gender
and birthdate
) :
{
"resourceType": "SearchParameter",
"extension": [
{
"url": "http://hapifhir.io/fhir/StructureDefinition/sp-unique",
"valueBoolean": false
}
],
"status": "active",
"code": "family-gender-birthdate",
"base": [
"Patient"
],
"type": "composite",
"expression": "Patient",
"component": [
{
"definition": "SearchParameter/individual-family",
"expression": "Patient"
},
{
"definition": "SearchParameter/individual-gender",
"expression": "Patient"
},
{
"definition": "SearchParameter/individual-birthdate",
"expression": "Patient"
}
]
}
Composite and Combo SearchParameters are composed of other SearchParameters which are listed under the component
element of the SearchParameter.
Smile CDR and HAPI FHIR support subsets of SearchParameterTypes for composed SearchParameters which will differ based on the containing SearchParameter definition (see sp_unique extension) and whether Indexing of Search Parameters is enabled.
The following table lists supported Types for contained SearchParameters based on the containing composed SearchParameter. Note the limitations described in the following section as well.
Containing composed SP / Contained SP Type | String | Token | Date | Quantity | Uri | Number | Reference |
---|---|---|---|---|---|---|---|
Combo Unique | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Combo Non-Unique | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Composite with full text indexing | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | |
Composite without full text indexing | ✔ | ✔ | ✔ | ✔ |
HFJ_IDX_CMP_STRING_UNIQ
table does not incorporate the partition ID.code
and has a required terminology binding (e.g. Patient.gender
).[resourceType]/[id]
. Searches will only leverage the index if the search URL is also in this exact form.