O3 Framework / createAttachment
createAttachment(
patientUuid,fileToUpload):Promise<FetchResponse<any>>
Defined in: packages/framework/esm-emr-api/src/attachments.ts:73
Creates a new attachment for a patient by uploading a file to the OpenMRS server. The file can be provided either as a File object or as base64-encoded content.
string
The UUID of the patient to associate the attachment with.
An object containing the file data and metadata to upload.
Should include file (File object) or base64Content, plus fileName and
fileDescription.
Promise<FetchResponse<any>>
A Promise that resolves with the FetchResponse containing the created attachment data.
import { createAttachment } from '@openmrs/esm-framework';
const response = await createAttachment('patient-uuid', {
file: selectedFile,
fileName: 'document.pdf',
fileDescription: 'Patient consent form'
});