Abridge Core Workflow A — Encounter-to-Note Pipeline
Overview
Primary money-path workflow for Abridge: capturing a clinical encounter via ambient listening, processing it through Abridge's generative AI, producing a structured clinical note, and pushing it into the EHR. This is the workflow that runs millions of times daily across health systems using Abridge.
Prerequisites
- Completed
abridge-install-auth setup
- EHR integration configured (Epic preferred)
- Audio capture infrastructure (microphone array or mobile device)
- HIPAA-compliant transport layer (TLS 1.3+)
Instructions
Step 1: Initialize Encounter Session
import axios, { AxiosInstance } from 'axios';
interface EncounterContext {
patient_id: string;
encounter_id: string;
provider_id: string;
specialty: string;
encounter_type: 'outpatient' | 'inpatient' | 'emergency';
department_id?: string;
language: string;
}
interface SessionResponse {
session_id: string;
websocket_url: string;
status: 'initialized' | 'recording' | 'processing' | 'completed';
created_at: string;
}
async function initializeEncounter(
api: AxiosInstance,
context: EncounterContext
): Promise<SessionResponse> {
const { data } = await api.post('/encounters/sessions', {
...context,
capture_mode: 'ambient',
note_template: 'soap',
real_time_preview: true,
smart_phrases_enabled: true,
});
console.log(`Encounter session initialized: ${data.session_id}`);
console.log(`WebSocket URL: ${data.websocket_url}`);
return data;
}
Step 2: Stream Audio via WebSocket
import WebSocket from 'ws';
interface AudioStreamConfig {
sampleRate: 16000;
channels: 1;
encoding: 'pcm_s16le';
chunkDurationMs: 100;
}
interface TranscriptFragment {
type: 'transcript_fragment';
speaker: 'provider' | 'patient' | 'unknown';
text: string;
confidence: number;
timestamp_ms: number;
is_final: boolean;
}
interface NotePreview {
type: 'note_preview';
sections: Record<string, string>;
last_updated: string;
}
function streamEncounterAudio(
wsUrl: string,
audioSource: NodeJS.ReadableStream
): <> {
( {
ws = (wsUrl, {
: {
: ,
: process..!,
},
});
ws.(, {
.();
audioSource.(, {
(ws. === .) {
ws.(chunk);
}
});
audioSource.(, {
ws.(.({ : }));
});
});
ws.(, {
msg = .(data.());
(msg. === ) {
frag = msg ;
(frag.) {
.();
}
}
(msg. === ) {
preview = msg ;
.(, .(preview.).());
}
});
ws.(, ());
ws.(, reject);
});
}
{ streamEncounterAudio, };
Step 3: Generate and Retrieve Clinical Note
interface ClinicalNote {
note_id: string;
session_id: string;
template: 'soap' | 'hp' | 'progress' | 'procedure';
sections: {
chief_complaint: string;
history_present_illness: string;
review_of_systems: string;
physical_exam: string;
assessment: string;
plan: string;
medications?: string;
allergies?: string;
};
coding: {
icd10: Array<{ code: string; description: string; confidence: number }>;
cpt: Array<{ code: string; description: string; confidence: number }>;
hcc: Array<{ code: string; raf_score: number }>;
};
: <{
: ;
: ;
: ;
: ;
: ;
}>;
: {
: ;
: ;
: ;
};
}
(): <> {
api.();
( i = ; i < ; i++) {
{ data } = api.();
(data. === ) {
data.;
}
( (r, ));
}
();
}
Step 4: Push Note to EHR via FHIR
import axios from 'axios';
interface FhirDocumentReference {
resourceType: 'DocumentReference';
status: 'current';
type: { coding: Array<{ system: string; code: string; display: string }> };
subject: { reference: string };
context: { encounter: Array<{ reference: string }> };
content: Array<{ attachment: { contentType: string; data: string } }>;
}
async function pushNoteToEpic(
fhirBaseUrl: string,
accessToken: string,
note: { patient_id: string; encounter_id: string; content: string }
): Promise<string> {
const docRef: FhirDocumentReference = {
resourceType: 'DocumentReference',
: ,
: {
: [{
: ,
: ,
: ,
}],
},
: { : },
: { : [{ : }] },
: [{
: {
: ,
: .(note.).(),
},
}],
};
response = axios.(
,
docRef,
{ : { : , : } }
);
.();
response..;
}
Output
- Ambient encounter session with real-time transcription
- Structured SOAP note with ICD-10, CPT, and HCC codes
- Source-mapped citations linking AI output to conversation audio
- FHIR DocumentReference created in Epic EHR
Error Handling
| Error | Cause | Solution |
|---|
| WebSocket disconnect | Network instability | Implement reconnection with buffered audio |
| Empty transcript | Microphone not capturing | Verify audio input device and sample rate |
| Low confidence score | Background noise | Use directional mic or noise cancellation |
FHIR push 422 | Invalid resource format | Validate FHIR R4 schema before POST |
| Note generation timeout | Complex multi-specialty encounter | Increase timeout; split into segments |
Resources
Next Steps
For patient-facing summaries and portal integration, see abridge-core-workflow-b.