@medplum/core 0.9.2 → 0.9.5
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/dist/cjs/index.js +2608 -2644
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +2606 -2644
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/cache.d.ts +12 -11
- package/dist/types/client.d.ts +713 -644
- package/dist/types/crypto.d.ts +9 -9
- package/dist/types/eventtarget.d.ts +13 -13
- package/dist/types/format.d.ts +15 -15
- package/dist/types/hl7.d.ts +43 -43
- package/dist/types/index.d.ts +10 -9
- package/dist/types/jwt.d.ts +5 -5
- package/dist/types/outcomes.d.ts +22 -22
- package/dist/types/readablepromise.d.ts +43 -0
- package/dist/types/search.d.ts +62 -62
- package/dist/types/searchparams.d.ts +35 -35
- package/dist/types/storage.d.ts +47 -47
- package/dist/types/types.d.ts +139 -139
- package/dist/types/utils.d.ts +131 -125
- package/package.json +2 -2
- package/dist/types/repo.d.ts +0 -116
package/dist/types/client.d.ts
CHANGED
|
@@ -1,644 +1,713 @@
|
|
|
1
|
-
import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
|
-
import type { Operation } from 'fast-json-patch';
|
|
3
|
-
import { EventTarget } from './eventtarget';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
66
|
-
readonly
|
|
67
|
-
readonly
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
readonly
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
readonly
|
|
96
|
-
readonly
|
|
97
|
-
readonly
|
|
98
|
-
readonly
|
|
99
|
-
readonly
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* const
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
* @param
|
|
224
|
-
* @returns Promise to the
|
|
225
|
-
*/
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
*
|
|
229
|
-
* @param
|
|
230
|
-
* @
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Tries to sign
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* @
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*
|
|
371
|
-
* @param
|
|
372
|
-
* @
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
*
|
|
378
|
-
* @param
|
|
379
|
-
* @
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
* @
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* The
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* The
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
* console.log(result.
|
|
594
|
-
* ```
|
|
595
|
-
*
|
|
596
|
-
* See the FHIR "
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
* @param
|
|
601
|
-
* @
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
* ```
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1
|
+
import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
|
+
import type { Operation } from 'fast-json-patch';
|
|
3
|
+
import { EventTarget } from './eventtarget';
|
|
4
|
+
import { Hl7Message } from './hl7';
|
|
5
|
+
import { ReadablePromise } from './readablepromise';
|
|
6
|
+
import { SearchRequest } from './search';
|
|
7
|
+
import { IndexedStructureDefinition } from './types';
|
|
8
|
+
import { ProfileResource } from './utils';
|
|
9
|
+
export interface MedplumClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The client ID.
|
|
12
|
+
* Optional. Default is to defer to the server to use the default client.
|
|
13
|
+
* Use this to use a specific client for SMART-on-FHIR.
|
|
14
|
+
*/
|
|
15
|
+
clientId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Base server URL.
|
|
18
|
+
* Optional. Default value is "https://api.medplum.com/".
|
|
19
|
+
* Use this to point to a custom Medplum deployment.
|
|
20
|
+
*/
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
/**
|
|
23
|
+
* OAuth2 authorize URL.
|
|
24
|
+
* Optional. Default value is baseUrl + "/oauth2/authorize".
|
|
25
|
+
* Use this if you want to use a separate OAuth server.
|
|
26
|
+
*/
|
|
27
|
+
authorizeUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* OAuth2 token URL.
|
|
30
|
+
* Optional. Default value is baseUrl + "/oauth2/token".
|
|
31
|
+
* Use this if you want to use a separate OAuth server.
|
|
32
|
+
*/
|
|
33
|
+
tokenUrl?: string;
|
|
34
|
+
/**
|
|
35
|
+
* OAuth2 logout URL.
|
|
36
|
+
* Optional. Default value is baseUrl + "/oauth2/logout".
|
|
37
|
+
* Use this if you want to use a separate OAuth server.
|
|
38
|
+
*/
|
|
39
|
+
logoutUrl?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Number of resources to store in the cache.
|
|
42
|
+
* Optional. Default value is 1000.
|
|
43
|
+
* Consider using this for performance of displaying Patient or Practitioner resources.
|
|
44
|
+
*/
|
|
45
|
+
resourceCacheSize?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Optional fetch implementation.
|
|
48
|
+
* Optional. Default is window.fetch.
|
|
49
|
+
* For nodejs applications, consider the 'node-fetch' package.
|
|
50
|
+
*/
|
|
51
|
+
fetch?: FetchLike;
|
|
52
|
+
/**
|
|
53
|
+
* Optional callback for when the client is unauthenticated.
|
|
54
|
+
* Default is do nothing.
|
|
55
|
+
* For client side applications, consider redirecting to a sign in page.
|
|
56
|
+
*/
|
|
57
|
+
onUnauthenticated?: () => void;
|
|
58
|
+
}
|
|
59
|
+
export interface FetchLike {
|
|
60
|
+
(url: string, options?: any): Promise<any>;
|
|
61
|
+
}
|
|
62
|
+
export interface RegisterRequest {
|
|
63
|
+
readonly firstName: string;
|
|
64
|
+
readonly lastName: string;
|
|
65
|
+
readonly projectName: string;
|
|
66
|
+
readonly email: string;
|
|
67
|
+
readonly password: string;
|
|
68
|
+
readonly remember?: boolean;
|
|
69
|
+
readonly recaptchaToken: string;
|
|
70
|
+
}
|
|
71
|
+
export interface GoogleCredentialResponse {
|
|
72
|
+
readonly clientId: string;
|
|
73
|
+
readonly credential: string;
|
|
74
|
+
}
|
|
75
|
+
export interface LoginAuthenticationResponse {
|
|
76
|
+
readonly login: string;
|
|
77
|
+
readonly code?: string;
|
|
78
|
+
readonly memberships?: ProjectMembership[];
|
|
79
|
+
}
|
|
80
|
+
export interface LoginProfileResponse {
|
|
81
|
+
readonly login: string;
|
|
82
|
+
readonly scope: string;
|
|
83
|
+
}
|
|
84
|
+
export interface LoginScopeResponse {
|
|
85
|
+
readonly login: string;
|
|
86
|
+
readonly code: string;
|
|
87
|
+
}
|
|
88
|
+
export interface LoginState {
|
|
89
|
+
readonly project: Reference<Project>;
|
|
90
|
+
readonly profile: Reference<ProfileResource>;
|
|
91
|
+
readonly accessToken: string;
|
|
92
|
+
readonly refreshToken: string;
|
|
93
|
+
}
|
|
94
|
+
export interface TokenResponse {
|
|
95
|
+
readonly token_type: string;
|
|
96
|
+
readonly id_token: string;
|
|
97
|
+
readonly access_token: string;
|
|
98
|
+
readonly refresh_token: string;
|
|
99
|
+
readonly expires_in: number;
|
|
100
|
+
readonly project: Reference<Project>;
|
|
101
|
+
readonly profile: Reference<ProfileResource>;
|
|
102
|
+
}
|
|
103
|
+
export interface BotEvent {
|
|
104
|
+
readonly contentType: string;
|
|
105
|
+
readonly input: Resource | Hl7Message | string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The MedplumClient class provides a client for the Medplum FHIR server.
|
|
109
|
+
*
|
|
110
|
+
* The client can be used in the browser, in a NodeJS application, or in a Medplum Bot.
|
|
111
|
+
*
|
|
112
|
+
* The client provides helpful methods for common operations such as:
|
|
113
|
+
* 1) Authenticating
|
|
114
|
+
* 2) Creating resources
|
|
115
|
+
* 2) Reading resources
|
|
116
|
+
* 3) Updating resources
|
|
117
|
+
* 5) Deleting resources
|
|
118
|
+
* 6) Searching
|
|
119
|
+
* 7) Making GraphQL queries
|
|
120
|
+
*
|
|
121
|
+
* Here is a quick example of how to use the client:
|
|
122
|
+
*
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { MedplumClient } from '@medplum/core';
|
|
125
|
+
* const medplum = new MedplumClient();
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* Create a `Patient`:
|
|
129
|
+
*
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const patient = await medplum.createResource({
|
|
132
|
+
* resourceType: 'Patient',
|
|
133
|
+
* name: [{
|
|
134
|
+
* given: ['Alice'],
|
|
135
|
+
* family: 'Smith'
|
|
136
|
+
* }]
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* Read a `Patient` by ID:
|
|
141
|
+
*
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const patient = await medplum.readResource('Patient', '123');
|
|
144
|
+
* console.log(patient.name[0].given[0]);
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* Search for a `Patient` by name:
|
|
148
|
+
*
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const bundle = await medplum.search('Patient?name=Alice');
|
|
151
|
+
* console.log(bundle.total);
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
export declare class MedplumClient extends EventTarget {
|
|
156
|
+
#private;
|
|
157
|
+
constructor(options?: MedplumClientOptions);
|
|
158
|
+
/**
|
|
159
|
+
* Clears all auth state including local storage and session storage.
|
|
160
|
+
*/
|
|
161
|
+
clear(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Makes an HTTP GET request to the specified URL.
|
|
164
|
+
*
|
|
165
|
+
* This is a lower level method for custom requests.
|
|
166
|
+
* For common operations, we recommend using higher level methods
|
|
167
|
+
* such as `readResource()`, `search()`, etc.
|
|
168
|
+
*
|
|
169
|
+
* @param url The target URL.
|
|
170
|
+
* @param options Optional fetch options.
|
|
171
|
+
* @returns Promise to the response content.
|
|
172
|
+
*/
|
|
173
|
+
get<T = any>(url: string, options?: RequestInit): ReadablePromise<T>;
|
|
174
|
+
/**
|
|
175
|
+
* Makes an HTTP POST request to the specified URL.
|
|
176
|
+
*
|
|
177
|
+
* This is a lower level method for custom requests.
|
|
178
|
+
* For common operations, we recommend using higher level methods
|
|
179
|
+
* such as `createResource()`.
|
|
180
|
+
*
|
|
181
|
+
* @param url The target URL.
|
|
182
|
+
* @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
|
|
183
|
+
* @param contentType The content type to be included in the "Content-Type" header.
|
|
184
|
+
* @param options Optional fetch options.
|
|
185
|
+
* @returns Promise to the response content.
|
|
186
|
+
*/
|
|
187
|
+
post(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
188
|
+
/**
|
|
189
|
+
* Makes an HTTP PUT request to the specified URL.
|
|
190
|
+
*
|
|
191
|
+
* This is a lower level method for custom requests.
|
|
192
|
+
* For common operations, we recommend using higher level methods
|
|
193
|
+
* such as `updateResource()`.
|
|
194
|
+
*
|
|
195
|
+
* @param url The target URL.
|
|
196
|
+
* @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
|
|
197
|
+
* @param contentType The content type to be included in the "Content-Type" header.
|
|
198
|
+
* @param options Optional fetch options.
|
|
199
|
+
* @returns Promise to the response content.
|
|
200
|
+
*/
|
|
201
|
+
put(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
|
|
202
|
+
/**
|
|
203
|
+
* Makes an HTTP PATCH request to the specified URL.
|
|
204
|
+
*
|
|
205
|
+
* This is a lower level method for custom requests.
|
|
206
|
+
* For common operations, we recommend using higher level methods
|
|
207
|
+
* such as `patchResource()`.
|
|
208
|
+
*
|
|
209
|
+
* @param url The target URL.
|
|
210
|
+
* @param operations Array of JSONPatch operations.
|
|
211
|
+
* @param options Optional fetch options.
|
|
212
|
+
* @returns Promise to the response content.
|
|
213
|
+
*/
|
|
214
|
+
patch(url: string, operations: Operation[], options?: RequestInit): Promise<any>;
|
|
215
|
+
/**
|
|
216
|
+
* Makes an HTTP DELETE request to the specified URL.
|
|
217
|
+
*
|
|
218
|
+
* This is a lower level method for custom requests.
|
|
219
|
+
* For common operations, we recommend using higher level methods
|
|
220
|
+
* such as `deleteResource()`.
|
|
221
|
+
*
|
|
222
|
+
* @param url The target URL.
|
|
223
|
+
* @param options Optional fetch options.
|
|
224
|
+
* @returns Promise to the response content.
|
|
225
|
+
*/
|
|
226
|
+
delete(url: string, options?: RequestInit): Promise<any>;
|
|
227
|
+
/**
|
|
228
|
+
* Tries to register a new user.
|
|
229
|
+
* @param request The registration request.
|
|
230
|
+
* @returns Promise to the authentication response.
|
|
231
|
+
*/
|
|
232
|
+
register(request: RegisterRequest): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Initiates a user login flow.
|
|
235
|
+
* @param email The email address of the user.
|
|
236
|
+
* @param password The password of the user.
|
|
237
|
+
* @param remember Optional flag to remember the user.
|
|
238
|
+
* @returns Promise to the authentication response.
|
|
239
|
+
*/
|
|
240
|
+
startLogin(email: string, password: string, remember?: boolean): Promise<LoginAuthenticationResponse>;
|
|
241
|
+
/**
|
|
242
|
+
* Tries to sign in with Google authentication.
|
|
243
|
+
* The response parameter is the result of a Google authentication.
|
|
244
|
+
* See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
|
|
245
|
+
* @param googleResponse The Google credential response.
|
|
246
|
+
* @returns Promise to the authentication response.
|
|
247
|
+
*/
|
|
248
|
+
startGoogleLogin(googleResponse: GoogleCredentialResponse): Promise<LoginAuthenticationResponse>;
|
|
249
|
+
/**
|
|
250
|
+
* Signs out locally.
|
|
251
|
+
* Does not invalidate tokens with the server.
|
|
252
|
+
*/
|
|
253
|
+
signOut(): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Tries to sign in the user.
|
|
256
|
+
* Returns true if the user is signed in.
|
|
257
|
+
* This may result in navigating away to the sign in page.
|
|
258
|
+
*/
|
|
259
|
+
signInWithRedirect(): Promise<ProfileResource | void> | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* Tries to sign out the user.
|
|
262
|
+
* See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
|
|
263
|
+
*/
|
|
264
|
+
signOutWithRedirect(): void;
|
|
265
|
+
/**
|
|
266
|
+
* Builds a FHIR URL from a collection of URL path components.
|
|
267
|
+
* For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
|
|
268
|
+
* @param path The path component of the URL.
|
|
269
|
+
* @returns The well-formed FHIR URL.
|
|
270
|
+
*/
|
|
271
|
+
fhirUrl(...path: string[]): string;
|
|
272
|
+
/**
|
|
273
|
+
* Sends a FHIR search request.
|
|
274
|
+
*
|
|
275
|
+
* Example using a FHIR search string:
|
|
276
|
+
*
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const bundle = await client.search('Patient?name=Alice');
|
|
279
|
+
* console.log(bundle);
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* Example using a structured search:
|
|
283
|
+
*
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const bundle = await client.search({
|
|
286
|
+
* resourceType: 'Patient',
|
|
287
|
+
* filters: [{
|
|
288
|
+
* code: 'name',
|
|
289
|
+
* operator: 'eq',
|
|
290
|
+
* value: 'Alice',
|
|
291
|
+
* }]
|
|
292
|
+
* });
|
|
293
|
+
* console.log(bundle);
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* The return value is a FHIR bundle:
|
|
297
|
+
*
|
|
298
|
+
* ```json
|
|
299
|
+
* {
|
|
300
|
+
* "resourceType": "Bundle",
|
|
301
|
+
* "type": "searchest",
|
|
302
|
+
* "total": 1,
|
|
303
|
+
* "entry": [
|
|
304
|
+
* {
|
|
305
|
+
* "resource": {
|
|
306
|
+
* "resourceType": "Patient",
|
|
307
|
+
* "name": [
|
|
308
|
+
* {
|
|
309
|
+
* "given": [
|
|
310
|
+
* "George"
|
|
311
|
+
* ],
|
|
312
|
+
* "family": "Washington"
|
|
313
|
+
* }
|
|
314
|
+
* ],
|
|
315
|
+
* }
|
|
316
|
+
* }
|
|
317
|
+
* ]
|
|
318
|
+
* }
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
322
|
+
*
|
|
323
|
+
* @param query The search query as either a string or a structured search object.
|
|
324
|
+
* @returns Promise to the search result bundle.
|
|
325
|
+
*/
|
|
326
|
+
search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<Bundle<T>>;
|
|
327
|
+
/**
|
|
328
|
+
* Sends a FHIR search request for a single resource.
|
|
329
|
+
*
|
|
330
|
+
* This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.
|
|
331
|
+
*
|
|
332
|
+
* Example using a FHIR search string:
|
|
333
|
+
*
|
|
334
|
+
* ```typescript
|
|
335
|
+
* const patient = await client.searchOne('Patient?identifier=123');
|
|
336
|
+
* console.log(patient);
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* The return value is the resource, if available; otherwise, undefined.
|
|
340
|
+
*
|
|
341
|
+
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
342
|
+
*
|
|
343
|
+
* @param query The search query as either a string or a structured search object.
|
|
344
|
+
* @returns Promise to the search result bundle.
|
|
345
|
+
*/
|
|
346
|
+
searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T | undefined>;
|
|
347
|
+
/**
|
|
348
|
+
* Sends a FHIR search request for an array of resources.
|
|
349
|
+
*
|
|
350
|
+
* This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.
|
|
351
|
+
*
|
|
352
|
+
* Example using a FHIR search string:
|
|
353
|
+
*
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const patients = await client.searchResources('Patient?name=Alice');
|
|
356
|
+
* console.log(patients);
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* The return value is an array of resources.
|
|
360
|
+
*
|
|
361
|
+
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
362
|
+
*
|
|
363
|
+
* @param query The search query as either a string or a structured search object.
|
|
364
|
+
* @returns Promise to the search result bundle.
|
|
365
|
+
*/
|
|
366
|
+
searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T[]>;
|
|
367
|
+
/**
|
|
368
|
+
* Searches a ValueSet resource using the "expand" operation.
|
|
369
|
+
* See: https://www.hl7.org/fhir/operation-valueset-expand.html
|
|
370
|
+
* @param system The ValueSet system url.
|
|
371
|
+
* @param filter The search string.
|
|
372
|
+
* @returns Promise to expanded ValueSet.
|
|
373
|
+
*/
|
|
374
|
+
searchValueSet(system: string, filter: string, options?: RequestInit): Promise<ValueSet>;
|
|
375
|
+
/**
|
|
376
|
+
* Returns a cached resource if it is available.
|
|
377
|
+
* @param resourceType The FHIR resource type.
|
|
378
|
+
* @param id The FHIR resource ID.
|
|
379
|
+
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
380
|
+
*/
|
|
381
|
+
getCached<T extends Resource>(resourceType: string, id: string): T | undefined;
|
|
382
|
+
/**
|
|
383
|
+
* Returns a cached resource if it is available.
|
|
384
|
+
* @param resourceType The FHIR resource type.
|
|
385
|
+
* @param id The FHIR resource ID.
|
|
386
|
+
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
387
|
+
*/
|
|
388
|
+
getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined;
|
|
389
|
+
/**
|
|
390
|
+
* Reads a resource by resource type and ID.
|
|
391
|
+
*
|
|
392
|
+
* Example:
|
|
393
|
+
*
|
|
394
|
+
* ```typescript
|
|
395
|
+
* const patient = await medplum.readResource('Patient', '123');
|
|
396
|
+
* console.log(patient);
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
400
|
+
*
|
|
401
|
+
* @param resourceType The FHIR resource type.
|
|
402
|
+
* @param id The resource ID.
|
|
403
|
+
* @returns The resource if available; undefined otherwise.
|
|
404
|
+
*/
|
|
405
|
+
readResource<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
|
|
406
|
+
/**
|
|
407
|
+
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
408
|
+
*
|
|
409
|
+
* If the resource is not available in the cache, it will be read from the server.
|
|
410
|
+
*
|
|
411
|
+
* Example:
|
|
412
|
+
*
|
|
413
|
+
* ```typescript
|
|
414
|
+
* const patient = await medplum.readCached('Patient', '123');
|
|
415
|
+
* console.log(patient);
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
419
|
+
*
|
|
420
|
+
* @param resourceType The FHIR resource type.
|
|
421
|
+
* @param id The resource ID.
|
|
422
|
+
* @returns The resource if available; undefined otherwise.
|
|
423
|
+
*/
|
|
424
|
+
readCached<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
|
|
425
|
+
/**
|
|
426
|
+
* Reads a resource by `Reference`.
|
|
427
|
+
*
|
|
428
|
+
* This is a convenience method for `readResource()` that accepts a `Reference` object.
|
|
429
|
+
*
|
|
430
|
+
* Example:
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const serviceRequest = await medplum.readResource('ServiceRequest', '123');
|
|
434
|
+
* const patient = await medplum.readReference(serviceRequest.subject);
|
|
435
|
+
* console.log(patient);
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
439
|
+
*
|
|
440
|
+
* @param reference The FHIR reference object.
|
|
441
|
+
* @returns The resource if available; undefined otherwise.
|
|
442
|
+
*/
|
|
443
|
+
readReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
|
|
444
|
+
/**
|
|
445
|
+
* Reads a resource by `Reference` using the in-memory resource cache.
|
|
446
|
+
*
|
|
447
|
+
* This is a convenience method for `readResource()` that accepts a `Reference` object.
|
|
448
|
+
*
|
|
449
|
+
* If the resource is not available in the cache, it will be read from the server.
|
|
450
|
+
*
|
|
451
|
+
* Example:
|
|
452
|
+
*
|
|
453
|
+
* ```typescript
|
|
454
|
+
* const serviceRequest = await medplum.readResource('ServiceRequest', '123');
|
|
455
|
+
* const patient = await medplum.readCachedReference(serviceRequest.subject);
|
|
456
|
+
* console.log(patient);
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
|
|
460
|
+
*
|
|
461
|
+
* @param reference The FHIR reference object.
|
|
462
|
+
* @returns The resource if available; undefined otherwise.
|
|
463
|
+
*/
|
|
464
|
+
readCachedReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
|
|
465
|
+
/**
|
|
466
|
+
* Returns a cached schema for a resource type.
|
|
467
|
+
* If the schema is not cached, returns undefined.
|
|
468
|
+
* It is assumed that a client will call requestSchema before using this method.
|
|
469
|
+
* @param resourceType The FHIR resource type.
|
|
470
|
+
* @returns The schema if immediately available, undefined otherwise.
|
|
471
|
+
*/
|
|
472
|
+
getSchema(): IndexedStructureDefinition;
|
|
473
|
+
/**
|
|
474
|
+
* Requests the schema for a resource type.
|
|
475
|
+
* If the schema is already cached, the promise is resolved immediately.
|
|
476
|
+
* @param resourceType The FHIR resource type.
|
|
477
|
+
* @returns Promise to a schema with the requested resource type.
|
|
478
|
+
*/
|
|
479
|
+
requestSchema(resourceType: string): Promise<IndexedStructureDefinition>;
|
|
480
|
+
/**
|
|
481
|
+
* Reads resource history by resource type and ID.
|
|
482
|
+
*
|
|
483
|
+
* The return value is a bundle of all versions of the resource.
|
|
484
|
+
*
|
|
485
|
+
* Example:
|
|
486
|
+
*
|
|
487
|
+
* ```typescript
|
|
488
|
+
* const history = await medplum.readHistory('Patient', '123');
|
|
489
|
+
* console.log(history);
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
|
|
493
|
+
*
|
|
494
|
+
* @param resourceType The FHIR resource type.
|
|
495
|
+
* @param id The resource ID.
|
|
496
|
+
* @returns The resource if available; undefined otherwise.
|
|
497
|
+
*/
|
|
498
|
+
readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
|
|
499
|
+
/**
|
|
500
|
+
* Reads a specific version of a resource by resource type, ID, and version ID.
|
|
501
|
+
*
|
|
502
|
+
* Example:
|
|
503
|
+
*
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const version = await medplum.readVersion('Patient', '123', '456');
|
|
506
|
+
* console.log(version);
|
|
507
|
+
* ```
|
|
508
|
+
*
|
|
509
|
+
* See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
|
|
510
|
+
*
|
|
511
|
+
* @param resourceType The FHIR resource type.
|
|
512
|
+
* @param id The resource ID.
|
|
513
|
+
* @returns The resource if available; undefined otherwise.
|
|
514
|
+
*/
|
|
515
|
+
readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>;
|
|
516
|
+
readPatientEverything(id: string): Promise<Bundle>;
|
|
517
|
+
/**
|
|
518
|
+
* Creates a new FHIR resource.
|
|
519
|
+
*
|
|
520
|
+
* The return value is the newly created resource, including the ID and meta.
|
|
521
|
+
*
|
|
522
|
+
* Example:
|
|
523
|
+
*
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const result = await medplum.createResource({
|
|
526
|
+
* resourceType: 'Patient',
|
|
527
|
+
* name: [{
|
|
528
|
+
* family: 'Smith',
|
|
529
|
+
* given: ['John']
|
|
530
|
+
* }]
|
|
531
|
+
* });
|
|
532
|
+
* console.log(result.id);
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
536
|
+
*
|
|
537
|
+
* @param resource The FHIR resource to create.
|
|
538
|
+
* @returns The result of the create operation.
|
|
539
|
+
*/
|
|
540
|
+
createResource<T extends Resource>(resource: T): Promise<T>;
|
|
541
|
+
/**
|
|
542
|
+
* Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
|
|
543
|
+
*
|
|
544
|
+
* The return value is the existing resource or the newly created resource, including the ID and meta.
|
|
545
|
+
*
|
|
546
|
+
* Example:
|
|
547
|
+
*
|
|
548
|
+
* ```typescript
|
|
549
|
+
* const result = await medplum.createResourceIfNoneExist(
|
|
550
|
+
* 'Patient?identifier=123',
|
|
551
|
+
* {
|
|
552
|
+
* resourceType: 'Patient',
|
|
553
|
+
* identifier: [{
|
|
554
|
+
* system: 'http://example.com/mrn',
|
|
555
|
+
* value: '123'
|
|
556
|
+
* }]
|
|
557
|
+
* name: [{
|
|
558
|
+
* family: 'Smith',
|
|
559
|
+
* given: ['John']
|
|
560
|
+
* }]
|
|
561
|
+
* });
|
|
562
|
+
* console.log(result.id);
|
|
563
|
+
* ```
|
|
564
|
+
*
|
|
565
|
+
* This method is syntactic sugar for:
|
|
566
|
+
*
|
|
567
|
+
* ```typescript
|
|
568
|
+
* return searchOne(query) ?? createResource(resource);
|
|
569
|
+
* ```
|
|
570
|
+
*
|
|
571
|
+
* The query parameter only contains the search parameters (what would be in the URL following the "?").
|
|
572
|
+
*
|
|
573
|
+
* See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
|
|
574
|
+
*
|
|
575
|
+
* @param resource The FHIR resource to create.
|
|
576
|
+
* @param query The search query for an equivalent resource.
|
|
577
|
+
* @returns The result of the create operation.
|
|
578
|
+
*/
|
|
579
|
+
createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T>;
|
|
580
|
+
/**
|
|
581
|
+
* Creates a FHIR `Binary` resource with the provided data content.
|
|
582
|
+
*
|
|
583
|
+
* The return value is the newly created resource, including the ID and meta.
|
|
584
|
+
*
|
|
585
|
+
* The `data` parameter can be a string or a `File` object.
|
|
586
|
+
*
|
|
587
|
+
* A `File` object often comes from a `<input type="file">` element.
|
|
588
|
+
*
|
|
589
|
+
* Example:
|
|
590
|
+
*
|
|
591
|
+
* ```typescript
|
|
592
|
+
* const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');
|
|
593
|
+
* console.log(result.id);
|
|
594
|
+
* ```
|
|
595
|
+
*
|
|
596
|
+
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
597
|
+
*
|
|
598
|
+
* @param data The binary data to upload.
|
|
599
|
+
* @param filename Optional filename for the binary.
|
|
600
|
+
* @param contentType Content type for the binary.
|
|
601
|
+
* @returns The result of the create operation.
|
|
602
|
+
*/
|
|
603
|
+
createBinary(data: string | File, filename: string | undefined, contentType: string): Promise<Binary>;
|
|
604
|
+
/**
|
|
605
|
+
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
606
|
+
*
|
|
607
|
+
* The return value is the newly created resource, including the ID and meta.
|
|
608
|
+
*
|
|
609
|
+
* The `docDefinition` parameter is a pdfmake document definition.
|
|
610
|
+
*
|
|
611
|
+
* Example:
|
|
612
|
+
*
|
|
613
|
+
* ```typescript
|
|
614
|
+
* const result = await medplum.createPdf({
|
|
615
|
+
* content: ['Hello world']
|
|
616
|
+
* });
|
|
617
|
+
* console.log(result.id);
|
|
618
|
+
* ```
|
|
619
|
+
*
|
|
620
|
+
* See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
|
|
621
|
+
*
|
|
622
|
+
* @param docDefinition The FHIR resource to create.
|
|
623
|
+
* @returns The result of the create operation.
|
|
624
|
+
*/
|
|
625
|
+
createPdf(docDefinition: Record<string, unknown>, filename?: string): Promise<Binary>;
|
|
626
|
+
/**
|
|
627
|
+
* Updates a FHIR resource.
|
|
628
|
+
*
|
|
629
|
+
* The return value is the updated resource, including the ID and meta.
|
|
630
|
+
*
|
|
631
|
+
* Example:
|
|
632
|
+
*
|
|
633
|
+
* ```typescript
|
|
634
|
+
* const result = await medplum.updateResource({
|
|
635
|
+
* resourceType: 'Patient',
|
|
636
|
+
* id: '123',
|
|
637
|
+
* name: [{
|
|
638
|
+
* family: 'Smith',
|
|
639
|
+
* given: ['John']
|
|
640
|
+
* }]
|
|
641
|
+
* });
|
|
642
|
+
* console.log(result.meta.versionId);
|
|
643
|
+
* ```
|
|
644
|
+
*
|
|
645
|
+
* See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
|
|
646
|
+
*
|
|
647
|
+
* @param resource The FHIR resource to update.
|
|
648
|
+
* @returns The result of the update operation.
|
|
649
|
+
*/
|
|
650
|
+
updateResource<T extends Resource>(resource: T): Promise<T>;
|
|
651
|
+
/**
|
|
652
|
+
* Updates a FHIR resource using JSONPatch operations.
|
|
653
|
+
*
|
|
654
|
+
* The return value is the updated resource, including the ID and meta.
|
|
655
|
+
*
|
|
656
|
+
* Example:
|
|
657
|
+
*
|
|
658
|
+
* ```typescript
|
|
659
|
+
* const result = await medplum.patchResource('Patient', '123', [
|
|
660
|
+
* {op: 'replace', path: '/name/0/family', value: 'Smith'},
|
|
661
|
+
* ]);
|
|
662
|
+
* console.log(result.meta.versionId);
|
|
663
|
+
* ```
|
|
664
|
+
*
|
|
665
|
+
* See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
|
|
666
|
+
*
|
|
667
|
+
* See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
|
|
668
|
+
*
|
|
669
|
+
* @param resourceType The FHIR resource type.
|
|
670
|
+
* @param id The resource ID.
|
|
671
|
+
* @param operations The JSONPatch operations.
|
|
672
|
+
* @returns The result of the patch operations.
|
|
673
|
+
*/
|
|
674
|
+
patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>;
|
|
675
|
+
/**
|
|
676
|
+
* Deletes a FHIR resource by resource type and ID.
|
|
677
|
+
*
|
|
678
|
+
* Example:
|
|
679
|
+
*
|
|
680
|
+
* ```typescript
|
|
681
|
+
* await medplum.deleteResource('Patient', '123');
|
|
682
|
+
* ```
|
|
683
|
+
*
|
|
684
|
+
* See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
|
|
685
|
+
*
|
|
686
|
+
* @param resourceType The FHIR resource type.
|
|
687
|
+
* @param id The resource ID.
|
|
688
|
+
* @returns The result of the delete operation.
|
|
689
|
+
*/
|
|
690
|
+
deleteResource(resourceType: string, id: string): Promise<any>;
|
|
691
|
+
graphql(query: string, options?: RequestInit): Promise<any>;
|
|
692
|
+
getActiveLogin(): LoginState | undefined;
|
|
693
|
+
setActiveLogin(login: LoginState): Promise<void>;
|
|
694
|
+
setAccessToken(accessToken: string): void;
|
|
695
|
+
getLogins(): LoginState[];
|
|
696
|
+
isLoading(): boolean;
|
|
697
|
+
getProfile(): ProfileResource | undefined;
|
|
698
|
+
getProfileAsync(): Promise<ProfileResource | undefined>;
|
|
699
|
+
getUserConfiguration(): UserConfiguration | undefined;
|
|
700
|
+
/**
|
|
701
|
+
* Downloads the URL as a blob.
|
|
702
|
+
* @param url The URL to request.
|
|
703
|
+
* @returns Promise to the response body as a blob.
|
|
704
|
+
*/
|
|
705
|
+
download(url: string, options?: RequestInit): Promise<Blob>;
|
|
706
|
+
/**
|
|
707
|
+
* Processes an OAuth authorization code.
|
|
708
|
+
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
709
|
+
* @param code The authorization code received by URL parameter.
|
|
710
|
+
*/
|
|
711
|
+
processCode(code: string): Promise<ProfileResource>;
|
|
712
|
+
clientCredentials(clientId: string, clientSecret: string): Promise<ProfileResource>;
|
|
713
|
+
}
|