DeveloperEncounters
AI Scribe Feature - Usage Guide
Overview
The AI Scribe is an intelligent assistant that provides real-time transcription and AI-powered clinical suggestions during patient encounters. It integrates seamlessly with the Care Plan workflow to enhance documentation efficiency and clinical decision-making.
Status: Production-ready with real backend API integration (December 2025)
Features
🎤 Audio Recording & Transcription
- Live Recording: Real-time audio capture with visual indicators via Deepgram SDK
- Voice Activity Detection: Dynamic audio level monitoring
- Speaker Identification: Automatic detection of Doctor vs. Patient speech (diarization)
- Pause/Resume: Control recording flow during encounters
- Confidence Scoring: AI confidence levels for transcription accuracy
- Medical Terminology: Enhanced recognition of medical terms (nova-2-medical model)
- Multi-Language Support: 21 languages including Indian regional languages
🤖 AI-Powered Suggestions
- Context-Aware: Suggestions based on chief complaint and transcription
- 10 Suggestion Types: Vitals, complaint, diagnosis, medication, test, treatment plan, follow-up, note, advice, diet
- Confidence Scoring: AI confidence levels (0.0-1.0)
- Accept/Reject: Easy approval workflow for suggestions with backend persistence
- Auto-Integration: Accepted suggestions can populate relevant encounter sections
- Multiple AI Providers: OpenAI, Anthropic, Google (configurable per clinic)
🌍 Geography-Based Provider Selection
The AI Scribe automatically selects the best transcription provider based on clinic location:
- India (IN): Deepgram with medical model
- USA (US): Deepgram
- Other regions: Configurable with fallback support
How to Use
Accessing AI Scribe
- Open an Encounter: Navigate to any active patient encounter
- Toggle AI Scribe: Click the "AI Scribe" button in the top-right corner
- Sidebar Opens: The AI Scribe sidebar appears on the right side
Recording Process
- Start Recording: Click the red "Start Recording" button
- Monitor Status: Watch the live duration counter and voice activity indicator
- Pause/Resume: Use pause button to temporarily stop recording
- Stop Recording: Click the square stop button when finished
AI Suggestions Workflow
- Auto-Generation: Suggestions appear automatically during recording
- Manual Generation: Click the wand icon to generate suggestions anytime
- Review Suggestions: Each suggestion shows type, confidence, and reasoning
- Accept/Reject: Use checkmark (accept) or X (reject) buttons
- Integration: Accepted suggestions automatically update the encounter
Real-Time Transcription
- Live Updates: Text appears in real-time as you speak
- Speaker Labels: Different colors for Doctor, Patient, and Unknown speakers
- Timestamps: Each segment includes time of utterance
- Confidence Scores: Visual indicators for transcription accuracy
- Auto-Scroll: Automatically scrolls to show latest transcription
Architecture
Real-Time Transcription Flow
- Audio Capture: Browser MediaStream API captures microphone audio
- WebSocket Connection: Deepgram SDK establishes live connection with temporary token
- Streaming: Audio chunks sent to Deepgram in real-time
- Transcription: Deepgram returns transcription segments with confidence scores
- Batch Upload: Segments batched every 3 seconds and uploaded to backend
- AI Processing: Backend generates suggestions based on accumulated transcript
Component Interface
interface AIScribeSidebarProps {
isOpen: boolean
appointmentId: string // Required - links to appointment
countryCode?: string // Optional - for provider selection
onSuggestionAccept?: (suggestion: AISuggestion) => void
onSuggestionReject?: (suggestionId: string) => void
onTranscriptionUpdate?: (transcription: string) => void
onStatusChange?: (status: AIScribeStatus) => void
className?: string
}State Management
- Zustand Store:
aiScribeStoremanages session, recording, and transcription state - Custom Hooks:
useTranscription(appointmentId, countryCode)- Main transcription hookuseAiSuggestions(appointmentId)- Suggestion managementuseAiScribeSettings()- Clinic settings
AI Suggestion Types
The backend supports 10 suggestion types:
| Type | Content Structure |
|---|---|
vitals | Blood pressure, heart rate, temperature, etc. |
complaint | Chief complaint and HPI |
diagnosis | ICD codes with reasoning |
medication | Drug name, dosage, frequency, duration |
test | Investigation name and reason |
treatment_plan | Treatment recommendations |
follow_up | Follow-up timing and instructions |
note | Clinical notes |
advice | Patient advice |
diet | Dietary recommendations |
Integration Points
With Encounter Tabs
- Observations Tab: Shows AI Scribe active status
- Auto-Save: Transcription triggers auto-save functionality
- Field Population: Accepted suggestions update relevant fields
With Care Plan Workflow
- Medication Integration: Ready for Phase 5 medication workflow
- Investigation Integration: Ready for Phase 6 investigations workflow
- Clinical Assessment: Directly updates observation notes
Technical Features
Performance Optimizations
- Lazy Loading: Components load only when needed
- Memory Management: Efficient state management for long recordings
- Auto-Cleanup: Automatic resource cleanup on component unmount
UI/UX Enhancements
- Responsive Design: Works on various screen sizes
- Visual Feedback: Clear indicators for all states and actions
- Keyboard Shortcuts: Space bar to start/stop recording (planned)
- Accessibility: Screen reader compatible, keyboard navigation
Data Handling
- Backend Persistence: Transcription segments stored in database via backend API
- Session Management: Sessions linked to appointments with full audit trail
- HIPAA Compliance: Audio not stored, only text transcripts
- Token Security: Temporary tokens issued by backend (configurable TTL 1-3600s)
- Batch Upload: Segments uploaded every 3 seconds for efficient API usage
Testing Checklist
- Open AI Scribe from encounter page
- Start recording and observe live duration counter
- Watch voice activity detection indicator
- See transcription segments appear with speaker labels
- Wait for auto-generated AI suggestions
- Accept an AI suggestion and verify it updates the encounter
- Reject an AI suggestion and verify it's marked as rejected
- Manually generate more suggestions using the wand icon
- Pause and resume recording
- Clear transcription and start fresh
- Test with different chief complaints to see scenario adaptation
Development Notes
File Locations (Feature Folder Structure)
apps/cms/src/features/aiScribe/
├── components/
│ └── AIScribeSidebar.tsx # Main sidebar component
├── hooks/
│ ├── useTranscription.ts # Transcription + audio capture
│ ├── useAiSuggestions.ts # Suggestion management
│ ├── useAiScribeSettings.ts # Clinic settings
│ └── useAudioCapture.ts # Audio capture utilities
├── services/
│ ├── api/ # Backend API services
│ │ ├── transcriptionSessionService.ts
│ │ ├── aiSuggestionService.ts
│ │ ├── clinicSettingsService.ts
│ │ └── transcriptionTokenService.ts
│ └── transcription/ # Transcription providers
│ ├── TranscriptionProvider.interface.ts
│ ├── TranscriptionProviderFactory.ts
│ └── providers/
│ └── DeepgramAdapter.ts
├── store/
│ └── aiScribeStore.ts # Zustand state management
├── types/
│ └── index.ts # TypeScript types
└── utils/
└── errorHandler.ts # Error handling utilitiesParent Component Integration
- PrescriptionPage:
apps/cms/src/features/prescription/pages/PrescriptionPage.tsx(main clinical documentation) - PatientSidebar:
apps/cms/src/features/prescription/components/PatientSidebar.tsx
Note: Encounters navigate directly to PrescriptionPage for clinical documentation. AI Scribe integrates with the prescription workflow.
Backend Documentation
- Complete implementation:
backend/docs/04-features/ai-scribe/AI_Scribe_Complete_Implementation.md - API reference:
backend/docs/04-features/ai-scribe/API_Reference.md
Future Enhancements (Planned)
- Settings Modal: UI for clinic-level AI Scribe configuration
- Voice Commands: "Add medication", "Order test" voice commands
- Export Functionality: Export transcripts to different formats
- Offline Mode: Local speech processing capability
- Additional Providers: AssemblyAI, Google STT, Azure integration
- Real-Time Collaboration: Pusher-based multi-user transcript viewing
Troubleshooting
Common Issues
-
No Transcription
- Ensure microphone permission is granted
- Check that recording is started and not paused
- Verify Deepgram connection status (connected indicator)
- Check browser console for WebSocket errors
-
Connection Failed
- Backend token service may be unavailable
- Check network connectivity
- Verify backend AI Scribe endpoints are accessible
- Token may have expired - retry will request new token
-
No AI Suggestions
- Wait for sufficient transcript content (minimum context needed)
- Click wand icon to manually trigger generation
- Check that AI suggestions are enabled in clinic settings
- Verify backend AI provider configuration
-
Speaker Detection Not Working
- Speaker diarization requires
speakerDetectionoption enabled - Works best with clear audio and distinct speakers
- May not work well with overlapping speech
- Speaker diarization requires
-
Performance Issues
- Long recording sessions may accumulate many segments
- Use pause during silent periods to reduce data
- Clear transcription to start fresh if needed
Error Messages
| Error | Cause | Solution |
|---|---|---|
CONNECTION_FAILED | Cannot connect to Deepgram | Check network, retry |
MICROPHONE_NOT_FOUND | No microphone detected | Connect microphone, grant permission |
PERMISSION_DENIED | Microphone access denied | Allow microphone in browser settings |
SEND_FAILED | WebSocket send error | Will auto-reconnect, retry |
TRANSCRIPTION_ERROR | Deepgram processing error | Recoverable, continue recording |
Browser Compatibility
- Recommended: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
- Required APIs: MediaDevices, WebSocket, Web Audio API
- Mobile browsers supported but optimized for desktop
Related Docs
- Feature access & gating (developer) — facility/practitioner gating, resolver API, override scope.
- Product access model — bundled vs. self-serve, what admins control.
- QA guide — enablement recipes and regression checklist.
Last Updated: December 2025