core.medplumclient.readreference
Home > @medplum/core > MedplumClient > readReference
MedplumClient.readReference() method
Reads a resource by Reference
.
This is a convenience method for readResource()
that accepts a Reference
object.
Signature:
readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
Parameters
Parameter | Type | Description |
---|---|---|
reference | Reference<T> | The FHIR reference object. |
options | RequestInit | (Optional) Optional fetch options. |
Returns:
The resource if available; undefined otherwise.
Example
Example:
const serviceRequest = await medplum.readResource('ServiceRequest', '123');
const patient = await medplum.readReference(serviceRequest.subject);
console.log(patient);
See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html\#read