Overview
Interacting with EHR data through the SDK
The sdk.ehr namespace is the primary interface for interacting with EHR data. It provides four main capabilities, each suited to different use cases:
Workflow Events
Subscribe to one-time events fired when the provider navigates the EHR — such as opening a patient chart or starting an encounter. Use these for triggering actions.
sdk.ehr.workflow.on('chart_open', (event) => {
console.log('Patient chart opened:', event.entities.patient);
});Learn more about Workflow Events
Context
Track real-time changes to entity data as the provider interacts with the EHR. Unlike workflow events (which fire once), context callbacks fire continuously as data is extracted and updated.
sdk.ehr.context.onChange('encounter_open:patient', (prev, curr) => {
if (curr) console.log('Patient data updated:', curr);
});Entity API
Read entity data through typed API methods. Use this to fetch additional data beyond what's available in the context (e.g., full patient demographics, problem list, insurance).
const result = await sdk.ehr.api.patient.getPatient();Writeback
Update EHR data with permission-aware, typed write operations. Some operations are disruptive (they interrupt the provider's workflow) and require explicit permission.
await sdk.ehr.context.encounter.update({ subjective: { chiefComplaintNotes: 'Headache' } });When to Use What
| I want to... | Use |
|---|---|
| Know when a chart opens or encounter starts | Workflow Events |
| Track patient/encounter data as it changes | Context |
| Fetch data not available in the context | Entity API |
| Write data back to the EHR | Writeback |