EHR Connectivity
Workflow Events
Subscribe to EHR workflow events
Workflow events fire once when the provider triggers a specific action in the EHR.
Subscribing to Events
const unsubscribe = sdk.ehr.workflow.on('chart_open', (event) => {
const patient = event.entities.patient;
console.log('Patient chart opened:', patient);
});
// Unsubscribe when done
unsubscribe();Multiple Events
sdk.ehr.workflow.on(['chart_open', 'encounter_open'], (event) => {
console.log('Event type:', event.type);
console.log('Entities:', event.entities);
});Available Events
Loading from CDN...
Event Shape
interface WorkflowEvent {
type: string;
timestamp: number;
entities: {
[entityType: string]:
| { type: 'existing'; id: string; entityType: string }
| { type: 'draft'; ehrTempId?: string; entityType: string };
};
metadata: {
componentId: string;
trigger: string;
systemId: string;
timestamp: number;
};
}Unsubscribing
// Option 1: Use the returned function
const unsubscribe = sdk.ehr.workflow.on('chart_open', handler);
unsubscribe();
// Option 2: Use off()
sdk.ehr.workflow.off('chart_open', handler);