Configuration
Every option is passed to OsiguPrescription.mount({...}) at initialisation.
Required
| Option | Type | Purpose |
|---|---|---|
container | string | HTMLElement | CSS 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
| Option | Type | Purpose |
|---|---|---|
locale | 'en' | 'es' | 'pt-BR' | UI language. Defaults to browser locale. |
theme | 'light' | 'dark' | 'auto' | Colour scheme. |
Prefill
| Option | Type | Purpose |
|---|---|---|
prefill.patientId | string | Skip patient search — start with this patient selected. |
prefill.patientSearchInput | object | Prefill the patient-search form values (e.g. { document_type: 'CC', document_number: '...' }). |
prefill.diagnoses | Array<{diagnosis_code: string}> | Preselect diagnoses. |
prefill.medications | Array<{product_code, quantity, posology?, duration_days?}> | Preselect medications. |
Delivery
Controls the "send to patient" step after issuance:
| Option | Type | Purpose |
|---|---|---|
delivery.channel | 'EMAIL' | 'LINK' | 'NONE' | Auto-deliver via email, show a copyable link, or skip delivery entirely. |
delivery.email | string | Override the delivery email (defaults to the patient's email on file). |
delivery.confirmBeforeSend | boolean | If true, prompt the doctor to confirm before dispatching. Default false. |
Behaviour hooks
| Option | Signature | Purpose |
|---|---|---|
hooks.beforeIssue | async (payload) => payload | false | Called with the request payload just before POST /prescriptions. Mutate or cancel. |
hooks.onStepChange | (step) => void | Fires on every step transition. |
hooks.decoratePatientResult | (patient) => patient | Post-process each patient in the search dropdown. |
hooks.decorateMedicationResult | (med) => med | Post-process each medication in the picker. |
Callback events
| Option | Signature | Purpose |
|---|---|---|
onReady | () => void | Widget is mounted and ready. |
onComplete | (outcome) => void | Prescription successfully issued. |
onError | (err) => void | Unrecoverable error. |
onClose | () => void | User dismissed the widget. |
Telemetry
| Option | Type | Purpose |
|---|---|---|
telemetry.trackingId | string | Custom identifier attached to Osigu's internal logs for this session. |
telemetry.disabled | boolean | Opt 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(),
});
Related
- Events — outcome payloads.
- Customization — theming and behaviour beyond the options above.