med-scribe-alliance-ts-sdk 2.0.25 → 2.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,6 +390,165 @@ Register with `client.registerCallback(name, handler)`, remove with `client.remo
|
|
|
390
390
|
| `onError` | `ErrorEvent` | VAD, worker, transport, or validation errors. |
|
|
391
391
|
| `onTokenRequired` | `TokenRequiredEvent` | 401 received — call `event.resolve(newToken)` to retry. |
|
|
392
392
|
|
|
393
|
+
#### Payload Shapes
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
// onRecordingStateChange
|
|
397
|
+
interface RecordingStateChangeEvent {
|
|
398
|
+
type: 'started' | 'paused' | 'resumed' | 'ended';
|
|
399
|
+
timestamp: string;
|
|
400
|
+
data?: any;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// onAudioEvent — discriminated union by `type`
|
|
404
|
+
type AudioEvent =
|
|
405
|
+
| { type: 'user_speech'; timestamp: string; data: { isSpeaking: boolean } }
|
|
406
|
+
| { type: 'silence_warning'; timestamp: string; data: { durationMs: number } }
|
|
407
|
+
| { type: 'chunk_ready'; timestamp: string; data: { chunkIndex: number; fileName: string; chunkData: Uint8Array[] } }
|
|
408
|
+
| { type: 'frame_processed'; timestamp: string; data: { isSpeech: number; notSpeech: number; frame: Float32Array; duration: number } };
|
|
409
|
+
|
|
410
|
+
// onUploadEvent
|
|
411
|
+
type UploadEvent =
|
|
412
|
+
| { type: 'progress'; timestamp: string; data: { successCount: number; totalCount: number } }
|
|
413
|
+
| { type: 'failed'; timestamp: string; data: { fileName: string; error: string } }
|
|
414
|
+
| { type: 'retry'; timestamp: string; data: { fileName: string; attempt: number } };
|
|
415
|
+
|
|
416
|
+
// onSessionEvent
|
|
417
|
+
type SessionEvent =
|
|
418
|
+
| { type: 'created'; timestamp: string; data: CreateSessionResponse }
|
|
419
|
+
| { type: 'ended'; timestamp: string; data: EndSessionResponse }
|
|
420
|
+
| { type: 'discarded'; timestamp: string; data: { sessionId: string | null; reason: 'cleared' | 'cancelled' | 'reset' } }
|
|
421
|
+
| { type: 'status_update'; timestamp: string; data: GetSessionStatusResponse }
|
|
422
|
+
| { type: 'partial_result'; timestamp: string; data: any };
|
|
423
|
+
|
|
424
|
+
// onError
|
|
425
|
+
interface ErrorEvent {
|
|
426
|
+
type: 'vad_error' | 'worker_error' | 'transport_error' | 'validation_error';
|
|
427
|
+
timestamp: string;
|
|
428
|
+
error: { code: string; message: string; details?: any };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// onTokenRequired — call event.resolve(newToken) to retry the failed request
|
|
432
|
+
interface TokenRequiredEvent {
|
|
433
|
+
resolve: (newToken: string) => void;
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## Request / Response Types
|
|
438
|
+
|
|
439
|
+
#### Session
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
interface CreateSessionRequest {
|
|
443
|
+
templates: string[];
|
|
444
|
+
upload_type: string; // 'chunked' | 'single' | 'stream'
|
|
445
|
+
communication_protocol: string; // 'http' | 'websocket'
|
|
446
|
+
model?: string;
|
|
447
|
+
language_hint?: string[];
|
|
448
|
+
transcript_language?: string;
|
|
449
|
+
additional_data?: Record<string, any>;
|
|
450
|
+
session_mode?: string; // 'consultation' | 'dictation'
|
|
451
|
+
patient_details?: PatientDetails;
|
|
452
|
+
session_id?: string; // optional client-supplied ID
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
interface CreateSessionResponse {
|
|
456
|
+
session_id: string;
|
|
457
|
+
status: SessionStatus;
|
|
458
|
+
created_at: string;
|
|
459
|
+
expires_at: string;
|
|
460
|
+
upload_url: string;
|
|
461
|
+
patient_details?: PatientDetails;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
interface PatchSessionRequest {
|
|
465
|
+
user_status?: string;
|
|
466
|
+
processing_status?: string;
|
|
467
|
+
patient_details?: PatientDetails;
|
|
468
|
+
additional_data?: Record<string, any>;
|
|
469
|
+
language_hint?: string[];
|
|
470
|
+
transcript_language?: string;
|
|
471
|
+
templates?: string[];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
interface PatchSessionResponse {
|
|
475
|
+
session_id: string;
|
|
476
|
+
status: string;
|
|
477
|
+
message: string;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
interface EndSessionResponse {
|
|
481
|
+
session_id: string;
|
|
482
|
+
status: SessionStatus;
|
|
483
|
+
message: string;
|
|
484
|
+
audio_files_received: number;
|
|
485
|
+
audio_files: string[];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface GetSessionStatusResponse {
|
|
489
|
+
session_id: string;
|
|
490
|
+
status: SessionStatus;
|
|
491
|
+
created_at: string;
|
|
492
|
+
expires_at?: string | null;
|
|
493
|
+
expired_at?: string | null;
|
|
494
|
+
completed_at?: string | null;
|
|
495
|
+
model_used?: string | null;
|
|
496
|
+
language_detected?: string | null;
|
|
497
|
+
audio_files_received: number;
|
|
498
|
+
audio_files: string[];
|
|
499
|
+
audio_files_processed?: number;
|
|
500
|
+
additional_data: Record<string, any>;
|
|
501
|
+
templates?: TemplateEntry[]; // { [templateId]: { status, data, fhir, error, ... } }
|
|
502
|
+
transcript?: string;
|
|
503
|
+
processing_errors?: ProcessingError[];
|
|
504
|
+
error?: { code: string; message: string; details?: Record<string, any> };
|
|
505
|
+
patient_details?: PatientDetails;
|
|
506
|
+
message?: string;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
interface ProcessTemplateResponse {
|
|
510
|
+
session_id: string;
|
|
511
|
+
template_id: string;
|
|
512
|
+
status: string;
|
|
513
|
+
message: string;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
interface PatientDetails {
|
|
517
|
+
oid?: string;
|
|
518
|
+
name?: string;
|
|
519
|
+
age?: string;
|
|
520
|
+
gender?: string;
|
|
521
|
+
mobile?: number;
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
#### Recording
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
interface StopRecordingResult {
|
|
529
|
+
failedUploads: string[];
|
|
530
|
+
totalFiles: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
interface EndRecordingResult extends StopRecordingResult {
|
|
534
|
+
sessionEnded: boolean;
|
|
535
|
+
endSessionResponse?: EndSessionResponse;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
interface RetryUploadResult {
|
|
539
|
+
retried: number;
|
|
540
|
+
succeeded: number;
|
|
541
|
+
stillFailed: string[];
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
interface PollOptions {
|
|
545
|
+
maxAttempts?: number;
|
|
546
|
+
intervalMs?: number;
|
|
547
|
+
onProgress?: (status: GetSessionStatusResponse) => void;
|
|
548
|
+
signal?: AbortSignal;
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
393
552
|
## Error Handling
|
|
394
553
|
|
|
395
554
|
All public async methods return `SDKResult<T>` — errors are returned, not thrown:
|