API Reference

Entity Types

Open in Claude

Entity type definitions — Patient, Encounter, Order, Referral

Entity types represent the core healthcare data structures available through the SDK. Each entity has a TypeScript type and a Zod schema for runtime validation.

Usage

import type { Patient, Encounter, Order, Referral } from '@vimconnect/app-sdk';

// Zod schemas for runtime validation
import {
  PatientSchema,
  EncounterSchema,
  OrderSchema,
  ReferralSchema,
} from '@vimconnect/app-sdk';

// Validate data at runtime
const result = PatientSchema.safeParse(data);
if (result.success) {
  const patient: Patient = result.data;
}

Accessing Entity Data

Entities are available through workflow events and context subscriptions:

// Via workflow events (entity references — IDs only)
sdk.ehr.workflow.on('chart_open', (event) => {
  const patientRef = event.entities.patient;
  console.log('Patient ID:', patientRef.id);
});

// Via context subscriptions (full entity data)
sdk.ehr.context.onChange('chart_open:patient', (prev, curr) => {
  if (curr) {
    console.log('Patient:', curr.fields.demographics?.firstName);
  }
});

// Via Entity API — get extended data for the patient in the current context
const result = await sdk.ehr.api.patient.getPatient();

Type Definitions

Loading from CDN...

On this page