openmrs-esm-core

O3 Framework / fetchCurrentPatient

Function: fetchCurrentPatient()

fetchCurrentPatient(patientUuid, fetchInit?): Promise<null | Patient>

Defined in: packages/framework/esm-emr-api/src/current-patient.ts:38

Fetches a patient by their UUID from the FHIR API.

Parameters

patientUuid

PatientUuid

The UUID of the patient to fetch, or null.

fetchInit?

FetchConfig

Optional fetch configuration options to pass to the request.

Returns

Promise<null | Patient>

A Promise that resolves with the FHIR Patient object, or null if the patient UUID is null.

Throws

Rethrows any error from the server request.

Example

import { fetchCurrentPatient } from '@openmrs/esm-framework';
const patient = await fetchCurrentPatient('patient-uuid');
if (patient) {
  console.log('Patient name:', patient.name?.[0]?.text);
}