core.medplumclient.searchresources
Home > @medplum/core > MedplumClient > searchResources
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<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: RequestInit): ReadablePromise<ResourceArray<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 | RequestInit | (Optional) Optional fetch options. |
Returns:
ReadablePromise<ResourceArray<ExtractResource<K>>>
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: https://www.hl7.org/fhir/search.html