## \_id [​](/content/docs/search/advanced-search-parameters#_id "Direct link to _id"/index.html)

The `_id` parameter allows you to search for any resource based on its `id` element. It is also the only way to search using multiple ids in FHIR. To do so, just enter the ids as a comma separated list.

Example: Searching for patients by \_id

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_id: 'homer-simpson,marge-simpson,lisa-simpson',

});
```

```bash
medplum get 'Patient?_id=homer-simpson,marge-simpson,lisa-simpson'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_id=homer-simpson,marge-simpson,lisa-simpson' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_lastUpdated [​](/content/docs/search/advanced-search-parameters#_lastupdated "Direct link to _lastUpdated"/index.html)

The `_lastUpdated` parameter allows you to search for resources based on when they were most recently changed.

This is especially useful when combined with [comparison operators](/content/docs/search/basic-search#searching-by-comparison/index.html), such as `gt` (greater than) or `lt` (less than) to find resources that have or have not been changed since a certain time or date.

Example: Searching for only communications that have occurred since the beginning of October, 2023

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Communication', {

_lastUpdated: 'gt2023-10-01',

});
```

```bash
medplum get 'Communication?_lastUpdated=gt2023-10-01'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Communication?&_lastUpdated=gt2023-10-01' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_summary [​](/content/docs/search/advanced-search-parameters#_summary "Direct link to _summary"/index.html)

The `_summary` parameter allows you to return only a portion of a resource's elements. Its primary intent is to optimize your queries by fetching only essential information. It is particularly useful when searching for large resources such as those with images or repeating elements.

The `_summary` parameter can contain one of the following value set:

| Value | Description |
| --- | --- |
| `true` | Only returns elements that are marked as `summary` in the resource definition. |
| `count` | Returns the count of matching resources, but none of the actual resource details for those matches. |

Example: Searching for a summary of a patient

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_id: 'homer-simpson',

_summary: true,

});

/*

Example response:

{

resourceType: 'Patient',

identifier: [\
\
    {\
\
      use: 'official',\
\
      system: 'https://example-hospital.org',\
\
      value: 'patient-1',\
\
    },\
\
  ],

active: true,

name: [\
\
    {\
\
      family: 'Simpson',\
\
      given: ['Homer', 'Jay'],\
\
    },\
\
  ],

gender: 'male',

birthDate: '1956-05-12',

deceasedBoolean: false,

address: [\
\
    {\
\
      use: 'home',\
\
      type: 'physical',\
\
      line: ['742 Evergreen Terrace'],\
\
      city: 'Springfield',\
\
    },\
\
  ],

managingOrganization: {

reference: 'Organization/example-hospital',

},

link: [\
\
    {\
\
      type: 'refer',\
\
    },\
\
  ],

};

*/
```

```bash
medplum get 'Patient?_id=homer-simpson&_summary=true'

Example response:

{

resourceType: 'Patient',

identifier: [\
\
    {\
\
      use: 'official',\
\
      system: 'https://example-hospital.org',\
\
      value: 'patient-1',\
\
    },\
\
  ],

active: true,

name: [\
\
    {\
\
      family: 'Simpson',\
\
      given: ['Homer', 'Jay'],\
\
    },\
\
  ],

gender: 'male',

birthDate: '1956-05-12',

deceasedBoolean: false,

address: [\
\
    {\
\
      use: 'home',\
\
      type: 'physical',\
\
      line: ['742 Evergreen Terrace'],\
\
      city: 'Springfield',\
\
    },\
\
  ],

managingOrganization: {

reference: 'Organization/example-hospital',

},

link: [\
\
    {\
\
      type: 'refer',\
\
    },\
\
  ],

};
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_id=homer-simpson&_summary=true' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \

Example response:

{

resourceType: 'Patient',

identifier: [\
\
    {\
\
      use: 'official',\
\
      system: 'https://example-hospital.org',\
\
      value: 'patient-1',\
\
    },\
\
  ],

active: true,

name: [\
\
    {\
\
      family: 'Simpson',\
\
      given: ['Homer', 'Jay'],\
\
    },\
\
  ],

gender: 'male',

birthDate: '1956-05-12',

deceasedBoolean: false,

address: [\
\
    {\
\
      use: 'home',\
\
      type: 'physical',\
\
      line: ['742 Evergreen Terrace'],\
\
      city: 'Springfield',\
\
    },\
\
  ],

managingOrganization: {

reference: 'Organization/example-hospital',

},

link: [\
\
    {\
\
      type: 'refer',\
\
    },\
\
  ],

};
```

## \_elements [​](/content/docs/search/advanced-search-parameters#_elements "Direct link to _elements"/index.html)

The `_elements` parameter is similar to `_summary` in that it allows you to return only a subset of the resource's elements. However, rather than a predefined value set, `_elements` allows you to choose which fields you would like to return.

The fields you choose should be formatted as a comma separated list of base elements for a given resource.
Note that any top-level mandatory or modifier elements should always be included in the chosen list of elements.

Example: Searching the subject and performers of observations

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Observation', {

_elements: 'status,code,subject,performer',

});

/*

Example Response:

[\
\
  {\
\
    resourceType: 'Observation',\
\
    status: 'final',\
\
    code: {\
\
      coding: [\
\
        {\
\
          system: 'http://loinc.org',\
\
          code: '8867-4',\
\
          display: 'Heart Rate',\
\
        },\
\
      ],\
\
    },\
\
    subject: {\
\
      reference: 'Patient/homer-simpson',\
\
    },\
\
    performer: [\
\
      {\
\
        reference: 'Practitioner/dr-alice-smith',\
\
      },\
\
    ],\
\
  },\
\
  {\
\
    resourceType: 'Observation',\
\
    status: 'preliminary',\
\
    code: {\
\
      coding: [\
\
        {\
\
          system: 'http://loinc.org',\
\
          code: '8310-5',\
\
          display: 'Body temperature',\
\
        },\
\
      ],\
\
    },\
\
    subject: {\
\
      reference: 'Patient/marge-simpson',\
\
    },\
\
    performer: [\
\
      {\
\
        reference: 'Practitioner/dr-gregory-house',\
\
      },\
\
    ],\
\
  },\
\
];

*/
```

```bash
medplum get 'Observation?_elements=status,code,subject,performer'

Example Response:

```bash
curl 'https://api.medplum.com/fhir/R4/Observations?_elements=status,code,subject,performer' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \

Example Response:

## \_tag [​](/content/docs/search/advanced-search-parameters#_tag "Direct link to _tag"/index.html)

The `_tag` parameter allows you to search on the `tag` field of the `meta` element of the resource you are searching for. The `tag` field contains user-defined tags to categorize the resource.

Example: Searching for observations that are tagged as critical

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Observation', {

_tag: 'https://example.org/tags|critical',

});
```

```bash
medplum get 'Observation?_tag=https://example.org/tags|critical'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Observation?_tag=https://example.org/tags|critical' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_compartment [​](/content/docs/search/advanced-search-parameters#_compartment "Direct link to _compartment"/index.html)

A compartment is a grouping of resources which share a common relation. For example, each `Patient` resource has its own compartment. A `Patient` compartment includes any resources which reference that `Patient`, usually in the `subject` field.

Medplum allows you to easily search using compartments by providing the non-standard `_compartment` parameter. This enables you to find all resources of a given type that are associated with a certain compartment.

Example: Find all communications for a patient

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Communication', {

_compartment: 'Patient/homer-simpson',

});
```

```bash
medplum get 'Communication?_compartment=Patient/homer-simpson'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Communication?_compartment=Patient/homer-simpson' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_total [​](/content/docs/search/advanced-search-parameters#_total "Direct link to _total"/index.html)

The `_total` parameter allows you to return the total count of matching resources in your search response. For more details see the [Paginated Search docs.](/content/docs/search/paginated-search#getting-the-total-number-of-results-with-_total/index.html)

`_total=accurate` limitation

The `_total=accurate` search parameter will only attempt to return the accurate count if the estimated total is under 1 million.

Example: Search for all patients in your organization and get an estimate of the total number

- Typescript
- CLI
- cURL

```ts
await medplum.search('Patient', {

_total: 'estimate',

});
```

```bash
medplum get 'Patient?_total=estimate'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_total=estimate' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_profile [​](/content/docs/search/advanced-search-parameters#_profile "Direct link to _profile"/index.html)

FHIR allows [profiling](http://hl7.org/fhir/R4/profiling.html) to create custom data structures that specify how resources can be sub-specialized to meet specific use cases. The `_profile` parameter allows you to search based on these profiles.

The `_profile` parameter is a reference parameter, meaning you may provide a reference as an argument to the parameter. See the [FHIR Profiles doc](/content/docs/fhir-datastore/profiles/index.html) to learn more about profiling.

Example: Search for observations that are part of the pediatric growth charts profile

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Observation', {

_profile: 'https://example.org/StructureDefinition/pediatric-growth-chart',

});
```

```bash
medplum get 'Observation?_profile=https://example.org/StructureDefinition/pediatric-growth-chart'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Observation?_profile=https://example.org/StructureDefinition/pediatric-growth-chart' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_security [​](/content/docs/search/advanced-search-parameters#_security "Direct link to _security"/index.html)

The `_security` parameter allows you to search on the `security` field of the `meta` element of the resource you are searching for.

The [Confidentiality Level Code System](http://terminology.hl7.org/CodeSystem/v3-Confidentiality) is a standard code system for confidentiality levels.

Example: Searching for patients that are of a **normal** confidentiality level.

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_security: 'http://terminology.hl7.org/CodeSystem/v3-Confidentiality|N',

});
```

```bash
medplum get 'Patient?_security=http://terminology.hl7.org/CodeSystem/v3-Confidentiality|N'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_security=http://terminology.hl7.org/CodeSystem/v3-Confidentiality|N' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_source [​](/content/docs/search/advanced-search-parameters#_source "Direct link to _source"/index.html)

The `_source` parameter allows you to search on the `source` field of the `meta` element of the resource you are searching for.

The `meta.source` field indicates the system or application that originally created or supplied the resource, which can be useful for filtering or tracking resources based on their origin.

Example: Searching for Patients sourced from `https://foomedical.com`

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_source: 'https://foomedical.com',

});
```

```bash
medplum get 'Patient?_source=https://foomedical.com'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_source=https://foomedical.com' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_filter [​](/content/docs/search/advanced-search-parameters#_filter "Direct link to _filter"/index.html)

The `_filter` parameter can be used to filter for more complex queries. For more details see the [\_filter Search Parameter docs](/content/docs/search/filter-search-parameter/index.html).

## \_sort [​](/content/docs/search/advanced-search-parameters#_sort "Direct link to _sort"/index.html)

The `_sort` parameter allows you to sort the results of your search based on different parameters. For details on how to use the `_sort` parameter, see the [Sorting the Results docs](/content/docs/search/basic-search#sorting-the-results/index.html).

## \_deleted [​](/content/docs/search/advanced-search-parameters#_deleted "Direct link to _deleted"/index.html)

The `_deleted` parameter allows you to search for resources that have been soft-deleted. By default, Medplum filters out deleted resources.

Mixing `_deleted` with other parameters

Mixing `_deleted` with most other search parameters will not work as expected. This is because the database columns backing other search parameters are not populated for deleted resources.

Example: Searching for deleted patients

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_deleted: true,

});
```

```bash
medplum get 'Patient?_deleted=true'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_deleted=true' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_project [​](/content/docs/search/advanced-search-parameters#_project "Direct link to _project"/index.html)

The `_project` parameter allows you to filter resources by their project ID. This is useful when logged in as [Super Admin](/content/docs/self-hosting/super-admin-guide/index.html) or working with linked projects to ensure data isolation.

Example: Searching for patients in a specific project

- Typescript
- CLI
- cURL

```ts
await medplum.searchResources('Patient', {

_project: '85283598-1859-408c-8c4c-a2c093d2d38c',

});
```

```bash
medplum get 'Patient?_project=85283598-1859-408c-8c4c-a2c093d2d38c'
```

```bash
curl 'https://api.medplum.com/fhir/R4/Patient?_project=85283598-1859-408c-8c4c-a2c093d2d38c' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_type [​](/content/docs/search/advanced-search-parameters#_type "Direct link to _type"/index.html)

The `_type` parameter allows you to restrict the search to specific resource types. This is particularly useful when performing a system-wide search or when searching across multiple resource types.

Example: Searching for Patients and Observations

- Typescript
- CLI
- cURL

```ts
await medplum.get('fhir/R4?_type=Patient,Observation&name=Smith');
```

```bash
medplum get 'fhir/R4?_type=Patient,Observation&name=Smith'
```

```bash
curl 'https://api.medplum.com/fhir/R4?_type=Patient,Observation&name=Smith' \

-H 'authorization: Bearer $ACCESS_TOKEN' \

-H 'content-type: application/fhir+json' \
```

## \_cursor [​](/content/docs/search/advanced-search-parameters#_cursor "Direct link to _cursor"/index.html)

The `_cursor` parameter is used for [cursor-based pagination](/content/docs/search/paginated-search#cursor-based-pagination/index.html). It is generally not constructed manually but is returned in the `link` section of a bundle response for the next page of results. Using `_cursor` is more efficient than `_offset` for deep pagination.
