change url and id to identify your search parameter
the code is actual name that is used in the search query
make sure base is correct
to define how to search and what to search, type and expression fields are used
xpathUsage and xpath are ignored
Define a custom SearchParameter
Let's define a custom search parameter that allows searching Patient resources by a specific extension with "http://example.org/fhir/StructureDefinition/occupation" URL:
POST /fhir/SearchParameter
content-type: application/json
accept: application/json
{
"url": "http://mycompany.com/Questionnaire-context-type-value-ref",
"component": [
{
"definition": "http://hl7.org/fhir/SearchParameter/Questionnaire-context-type",
"expression": "code"
},
{
"definition": "http://mycompany.com/Questionnaire-context-ref",
"expression": "value.as(Reference)"
}
],
"id": "Questionnaire-context-type-value",
"base": [
"Questionnaire"
],
"expression": "Questionnaire.useContext",
"name": "context-type-value",
"status": "draft",
"multipleOr": false,
"type": "composite",
"version": "4.0.1",
"xpathUsage": "normal",
"resourceType": "SearchParameter",
"code": "context-type-value-ref",
"description": "A use context type and reference value assigned to the questionnaire"
}
You can read more about all these fields in
Here, the main fields are type and expression. String type means that we search for strings in a case-insensitive, accent-insensitive way. See also
The expression field uses and defines that we search in "extension" field, filter all the extensions by the URL, and get their value. Note that we use .as(string) to match .