@yannelli/nextvisit-sdk 1.0.1
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 +399 -0
- package/dist/index.d.mts +1416 -0
- package/dist/index.d.ts +1416 -0
- package/dist/index.js +953 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +937 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client configuration options
|
|
3
|
+
*/
|
|
4
|
+
interface HttpClientConfig {
|
|
5
|
+
/** Base URL for API requests */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Authentication token */
|
|
8
|
+
token?: string;
|
|
9
|
+
/** Custom fetch implementation (for testing or custom environments) */
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
/** Request timeout in milliseconds */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Request options for HTTP methods
|
|
16
|
+
*/
|
|
17
|
+
interface RequestOptions {
|
|
18
|
+
/** Query parameters */
|
|
19
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
/** Request headers */
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
/** Abort signal for request cancellation */
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Internal HTTP client for making API requests
|
|
27
|
+
*/
|
|
28
|
+
declare class HttpClient {
|
|
29
|
+
private readonly baseUrl;
|
|
30
|
+
private token?;
|
|
31
|
+
private readonly fetchFn;
|
|
32
|
+
private readonly timeout;
|
|
33
|
+
constructor(config: HttpClientConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Set the authentication token
|
|
36
|
+
*/
|
|
37
|
+
setToken(token: string | undefined): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current authentication token
|
|
40
|
+
*/
|
|
41
|
+
getToken(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Build URL with query parameters
|
|
44
|
+
*/
|
|
45
|
+
private buildUrl;
|
|
46
|
+
/**
|
|
47
|
+
* Build request headers
|
|
48
|
+
*/
|
|
49
|
+
private buildHeaders;
|
|
50
|
+
/**
|
|
51
|
+
* Handle API error responses
|
|
52
|
+
*/
|
|
53
|
+
private handleError;
|
|
54
|
+
/**
|
|
55
|
+
* Execute a fetch request with timeout
|
|
56
|
+
*/
|
|
57
|
+
private executeFetch;
|
|
58
|
+
/**
|
|
59
|
+
* Make a GET request
|
|
60
|
+
*/
|
|
61
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Make a POST request with JSON body
|
|
64
|
+
*/
|
|
65
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
66
|
+
/**
|
|
67
|
+
* Make a POST request with FormData body (for file uploads)
|
|
68
|
+
*/
|
|
69
|
+
postForm<T>(path: string, formData: FormData, options?: RequestOptions): Promise<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Make a PUT request with JSON body
|
|
72
|
+
*/
|
|
73
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Make a DELETE request
|
|
76
|
+
*/
|
|
77
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Base class for API resources
|
|
82
|
+
*/
|
|
83
|
+
declare abstract class BaseResource {
|
|
84
|
+
protected readonly http: HttpClient;
|
|
85
|
+
constructor(http: HttpClient);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* API error response structure
|
|
90
|
+
*/
|
|
91
|
+
interface ApiError {
|
|
92
|
+
/** Error message */
|
|
93
|
+
message: string;
|
|
94
|
+
/** Detailed validation errors by field */
|
|
95
|
+
errors?: Record<string, string[]>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Pagination links for list responses
|
|
99
|
+
*/
|
|
100
|
+
interface PaginationLinks {
|
|
101
|
+
first?: string;
|
|
102
|
+
last?: string;
|
|
103
|
+
prev?: string | null;
|
|
104
|
+
next?: string | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Pagination metadata for list responses
|
|
108
|
+
*/
|
|
109
|
+
interface PaginationMeta {
|
|
110
|
+
current_page: number;
|
|
111
|
+
from: number | null;
|
|
112
|
+
last_page: number;
|
|
113
|
+
path: string;
|
|
114
|
+
per_page: number;
|
|
115
|
+
to: number | null;
|
|
116
|
+
total: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Paginated response wrapper
|
|
120
|
+
*/
|
|
121
|
+
interface PaginatedResponse<T> {
|
|
122
|
+
data: T[];
|
|
123
|
+
links: PaginationLinks;
|
|
124
|
+
meta: PaginationMeta;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Simple message response
|
|
128
|
+
*/
|
|
129
|
+
interface MessageResponse {
|
|
130
|
+
message: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Login request payload
|
|
135
|
+
*/
|
|
136
|
+
interface LoginRequest {
|
|
137
|
+
/** User's email address */
|
|
138
|
+
email: string;
|
|
139
|
+
/** User's password */
|
|
140
|
+
password: string;
|
|
141
|
+
/** Name of the device requesting the token */
|
|
142
|
+
device_name: string;
|
|
143
|
+
/** Two-factor authentication code (if 2FA is enabled) */
|
|
144
|
+
two_factor_code?: string;
|
|
145
|
+
/** Email OTP verification code (for users with linked social providers) */
|
|
146
|
+
otp_code?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Google Sign-In authentication request
|
|
150
|
+
*/
|
|
151
|
+
interface GoogleAuthRequest {
|
|
152
|
+
/** Google ID token obtained from Google Sign-In SDK */
|
|
153
|
+
id_token: string;
|
|
154
|
+
/** Name of the device or application (max 255 chars) */
|
|
155
|
+
device_name: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Basic user info returned with token
|
|
159
|
+
*/
|
|
160
|
+
interface TokenUser {
|
|
161
|
+
/** User's unique identifier */
|
|
162
|
+
id: number;
|
|
163
|
+
/** User's full name */
|
|
164
|
+
name: string;
|
|
165
|
+
/** ID of the user's current team */
|
|
166
|
+
current_team_id: number;
|
|
167
|
+
/** User's email address */
|
|
168
|
+
email: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Basic team info returned with token
|
|
172
|
+
*/
|
|
173
|
+
interface TokenTeam {
|
|
174
|
+
/** Team's unique identifier */
|
|
175
|
+
id: number;
|
|
176
|
+
/** Name of the team */
|
|
177
|
+
name: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Verification type for enhanced security authentication
|
|
181
|
+
*/
|
|
182
|
+
type VerificationType = "two_factor" | "email_otp";
|
|
183
|
+
/**
|
|
184
|
+
* Response when verification is required (2FA or email OTP)
|
|
185
|
+
*/
|
|
186
|
+
interface VerificationRequiredResponse {
|
|
187
|
+
/** Status indicating verification is required */
|
|
188
|
+
status: "verification_required";
|
|
189
|
+
/** Type of verification required */
|
|
190
|
+
verification_type: VerificationType;
|
|
191
|
+
/** Human-readable message for the user */
|
|
192
|
+
message: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Successful token creation response
|
|
196
|
+
*/
|
|
197
|
+
interface TokenSuccessResponse {
|
|
198
|
+
/** Status of the token request */
|
|
199
|
+
status: "success";
|
|
200
|
+
/** Authentication token value */
|
|
201
|
+
token: string;
|
|
202
|
+
/** Unique identifier for the token */
|
|
203
|
+
token_id: number;
|
|
204
|
+
/** Basic information about the authenticated user */
|
|
205
|
+
user: TokenUser;
|
|
206
|
+
/** Basic information about the user's current team */
|
|
207
|
+
team: TokenTeam;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Token creation response (can be success or require verification)
|
|
211
|
+
*/
|
|
212
|
+
type TokenResponse = TokenSuccessResponse | VerificationRequiredResponse;
|
|
213
|
+
/**
|
|
214
|
+
* Google Sign-In authentication response
|
|
215
|
+
*/
|
|
216
|
+
interface GoogleAuthResponse {
|
|
217
|
+
/** Status of the authentication request */
|
|
218
|
+
status: "success";
|
|
219
|
+
/** Authentication token value */
|
|
220
|
+
token: string;
|
|
221
|
+
/** Unique identifier for the token */
|
|
222
|
+
token_id: number;
|
|
223
|
+
/** Basic information about the authenticated user */
|
|
224
|
+
user: TokenUser;
|
|
225
|
+
/** Basic information about the user's current team */
|
|
226
|
+
team: TokenTeam;
|
|
227
|
+
/** Whether this is a newly created user account */
|
|
228
|
+
is_new_user: boolean;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Token revocation response
|
|
232
|
+
*/
|
|
233
|
+
interface RevokeTokenResponse {
|
|
234
|
+
/** Status message */
|
|
235
|
+
message: string;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Token information for listing tokens
|
|
239
|
+
*/
|
|
240
|
+
interface TokenInfo {
|
|
241
|
+
/** Unique identifier for the token */
|
|
242
|
+
id: number;
|
|
243
|
+
/** Name of the device or application the token was created for */
|
|
244
|
+
name: string;
|
|
245
|
+
/** When the token was created */
|
|
246
|
+
created_at: string;
|
|
247
|
+
/** When the token was last used */
|
|
248
|
+
last_used_at?: string | null;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Response for listing tokens
|
|
252
|
+
*/
|
|
253
|
+
interface TokensListResponse {
|
|
254
|
+
/** List of tokens */
|
|
255
|
+
tokens: TokenInfo[];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Full user object
|
|
260
|
+
*/
|
|
261
|
+
interface User {
|
|
262
|
+
/** Unique identifier for the user */
|
|
263
|
+
id: number;
|
|
264
|
+
/** Full name of the user */
|
|
265
|
+
name: string;
|
|
266
|
+
/** Email address of the user */
|
|
267
|
+
email: string;
|
|
268
|
+
/** Timestamp when the user was created */
|
|
269
|
+
created_at: string;
|
|
270
|
+
/** Timestamp when the user was last updated */
|
|
271
|
+
updated_at: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Template associated with a progress note
|
|
276
|
+
*/
|
|
277
|
+
interface ProgressNoteTemplate {
|
|
278
|
+
/** Template ID used for this note */
|
|
279
|
+
id: number;
|
|
280
|
+
/** Name of the template */
|
|
281
|
+
name: string;
|
|
282
|
+
/** Description of the template */
|
|
283
|
+
description?: string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Patient associated with a progress note
|
|
287
|
+
*/
|
|
288
|
+
interface Patient {
|
|
289
|
+
/** Patient's unique identifier */
|
|
290
|
+
id: number;
|
|
291
|
+
/** Patient's name */
|
|
292
|
+
name?: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Audio metadata for a progress note
|
|
296
|
+
*/
|
|
297
|
+
interface ProgressNoteAudio {
|
|
298
|
+
/** Duration of the audio in seconds */
|
|
299
|
+
duration?: number;
|
|
300
|
+
/** Bitrate of the audio file */
|
|
301
|
+
bitrate?: number;
|
|
302
|
+
/** Size of the audio file in bytes */
|
|
303
|
+
size?: number;
|
|
304
|
+
/** When the audio was uploaded */
|
|
305
|
+
uploaded_at?: string;
|
|
306
|
+
/** When the audio file will expire */
|
|
307
|
+
expires_at?: string;
|
|
308
|
+
/** Temporary URL to access the audio file */
|
|
309
|
+
file_url?: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Status flags for a progress note
|
|
313
|
+
*/
|
|
314
|
+
interface ProgressNoteHas {
|
|
315
|
+
/** Whether analysis has been completed */
|
|
316
|
+
content: boolean;
|
|
317
|
+
/** Whether transcription has been completed */
|
|
318
|
+
transcription: boolean;
|
|
319
|
+
/** Whether the note has been reviewed and signed */
|
|
320
|
+
signed: boolean;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Full progress note object
|
|
324
|
+
*/
|
|
325
|
+
interface ProgressNote {
|
|
326
|
+
/** Unique identifier for the progress note */
|
|
327
|
+
id: number;
|
|
328
|
+
/** Name or title of the progress note */
|
|
329
|
+
name: string;
|
|
330
|
+
/** Transcribed content of the audio recording */
|
|
331
|
+
transcription?: string;
|
|
332
|
+
/** AI-generated analysis of the transcription */
|
|
333
|
+
analysis?: string;
|
|
334
|
+
/** Template used for this note */
|
|
335
|
+
template?: ProgressNoteTemplate;
|
|
336
|
+
/** Associated patient information */
|
|
337
|
+
patient?: Patient;
|
|
338
|
+
/** Audio file metadata */
|
|
339
|
+
audio?: ProgressNoteAudio;
|
|
340
|
+
/** Status flags */
|
|
341
|
+
has?: ProgressNoteHas;
|
|
342
|
+
/** ID of the team this note belongs to */
|
|
343
|
+
team_id: number;
|
|
344
|
+
/** ID of the user who created this note */
|
|
345
|
+
user_id: number;
|
|
346
|
+
/** Information about the user who created the note */
|
|
347
|
+
user?: User;
|
|
348
|
+
/** When transcription process started */
|
|
349
|
+
transcription_started_at?: string;
|
|
350
|
+
/** When transcription was completed */
|
|
351
|
+
transcription_completed_at?: string;
|
|
352
|
+
/** When analysis process started */
|
|
353
|
+
analysis_started_at?: string;
|
|
354
|
+
/** When analysis was completed */
|
|
355
|
+
analysis_completed_at?: string;
|
|
356
|
+
/** Any error state during processing */
|
|
357
|
+
error_state?: string | null;
|
|
358
|
+
/** When the progress note was created */
|
|
359
|
+
created_at: string;
|
|
360
|
+
/** When the progress note was last updated */
|
|
361
|
+
updated_at: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Sort options for listing progress notes
|
|
365
|
+
*/
|
|
366
|
+
type ProgressNoteSortBy = "latest" | "oldest";
|
|
367
|
+
/**
|
|
368
|
+
* Query parameters for listing progress notes
|
|
369
|
+
*/
|
|
370
|
+
interface ListProgressNotesParams {
|
|
371
|
+
/** Filter notes by patient ID */
|
|
372
|
+
patient_id?: number;
|
|
373
|
+
/** Number of items per page (1-100) */
|
|
374
|
+
per_page?: number;
|
|
375
|
+
/** Sort order for results */
|
|
376
|
+
sort_by?: ProgressNoteSortBy;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Response for audio URL request
|
|
380
|
+
*/
|
|
381
|
+
interface AudioUrlResponse {
|
|
382
|
+
/** Temporary URL to access the audio file */
|
|
383
|
+
url: string;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Parameters for creating a progress note with audio file
|
|
387
|
+
*/
|
|
388
|
+
interface CreateProgressNoteWithFileParams {
|
|
389
|
+
/** Name or title of the progress note */
|
|
390
|
+
name: string;
|
|
391
|
+
/** ID of the associated patient (optional) */
|
|
392
|
+
patient_id?: number;
|
|
393
|
+
/** Audio file of the encounter */
|
|
394
|
+
file: File | Blob;
|
|
395
|
+
/** ID of the prompt/template to use (optional, defaults to 1) */
|
|
396
|
+
model_id?: number;
|
|
397
|
+
/** Additional context information for the note (optional) */
|
|
398
|
+
context?: string;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Parameters for creating a text-only progress note
|
|
402
|
+
*/
|
|
403
|
+
interface CreateProgressNoteTextParams {
|
|
404
|
+
/** Name or title of the progress note */
|
|
405
|
+
name: string;
|
|
406
|
+
/** Text content of the note (120-40000 characters) */
|
|
407
|
+
note: string;
|
|
408
|
+
/** ID of the prompt/template to use */
|
|
409
|
+
model_id: number;
|
|
410
|
+
/** ID of the associated patient (optional) */
|
|
411
|
+
patient_id?: number;
|
|
412
|
+
/** Additional context information for the note (optional) */
|
|
413
|
+
context?: string;
|
|
414
|
+
/** Array of document IDs to link to this note (optional) */
|
|
415
|
+
documents?: number[];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Parameters for creating a progress note (audio file or text-only)
|
|
419
|
+
*/
|
|
420
|
+
type CreateProgressNoteParams = CreateProgressNoteWithFileParams | CreateProgressNoteTextParams;
|
|
421
|
+
/**
|
|
422
|
+
* Parameters for updating a progress note
|
|
423
|
+
*/
|
|
424
|
+
interface UpdateProgressNoteParams {
|
|
425
|
+
/** Name or title of the progress note */
|
|
426
|
+
name?: string;
|
|
427
|
+
/** Transcribed content of the audio recording */
|
|
428
|
+
transcription?: string;
|
|
429
|
+
/** AI-generated analysis of the transcription */
|
|
430
|
+
analysis?: string;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Full patient object
|
|
435
|
+
*/
|
|
436
|
+
interface PatientFull {
|
|
437
|
+
/** Unique identifier for the patient */
|
|
438
|
+
id: number;
|
|
439
|
+
/** UUID for the patient */
|
|
440
|
+
uuid: string;
|
|
441
|
+
/** Patient's first name */
|
|
442
|
+
first_name: string;
|
|
443
|
+
/** Patient's middle name */
|
|
444
|
+
middle_name?: string | null;
|
|
445
|
+
/** Patient's last name */
|
|
446
|
+
last_name: string;
|
|
447
|
+
/** Patient's gender (when demographics are loaded) */
|
|
448
|
+
gender?: string | null;
|
|
449
|
+
/** Patient's date of birth */
|
|
450
|
+
date_of_birth: string;
|
|
451
|
+
/** Clinical notes about the patient */
|
|
452
|
+
notes?: string | null;
|
|
453
|
+
/** List of current medications (when loaded) */
|
|
454
|
+
latest_medications?: string[];
|
|
455
|
+
/** User who created the patient (when loaded) */
|
|
456
|
+
user?: User;
|
|
457
|
+
/** Patient timeline events (when loaded) */
|
|
458
|
+
timeline?: unknown[];
|
|
459
|
+
/** Recent encounters/progress notes (when loaded) */
|
|
460
|
+
encounters?: ProgressNote[];
|
|
461
|
+
/** Additional metadata */
|
|
462
|
+
meta?: Record<string, unknown> | null;
|
|
463
|
+
/** When the patient was created */
|
|
464
|
+
created_at: string;
|
|
465
|
+
/** When the patient was last updated */
|
|
466
|
+
updated_at: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Sort options for listing patients
|
|
470
|
+
*/
|
|
471
|
+
type PatientSortField = "id" | "-id" | "first_name" | "-first_name" | "last_name" | "-last_name" | "date_of_birth" | "-date_of_birth" | "created_at" | "-created_at" | "updated_at" | "-updated_at";
|
|
472
|
+
/**
|
|
473
|
+
* Trashed filter options
|
|
474
|
+
*/
|
|
475
|
+
type PatientTrashedFilter = "with" | "only";
|
|
476
|
+
/**
|
|
477
|
+
* Query parameters for listing patients
|
|
478
|
+
*/
|
|
479
|
+
interface ListPatientsParams {
|
|
480
|
+
/** Number of items per page */
|
|
481
|
+
per_page?: number;
|
|
482
|
+
/** Sort field. Prefix with - for descending order */
|
|
483
|
+
sort?: PatientSortField;
|
|
484
|
+
/** Filter by first name */
|
|
485
|
+
"filter[first_name]"?: string;
|
|
486
|
+
/** Filter by last name */
|
|
487
|
+
"filter[last_name]"?: string;
|
|
488
|
+
/** Filter by date of birth */
|
|
489
|
+
"filter[date_of_birth]"?: string;
|
|
490
|
+
/** Include soft-deleted patients */
|
|
491
|
+
"filter[trashed]"?: PatientTrashedFilter;
|
|
492
|
+
/** Comma-separated list of relationships to include */
|
|
493
|
+
include?: string;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Parameters for creating a patient
|
|
497
|
+
*/
|
|
498
|
+
interface CreatePatientParams {
|
|
499
|
+
/** Patient's first name */
|
|
500
|
+
first_name: string;
|
|
501
|
+
/** Patient's middle name */
|
|
502
|
+
middle_name?: string | null;
|
|
503
|
+
/** Patient's last name */
|
|
504
|
+
last_name: string;
|
|
505
|
+
/** Patient's date of birth (must be before today) */
|
|
506
|
+
date_of_birth: string;
|
|
507
|
+
/** Clinical notes about the patient */
|
|
508
|
+
notes?: string | null;
|
|
509
|
+
/** Known allergies */
|
|
510
|
+
allergies?: string | null;
|
|
511
|
+
/** Insurance information */
|
|
512
|
+
insurance?: string | null;
|
|
513
|
+
/** Additional metadata */
|
|
514
|
+
meta?: Record<string, unknown> | null;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Parameters for updating a patient
|
|
518
|
+
*/
|
|
519
|
+
interface UpdatePatientParams {
|
|
520
|
+
/** Patient's first name */
|
|
521
|
+
first_name?: string;
|
|
522
|
+
/** Patient's middle name */
|
|
523
|
+
middle_name?: string | null;
|
|
524
|
+
/** Patient's last name */
|
|
525
|
+
last_name?: string;
|
|
526
|
+
/** Patient's date of birth (must be before today) */
|
|
527
|
+
date_of_birth?: string;
|
|
528
|
+
/** Clinical notes about the patient */
|
|
529
|
+
notes?: string | null;
|
|
530
|
+
/** Known allergies */
|
|
531
|
+
allergies?: string | null;
|
|
532
|
+
/** Additional metadata */
|
|
533
|
+
meta?: Record<string, unknown> | null;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Sort options for search
|
|
537
|
+
*/
|
|
538
|
+
type PatientSearchSortBy = "asc" | "desc";
|
|
539
|
+
/**
|
|
540
|
+
* Query parameters for searching patients
|
|
541
|
+
*/
|
|
542
|
+
interface SearchPatientsParams {
|
|
543
|
+
/** Search query string */
|
|
544
|
+
query: string;
|
|
545
|
+
/** Number of results per page (1-100) */
|
|
546
|
+
per_page?: number;
|
|
547
|
+
/** Sort order by updated_at */
|
|
548
|
+
sort_by?: PatientSearchSortBy;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Response wrapper for single patient
|
|
552
|
+
*/
|
|
553
|
+
interface PatientResponse {
|
|
554
|
+
/** Patient data */
|
|
555
|
+
data: PatientFull;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Billing plan information
|
|
560
|
+
*/
|
|
561
|
+
interface BillingPlan {
|
|
562
|
+
/** Unique identifier for the plan */
|
|
563
|
+
id: number;
|
|
564
|
+
/** Display name of the plan */
|
|
565
|
+
name: string;
|
|
566
|
+
/** URL-friendly identifier for the plan */
|
|
567
|
+
slug: string;
|
|
568
|
+
/** Price of the plan per user */
|
|
569
|
+
price: number;
|
|
570
|
+
/** Currency symbol or prefix for price display */
|
|
571
|
+
price_prefix?: string;
|
|
572
|
+
/** Suffix for price display (e.g., per month) */
|
|
573
|
+
price_suffix?: string;
|
|
574
|
+
/** Short description of the plan */
|
|
575
|
+
description?: string;
|
|
576
|
+
/** List of features included in the plan */
|
|
577
|
+
features?: string[];
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Response for listing billing plans
|
|
581
|
+
*/
|
|
582
|
+
interface BillingPlansResponse {
|
|
583
|
+
/** List of available billing plans */
|
|
584
|
+
plans: BillingPlan[];
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Billing cost estimate
|
|
588
|
+
*/
|
|
589
|
+
interface BillingEstimate {
|
|
590
|
+
/** Total number of users in the team and child teams */
|
|
591
|
+
users: number;
|
|
592
|
+
/** Total estimated cost */
|
|
593
|
+
total: number;
|
|
594
|
+
/** Formatted total cost with currency symbol */
|
|
595
|
+
total_formatted: string;
|
|
596
|
+
/** Next billing renewal date */
|
|
597
|
+
renewal_date: string;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Trial information
|
|
601
|
+
*/
|
|
602
|
+
interface BillingTrial {
|
|
603
|
+
/** Whether the user had a trial that has expired */
|
|
604
|
+
has_expired_trial: boolean;
|
|
605
|
+
/** Whether the user is currently on a trial */
|
|
606
|
+
on_trial: boolean;
|
|
607
|
+
/** Date when the trial ends */
|
|
608
|
+
trial_ends_at?: string | null;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Subscription plan details in usage response
|
|
612
|
+
*/
|
|
613
|
+
interface BillingPlanStatus {
|
|
614
|
+
/** Name of the subscribed plan */
|
|
615
|
+
name: string;
|
|
616
|
+
/** Current subscription status */
|
|
617
|
+
status: "active" | "past_due" | "canceled" | "incomplete" | "incomplete_expired" | "trialing" | "paused";
|
|
618
|
+
/** Date when the subscription ends (if canceled) */
|
|
619
|
+
ends_at?: string | null;
|
|
620
|
+
/** Whether the subscription is currently active */
|
|
621
|
+
active: boolean;
|
|
622
|
+
/** Whether the subscription has past due payments */
|
|
623
|
+
past_due: boolean;
|
|
624
|
+
/** Trial information */
|
|
625
|
+
trial: BillingTrial;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Usage statistics
|
|
629
|
+
*/
|
|
630
|
+
interface BillingUsageStats {
|
|
631
|
+
/** Total usage count (weighted sum of all items) */
|
|
632
|
+
used: number;
|
|
633
|
+
/** Weighted count of peer reviews (0.25 per review) */
|
|
634
|
+
peer_reviews: string;
|
|
635
|
+
/** Count of encounters (1.0 per encounter) */
|
|
636
|
+
encounters: string;
|
|
637
|
+
/** Weighted count of documents (0.5 per document) */
|
|
638
|
+
documents: string;
|
|
639
|
+
/** Start date of the current billing period */
|
|
640
|
+
period_start: string;
|
|
641
|
+
/** End date of the current billing period */
|
|
642
|
+
period_end: string;
|
|
643
|
+
/** Date when usage resets */
|
|
644
|
+
resets_at: string;
|
|
645
|
+
/** Maximum allowed usage for the current plan */
|
|
646
|
+
limit: number;
|
|
647
|
+
/** Timestamp when usage was last calculated */
|
|
648
|
+
updated: string;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Billing usage response
|
|
652
|
+
*/
|
|
653
|
+
interface BillingUsage {
|
|
654
|
+
/** Current subscription plan details */
|
|
655
|
+
plan: BillingPlanStatus;
|
|
656
|
+
/** Usage statistics for the current billing period */
|
|
657
|
+
usage: BillingUsageStats;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Response for audio transcription
|
|
662
|
+
*/
|
|
663
|
+
interface TranscriptionResponse {
|
|
664
|
+
/** Status of the transcription request */
|
|
665
|
+
status: "success" | "error";
|
|
666
|
+
/** Whether the transcription was successful */
|
|
667
|
+
success: boolean;
|
|
668
|
+
/** Human-readable status message */
|
|
669
|
+
message: string;
|
|
670
|
+
/** The transcribed text from the audio file */
|
|
671
|
+
text?: string | null;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Response for transcription token request
|
|
675
|
+
*/
|
|
676
|
+
interface TranscriptionTokenResponse {
|
|
677
|
+
/** Whether the token was retrieved successfully */
|
|
678
|
+
success: boolean;
|
|
679
|
+
/** Human-readable status message */
|
|
680
|
+
message: string;
|
|
681
|
+
/** Temporary Deepgram API token for client-side transcription */
|
|
682
|
+
token?: string | null;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Parameters for transcribing an audio file
|
|
686
|
+
*/
|
|
687
|
+
interface TranscribeFileParams {
|
|
688
|
+
/** Audio file to transcribe. Supported formats: mp3, mp4, m4a, wav, ogg, webm, flac, aac, pcm, opus. Maximum size: 200MB */
|
|
689
|
+
file: File | Blob;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Authentication resource for managing access tokens
|
|
694
|
+
*/
|
|
695
|
+
declare class AuthResource extends BaseResource {
|
|
696
|
+
/**
|
|
697
|
+
* Create a new access token (login)
|
|
698
|
+
*
|
|
699
|
+
* Authenticates a user with email and password, returning an access token
|
|
700
|
+
* that can be used for subsequent API requests.
|
|
701
|
+
*
|
|
702
|
+
* @param credentials - Login credentials
|
|
703
|
+
* @returns Token response with access token and user info
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```typescript
|
|
707
|
+
* const response = await client.auth.createToken({
|
|
708
|
+
* email: "user@example.com",
|
|
709
|
+
* password: "password123",
|
|
710
|
+
* device_name: "My App"
|
|
711
|
+
* });
|
|
712
|
+
*
|
|
713
|
+
* console.log(response.token); // Use this token for authentication
|
|
714
|
+
* ```
|
|
715
|
+
*/
|
|
716
|
+
createToken(credentials: LoginRequest): Promise<TokenResponse>;
|
|
717
|
+
/**
|
|
718
|
+
* Authenticate with Google Sign-In
|
|
719
|
+
*
|
|
720
|
+
* Authenticates a user using a Google ID token obtained from Google Sign-In SDK.
|
|
721
|
+
* Supports tokens from web applications, Chrome extensions, iOS apps, and Android apps.
|
|
722
|
+
* If the user doesn't exist, a new account is automatically created.
|
|
723
|
+
*
|
|
724
|
+
* @param params - Google authentication parameters
|
|
725
|
+
* @returns Authentication response with access token and user info
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* ```typescript
|
|
729
|
+
* // Web application
|
|
730
|
+
* const response = await client.auth.googleAuth({
|
|
731
|
+
* id_token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
732
|
+
* device_name: "Web Browser"
|
|
733
|
+
* });
|
|
734
|
+
*
|
|
735
|
+
* if (response.is_new_user) {
|
|
736
|
+
* console.log("Welcome! Your account has been created.");
|
|
737
|
+
* }
|
|
738
|
+
*
|
|
739
|
+
* // Use response.token for subsequent requests
|
|
740
|
+
* client.setToken(response.token);
|
|
741
|
+
* ```
|
|
742
|
+
*/
|
|
743
|
+
googleAuth(params: GoogleAuthRequest): Promise<GoogleAuthResponse>;
|
|
744
|
+
/**
|
|
745
|
+
* Revoke the current access token (logout)
|
|
746
|
+
*
|
|
747
|
+
* Invalidates the current authentication token. After calling this method,
|
|
748
|
+
* the token can no longer be used for API requests.
|
|
749
|
+
*
|
|
750
|
+
* @returns Confirmation message
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```typescript
|
|
754
|
+
* await client.auth.revokeCurrentToken();
|
|
755
|
+
* // Token is now invalid
|
|
756
|
+
* ```
|
|
757
|
+
*/
|
|
758
|
+
revokeCurrentToken(): Promise<RevokeTokenResponse>;
|
|
759
|
+
/**
|
|
760
|
+
* List all tokens for the authenticated user
|
|
761
|
+
*
|
|
762
|
+
* Returns a list of all active tokens associated with the current user,
|
|
763
|
+
* including information about when each token was created and last used.
|
|
764
|
+
*
|
|
765
|
+
* @returns List of tokens
|
|
766
|
+
*
|
|
767
|
+
* @example
|
|
768
|
+
* ```typescript
|
|
769
|
+
* const response = await client.auth.listTokens();
|
|
770
|
+
*
|
|
771
|
+
* for (const token of response.tokens) {
|
|
772
|
+
* console.log(`${token.name} - Created: ${token.created_at}`);
|
|
773
|
+
* }
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
listTokens(): Promise<TokensListResponse>;
|
|
777
|
+
/**
|
|
778
|
+
* Revoke a specific token by ID
|
|
779
|
+
*
|
|
780
|
+
* Invalidates a specific token by its ID. This can be used to revoke
|
|
781
|
+
* tokens on other devices or applications.
|
|
782
|
+
*
|
|
783
|
+
* @param id - The unique identifier of the token to revoke
|
|
784
|
+
* @returns Confirmation message
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* // List tokens and revoke a specific one
|
|
789
|
+
* const { tokens } = await client.auth.listTokens();
|
|
790
|
+
* const oldToken = tokens.find(t => t.name === "Old Device");
|
|
791
|
+
*
|
|
792
|
+
* if (oldToken) {
|
|
793
|
+
* await client.auth.revokeToken(oldToken.id);
|
|
794
|
+
* console.log("Token revoked");
|
|
795
|
+
* }
|
|
796
|
+
* ```
|
|
797
|
+
*/
|
|
798
|
+
revokeToken(id: number): Promise<RevokeTokenResponse>;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Users resource for managing user accounts
|
|
803
|
+
*/
|
|
804
|
+
declare class UsersResource extends BaseResource {
|
|
805
|
+
/**
|
|
806
|
+
* Get the currently authenticated user
|
|
807
|
+
*
|
|
808
|
+
* Retrieves the full profile of the user associated with the current
|
|
809
|
+
* authentication token.
|
|
810
|
+
*
|
|
811
|
+
* @returns The authenticated user's details
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```typescript
|
|
815
|
+
* const user = await client.users.getCurrentUser();
|
|
816
|
+
* console.log(`Logged in as ${user.name} (${user.email})`);
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
getCurrentUser(): Promise<User>;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Patients resource for managing patient records
|
|
824
|
+
*/
|
|
825
|
+
declare class PatientsResource extends BaseResource {
|
|
826
|
+
/**
|
|
827
|
+
* List patients
|
|
828
|
+
*
|
|
829
|
+
* Returns a paginated list of patients with optional filtering
|
|
830
|
+
* and customizable pagination/sorting.
|
|
831
|
+
*
|
|
832
|
+
* @param params - Optional filtering and pagination parameters
|
|
833
|
+
* @returns Paginated list of patients
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* ```typescript
|
|
837
|
+
* // Get all patients
|
|
838
|
+
* const patients = await client.patients.list();
|
|
839
|
+
*
|
|
840
|
+
* // Filter and sort patients
|
|
841
|
+
* const filtered = await client.patients.list({
|
|
842
|
+
* "filter[last_name]": "Smith",
|
|
843
|
+
* sort: "-created_at",
|
|
844
|
+
* per_page: 25
|
|
845
|
+
* });
|
|
846
|
+
*
|
|
847
|
+
* // Include soft-deleted patients
|
|
848
|
+
* const withTrashed = await client.patients.list({
|
|
849
|
+
* "filter[trashed]": "with"
|
|
850
|
+
* });
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
list(params?: ListPatientsParams): Promise<PaginatedResponse<PatientFull>>;
|
|
854
|
+
/**
|
|
855
|
+
* Get a specific patient
|
|
856
|
+
*
|
|
857
|
+
* Retrieves detailed information about a single patient by their ID.
|
|
858
|
+
*
|
|
859
|
+
* @param id - The patient ID
|
|
860
|
+
* @returns The patient details wrapped in a response object
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```typescript
|
|
864
|
+
* const response = await client.patients.get(123);
|
|
865
|
+
* console.log(response.data.first_name);
|
|
866
|
+
* console.log(response.data.date_of_birth);
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
869
|
+
get(id: number): Promise<PatientResponse>;
|
|
870
|
+
/**
|
|
871
|
+
* Create a new patient
|
|
872
|
+
*
|
|
873
|
+
* Creates a new patient record with the provided information.
|
|
874
|
+
*
|
|
875
|
+
* @param params - The patient data
|
|
876
|
+
* @returns The created patient wrapped in a response object
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```typescript
|
|
880
|
+
* const response = await client.patients.create({
|
|
881
|
+
* first_name: "John",
|
|
882
|
+
* last_name: "Doe",
|
|
883
|
+
* date_of_birth: "1990-05-15",
|
|
884
|
+
* notes: "New patient referral",
|
|
885
|
+
* allergies: "Penicillin"
|
|
886
|
+
* });
|
|
887
|
+
*
|
|
888
|
+
* console.log(response.data.id);
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
create(params: CreatePatientParams): Promise<PatientResponse>;
|
|
892
|
+
/**
|
|
893
|
+
* Update a patient
|
|
894
|
+
*
|
|
895
|
+
* Updates an existing patient's information.
|
|
896
|
+
*
|
|
897
|
+
* @param id - The patient ID
|
|
898
|
+
* @param params - The fields to update
|
|
899
|
+
* @returns The updated patient wrapped in a response object
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* ```typescript
|
|
903
|
+
* const response = await client.patients.update(123, {
|
|
904
|
+
* first_name: "Jonathan",
|
|
905
|
+
* notes: "Updated contact information"
|
|
906
|
+
* });
|
|
907
|
+
*
|
|
908
|
+
* console.log(response.data.first_name); // "Jonathan"
|
|
909
|
+
* ```
|
|
910
|
+
*/
|
|
911
|
+
update(id: number, params: UpdatePatientParams): Promise<PatientResponse>;
|
|
912
|
+
/**
|
|
913
|
+
* Delete a patient (soft delete)
|
|
914
|
+
*
|
|
915
|
+
* Soft deletes a patient record. The patient can be restored or
|
|
916
|
+
* permanently deleted later. Use the trashed filter to view deleted patients.
|
|
917
|
+
*
|
|
918
|
+
* @param id - The patient ID
|
|
919
|
+
* @returns Confirmation message
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```typescript
|
|
923
|
+
* await client.patients.delete(123);
|
|
924
|
+
* console.log("Patient soft deleted successfully");
|
|
925
|
+
*
|
|
926
|
+
* // View deleted patients
|
|
927
|
+
* const deleted = await client.patients.list({
|
|
928
|
+
* "filter[trashed]": "only"
|
|
929
|
+
* });
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
delete(id: number): Promise<MessageResponse>;
|
|
933
|
+
/**
|
|
934
|
+
* Search patients
|
|
935
|
+
*
|
|
936
|
+
* Searches for patients matching the query string within the authenticated
|
|
937
|
+
* user's current team.
|
|
938
|
+
*
|
|
939
|
+
* @param params - Search parameters including query string
|
|
940
|
+
* @returns Paginated list of matching patients
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* // Search for patients by name
|
|
945
|
+
* const results = await client.patients.search({
|
|
946
|
+
* query: "John",
|
|
947
|
+
* per_page: 10,
|
|
948
|
+
* sort_by: "desc"
|
|
949
|
+
* });
|
|
950
|
+
*
|
|
951
|
+
* console.log(`Found ${results.meta.total} patients`);
|
|
952
|
+
* results.data.forEach(patient => {
|
|
953
|
+
* console.log(`${patient.first_name} ${patient.last_name}`);
|
|
954
|
+
* });
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
search(params: SearchPatientsParams): Promise<PaginatedResponse<PatientFull>>;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Progress Notes resource for managing clinical documentation
|
|
962
|
+
*/
|
|
963
|
+
declare class ProgressNotesResource extends BaseResource {
|
|
964
|
+
/**
|
|
965
|
+
* List progress notes
|
|
966
|
+
*
|
|
967
|
+
* Returns a paginated list of progress notes with optional filtering
|
|
968
|
+
* by patient and customizable pagination/sorting.
|
|
969
|
+
*
|
|
970
|
+
* @param params - Optional filtering and pagination parameters
|
|
971
|
+
* @returns Paginated list of progress notes
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```typescript
|
|
975
|
+
* // Get latest notes
|
|
976
|
+
* const notes = await client.progressNotes.list();
|
|
977
|
+
*
|
|
978
|
+
* // Filter by patient
|
|
979
|
+
* const patientNotes = await client.progressNotes.list({
|
|
980
|
+
* patient_id: 123,
|
|
981
|
+
* per_page: 25,
|
|
982
|
+
* sort_by: "oldest"
|
|
983
|
+
* });
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
list(params?: ListProgressNotesParams): Promise<PaginatedResponse<ProgressNote>>;
|
|
987
|
+
/**
|
|
988
|
+
* Get a specific progress note
|
|
989
|
+
*
|
|
990
|
+
* Retrieves detailed information about a single progress note by its ID.
|
|
991
|
+
*
|
|
992
|
+
* @param id - The progress note ID
|
|
993
|
+
* @returns The progress note details
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* ```typescript
|
|
997
|
+
* const note = await client.progressNotes.get(123);
|
|
998
|
+
* console.log(note.name);
|
|
999
|
+
* console.log(note.transcription);
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
get(id: number): Promise<ProgressNote>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Get audio URL for a progress note
|
|
1005
|
+
*
|
|
1006
|
+
* Retrieves a temporary URL to access the audio file associated with
|
|
1007
|
+
* a progress note. The URL is time-limited and will expire.
|
|
1008
|
+
*
|
|
1009
|
+
* @param id - The progress note ID
|
|
1010
|
+
* @returns Object containing the temporary audio URL
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
* ```typescript
|
|
1014
|
+
* const response = await client.progressNotes.getAudioUrl(123);
|
|
1015
|
+
* console.log(response.url); // Temporary URL to audio file
|
|
1016
|
+
* ```
|
|
1017
|
+
*/
|
|
1018
|
+
getAudioUrl(id: number): Promise<AudioUrlResponse>;
|
|
1019
|
+
/**
|
|
1020
|
+
* Create a new progress note
|
|
1021
|
+
*
|
|
1022
|
+
* Creates a new progress note with either an audio file or text content.
|
|
1023
|
+
* For audio files, the audio will be transcribed and analyzed asynchronously.
|
|
1024
|
+
* For text-only notes, provide the note content directly.
|
|
1025
|
+
*
|
|
1026
|
+
* @param params - The progress note data (audio file or text-only)
|
|
1027
|
+
* @returns The created progress note
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* // With audio file
|
|
1032
|
+
* const audioFile = new File([audioBlob], "recording.mp3", {
|
|
1033
|
+
* type: "audio/mpeg"
|
|
1034
|
+
* });
|
|
1035
|
+
*
|
|
1036
|
+
* const note = await client.progressNotes.create({
|
|
1037
|
+
* name: "Follow-up Visit - John Doe",
|
|
1038
|
+
* patient_id: 456,
|
|
1039
|
+
* file: audioFile,
|
|
1040
|
+
* model_id: 1 // Optional template
|
|
1041
|
+
* });
|
|
1042
|
+
*
|
|
1043
|
+
* // Text-only note
|
|
1044
|
+
* const textNote = await client.progressNotes.create({
|
|
1045
|
+
* name: "Patient Consultation",
|
|
1046
|
+
* note: "Patient presented with symptoms of...",
|
|
1047
|
+
* model_id: 1,
|
|
1048
|
+
* patient_id: 456
|
|
1049
|
+
* });
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
create(params: CreateProgressNoteParams): Promise<ProgressNote>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Update a progress note
|
|
1055
|
+
*
|
|
1056
|
+
* Updates an existing progress note's metadata, transcription, or analysis.
|
|
1057
|
+
*
|
|
1058
|
+
* @param id - The progress note ID
|
|
1059
|
+
* @param params - The fields to update
|
|
1060
|
+
* @returns The updated progress note
|
|
1061
|
+
*
|
|
1062
|
+
* @example
|
|
1063
|
+
* ```typescript
|
|
1064
|
+
* const updated = await client.progressNotes.update(123, {
|
|
1065
|
+
* name: "Updated Visit Name",
|
|
1066
|
+
* transcription: "Corrected transcription text..."
|
|
1067
|
+
* });
|
|
1068
|
+
* ```
|
|
1069
|
+
*/
|
|
1070
|
+
update(id: number, params: UpdateProgressNoteParams): Promise<ProgressNote>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Delete a progress note
|
|
1073
|
+
*
|
|
1074
|
+
* Permanently deletes a progress note and its associated audio files.
|
|
1075
|
+
* This action cannot be undone.
|
|
1076
|
+
*
|
|
1077
|
+
* @param id - The progress note ID
|
|
1078
|
+
* @returns Confirmation message
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```typescript
|
|
1082
|
+
* await client.progressNotes.delete(123);
|
|
1083
|
+
* console.log("Note deleted successfully");
|
|
1084
|
+
* ```
|
|
1085
|
+
*/
|
|
1086
|
+
delete(id: number): Promise<MessageResponse>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Sign a progress note
|
|
1089
|
+
*
|
|
1090
|
+
* Marks a progress note as reviewed and signed. A note can only be signed
|
|
1091
|
+
* after transcription and analysis have been completed.
|
|
1092
|
+
*
|
|
1093
|
+
* @param id - The progress note ID
|
|
1094
|
+
* @returns The signed progress note
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* const signedNote = await client.progressNotes.sign(123);
|
|
1099
|
+
* console.log(signedNote.has?.signed); // true
|
|
1100
|
+
* ```
|
|
1101
|
+
*/
|
|
1102
|
+
sign(id: number): Promise<ProgressNote>;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Billing resource for managing subscription and usage
|
|
1107
|
+
*/
|
|
1108
|
+
declare class BillingResource extends BaseResource {
|
|
1109
|
+
/**
|
|
1110
|
+
* List available billing plans
|
|
1111
|
+
*
|
|
1112
|
+
* Retrieves all available billing plans that can be subscribed to,
|
|
1113
|
+
* including pricing information and features.
|
|
1114
|
+
*
|
|
1115
|
+
* @returns List of available billing plans
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* ```typescript
|
|
1119
|
+
* const response = await client.billing.listPlans();
|
|
1120
|
+
*
|
|
1121
|
+
* for (const plan of response.plans) {
|
|
1122
|
+
* console.log(`${plan.name}: ${plan.price_prefix}${plan.price}${plan.price_suffix}`);
|
|
1123
|
+
* if (plan.features) {
|
|
1124
|
+
* plan.features.forEach(feature => console.log(` - ${feature}`));
|
|
1125
|
+
* }
|
|
1126
|
+
* }
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
listPlans(): Promise<BillingPlansResponse>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Get billing cost estimate
|
|
1132
|
+
*
|
|
1133
|
+
* Calculates the estimated billing cost based on the current number
|
|
1134
|
+
* of users in the team and any child teams.
|
|
1135
|
+
*
|
|
1136
|
+
* @returns Billing cost estimate with user count and formatted total
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```typescript
|
|
1140
|
+
* const estimate = await client.billing.getEstimate();
|
|
1141
|
+
*
|
|
1142
|
+
* console.log(`Users: ${estimate.users}`);
|
|
1143
|
+
* console.log(`Estimated cost: ${estimate.total_formatted}`);
|
|
1144
|
+
* console.log(`Next renewal: ${estimate.renewal_date}`);
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
getEstimate(): Promise<BillingEstimate>;
|
|
1148
|
+
/**
|
|
1149
|
+
* Get billing usage statistics
|
|
1150
|
+
*
|
|
1151
|
+
* Retrieves usage statistics for a specific billing module, including
|
|
1152
|
+
* the current subscription plan status and detailed usage metrics.
|
|
1153
|
+
*
|
|
1154
|
+
* @param module - The billing module to get usage for (e.g., 'notes')
|
|
1155
|
+
* @returns Billing usage with plan status and usage statistics
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* const usage = await client.billing.getUsage("notes");
|
|
1160
|
+
*
|
|
1161
|
+
* console.log(`Plan: ${usage.plan.name} (${usage.plan.status})`);
|
|
1162
|
+
* console.log(`Usage: ${usage.usage.used} / ${usage.usage.limit}`);
|
|
1163
|
+
* console.log(`Period: ${usage.usage.period_start} to ${usage.usage.period_end}`);
|
|
1164
|
+
*
|
|
1165
|
+
* if (usage.plan.trial.on_trial) {
|
|
1166
|
+
* console.log(`Trial ends: ${usage.plan.trial.trial_ends_at}`);
|
|
1167
|
+
* }
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
getUsage(module: string): Promise<BillingUsage>;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Transcription resource for audio transcription services
|
|
1175
|
+
*/
|
|
1176
|
+
declare class TranscriptionResource extends BaseResource {
|
|
1177
|
+
/**
|
|
1178
|
+
* Transcribe an audio file
|
|
1179
|
+
*
|
|
1180
|
+
* Uploads an audio file and returns the transcribed text using AI-powered speech recognition.
|
|
1181
|
+
* Supported formats: mp3, mp4, m4a, wav, ogg, webm, flac, aac, pcm, opus
|
|
1182
|
+
* Maximum file size: 200MB
|
|
1183
|
+
*
|
|
1184
|
+
* @param params - The transcription parameters including the audio file
|
|
1185
|
+
* @returns Transcription response with the transcribed text
|
|
1186
|
+
*
|
|
1187
|
+
* @example
|
|
1188
|
+
* ```typescript
|
|
1189
|
+
* // Transcribe an audio file from a file input
|
|
1190
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
1191
|
+
* const file = fileInput.files[0];
|
|
1192
|
+
*
|
|
1193
|
+
* const response = await client.transcription.transcribeFile({ file });
|
|
1194
|
+
*
|
|
1195
|
+
* if (response.success) {
|
|
1196
|
+
* console.log(response.text); // The transcribed text
|
|
1197
|
+
* }
|
|
1198
|
+
* ```
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* // Transcribe a Blob from recorded audio
|
|
1203
|
+
* const audioBlob = new Blob(audioChunks, { type: 'audio/webm' });
|
|
1204
|
+
*
|
|
1205
|
+
* const response = await client.transcription.transcribeFile({
|
|
1206
|
+
* file: audioBlob
|
|
1207
|
+
* });
|
|
1208
|
+
*
|
|
1209
|
+
* console.log(response.message); // Status message
|
|
1210
|
+
* ```
|
|
1211
|
+
*/
|
|
1212
|
+
transcribeFile(params: TranscribeFileParams): Promise<TranscriptionResponse>;
|
|
1213
|
+
/**
|
|
1214
|
+
* Get a temporary transcription token
|
|
1215
|
+
*
|
|
1216
|
+
* Returns a temporary Deepgram API token for client-side audio transcription.
|
|
1217
|
+
* The token is short-lived and should be used immediately.
|
|
1218
|
+
*
|
|
1219
|
+
* @returns Token response with the temporary API token
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* const response = await client.transcription.getToken();
|
|
1224
|
+
*
|
|
1225
|
+
* if (response.success && response.token) {
|
|
1226
|
+
* // Use the token for client-side Deepgram SDK
|
|
1227
|
+
* const deepgram = createClient(response.token);
|
|
1228
|
+
* }
|
|
1229
|
+
* ```
|
|
1230
|
+
*/
|
|
1231
|
+
getToken(): Promise<TranscriptionTokenResponse>;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* Default production API base URL
|
|
1236
|
+
*/
|
|
1237
|
+
declare const DEFAULT_BASE_URL = "https://nextvisit.app/api";
|
|
1238
|
+
/**
|
|
1239
|
+
* Configuration options for the Nextvisit client
|
|
1240
|
+
*/
|
|
1241
|
+
interface NextvisitClientConfig {
|
|
1242
|
+
/**
|
|
1243
|
+
* Authentication token for API requests
|
|
1244
|
+
*
|
|
1245
|
+
* Can be obtained by calling `client.auth.createToken()` or from
|
|
1246
|
+
* a previously stored token.
|
|
1247
|
+
*/
|
|
1248
|
+
token?: string;
|
|
1249
|
+
/**
|
|
1250
|
+
* Base URL for API requests
|
|
1251
|
+
*
|
|
1252
|
+
* Defaults to the production API (https://nextvisit.app/api).
|
|
1253
|
+
* Use "http://localhost/api" for local development.
|
|
1254
|
+
*/
|
|
1255
|
+
baseUrl?: string;
|
|
1256
|
+
/**
|
|
1257
|
+
* Custom fetch implementation
|
|
1258
|
+
*
|
|
1259
|
+
* Useful for testing or custom HTTP handling. If not provided,
|
|
1260
|
+
* the global `fetch` function will be used.
|
|
1261
|
+
*/
|
|
1262
|
+
fetch?: typeof fetch;
|
|
1263
|
+
/**
|
|
1264
|
+
* Request timeout in milliseconds
|
|
1265
|
+
*
|
|
1266
|
+
* Defaults to 30000 (30 seconds).
|
|
1267
|
+
*/
|
|
1268
|
+
timeout?: number;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Nextvisit API client
|
|
1272
|
+
*
|
|
1273
|
+
* The main entry point for interacting with the Nextvisit Clinical
|
|
1274
|
+
* Documentation API. Provides access to all API resources through
|
|
1275
|
+
* typed, promise-based methods.
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* ```typescript
|
|
1279
|
+
* import { NextvisitClient } from "@yannelli/nextvisit-sdk";
|
|
1280
|
+
*
|
|
1281
|
+
* // Create a client with an existing token
|
|
1282
|
+
* const client = new NextvisitClient({
|
|
1283
|
+
* token: "nv-sk-..."
|
|
1284
|
+
* });
|
|
1285
|
+
*
|
|
1286
|
+
* // Or authenticate to get a token
|
|
1287
|
+
* const client = new NextvisitClient();
|
|
1288
|
+
* const { token } = await client.auth.createToken({
|
|
1289
|
+
* email: "user@example.com",
|
|
1290
|
+
* password: "password",
|
|
1291
|
+
* device_name: "My App"
|
|
1292
|
+
* });
|
|
1293
|
+
* client.setToken(token);
|
|
1294
|
+
*
|
|
1295
|
+
* // Use the API
|
|
1296
|
+
* const user = await client.users.getCurrentUser();
|
|
1297
|
+
* const notes = await client.progressNotes.list();
|
|
1298
|
+
* ```
|
|
1299
|
+
*/
|
|
1300
|
+
declare class NextvisitClient {
|
|
1301
|
+
private readonly http;
|
|
1302
|
+
/**
|
|
1303
|
+
* Authentication resource for managing access tokens
|
|
1304
|
+
*/
|
|
1305
|
+
readonly auth: AuthResource;
|
|
1306
|
+
/**
|
|
1307
|
+
* Users resource for managing user accounts
|
|
1308
|
+
*/
|
|
1309
|
+
readonly users: UsersResource;
|
|
1310
|
+
/**
|
|
1311
|
+
* Progress Notes resource for managing clinical documentation
|
|
1312
|
+
*/
|
|
1313
|
+
readonly progressNotes: ProgressNotesResource;
|
|
1314
|
+
/**
|
|
1315
|
+
* Billing resource for managing subscription and usage
|
|
1316
|
+
*/
|
|
1317
|
+
readonly billing: BillingResource;
|
|
1318
|
+
/**
|
|
1319
|
+
* Transcription resource for audio transcription services
|
|
1320
|
+
*/
|
|
1321
|
+
readonly transcription: TranscriptionResource;
|
|
1322
|
+
/**
|
|
1323
|
+
* Patients resource for managing patient records
|
|
1324
|
+
*/
|
|
1325
|
+
readonly patients: PatientsResource;
|
|
1326
|
+
/**
|
|
1327
|
+
* Create a new Nextvisit API client
|
|
1328
|
+
*
|
|
1329
|
+
* @param config - Client configuration options
|
|
1330
|
+
*/
|
|
1331
|
+
constructor(config?: NextvisitClientConfig);
|
|
1332
|
+
/**
|
|
1333
|
+
* Set the authentication token
|
|
1334
|
+
*
|
|
1335
|
+
* Updates the token used for API requests. Call this after
|
|
1336
|
+
* authenticating with `auth.createToken()`.
|
|
1337
|
+
*
|
|
1338
|
+
* @param token - The authentication token
|
|
1339
|
+
*
|
|
1340
|
+
* @example
|
|
1341
|
+
* ```typescript
|
|
1342
|
+
* const { token } = await client.auth.createToken(credentials);
|
|
1343
|
+
* client.setToken(token);
|
|
1344
|
+
* ```
|
|
1345
|
+
*/
|
|
1346
|
+
setToken(token: string): void;
|
|
1347
|
+
/**
|
|
1348
|
+
* Clear the authentication token
|
|
1349
|
+
*
|
|
1350
|
+
* Removes the current token. Subsequent requests will be
|
|
1351
|
+
* unauthenticated.
|
|
1352
|
+
*
|
|
1353
|
+
* @example
|
|
1354
|
+
* ```typescript
|
|
1355
|
+
* await client.auth.revokeCurrentToken();
|
|
1356
|
+
* client.clearToken();
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
1359
|
+
clearToken(): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Check if the client has an authentication token set
|
|
1362
|
+
*
|
|
1363
|
+
* @returns `true` if a token is set, `false` otherwise
|
|
1364
|
+
*/
|
|
1365
|
+
hasToken(): boolean;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* Base error class for Nextvisit API errors
|
|
1370
|
+
*/
|
|
1371
|
+
declare class NextvisitError extends Error {
|
|
1372
|
+
constructor(message: string);
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Error thrown when the API returns an error response
|
|
1376
|
+
*/
|
|
1377
|
+
declare class NextvisitApiError extends NextvisitError {
|
|
1378
|
+
/** HTTP status code */
|
|
1379
|
+
readonly status: number;
|
|
1380
|
+
/** Detailed validation errors by field */
|
|
1381
|
+
readonly errors?: Record<string, string[]>;
|
|
1382
|
+
constructor(status: number, error: ApiError);
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Error thrown when authentication fails (401)
|
|
1386
|
+
*/
|
|
1387
|
+
declare class UnauthorizedError extends NextvisitApiError {
|
|
1388
|
+
constructor(error: ApiError);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Error thrown when access is forbidden (403)
|
|
1392
|
+
*/
|
|
1393
|
+
declare class ForbiddenError extends NextvisitApiError {
|
|
1394
|
+
constructor(error: ApiError);
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Error thrown when a resource is not found (404)
|
|
1398
|
+
*/
|
|
1399
|
+
declare class NotFoundError extends NextvisitApiError {
|
|
1400
|
+
constructor(error: ApiError);
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Error thrown when validation fails (422)
|
|
1404
|
+
*/
|
|
1405
|
+
declare class ValidationError extends NextvisitApiError {
|
|
1406
|
+
constructor(error: ApiError);
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Error thrown when a network request fails
|
|
1410
|
+
*/
|
|
1411
|
+
declare class NetworkError extends NextvisitError {
|
|
1412
|
+
readonly cause?: Error;
|
|
1413
|
+
constructor(message: string, cause?: Error);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
export { type ApiError, type AudioUrlResponse, AuthResource, type BillingEstimate, type BillingPlan, type BillingPlanStatus, type BillingPlansResponse, BillingResource, type BillingTrial, type BillingUsage, type BillingUsageStats, type CreatePatientParams, type CreateProgressNoteParams, type CreateProgressNoteTextParams, type CreateProgressNoteWithFileParams, DEFAULT_BASE_URL, ForbiddenError, type GoogleAuthRequest, type GoogleAuthResponse, type ListPatientsParams, type ListProgressNotesParams, type LoginRequest, type MessageResponse, NetworkError, NextvisitApiError, NextvisitClient, type NextvisitClientConfig, NextvisitError, NotFoundError, type PaginatedResponse, type PaginationLinks, type PaginationMeta, type Patient, type PatientFull, type PatientResponse, type PatientSearchSortBy, type PatientSortField, type PatientTrashedFilter, PatientsResource, type ProgressNote, type ProgressNoteAudio, type ProgressNoteHas, type ProgressNoteSortBy, type ProgressNoteTemplate, ProgressNotesResource, type RevokeTokenResponse, type SearchPatientsParams, type TokenInfo, type TokenResponse, type TokenSuccessResponse, type TokenTeam, type TokenUser, type TokensListResponse, type TranscribeFileParams, TranscriptionResource, type TranscriptionResponse, type TranscriptionTokenResponse, UnauthorizedError, type UpdatePatientParams, type UpdateProgressNoteParams, type User, UsersResource, ValidationError, type VerificationRequiredResponse, type VerificationType };
|