> ## Documentation Index
> Fetch the complete documentation index at: https://help.elationhealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Operations

The search operation lets you fetch resources by filtering them with supplied parameters. The parameters are a series of name=\[value] pairs. The syntax for Read and Search is described [here](/articles/fhir/us-core-guidance).

Parameters can be encoded in the URL in case of search by GET method:

```
GET [base]/[type]?name=value&...{&_format=[mime-type]}}
```

or as an application/x-www-form-urlencoded submission for a POST:

```
POST  [base]/[type]/_search{?[parameters]{&_format=[mime-type]}}
```

The response to any search operation is always a list of resources in a `Bundle` or an `OperationOutcome`.

## Supported global search parameters

The following parameters apply to [all resources](https://www.hl7.org/fhir/resource.html#search):

| Parameters for all resources                                       | Status      |
| ------------------------------------------------------------------ | ----------- |
| [\_id](https://www.hl7.org/fhir/search.html#id)                    | supported   |
| [`_lastUpdated`](https://www.hl7.org/fhir/search.html#lastUpdated) | supported   |
| [\_tag](https://www.hl7.org/fhir/search.html#tag)                  | supported   |
| [\_profile](https://www.hl7.org/fhir/search.html#profile)          | supported   |
| [\_security](https://www.hl7.org/fhir/search.html#security)        | supported   |
| [\_source](https://www.hl7.org/fhir/search.html#all)               | supported   |
| [\_text](https://www.hl7.org/fhir/search.html#text)                | unsupported |
| [\_content](https://www.hl7.org/fhir/search.html#content)          | unsupported |
| [\_list](https://www.hl7.org/fhir/search.html#list)                | unsupported |
| [\_has](https://www.hl7.org/fhir/search.html#has)                  | unsupported |
| [\_type](https://www.hl7.org/fhir/search.html#_type)               | unsupported |

## Supported search parameter types

Each search parameter is defined by a type that specifies how the search parameter behaves. These are the defined parameter types:

| Search Parameter Type                                       | Status      |
| ----------------------------------------------------------- | ----------- |
| [number](https://www.hl7.org/fhir/search.html#number)       | supported   |
| [date](https://www.hl7.org/fhir/search.html#date)           | supported   |
| [string](https://www.hl7.org/fhir/search.html#string)       | supported   |
| [token](https://www.hl7.org/fhir/search.html#token)         | supported   |
| [reference](https://www.hl7.org/fhir/search.html#reference) | supported   |
| [composite](https://www.hl7.org/fhir/search.html#composite) | supported   |
| [quantity](https://www.hl7.org/fhir/search.html#quantity)   | unsupported |
| [uri](https://www.hl7.org/fhir/search.html#uri)             | supported   |
| [special](https://www.hl7.org/fhir/search.html#special)     | unsupported |

## Support of modifiers/prefixes for number/date search parameter type

| Search Parameter Type/Modifier or Prefix              | missing | gt | lt | ge | le | sa | eb | ne |
| ----------------------------------------------------- | ------- | -- | -- | -- | -- | -- | -- | -- |
| [number](https://www.hl7.org/fhir/search.html#number) | +       | +  | +  | +  | +  | +  | +  | +  |
| [date](https://www.hl7.org/fhir/search.html#date)     | +       | +  | +  | +  | +  | +  | +  | +  |
| [dateTime]()                                          | +       | +  | +  | +  | +  | +  | +  | +  |
| [instant]()                                           | +       | +  | +  | +  | +  | +  | +  | +  |
| [Period]()                                            | +       | +  | +  | +  | +  | +  | +  | +  |
| [Timing]()                                            | -       | -  | -  | -  | -  | -  | -  | -  |

## Support of modifiers/prefixes for string search parameter type

| Search Parameter Type/Modifier or Prefix              | missing | exact | contains |
| ----------------------------------------------------- | ------- | ----- | -------- |
| [string](https://www.hl7.org/fhir/search.html#string) | -       | +     | +        |
| string.Address                                        | -       | -     | -        |
| string.HumanName                                      | -       | +     | +        |

## Support of modifiers/prefixes for token search parameter type

| Search Parameter Type/Modifier or Prefix            | missing | text | not | above | below | in | not-in | of-type |
| --------------------------------------------------- | ------- | ---- | --- | ----- | ----- | -- | ------ | ------- |
| [token](https://www.hl7.org/fhir/search.html#token) | +       | +    | +   | -     | -     | -  | -      | +       |

## Support of modifiers/prefixes for reference search parameter type

| Search Parameter Type/Modifier or Prefix                    | missing | type | identifier | above | below |
| ----------------------------------------------------------- | ------- | ---- | ---------- | ----- | ----- |
| [reference](https://www.hl7.org/fhir/search.html#reference) | +       | +    | +          | -     | -     |

## Support of modifiers/prefixes for uri search parameter type

| Search Parameter Type/Modifier or Prefix        | missing | above | below |
| ----------------------------------------------- | ------- | ----- | ----- |
| [uri](https://www.hl7.org/fhir/search.html#uri) | -       | -     | -     |

## Dynamic search

Search in Kodjin FHIR is dynamic. In order to enable search on some new parameter SearchParameter resource should be added via API. Elastic Search index should also be configured.

## Pagination

Search in Kodjin supports two types of pagination:

-offset pagination (with skip or page params). *Examples*:

```
	curl --location --request GET 'https://test.fhir.edenlab.tech/fhir/Coverage' \
	--header 'Prefer: pagination=offset-skip'
```

```
	curl --location --request GET 'https://test.fhir.edenlab.tech/fhir/Coverage' \
	--header 'Prefer: pagination=offset-page'
```

-cursor pagination. *Example*:

```
	curl --location --request GET 'https://test.fhir.edenlab.tech/fhir/Patient?_count=3' \
	--header 'Prefer: pagination=cursor'
```

Default one is the cursor.

## Handling errors

Kodjin will not return an error if a parameter refers to a non-existent resource e.g. `GET [base]/Observation?subject=101`, where "101" does not exist, or to an unknown code e.g. `GET [base]/Observation?code=loinc|1234-1`, where the LOINC code "1234-1" is not known to the server. The response will be an empty search bundle.

Kodjin will return an error if it receives parameters from the client that it does not recognize, or parameters it recognizes but do not support (either in general, or for a specific search).

By default Kodjin FHIR Server ignores unknown or unsupported parameters for the following reasons: various HTTP stacks and proxies may add parameters that aren't under the control of the client.

Clients can specify how the server should behave, by using the prefer header:\
-Prefer: handling=strict: Client requests that the server return an error for any unknown or unsupported parameter\
-Prefer: handling=lenient: Client requests that the server ignore any unknown or unsupported parameter

*Example:*

```
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "not-found",
            "details": {
                "text": "Unknown query param: test"
            }
        }
    ]
}
```
