Skip to main content

Configuration

Every option is passed to OsiguPrescription.mount({...}) at initialisation.

Required​

OptionTypePurpose
containerstring | HTMLElementCSS selector or DOM node the widget renders into.
getToken() => Promise<string>Called whenever the widget needs an OAuth access token.
environment'sandbox' | 'production'Osigu environment.

Common​

OptionTypePurpose
locale'en' | 'es' | 'pt-BR'UI language. Defaults to browser locale.
theme'light' | 'dark' | 'auto'Colour scheme.

Prefill​

OptionTypePurpose
prefill.patientIdstringSkip patient search — start with this patient selected.
prefill.patientSearchInputobjectPrefill the patient-search form values (e.g. { document_type: 'CC', document_number: '...' }).
prefill.diagnosesArray<{diagnosis_code: string}>Preselect diagnoses.
prefill.medicationsArray<{product_code, quantity, posology?, duration_days?}>Preselect medications.

Delivery​

Controls the "send to patient" step after issuance:

OptionTypePurpose
delivery.channel'EMAIL' | 'LINK' | 'NONE'Auto-deliver via email, show a copyable link, or skip delivery entirely.
delivery.emailstringOverride the delivery email (defaults to the patient's email on file).
delivery.confirmBeforeSendbooleanIf true, prompt the doctor to confirm before dispatching. Default false.

Behaviour hooks​

OptionSignaturePurpose
hooks.beforeIssueasync (payload) => payload | falseCalled with the request payload just before POST /prescriptions. Mutate or cancel.
hooks.onStepChange(step) => voidFires on every step transition.
hooks.decoratePatientResult(patient) => patientPost-process each patient in the search dropdown.
hooks.decorateMedicationResult(med) => medPost-process each medication in the picker.

Callback events​

OptionSignaturePurpose
onReady() => voidWidget is mounted and ready.
onComplete(outcome) => voidPrescription successfully issued.
onError(err) => voidUnrecoverable error.
onClose() => voidUser dismissed the widget.

Telemetry​

OptionTypePurpose
telemetry.trackingIdstringCustom identifier attached to Osigu's internal logs for this session.
telemetry.disabledbooleanOpt out of Osigu usage analytics.

Full example​

OsiguPrescription.mount({
container: '#osigu-rx',
getToken: async () => (await fetch('/api/osigu/token')).json().then(r => r.access_token),
environment: 'sandbox',
locale: 'es',
theme: 'auto',

prefill: {
patientId: 'pat_01HXE...',
diagnoses: [{ diagnosis_code: 'R51' }],
},

delivery: {
channel: 'EMAIL',
confirmBeforeSend: true,
},

hooks: {
beforeIssue: async (payload) => {
// Stamp an internal encounter ID
payload.notes = `Encounter ${encounterId}\n${payload.notes ?? ''}`;
return payload;
},
onStepChange: (step) => analytics.track('rx_step', { step }),
},

telemetry: {
trackingId: `encounter-${encounterId}`,
},

onReady: () => console.log('rx widget ready'),
onComplete: (outcome) => {
persistPrescription(outcome.prescription_id);
showToast(`Prescription ${outcome.prescription_code} issued`);
},
onError: (err) => Sentry.captureException(err),
onClose: () => history.back(),
});
  • Events — outcome payloads.
  • Customization — theming and behaviour beyond the options above.