SKILL.md
Abridge Hello World
Overview
Minimal working example demonstrating Abridge's ambient clinical documentation. This creates a simulated encounter session, sends audio/transcript data, and receives a structured clinical note.
Prerequisites
- Completed
abridge-install-authsetup - Abridge sandbox credentials configured
- Node.js 18+ with TypeScript
Instructions
Step 1: Create Project Structure
mkdir abridge-hello-world && cd abridge-hello-world
npm init -y
npm install axios dotenv typescript @types/node
npx tsc --init --target ES2022 --module NodeNext --moduleResolution NodeNext
Step 2: Build the Encounter Session Client
// src/encounter-session.ts
import axios, { AxiosInstance } from 'axios';
interface EncounterSession {
session_id: string;
patient_id: string;
provider_id: string;
encounter_type: 'outpatient' | 'inpatient' | 'emergency';
status: 'active' | 'processing' | 'completed';
created_at: string;
}
interface ClinicalNote {
note_id: string;
session_id: string;
sections: {
chief_complaint: string;
history_present_illness: string;
review_of_systems: string;
physical_exam: string;
assessment: string;
plan: string;
};
icd10_codes: Array<{ code: string; description: string }>;
cpt_codes: Array<{ code: string; description: string }>;
confidence_score: number;
source_citations: Array<{
section: string;
text: string;
audio_timestamp_start: number;
audio_timestamp_end: number;
}>;
}
class AbridgeClient {
private api: AxiosInstance;
constructor() {
this.api = axios.create({
baseURL: process.env.ABRIDGE_SANDBOX_URL || 'https://sandbox.api.abridge.com/v1',
headers: {
'Authorization': `Bearer ${process.env.ABRIDGE_CLIENT_SECRET}`,
'X-Org-Id': process.env.ABRIDGE_ORG_ID!,
'Content-Type': 'application/json',
},
timeout: 30000,
});
}
async createSession(
patientId: string,
providerId: string,
encounterType: EncounterSession['encounter_type'] = 'outpatient'
): Promise<EncounterSession> {
const { data } = await this.api.post('/sessions', {
patient_id: patientId,
provider_id: providerId,
encounter_type: encounterType,
specialty: 'internal_medicine',
language: 'en',
});
return data;
}
async submitTranscript(sessionId: string, transcript: string): Promise<void> {
await this.api.post(`/sessions/${sessionId}/transcript`, {
text: transcript,
format: 'plain_text',
});
}
async generateNote(sessionId: string): Promise<ClinicalNote> {
// Trigger note generation
await this.api.post(`/sessions/${sessionId}/generate`);
// Poll for completion (Abridge processes asynchronously)
let attempts = 0;
while (attempts < 30) {
const { data: session } = await this.api.get(`/sessions/${sessionId}`);
if (session.status === 'completed') {
const { data: note } = await this.api.get(`/sessions/${sessionId}/note`);
return note;
}
await new Promise(r => setTimeout(r, 2000));
attempts++;
}
throw new Error('Note generation timed out after 60s');
}
}
export { AbridgeClient, EncounterSession, ClinicalNote };
