Skip to main content

core.medplumclient.search

Home > @medplum/core > MedplumClient > search

MedplumClient.search() method

Sends a FHIR search request.

Signature:

search<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<Bundle<ExtractResource<K>>>;

Parameters

Parameter

Type

Description

resourceType

K

The FHIR resource type.

query

QueryTypes

(Optional) Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.

options

MedplumRequestOptions

(Optional) Optional fetch options.

Returns:

ReadablePromise<Bundle<ExtractResource<K>>>

Promise to the search result bundle.

Example 1

Example using a FHIR search string:

const bundle = await client.search('Patient', 'name=Alice');
console.log(bundle);

Example 2

The return value is a FHIR bundle:

{
"resourceType": "Bundle",
"type": "searchset",
"entry": [
{
"resource": {
"resourceType": "Patient",
"name": [
{
"given": [
"George"
],
"family": "Washington"
}
],
}
}
]
}

Example 3

To query the count of a search, use the summary feature like so:

const patients = medplum.search('Patient', '_summary=count');

See FHIR search for full details: https://www.hl7.org/fhir/search.html