core.medplumclient.searchresources | Medplum

MedplumClient.searchResources() method

Sends a FHIR search request for an array of resources.

This is a convenience method for search() that returns the resources as an array rather than a Bundle.

Signature:

searchResources<RT extends ResourceType>(resourceType: RT, query?: QueryTypes, options?: MedplumRequestOptions): ReadablePromise<ResourceArray<WithId<ExtractResource<RT>>>>;

Parameters

Parameter Type Description
resourceType RT 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 < ResourceArray < WithId <ExtractResource>>>>

Promise to the array of search results.

Example

Example using a FHIR search string:

const patients = await client.searchResources('Patient', 'name=Alice');

console.log(patients);

The return value is an array of resources.

See FHIR search for full details.