openmrs-esm-core

O3 Framework / saveVisit

Function: saveVisit()

saveVisit(payload, abortController): Promise<FetchResponse<Visit>>

Defined in: packages/framework/esm-emr-api/src/visit-utils.ts:134

Creates a new visit by sending a POST request to the OpenMRS REST API.

Parameters

payload

NewVisitPayload

The visit data to create, including patient UUID, visit type, start datetime, and other visit attributes.

abortController

AbortController

An AbortController to allow cancellation of the request.

Returns

Promise<FetchResponse<Visit>>

A Promise that resolves with the FetchResponse containing the created Visit.

Example

import { saveVisit } from '@openmrs/esm-framework';
const abortController = new AbortController();
const response = await saveVisit({
  patient: 'patient-uuid',
  visitType: 'visit-type-uuid',
  startDatetime: new Date().toISOString()
}, abortController);