@health-samurai/aidbox-client 0.0.0-alpha.2 → 0.0.0-alpha.4
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 +295 -66
- package/dist/src/auth-providers.d.ts +22 -0
- package/dist/src/auth-providers.d.ts.map +1 -1
- package/dist/src/auth-providers.js +149 -13
- package/dist/src/client.d.ts +504 -31
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +1455 -934
- package/dist/src/fhir-types/hl7-fhir-r4-core/Address.d.ts +26 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Address.d.ts.map +1 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Address.js +5 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/ContactPoint.d.ts +16 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/ContactPoint.d.ts.map +1 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/ContactPoint.js +5 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/DomainResource.d.ts +1 -1
- package/dist/src/fhir-types/hl7-fhir-r4-core/DomainResource.d.ts.map +1 -1
- package/dist/src/fhir-types/hl7-fhir-r4-core/HumanName.d.ts +20 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/HumanName.d.ts.map +1 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/HumanName.js +5 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Patient.d.ts +58 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Patient.d.ts.map +1 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Patient.js +10 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/Resource.d.ts +1 -1
- package/dist/src/fhir-types/hl7-fhir-r4-core/Resource.d.ts.map +1 -1
- package/dist/src/fhir-types/hl7-fhir-r4-core/index.d.ts +5 -0
- package/dist/src/fhir-types/hl7-fhir-r4-core/index.d.ts.map +1 -1
- package/dist/src/fhir-types/hl7-fhir-r4-core/index.js +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/result.d.ts +114 -3
- package/dist/src/result.d.ts.map +1 -1
- package/dist/src/result.js +6 -2
- package/dist/src/smart-backend-services.d.ts +44 -0
- package/dist/src/smart-backend-services.d.ts.map +1 -0
- package/dist/src/smart-backend-services.js +685 -0
- package/dist/src/types.d.ts +104 -70
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +10 -2
- package/dist/src/utils.d.ts +10 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +22 -0
- package/dist/test/auth-providers.test.d.ts +2 -0
- package/dist/test/auth-providers.test.d.ts.map +1 -0
- package/dist/test/basic-auth.test.d.ts +2 -0
- package/dist/test/basic-auth.test.d.ts.map +1 -0
- package/dist/test/smart-backend-services.test.d.ts +2 -0
- package/dist/test/smart-backend-services.test.d.ts.map +1 -0
- package/dist/test/utils.test.d.ts +2 -0
- package/dist/test/utils.test.d.ts.map +1 -0
- package/package.json +3 -1
- package/dist/src/fhir-http.d.ts +0 -96
- package/dist/src/fhir-http.d.ts.map +0 -1
- package/dist/src/fhir-http.js +0 -1
package/dist/src/client.js
CHANGED
|
@@ -35,6 +35,40 @@ function _async_to_generator(fn) {
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
39
|
+
if (privateCollection.has(obj)) {
|
|
40
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _class_call_check(instance, Constructor) {
|
|
44
|
+
if (!(instance instanceof Constructor)) {
|
|
45
|
+
throw new TypeError("Cannot call a class as a function");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _class_private_method_get(receiver, privateSet, fn) {
|
|
49
|
+
if (!privateSet.has(receiver)) {
|
|
50
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
51
|
+
}
|
|
52
|
+
return fn;
|
|
53
|
+
}
|
|
54
|
+
function _class_private_method_init(obj, privateSet) {
|
|
55
|
+
_check_private_redeclaration(obj, privateSet);
|
|
56
|
+
privateSet.add(obj);
|
|
57
|
+
}
|
|
58
|
+
function _defineProperties(target, props) {
|
|
59
|
+
for(var i = 0; i < props.length; i++){
|
|
60
|
+
var descriptor = props[i];
|
|
61
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
62
|
+
descriptor.configurable = true;
|
|
63
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
64
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
68
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
69
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
70
|
+
return Constructor;
|
|
71
|
+
}
|
|
38
72
|
function _define_property(obj, key, value) {
|
|
39
73
|
if (key in obj) {
|
|
40
74
|
Object.defineProperty(obj, key, {
|
|
@@ -208,967 +242,1454 @@ var makeUrl = function(parts) {
|
|
|
208
242
|
}).join("/"));
|
|
209
243
|
};
|
|
210
244
|
var basePath = "fhir";
|
|
245
|
+
var _internalRawRequest = /*#__PURE__*/ new WeakSet();
|
|
246
|
+
/// IMPORTANT:
|
|
247
|
+
///
|
|
248
|
+
/// PLEASE, use one sentence per line approach in the docstrings.
|
|
249
|
+
/// Don't use hard-wrapping, it makes git-diff a painfull experience.
|
|
211
250
|
/**
|
|
212
251
|
* Create a client to the FHIR server.
|
|
213
252
|
*
|
|
214
253
|
* ```typescript
|
|
254
|
+
* import type { User } from "@health-samurai/aidbox-client";
|
|
255
|
+
*
|
|
215
256
|
* const baseUrl = "https://fhir-server.address";
|
|
216
|
-
* const client =
|
|
257
|
+
* const client = new AidboxClient(
|
|
217
258
|
* baseUrl,
|
|
218
|
-
*
|
|
219
|
-
*
|
|
259
|
+
* new BrowserAuthProvider(baseUrl);
|
|
260
|
+
* );
|
|
220
261
|
*
|
|
221
262
|
* // alternatively, specify different FHIR types:
|
|
222
263
|
* import type { Bundle, OperationOutcome } from "hl7-fhir-r5-core";
|
|
223
|
-
* const client =
|
|
264
|
+
* const client = new AidboxClient<Bundle, OperationOutcome, User>(
|
|
224
265
|
* baseUrl,
|
|
225
266
|
* authProvider: new BrowserAuthProvider(baseUrl);
|
|
226
|
-
*
|
|
267
|
+
* );
|
|
227
268
|
* ```
|
|
228
269
|
*
|
|
229
270
|
* Main client functions are `request` for typed interactions, and `rawRequest` for manual response processing.
|
|
230
271
|
*
|
|
231
|
-
* This client also provides a set of convenience methods for accessing FHIR operations
|
|
272
|
+
* This client also provides a set of convenience methods for accessing FHIR operations, provided below.
|
|
232
273
|
*
|
|
233
|
-
*
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
params: params,
|
|
298
|
-
headers: requestHeaders,
|
|
299
|
-
body: body !== null && body !== void 0 ? body : ""
|
|
300
|
-
};
|
|
301
|
-
_state.label = 1;
|
|
302
|
-
case 1:
|
|
303
|
-
_state.trys.push([
|
|
304
|
-
1,
|
|
305
|
-
3,
|
|
306
|
-
,
|
|
307
|
-
4
|
|
308
|
-
]);
|
|
309
|
-
return [
|
|
310
|
-
4,
|
|
311
|
-
authProvider.fetch(urlObj.toString(), {
|
|
312
|
-
method: method,
|
|
313
|
-
headers: requestHeaders,
|
|
314
|
-
body: body || null,
|
|
315
|
-
cache: "no-store"
|
|
316
|
-
})
|
|
317
|
-
];
|
|
318
|
-
case 2:
|
|
319
|
-
response = _state.sent();
|
|
320
|
-
responseHeaders = {};
|
|
321
|
-
response.headers.forEach(function(value, key) {
|
|
322
|
-
responseHeaders[key] = value;
|
|
323
|
-
});
|
|
324
|
-
return [
|
|
325
|
-
2,
|
|
326
|
-
{
|
|
327
|
-
response: response,
|
|
328
|
-
responseHeaders: responseHeaders,
|
|
329
|
-
duration: performance.now() - startTime,
|
|
330
|
-
request: request
|
|
331
|
-
}
|
|
332
|
-
];
|
|
333
|
-
case 3:
|
|
334
|
-
e = _state.sent();
|
|
335
|
-
return [
|
|
336
|
-
2,
|
|
337
|
-
{
|
|
338
|
-
error: new RequestError(e && (typeof e === "undefined" ? "undefined" : _type_of(e)) === "object" && "message" in e ? "error during request: ".concat(e.message) : "unknown error during request", {
|
|
339
|
-
cause: e,
|
|
340
|
-
request: request
|
|
341
|
-
}),
|
|
342
|
-
duration: performance.now() - startTime,
|
|
343
|
-
request: request
|
|
344
|
-
}
|
|
345
|
-
];
|
|
346
|
-
case 4:
|
|
347
|
-
return [
|
|
348
|
-
2
|
|
349
|
-
];
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
})();
|
|
353
|
-
};
|
|
354
|
-
var rawRequest = function(requestParams) {
|
|
355
|
-
return _async_to_generator(function() {
|
|
356
|
-
var result;
|
|
357
|
-
return _ts_generator(this, function(_state) {
|
|
358
|
-
switch(_state.label){
|
|
359
|
-
case 0:
|
|
360
|
-
return [
|
|
361
|
-
4,
|
|
362
|
-
internalRawRequest(requestParams)
|
|
363
|
-
];
|
|
364
|
-
case 1:
|
|
365
|
-
result = _state.sent();
|
|
366
|
-
if (isInternalErrorResponse(result)) throw result.error;
|
|
367
|
-
if (!result.response.ok) throw new ErrorResponse("HTTP ".concat(result.response.status, ": ").concat(result.response.statusText), result);
|
|
368
|
-
return [
|
|
369
|
-
2,
|
|
370
|
-
result
|
|
371
|
-
];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
})();
|
|
375
|
-
};
|
|
376
|
-
var request = function(params) {
|
|
377
|
-
return _async_to_generator(function() {
|
|
378
|
-
var response, body;
|
|
379
|
-
return _ts_generator(this, function(_state) {
|
|
380
|
-
switch(_state.label){
|
|
381
|
-
case 0:
|
|
382
|
-
return [
|
|
383
|
-
4,
|
|
384
|
-
internalRawRequest(params)
|
|
385
|
-
];
|
|
386
|
-
case 1:
|
|
387
|
-
response = _state.sent();
|
|
388
|
-
if (isInternalErrorResponse(response)) throw response.error;
|
|
389
|
-
return [
|
|
390
|
-
4,
|
|
391
|
-
coerceBody(response)
|
|
392
|
-
];
|
|
393
|
-
case 2:
|
|
394
|
-
body = _state.sent();
|
|
395
|
-
if (!response.response.ok) {
|
|
396
|
-
if (body.resourceType === "OperationOutcome") return [
|
|
397
|
-
2,
|
|
398
|
-
Err(_object_spread({
|
|
399
|
-
resource: body
|
|
400
|
-
}, response))
|
|
401
|
-
];
|
|
402
|
-
throw new ErrorResponse("HTTP ".concat(response.response.status, ": ").concat(response.response.statusText), response);
|
|
274
|
+
* @showGroups
|
|
275
|
+
*/ export var AidboxClient = /*#__PURE__*/ function() {
|
|
276
|
+
"use strict";
|
|
277
|
+
function AidboxClient(baseUrl, authProvider) {
|
|
278
|
+
_class_call_check(this, AidboxClient);
|
|
279
|
+
// TODO: async response pattern
|
|
280
|
+
_class_private_method_init(this, _internalRawRequest);
|
|
281
|
+
_define_property(this, "baseUrl", void 0);
|
|
282
|
+
_define_property(this, "authProvider", void 0);
|
|
283
|
+
this.baseUrl = baseUrl;
|
|
284
|
+
this.authProvider = authProvider;
|
|
285
|
+
}
|
|
286
|
+
_create_class(AidboxClient, [
|
|
287
|
+
{
|
|
288
|
+
key: "read",
|
|
289
|
+
value: /// FHIR HTTP methods
|
|
290
|
+
/**
|
|
291
|
+
*
|
|
292
|
+
* Read the current state of the resource
|
|
293
|
+
*
|
|
294
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
295
|
+
*
|
|
296
|
+
* ```
|
|
297
|
+
* GET [base]/[type]/[id] {?_format=[mime-type]}
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#read
|
|
301
|
+
*
|
|
302
|
+
* Example usage:
|
|
303
|
+
*
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const patient = await client.read<Patient>({
|
|
306
|
+
* type: "Patient",
|
|
307
|
+
* id: "patient-id",
|
|
308
|
+
* });
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* @group Instance Level Interactions
|
|
312
|
+
*/ function read(opts) {
|
|
313
|
+
return _async_to_generator(function() {
|
|
314
|
+
var requestParams;
|
|
315
|
+
return _ts_generator(this, function(_state) {
|
|
316
|
+
switch(_state.label){
|
|
317
|
+
case 0:
|
|
318
|
+
requestParams = {
|
|
319
|
+
url: makeUrl([
|
|
320
|
+
basePath,
|
|
321
|
+
opts.type,
|
|
322
|
+
opts.id
|
|
323
|
+
]),
|
|
324
|
+
method: "GET"
|
|
325
|
+
};
|
|
326
|
+
if (opts.mimeType) requestParams.headers = {
|
|
327
|
+
accept: opts.mimeType
|
|
328
|
+
};
|
|
329
|
+
return [
|
|
330
|
+
4,
|
|
331
|
+
this.request(requestParams)
|
|
332
|
+
];
|
|
333
|
+
case 1:
|
|
334
|
+
return [
|
|
335
|
+
2,
|
|
336
|
+
_state.sent()
|
|
337
|
+
];
|
|
403
338
|
}
|
|
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
|
-
return _async_to_generator(function() {
|
|
496
|
-
return _ts_generator(this, function(_state) {
|
|
497
|
-
switch(_state.label){
|
|
498
|
-
case 0:
|
|
499
|
-
return [
|
|
500
|
-
4,
|
|
501
|
-
request({
|
|
502
|
-
url: makeUrl([
|
|
503
|
-
basePath,
|
|
504
|
-
opts.type,
|
|
505
|
-
opts.id,
|
|
506
|
-
"_history",
|
|
507
|
-
opts.vid
|
|
508
|
-
]),
|
|
509
|
-
method: "GET"
|
|
510
|
-
})
|
|
511
|
-
];
|
|
512
|
-
case 1:
|
|
513
|
-
return [
|
|
514
|
-
2,
|
|
515
|
-
_state.sent()
|
|
516
|
-
];
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
})();
|
|
520
|
-
};
|
|
521
|
-
var searchType = function(opts) {
|
|
522
|
-
return _async_to_generator(function() {
|
|
523
|
-
var url, requestParams;
|
|
524
|
-
return _ts_generator(this, function(_state) {
|
|
525
|
-
switch(_state.label){
|
|
526
|
-
case 0:
|
|
527
|
-
url = [
|
|
528
|
-
basePath,
|
|
529
|
-
opts.type
|
|
530
|
-
];
|
|
531
|
-
requestParams = {
|
|
532
|
-
url: makeUrl(url),
|
|
533
|
-
method: "GET",
|
|
534
|
-
headers: {
|
|
535
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
536
|
-
},
|
|
537
|
-
params: opts.query
|
|
538
|
-
};
|
|
539
|
-
return [
|
|
540
|
-
4,
|
|
541
|
-
request(requestParams)
|
|
542
|
-
];
|
|
543
|
-
case 1:
|
|
544
|
-
return [
|
|
545
|
-
2,
|
|
546
|
-
_state.sent()
|
|
547
|
-
];
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
})();
|
|
551
|
-
};
|
|
552
|
-
var searchSystem = function(opts) {
|
|
553
|
-
return _async_to_generator(function() {
|
|
554
|
-
var url, requestParams;
|
|
555
|
-
return _ts_generator(this, function(_state) {
|
|
556
|
-
switch(_state.label){
|
|
557
|
-
case 0:
|
|
558
|
-
url = [
|
|
559
|
-
basePath
|
|
560
|
-
];
|
|
561
|
-
requestParams = {
|
|
562
|
-
url: makeUrl(url),
|
|
563
|
-
method: "GET",
|
|
564
|
-
headers: {
|
|
565
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
566
|
-
},
|
|
567
|
-
params: opts.query
|
|
568
|
-
};
|
|
569
|
-
return [
|
|
570
|
-
4,
|
|
571
|
-
request(requestParams)
|
|
572
|
-
];
|
|
573
|
-
case 1:
|
|
574
|
-
return [
|
|
575
|
-
2,
|
|
576
|
-
_state.sent()
|
|
577
|
-
];
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
})();
|
|
581
|
-
};
|
|
582
|
-
var searchCompartment = function(opts) {
|
|
583
|
-
return _async_to_generator(function() {
|
|
584
|
-
var url, requestParams;
|
|
585
|
-
return _ts_generator(this, function(_state) {
|
|
586
|
-
switch(_state.label){
|
|
587
|
-
case 0:
|
|
588
|
-
url = [
|
|
589
|
-
basePath,
|
|
590
|
-
opts.compartment,
|
|
591
|
-
opts.compartmentId,
|
|
592
|
-
opts.type
|
|
593
|
-
];
|
|
594
|
-
requestParams = {
|
|
595
|
-
url: makeUrl(url),
|
|
596
|
-
method: "GET",
|
|
597
|
-
headers: {
|
|
598
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
599
|
-
},
|
|
600
|
-
params: opts.query
|
|
601
|
-
};
|
|
602
|
-
return [
|
|
603
|
-
4,
|
|
604
|
-
request(requestParams)
|
|
605
|
-
];
|
|
606
|
-
case 1:
|
|
607
|
-
return [
|
|
608
|
-
2,
|
|
609
|
-
_state.sent()
|
|
610
|
-
];
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
})();
|
|
614
|
-
};
|
|
615
|
-
var create = function(opts) {
|
|
616
|
-
return _async_to_generator(function() {
|
|
617
|
-
return _ts_generator(this, function(_state) {
|
|
618
|
-
switch(_state.label){
|
|
619
|
-
case 0:
|
|
620
|
-
return [
|
|
621
|
-
4,
|
|
622
|
-
request({
|
|
623
|
-
url: makeUrl([
|
|
624
|
-
basePath,
|
|
625
|
-
opts.type
|
|
626
|
-
]),
|
|
627
|
-
method: "POST",
|
|
628
|
-
body: JSON.stringify(opts.resource)
|
|
629
|
-
})
|
|
630
|
-
];
|
|
631
|
-
case 1:
|
|
632
|
-
return [
|
|
633
|
-
2,
|
|
634
|
-
_state.sent()
|
|
635
|
-
];
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
})();
|
|
639
|
-
};
|
|
640
|
-
var conditionalCreate = function(opts) {
|
|
641
|
-
return _async_to_generator(function() {
|
|
642
|
-
return _ts_generator(this, function(_state) {
|
|
643
|
-
switch(_state.label){
|
|
644
|
-
case 0:
|
|
645
|
-
return [
|
|
646
|
-
4,
|
|
647
|
-
request({
|
|
648
|
-
url: makeUrl([
|
|
649
|
-
basePath,
|
|
650
|
-
opts.type
|
|
651
|
-
]),
|
|
652
|
-
method: "POST",
|
|
653
|
-
headers: {
|
|
654
|
-
"If-None-Exist": new URLSearchParams(opts.searchParameters).toString()
|
|
655
|
-
},
|
|
656
|
-
body: JSON.stringify(opts.resource)
|
|
657
|
-
})
|
|
658
|
-
];
|
|
659
|
-
case 1:
|
|
660
|
-
return [
|
|
661
|
-
2,
|
|
662
|
-
_state.sent()
|
|
663
|
-
];
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
})();
|
|
667
|
-
};
|
|
668
|
-
var update = function(opts) {
|
|
669
|
-
return _async_to_generator(function() {
|
|
670
|
-
return _ts_generator(this, function(_state) {
|
|
671
|
-
switch(_state.label){
|
|
672
|
-
case 0:
|
|
673
|
-
return [
|
|
674
|
-
4,
|
|
675
|
-
request({
|
|
676
|
-
url: makeUrl([
|
|
677
|
-
basePath,
|
|
678
|
-
opts.type,
|
|
679
|
-
opts.id
|
|
680
|
-
]),
|
|
681
|
-
method: "PUT",
|
|
682
|
-
body: JSON.stringify(opts.resource)
|
|
683
|
-
})
|
|
684
|
-
];
|
|
685
|
-
case 1:
|
|
686
|
-
return [
|
|
687
|
-
2,
|
|
688
|
-
_state.sent()
|
|
689
|
-
];
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
})();
|
|
693
|
-
};
|
|
694
|
-
var conditionalUpdate = function(opts) {
|
|
695
|
-
return _async_to_generator(function() {
|
|
696
|
-
return _ts_generator(this, function(_state) {
|
|
697
|
-
switch(_state.label){
|
|
698
|
-
case 0:
|
|
699
|
-
return [
|
|
700
|
-
4,
|
|
701
|
-
request({
|
|
702
|
-
url: makeUrl([
|
|
339
|
+
});
|
|
340
|
+
}).call(this);
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
key: "vread",
|
|
345
|
+
value: /**
|
|
346
|
+
* Read the state of a specific version of the resource
|
|
347
|
+
*
|
|
348
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
349
|
+
*
|
|
350
|
+
* ```
|
|
351
|
+
* GET [base]/[type]/[id]/_history/[vid] {?_format=[mime-type]}
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#vread
|
|
355
|
+
*
|
|
356
|
+
* Example usage:
|
|
357
|
+
*
|
|
358
|
+
* ```typescript
|
|
359
|
+
* const patient = await client.vread<Patient>({
|
|
360
|
+
* type: "Patient",
|
|
361
|
+
* id: "patient-id",
|
|
362
|
+
* vid: "version-id",
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @group Instance Level Interactions
|
|
367
|
+
*/ function vread(opts) {
|
|
368
|
+
return _async_to_generator(function() {
|
|
369
|
+
var requestParams;
|
|
370
|
+
return _ts_generator(this, function(_state) {
|
|
371
|
+
switch(_state.label){
|
|
372
|
+
case 0:
|
|
373
|
+
requestParams = {
|
|
374
|
+
url: makeUrl([
|
|
375
|
+
basePath,
|
|
376
|
+
opts.type,
|
|
377
|
+
opts.id,
|
|
378
|
+
"_history",
|
|
379
|
+
opts.vid
|
|
380
|
+
]),
|
|
381
|
+
method: "GET"
|
|
382
|
+
};
|
|
383
|
+
if (opts.mimeType) requestParams.headers = {
|
|
384
|
+
accept: opts.mimeType
|
|
385
|
+
};
|
|
386
|
+
return [
|
|
387
|
+
4,
|
|
388
|
+
this.request(requestParams)
|
|
389
|
+
];
|
|
390
|
+
case 1:
|
|
391
|
+
return [
|
|
392
|
+
2,
|
|
393
|
+
_state.sent()
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}).call(this);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
key: "searchType",
|
|
402
|
+
value: /**
|
|
403
|
+
* Search the resource type based on some filter criteria.
|
|
404
|
+
*
|
|
405
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
406
|
+
*
|
|
407
|
+
* ```
|
|
408
|
+
* GET [base]/[resource-type]/?param1=value&...{&_format=[mime-type]}
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#search-get
|
|
412
|
+
*
|
|
413
|
+
* Example usage:
|
|
414
|
+
*
|
|
415
|
+
* ```typescript
|
|
416
|
+
* const searchset: Bundle = await client.searchType({
|
|
417
|
+
* type: "Patient",
|
|
418
|
+
* query: [["family", "Unknown"]],
|
|
419
|
+
* });
|
|
420
|
+
* ```
|
|
421
|
+
*
|
|
422
|
+
* @group Type Level Interactions
|
|
423
|
+
*/ function searchType(opts) {
|
|
424
|
+
return _async_to_generator(function() {
|
|
425
|
+
var url, requestParams;
|
|
426
|
+
return _ts_generator(this, function(_state) {
|
|
427
|
+
switch(_state.label){
|
|
428
|
+
case 0:
|
|
429
|
+
url = [
|
|
703
430
|
basePath,
|
|
704
431
|
opts.type
|
|
705
|
-
]
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
432
|
+
];
|
|
433
|
+
requestParams = {
|
|
434
|
+
url: makeUrl(url),
|
|
435
|
+
method: "GET",
|
|
436
|
+
headers: {
|
|
437
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
438
|
+
},
|
|
439
|
+
params: opts.query
|
|
440
|
+
};
|
|
441
|
+
return [
|
|
442
|
+
4,
|
|
443
|
+
this.request(requestParams)
|
|
444
|
+
];
|
|
445
|
+
case 1:
|
|
446
|
+
return [
|
|
447
|
+
2,
|
|
448
|
+
_state.sent()
|
|
449
|
+
];
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}).call(this);
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
key: "searchSystem",
|
|
457
|
+
value: /**
|
|
458
|
+
* Search the system based on some filter criteria.
|
|
459
|
+
*
|
|
460
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
461
|
+
*
|
|
462
|
+
* ```
|
|
463
|
+
* GET [base]?param1=value&...{&_format=[mime-type]}
|
|
464
|
+
* ```
|
|
465
|
+
*
|
|
466
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#search-get
|
|
467
|
+
*
|
|
468
|
+
* Example usage:
|
|
469
|
+
*
|
|
470
|
+
* ```typescript
|
|
471
|
+
* const searchset: Bundle = await client.searchSystem({
|
|
472
|
+
* query: [["family", "Unknown"]]
|
|
473
|
+
* });
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* @group Whole System Interactions
|
|
477
|
+
*/ function searchSystem(opts) {
|
|
478
|
+
return _async_to_generator(function() {
|
|
479
|
+
var url, requestParams;
|
|
480
|
+
return _ts_generator(this, function(_state) {
|
|
481
|
+
switch(_state.label){
|
|
482
|
+
case 0:
|
|
483
|
+
url = [
|
|
484
|
+
basePath
|
|
485
|
+
];
|
|
486
|
+
requestParams = {
|
|
487
|
+
url: makeUrl(url),
|
|
488
|
+
method: "GET",
|
|
489
|
+
headers: {
|
|
490
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
491
|
+
},
|
|
492
|
+
params: opts.query
|
|
493
|
+
};
|
|
494
|
+
return [
|
|
495
|
+
4,
|
|
496
|
+
this.request(requestParams)
|
|
497
|
+
];
|
|
498
|
+
case 1:
|
|
499
|
+
return [
|
|
500
|
+
2,
|
|
501
|
+
_state.sent()
|
|
502
|
+
];
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}).call(this);
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
key: "searchCompartment",
|
|
510
|
+
value: /**
|
|
511
|
+
* Search the resource type across the compartment based on some filter criteria.
|
|
512
|
+
*
|
|
513
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
514
|
+
*
|
|
515
|
+
* ```
|
|
516
|
+
* GET [base]/[compartment-type]/[compartment-id]/[resource-type]?param1=value&...{&_format=[mime-type]}
|
|
517
|
+
* ```
|
|
518
|
+
*
|
|
519
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#search-get
|
|
520
|
+
*
|
|
521
|
+
* Example usage:
|
|
522
|
+
*
|
|
523
|
+
* ```typescript
|
|
524
|
+
* const result: Bundle = await client.searchCompartment({
|
|
525
|
+
* compartment: "Patient",
|
|
526
|
+
* compartmentId: "patient-id",
|
|
527
|
+
* type: "Observation",
|
|
528
|
+
* query: [["status", "final"]],
|
|
529
|
+
* });
|
|
530
|
+
* ```
|
|
531
|
+
*
|
|
532
|
+
* @group Compartment Interactions
|
|
533
|
+
*/ function searchCompartment(opts) {
|
|
534
|
+
return _async_to_generator(function() {
|
|
535
|
+
var url, requestParams;
|
|
536
|
+
return _ts_generator(this, function(_state) {
|
|
537
|
+
switch(_state.label){
|
|
538
|
+
case 0:
|
|
539
|
+
url = [
|
|
758
540
|
basePath,
|
|
541
|
+
opts.compartment,
|
|
542
|
+
opts.compartmentId,
|
|
759
543
|
opts.type
|
|
760
|
-
]
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
var deleteOp = function(opts) {
|
|
779
|
-
return _async_to_generator(function() {
|
|
780
|
-
var response, body;
|
|
781
|
-
return _ts_generator(this, function(_state) {
|
|
782
|
-
switch(_state.label){
|
|
783
|
-
case 0:
|
|
784
|
-
return [
|
|
785
|
-
4,
|
|
786
|
-
internalRawRequest({
|
|
787
|
-
url: makeUrl([
|
|
788
|
-
basePath,
|
|
789
|
-
opts.type,
|
|
790
|
-
opts.id
|
|
791
|
-
]),
|
|
792
|
-
method: "DELETE"
|
|
793
|
-
})
|
|
794
|
-
];
|
|
795
|
-
case 1:
|
|
796
|
-
response = _state.sent();
|
|
797
|
-
if (isInternalErrorResponse(response)) throw response.error;
|
|
798
|
-
if (response.response.status === 204) return [
|
|
799
|
-
2,
|
|
800
|
-
Ok(_object_spread({
|
|
801
|
-
resource: undefined
|
|
802
|
-
}, response))
|
|
803
|
-
];
|
|
804
|
-
return [
|
|
805
|
-
4,
|
|
806
|
-
coerceBody(response)
|
|
807
|
-
];
|
|
808
|
-
case 2:
|
|
809
|
-
body = _state.sent();
|
|
810
|
-
if (!response.response.ok) {
|
|
811
|
-
if (body.resourceType === "OperationOutcome") return [
|
|
812
|
-
2,
|
|
813
|
-
Err(_object_spread({
|
|
814
|
-
resource: body
|
|
815
|
-
}, response))
|
|
816
|
-
];
|
|
817
|
-
throw new ErrorResponse("HTTP ".concat(response.response.status, ": ").concat(response.response.statusText), response);
|
|
544
|
+
];
|
|
545
|
+
requestParams = {
|
|
546
|
+
url: makeUrl(url),
|
|
547
|
+
method: "GET",
|
|
548
|
+
headers: {
|
|
549
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
550
|
+
},
|
|
551
|
+
params: opts.query
|
|
552
|
+
};
|
|
553
|
+
return [
|
|
554
|
+
4,
|
|
555
|
+
this.request(requestParams)
|
|
556
|
+
];
|
|
557
|
+
case 1:
|
|
558
|
+
return [
|
|
559
|
+
2,
|
|
560
|
+
_state.sent()
|
|
561
|
+
];
|
|
818
562
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
563
|
+
});
|
|
564
|
+
}).call(this);
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
key: "create",
|
|
569
|
+
value: /**
|
|
570
|
+
* Create a new resource with a server assigned id.
|
|
571
|
+
*
|
|
572
|
+
* The `create` interaction is performed by an HTTP POST command as shown:
|
|
573
|
+
*
|
|
574
|
+
* ```
|
|
575
|
+
* POST [base]/[type] {?_format=[mime-type]}
|
|
576
|
+
* ```
|
|
577
|
+
*
|
|
578
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#create
|
|
579
|
+
*
|
|
580
|
+
* Example usage:
|
|
581
|
+
*
|
|
582
|
+
* ```typescript
|
|
583
|
+
* const patient = await client.create<Patient>({
|
|
584
|
+
* type: "Patient",
|
|
585
|
+
* resource: {
|
|
586
|
+
* id: "patient-id",
|
|
587
|
+
* name: [{
|
|
588
|
+
* family: "Test",
|
|
589
|
+
* given: ["Patient"],
|
|
590
|
+
* }],
|
|
591
|
+
* },
|
|
592
|
+
* });
|
|
593
|
+
* ```
|
|
594
|
+
*
|
|
595
|
+
* @group Type Level Interactions
|
|
596
|
+
*/ function create(opts) {
|
|
597
|
+
return _async_to_generator(function() {
|
|
598
|
+
return _ts_generator(this, function(_state) {
|
|
599
|
+
switch(_state.label){
|
|
600
|
+
case 0:
|
|
601
|
+
return [
|
|
602
|
+
4,
|
|
603
|
+
this.request({
|
|
604
|
+
url: makeUrl([
|
|
605
|
+
basePath,
|
|
606
|
+
opts.type
|
|
607
|
+
]),
|
|
608
|
+
method: "POST",
|
|
609
|
+
body: JSON.stringify(opts.resource)
|
|
610
|
+
})
|
|
611
|
+
];
|
|
612
|
+
case 1:
|
|
613
|
+
return [
|
|
614
|
+
2,
|
|
615
|
+
_state.sent()
|
|
616
|
+
];
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}).call(this);
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
key: "conditionalCreate",
|
|
624
|
+
value: /**
|
|
625
|
+
* The conditional create interaction allows a client to create a new resource only if some equivalent resource does not already exist on the server.
|
|
626
|
+
* The client defines what equivalence means in this case by supplying a FHIR search query using an HL7 defined extension header `If-None-Exist`.
|
|
627
|
+
*
|
|
628
|
+
* The conditional `create` interaction is performed by an HTTP POST command as shown:
|
|
629
|
+
*
|
|
630
|
+
* ```
|
|
631
|
+
* POST [base]/[type]?param1=value&...{&_format=[mime-type]}
|
|
632
|
+
* ```
|
|
633
|
+
*
|
|
634
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#ccreate
|
|
635
|
+
*
|
|
636
|
+
* @group Type Level Interactions
|
|
637
|
+
*/ function conditionalCreate(opts) {
|
|
638
|
+
return _async_to_generator(function() {
|
|
639
|
+
return _ts_generator(this, function(_state) {
|
|
640
|
+
switch(_state.label){
|
|
641
|
+
case 0:
|
|
642
|
+
return [
|
|
643
|
+
4,
|
|
644
|
+
this.request({
|
|
645
|
+
url: makeUrl([
|
|
646
|
+
basePath,
|
|
647
|
+
opts.type
|
|
648
|
+
]),
|
|
649
|
+
method: "POST",
|
|
650
|
+
headers: {
|
|
651
|
+
"If-None-Exist": new URLSearchParams(opts.searchParameters).toString()
|
|
652
|
+
},
|
|
653
|
+
body: JSON.stringify(opts.resource)
|
|
654
|
+
})
|
|
655
|
+
];
|
|
656
|
+
case 1:
|
|
657
|
+
return [
|
|
658
|
+
2,
|
|
659
|
+
_state.sent()
|
|
660
|
+
];
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
}).call(this);
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
key: "update",
|
|
668
|
+
value: /**
|
|
669
|
+
* Update an existing resource by its id (or create it if it is new)
|
|
670
|
+
*
|
|
671
|
+
* The `update` interaction is performed by an HTTP PUT command as shown:
|
|
672
|
+
*
|
|
673
|
+
* ```
|
|
674
|
+
* PUT [base]/[type]/[id] {?_format=[mime-type]}
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#update
|
|
678
|
+
*
|
|
679
|
+
* Example usage:
|
|
680
|
+
*
|
|
681
|
+
* ```typescript
|
|
682
|
+
* const result = await client.update<Patient>({
|
|
683
|
+
* type: "Patient",
|
|
684
|
+
* id: patientId,
|
|
685
|
+
* resource: {
|
|
686
|
+
* resourceType: "Patient",
|
|
687
|
+
* name: [{
|
|
688
|
+
* family: "Smith",
|
|
689
|
+
* given: ["John"],
|
|
690
|
+
* }],
|
|
691
|
+
* },
|
|
692
|
+
* });
|
|
693
|
+
* ```
|
|
694
|
+
*
|
|
695
|
+
* @group Instance Level Interactions
|
|
696
|
+
*/ function update(opts) {
|
|
697
|
+
return _async_to_generator(function() {
|
|
698
|
+
return _ts_generator(this, function(_state) {
|
|
699
|
+
switch(_state.label){
|
|
700
|
+
case 0:
|
|
701
|
+
return [
|
|
702
|
+
4,
|
|
703
|
+
this.request({
|
|
704
|
+
url: makeUrl([
|
|
705
|
+
basePath,
|
|
706
|
+
opts.type,
|
|
707
|
+
opts.id
|
|
708
|
+
]),
|
|
709
|
+
method: "PUT",
|
|
710
|
+
body: JSON.stringify(opts.resource)
|
|
711
|
+
})
|
|
712
|
+
];
|
|
713
|
+
case 1:
|
|
714
|
+
return [
|
|
715
|
+
2,
|
|
716
|
+
_state.sent()
|
|
717
|
+
];
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}).call(this);
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
key: "conditionalUpdate",
|
|
725
|
+
value: /**
|
|
726
|
+
* Conditional Update allows a client to update an existing resource based on some identification criteria, rather than by logical id.
|
|
727
|
+
*
|
|
728
|
+
* The conditional `update` interaction is performed by an HTTP PUT command as shown:
|
|
729
|
+
*
|
|
730
|
+
* ```
|
|
731
|
+
* PUT [base]/[type]?[search parameters]
|
|
732
|
+
* ```
|
|
733
|
+
*
|
|
734
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#cond-update
|
|
735
|
+
*
|
|
736
|
+
* @group Instance Level Interactions
|
|
737
|
+
*/ function conditionalUpdate(opts) {
|
|
738
|
+
return _async_to_generator(function() {
|
|
739
|
+
return _ts_generator(this, function(_state) {
|
|
740
|
+
switch(_state.label){
|
|
741
|
+
case 0:
|
|
742
|
+
return [
|
|
743
|
+
4,
|
|
744
|
+
this.request({
|
|
745
|
+
url: makeUrl([
|
|
746
|
+
basePath,
|
|
747
|
+
opts.type
|
|
748
|
+
]),
|
|
749
|
+
method: "PUT",
|
|
750
|
+
body: JSON.stringify(opts.resource),
|
|
751
|
+
params: opts.searchParameters
|
|
752
|
+
})
|
|
753
|
+
];
|
|
754
|
+
case 1:
|
|
755
|
+
return [
|
|
756
|
+
2,
|
|
757
|
+
_state.sent()
|
|
758
|
+
];
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
}).call(this);
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
key: "patch",
|
|
766
|
+
value: /**
|
|
767
|
+
* Update an existing resource by posting a set of changes to it.
|
|
768
|
+
*
|
|
769
|
+
* The `patch` interaction is performed by an HTTP PATCH command as shown:
|
|
770
|
+
*
|
|
771
|
+
* ```
|
|
772
|
+
* PATCH [base]/[type]/[id] {?_format=[mime-type]}
|
|
773
|
+
* ```
|
|
774
|
+
*
|
|
775
|
+
* The body of a PATCH interaction is a JSON Patch icon document with a content type of `application/json-patch+json`.
|
|
776
|
+
*
|
|
777
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#patch
|
|
778
|
+
*
|
|
779
|
+
* @group Instance Level Interactions
|
|
780
|
+
*/ function patch(opts) {
|
|
781
|
+
return _async_to_generator(function() {
|
|
782
|
+
return _ts_generator(this, function(_state) {
|
|
783
|
+
switch(_state.label){
|
|
784
|
+
case 0:
|
|
785
|
+
return [
|
|
786
|
+
4,
|
|
787
|
+
this.request({
|
|
788
|
+
url: makeUrl([
|
|
789
|
+
basePath,
|
|
790
|
+
opts.type,
|
|
791
|
+
opts.id
|
|
792
|
+
]),
|
|
793
|
+
method: "PATCH",
|
|
794
|
+
headers: {
|
|
795
|
+
"Content-Type": "application/json-patch+json"
|
|
796
|
+
},
|
|
797
|
+
body: JSON.stringify(opts.patch)
|
|
798
|
+
})
|
|
799
|
+
];
|
|
800
|
+
case 1:
|
|
801
|
+
return [
|
|
802
|
+
2,
|
|
803
|
+
_state.sent()
|
|
804
|
+
];
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}).call(this);
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
key: "conditionalPatch",
|
|
812
|
+
value: /**
|
|
813
|
+
* Conditional Patch performs a search using the standard search facilities for the resource type, with the goal of resolving a single logical id for this request.
|
|
814
|
+
* The action it takes depends on how many matches are found.
|
|
815
|
+
*
|
|
816
|
+
* The conditional `patch` interaction is performed by an HTTP PATCH command as shown:
|
|
817
|
+
*
|
|
818
|
+
* ```
|
|
819
|
+
* PATCH [base]/[type]?param1=value&...{&_format=[mime-type]}
|
|
820
|
+
* ```
|
|
821
|
+
*
|
|
822
|
+
* The body of a PATCH interaction is a JSON Patch icon document with a content type of `application/json-patch+json`.
|
|
823
|
+
*
|
|
824
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#cond-patch
|
|
825
|
+
*
|
|
826
|
+
* @group Instance Level Interactions
|
|
827
|
+
*/ function conditionalPatch(opts) {
|
|
828
|
+
return _async_to_generator(function() {
|
|
829
|
+
return _ts_generator(this, function(_state) {
|
|
830
|
+
switch(_state.label){
|
|
831
|
+
case 0:
|
|
832
|
+
return [
|
|
833
|
+
4,
|
|
834
|
+
this.request({
|
|
835
|
+
url: makeUrl([
|
|
836
|
+
basePath,
|
|
837
|
+
opts.type
|
|
838
|
+
]),
|
|
839
|
+
method: "PATCH",
|
|
840
|
+
headers: {
|
|
841
|
+
"Content-Type": "application/json-patch+json"
|
|
842
|
+
},
|
|
843
|
+
params: opts.searchParameters,
|
|
844
|
+
body: JSON.stringify(opts.patch)
|
|
845
|
+
})
|
|
846
|
+
];
|
|
847
|
+
case 1:
|
|
848
|
+
return [
|
|
849
|
+
2,
|
|
850
|
+
_state.sent()
|
|
851
|
+
];
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
}).call(this);
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
key: "delete",
|
|
859
|
+
value: /**
|
|
860
|
+
* Delete a resource.
|
|
861
|
+
*
|
|
862
|
+
* The interaction is performed by an HTTP DELETE command as shown:
|
|
863
|
+
*
|
|
864
|
+
* ```
|
|
865
|
+
* DELETE [base]/[type]/[id]
|
|
866
|
+
* ```
|
|
867
|
+
*
|
|
868
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#delete
|
|
869
|
+
*
|
|
870
|
+
* Example usage:
|
|
871
|
+
*
|
|
872
|
+
* ```typescript
|
|
873
|
+
* const patient = await client.delete<Patient>({
|
|
874
|
+
* type: "Patient",
|
|
875
|
+
* id: "patient-id",
|
|
876
|
+
* });
|
|
877
|
+
* ```
|
|
878
|
+
*
|
|
879
|
+
* @group Instance Level Interactions
|
|
880
|
+
*/ function _delete(opts) {
|
|
881
|
+
return _async_to_generator(function() {
|
|
882
|
+
var response, body;
|
|
883
|
+
return _ts_generator(this, function(_state) {
|
|
884
|
+
switch(_state.label){
|
|
885
|
+
case 0:
|
|
886
|
+
return [
|
|
887
|
+
4,
|
|
888
|
+
_class_private_method_get(this, _internalRawRequest, internalRawRequest).call(this, {
|
|
889
|
+
url: makeUrl([
|
|
890
|
+
basePath,
|
|
891
|
+
opts.type,
|
|
892
|
+
opts.id
|
|
893
|
+
]),
|
|
894
|
+
method: "DELETE"
|
|
895
|
+
})
|
|
896
|
+
];
|
|
897
|
+
case 1:
|
|
898
|
+
response = _state.sent();
|
|
899
|
+
if (isInternalErrorResponse(response)) throw response.error;
|
|
900
|
+
if (response.response.status === 204) return [
|
|
901
|
+
2,
|
|
902
|
+
Ok(_object_spread({
|
|
903
|
+
resource: undefined
|
|
904
|
+
}, response))
|
|
905
|
+
];
|
|
906
|
+
return [
|
|
907
|
+
4,
|
|
908
|
+
coerceBody(response)
|
|
909
|
+
];
|
|
910
|
+
case 2:
|
|
911
|
+
body = _state.sent();
|
|
912
|
+
if (!response.response.ok) {
|
|
913
|
+
if (body.resourceType === "OperationOutcome") return [
|
|
914
|
+
2,
|
|
915
|
+
Err(_object_spread({
|
|
916
|
+
resource: body
|
|
917
|
+
}, response))
|
|
918
|
+
];
|
|
919
|
+
throw new ErrorResponse("HTTP ".concat(response.response.status, ": ").concat(response.response.statusText), response);
|
|
920
|
+
}
|
|
921
|
+
return [
|
|
922
|
+
2,
|
|
923
|
+
Ok(_object_spread({
|
|
924
|
+
resource: body
|
|
925
|
+
}, response))
|
|
926
|
+
];
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
}).call(this);
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
key: "deleteHistory",
|
|
934
|
+
value: /**
|
|
935
|
+
* Delete all historical versions of a resource.
|
|
936
|
+
*
|
|
937
|
+
* The interaction is performed by an HTTP DELETE command as shown:
|
|
938
|
+
*
|
|
939
|
+
* ```
|
|
940
|
+
* DELETE [base]/[type]/[id]/_history
|
|
941
|
+
* ```
|
|
942
|
+
*
|
|
943
|
+
* FHIR Reference: https://build.fhir.org/http.html#delete-history
|
|
944
|
+
*
|
|
945
|
+
* @group Instance Level Interactions
|
|
946
|
+
*/ function deleteHistory(opts) {
|
|
947
|
+
return _async_to_generator(function() {
|
|
948
|
+
return _ts_generator(this, function(_state) {
|
|
949
|
+
switch(_state.label){
|
|
950
|
+
case 0:
|
|
951
|
+
return [
|
|
952
|
+
4,
|
|
953
|
+
this.request({
|
|
954
|
+
url: makeUrl([
|
|
955
|
+
basePath,
|
|
956
|
+
opts.type,
|
|
957
|
+
opts.id,
|
|
958
|
+
"_history"
|
|
959
|
+
]),
|
|
960
|
+
method: "DELETE"
|
|
961
|
+
})
|
|
962
|
+
];
|
|
963
|
+
case 1:
|
|
964
|
+
return [
|
|
965
|
+
2,
|
|
966
|
+
_state.sent()
|
|
967
|
+
];
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}).call(this);
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
key: "deleteHistoryVersion",
|
|
975
|
+
value: /**
|
|
976
|
+
* Delete a specific version of a resource.
|
|
977
|
+
*
|
|
978
|
+
* The interaction is performed by an HTTP DELETE command as shown:
|
|
979
|
+
*
|
|
980
|
+
* ```
|
|
981
|
+
* DELETE [base]/[type]/[id]/_history/[vid]
|
|
982
|
+
* ```
|
|
983
|
+
*
|
|
984
|
+
* FHIR Reference: https://build.fhir.org/http.html#delete-history-version
|
|
985
|
+
*
|
|
986
|
+
* @group Instance Level Interactions
|
|
987
|
+
*/ function deleteHistoryVersion(opts) {
|
|
988
|
+
return _async_to_generator(function() {
|
|
989
|
+
return _ts_generator(this, function(_state) {
|
|
990
|
+
switch(_state.label){
|
|
991
|
+
case 0:
|
|
992
|
+
return [
|
|
993
|
+
4,
|
|
994
|
+
this.request({
|
|
995
|
+
url: makeUrl([
|
|
996
|
+
basePath,
|
|
997
|
+
opts.type,
|
|
998
|
+
opts.id,
|
|
999
|
+
"_history",
|
|
1000
|
+
opts.vid
|
|
1001
|
+
]),
|
|
1002
|
+
method: "DELETE"
|
|
1003
|
+
})
|
|
1004
|
+
];
|
|
1005
|
+
case 1:
|
|
1006
|
+
return [
|
|
1007
|
+
2,
|
|
1008
|
+
_state.sent()
|
|
1009
|
+
];
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
}).call(this);
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
key: "conditionalDelete",
|
|
1017
|
+
value: /**
|
|
1018
|
+
* Conditional Delete across all resource types based on some filter criteria
|
|
1019
|
+
*
|
|
1020
|
+
* If type is provided, performs conditional delete across a particular resource type based on some filter criteria.
|
|
1021
|
+
*
|
|
1022
|
+
* To accomplish this, the client issues an HTTP DELETE as shown:
|
|
1023
|
+
*
|
|
1024
|
+
* ```
|
|
1025
|
+
* DELETE [base]/[type]?[search parameters]
|
|
1026
|
+
* DELETE [base]?[search parameters]
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#cdelete
|
|
1030
|
+
*
|
|
1031
|
+
* @group Type Level Interactions
|
|
1032
|
+
* @group Whole System Interactions
|
|
1033
|
+
*/ function conditionalDelete(opts) {
|
|
1034
|
+
return _async_to_generator(function() {
|
|
1035
|
+
var url, requestParams;
|
|
1036
|
+
return _ts_generator(this, function(_state) {
|
|
1037
|
+
switch(_state.label){
|
|
1038
|
+
case 0:
|
|
1039
|
+
url = [
|
|
1040
|
+
basePath
|
|
1041
|
+
];
|
|
1042
|
+
if (opts.type) url.push(opts.type);
|
|
1043
|
+
requestParams = {
|
|
1044
|
+
url: makeUrl(url),
|
|
1045
|
+
method: "DELETE",
|
|
1046
|
+
params: opts.searchParameters
|
|
1047
|
+
};
|
|
1048
|
+
return [
|
|
1049
|
+
4,
|
|
1050
|
+
this.request(requestParams)
|
|
1051
|
+
];
|
|
1052
|
+
case 1:
|
|
1053
|
+
return [
|
|
1054
|
+
2,
|
|
1055
|
+
_state.sent()
|
|
1056
|
+
];
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
}).call(this);
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
key: "historyInstance",
|
|
1064
|
+
value: /**
|
|
1065
|
+
* Retrieve the change history for a particular resource.
|
|
1066
|
+
*
|
|
1067
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
1068
|
+
*
|
|
1069
|
+
* ```
|
|
1070
|
+
* GET [base]/[type]/[id]/_history{?[parameters]&_format=[mime-type]}
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1073
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#history
|
|
1074
|
+
*
|
|
1075
|
+
* @group Instance Level Interactions
|
|
1076
|
+
*/ function historyInstance(opts) {
|
|
1077
|
+
return _async_to_generator(function() {
|
|
1078
|
+
var url, requestParams;
|
|
1079
|
+
return _ts_generator(this, function(_state) {
|
|
1080
|
+
switch(_state.label){
|
|
1081
|
+
case 0:
|
|
1082
|
+
url = [
|
|
838
1083
|
basePath,
|
|
839
1084
|
opts.type,
|
|
840
1085
|
opts.id,
|
|
841
1086
|
"_history"
|
|
842
|
-
]
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
1087
|
+
];
|
|
1088
|
+
requestParams = {
|
|
1089
|
+
url: makeUrl(url),
|
|
1090
|
+
method: "GET"
|
|
1091
|
+
};
|
|
1092
|
+
return [
|
|
1093
|
+
4,
|
|
1094
|
+
this.request(requestParams)
|
|
1095
|
+
];
|
|
1096
|
+
case 1:
|
|
1097
|
+
return [
|
|
1098
|
+
2,
|
|
1099
|
+
_state.sent()
|
|
1100
|
+
];
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}).call(this);
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
key: "historySystem",
|
|
1108
|
+
value: /**
|
|
1109
|
+
* Retrieve the change history for a particular resource type.
|
|
1110
|
+
*
|
|
1111
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
1112
|
+
*
|
|
1113
|
+
* ```
|
|
1114
|
+
* GET [base]/[type]/_history{?[parameters]&_format=[mime-type]}
|
|
1115
|
+
* ```
|
|
1116
|
+
*
|
|
1117
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#history
|
|
1118
|
+
*
|
|
1119
|
+
* @group Whole System Interactions
|
|
1120
|
+
*/ function historySystem(_) {
|
|
1121
|
+
return _async_to_generator(function() {
|
|
1122
|
+
var url, requestParams;
|
|
1123
|
+
return _ts_generator(this, function(_state) {
|
|
1124
|
+
switch(_state.label){
|
|
1125
|
+
case 0:
|
|
1126
|
+
url = [
|
|
1127
|
+
basePath,
|
|
1128
|
+
"_history"
|
|
1129
|
+
];
|
|
1130
|
+
requestParams = {
|
|
1131
|
+
url: makeUrl(url),
|
|
1132
|
+
method: "GET"
|
|
1133
|
+
};
|
|
1134
|
+
return [
|
|
1135
|
+
4,
|
|
1136
|
+
this.request(requestParams)
|
|
1137
|
+
];
|
|
1138
|
+
case 1:
|
|
1139
|
+
return [
|
|
1140
|
+
2,
|
|
1141
|
+
_state.sent()
|
|
1142
|
+
];
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}).call(this);
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
key: "historyType",
|
|
1150
|
+
value: /**
|
|
1151
|
+
* Retrieve the change history for all resources.
|
|
1152
|
+
*
|
|
1153
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
1154
|
+
*
|
|
1155
|
+
* ```
|
|
1156
|
+
* GET [base]/_history{?[parameters]&_format=[mime-type]}
|
|
1157
|
+
* ```
|
|
1158
|
+
*
|
|
1159
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#history
|
|
1160
|
+
*
|
|
1161
|
+
* @group Type Level Interactions
|
|
1162
|
+
*/ function historyType(opts) {
|
|
1163
|
+
return _async_to_generator(function() {
|
|
1164
|
+
var url, requestParams;
|
|
1165
|
+
return _ts_generator(this, function(_state) {
|
|
1166
|
+
switch(_state.label){
|
|
1167
|
+
case 0:
|
|
1168
|
+
url = [
|
|
864
1169
|
basePath,
|
|
865
1170
|
opts.type,
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1171
|
+
"_history"
|
|
1172
|
+
];
|
|
1173
|
+
requestParams = {
|
|
1174
|
+
url: makeUrl(url),
|
|
1175
|
+
method: "GET"
|
|
1176
|
+
};
|
|
1177
|
+
return [
|
|
1178
|
+
4,
|
|
1179
|
+
this.request(requestParams)
|
|
1180
|
+
];
|
|
1181
|
+
case 1:
|
|
1182
|
+
return [
|
|
1183
|
+
2,
|
|
1184
|
+
_state.sent()
|
|
1185
|
+
];
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
}).call(this);
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
key: "capabilities",
|
|
1193
|
+
value: /**
|
|
1194
|
+
* Get a capability statement for the system.
|
|
1195
|
+
*
|
|
1196
|
+
* The interaction is performed by an HTTP GET command as shown:
|
|
1197
|
+
*
|
|
1198
|
+
* ```
|
|
1199
|
+
* GET [base]/metadata{?mode=[mode]} {&_format=[mime-type]}
|
|
1200
|
+
* ```
|
|
1201
|
+
*
|
|
1202
|
+
* The `mode` can be:
|
|
1203
|
+
*
|
|
1204
|
+
* | Mode | Description |
|
|
1205
|
+
* |---------------|------------------------------------------------------------------------------------------------------------------------------|
|
|
1206
|
+
* | `full` | A `CapabilityStatement` that specifies which resource types and interactions are supported |
|
|
1207
|
+
* | `normative` | As above, but only the normative portions of the Capability Statement |
|
|
1208
|
+
* | `terminology` | A `TerminologyCapabilities` resource that provides further information about terminologies which are supported by the server |
|
|
1209
|
+
*
|
|
1210
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#capabilities
|
|
1211
|
+
*
|
|
1212
|
+
* @group Whole System Interactions
|
|
1213
|
+
*/ function capabilities(opts) {
|
|
1214
|
+
return _async_to_generator(function() {
|
|
1215
|
+
return _ts_generator(this, function(_state) {
|
|
1216
|
+
switch(_state.label){
|
|
1217
|
+
case 0:
|
|
1218
|
+
return [
|
|
1219
|
+
4,
|
|
1220
|
+
this.request({
|
|
1221
|
+
url: makeUrl([
|
|
1222
|
+
basePath,
|
|
1223
|
+
"metadata"
|
|
1224
|
+
]),
|
|
1225
|
+
method: "GET",
|
|
1226
|
+
headers: {
|
|
1227
|
+
Accept: "application/fhir+json"
|
|
1228
|
+
},
|
|
1229
|
+
params: [
|
|
1230
|
+
[
|
|
1231
|
+
"mode",
|
|
1232
|
+
opts.mode
|
|
1233
|
+
],
|
|
1234
|
+
[
|
|
1235
|
+
"_format",
|
|
1236
|
+
"application/fhir+json"
|
|
1237
|
+
]
|
|
1238
|
+
]
|
|
1239
|
+
})
|
|
1240
|
+
];
|
|
1241
|
+
case 1:
|
|
1242
|
+
return [
|
|
1243
|
+
2,
|
|
1244
|
+
_state.sent()
|
|
1245
|
+
];
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
}).call(this);
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
key: "batch",
|
|
1253
|
+
value: /**
|
|
1254
|
+
* Perform multiple operations in a batch request (e.g. create, read, update, delete, patch, and/or [extended operations])
|
|
1255
|
+
*
|
|
1256
|
+
* A batch interaction is performed by an HTTP POST command as shown:
|
|
1257
|
+
*
|
|
1258
|
+
* ```
|
|
1259
|
+
* POST [base] {?_format=[mime-type]}
|
|
1260
|
+
* ```
|
|
1261
|
+
*
|
|
1262
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#transaction
|
|
1263
|
+
*
|
|
1264
|
+
* @group Whole System Interactions
|
|
1265
|
+
*/ function batch(opts) {
|
|
1266
|
+
return _async_to_generator(function() {
|
|
1267
|
+
return _ts_generator(this, function(_state) {
|
|
1268
|
+
switch(_state.label){
|
|
1269
|
+
case 0:
|
|
1270
|
+
return [
|
|
1271
|
+
4,
|
|
1272
|
+
this.request({
|
|
1273
|
+
url: makeUrl([
|
|
1274
|
+
basePath
|
|
1275
|
+
]),
|
|
1276
|
+
method: "POST",
|
|
1277
|
+
params: [
|
|
1278
|
+
[
|
|
1279
|
+
"_format",
|
|
1280
|
+
opts.format
|
|
1281
|
+
]
|
|
1282
|
+
],
|
|
1283
|
+
body: JSON.stringify(opts.bundle)
|
|
1284
|
+
})
|
|
1285
|
+
];
|
|
1286
|
+
case 1:
|
|
1287
|
+
return [
|
|
1288
|
+
2,
|
|
1289
|
+
_state.sent()
|
|
1290
|
+
];
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}).call(this);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
key: "transaction",
|
|
1298
|
+
value: /**
|
|
1299
|
+
* Perform multiple operations as a transaction (e.g. create, read, update, delete, patch, and/or [extended operations])
|
|
1300
|
+
*
|
|
1301
|
+
* A transaction interaction is performed by an HTTP POST command as shown:
|
|
1302
|
+
*
|
|
1303
|
+
* ```
|
|
1304
|
+
* POST [base] {?_format=[mime-type]}
|
|
1305
|
+
* ```
|
|
1306
|
+
*
|
|
1307
|
+
* FHIR Reference: https://hl7.org/fhir/http.html#transaction
|
|
1308
|
+
*
|
|
1309
|
+
* @group Whole System Interactions
|
|
1310
|
+
*/ function transaction(opts) {
|
|
1311
|
+
return _async_to_generator(function() {
|
|
1312
|
+
return _ts_generator(this, function(_state) {
|
|
1313
|
+
switch(_state.label){
|
|
1314
|
+
case 0:
|
|
1315
|
+
return [
|
|
1316
|
+
4,
|
|
1317
|
+
this.request({
|
|
1318
|
+
url: makeUrl([
|
|
1319
|
+
basePath
|
|
1320
|
+
]),
|
|
1321
|
+
method: "POST",
|
|
1322
|
+
params: [
|
|
1323
|
+
[
|
|
1324
|
+
"_format",
|
|
1325
|
+
opts.format
|
|
1326
|
+
]
|
|
1327
|
+
],
|
|
1328
|
+
body: JSON.stringify(opts.bundle)
|
|
1329
|
+
})
|
|
1330
|
+
];
|
|
1331
|
+
case 1:
|
|
1332
|
+
return [
|
|
1333
|
+
2,
|
|
1334
|
+
_state.sent()
|
|
1335
|
+
];
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
}).call(this);
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
key: "operation",
|
|
1343
|
+
value: /**
|
|
1344
|
+
* Perform an operation as defined by an `OperationDefinition`.
|
|
1345
|
+
*
|
|
1346
|
+
* The interaction is performed by an HTTP POST command as shown:
|
|
1347
|
+
*
|
|
1348
|
+
* ```
|
|
1349
|
+
* POST [base]/[type]/[operation] {?_format=[mime-type]}
|
|
1350
|
+
* POST [base]/[type]/[id]/[operation] {?_format=[mime-type]}
|
|
1351
|
+
* ```
|
|
1352
|
+
*
|
|
1353
|
+
* FHIR Reference: https://hl7.org/fhir/operations.html
|
|
1354
|
+
*
|
|
1355
|
+
* @group Operations
|
|
1356
|
+
*/ function operation(opts) {
|
|
1357
|
+
return _async_to_generator(function() {
|
|
1358
|
+
var url, requestParams;
|
|
1359
|
+
return _ts_generator(this, function(_state) {
|
|
1360
|
+
switch(_state.label){
|
|
1361
|
+
case 0:
|
|
1362
|
+
url = [
|
|
1003
1363
|
basePath,
|
|
1004
|
-
|
|
1005
|
-
]
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1364
|
+
opts.type
|
|
1365
|
+
];
|
|
1366
|
+
if (opts.id) url.push(opts.id);
|
|
1367
|
+
url.push(opts.operation);
|
|
1368
|
+
requestParams = {
|
|
1369
|
+
url: makeUrl(url),
|
|
1370
|
+
method: "POST"
|
|
1371
|
+
};
|
|
1372
|
+
if (opts.resource) requestParams.body = JSON.stringify(opts.resource);
|
|
1373
|
+
return [
|
|
1374
|
+
4,
|
|
1375
|
+
this.request(requestParams)
|
|
1376
|
+
];
|
|
1377
|
+
case 1:
|
|
1378
|
+
return [
|
|
1379
|
+
2,
|
|
1380
|
+
_state.sent()
|
|
1381
|
+
];
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1384
|
+
}).call(this);
|
|
1385
|
+
}
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
key: "validate",
|
|
1389
|
+
value: /**
|
|
1390
|
+
* Perform the Validate Operation.
|
|
1391
|
+
*
|
|
1392
|
+
* The interaction is performed by an HTTP POST command as shown:
|
|
1393
|
+
*
|
|
1394
|
+
* ```
|
|
1395
|
+
* [base]/[type]/$validate
|
|
1396
|
+
* [base]/[type]/[id]/$validate
|
|
1397
|
+
* ```
|
|
1398
|
+
*
|
|
1399
|
+
* FHIR Reference: https://hl7.org/fhir/operation-resource-validate.html
|
|
1400
|
+
*
|
|
1401
|
+
* @group Operations
|
|
1402
|
+
*/ function validate(opts) {
|
|
1403
|
+
return _async_to_generator(function() {
|
|
1404
|
+
return _ts_generator(this, function(_state) {
|
|
1405
|
+
switch(_state.label){
|
|
1406
|
+
case 0:
|
|
1407
|
+
return [
|
|
1408
|
+
4,
|
|
1409
|
+
this.operation(_object_spread({
|
|
1410
|
+
operation: "$validate"
|
|
1411
|
+
}, opts))
|
|
1412
|
+
];
|
|
1413
|
+
case 1:
|
|
1414
|
+
return [
|
|
1415
|
+
2,
|
|
1416
|
+
_state.sent()
|
|
1417
|
+
];
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
}).call(this);
|
|
1421
|
+
}
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
key: "userinfo",
|
|
1425
|
+
value: /**
|
|
1426
|
+
* Performs a request to `/auth/userinfo`.
|
|
1427
|
+
*
|
|
1428
|
+
* @group Aidbox methods
|
|
1429
|
+
*/ function userinfo() {
|
|
1430
|
+
return _async_to_generator(function() {
|
|
1431
|
+
var user;
|
|
1432
|
+
return _ts_generator(this, function(_state) {
|
|
1433
|
+
switch(_state.label){
|
|
1434
|
+
case 0:
|
|
1435
|
+
return [
|
|
1436
|
+
4,
|
|
1437
|
+
this.rawRequest({
|
|
1438
|
+
url: "/auth/userinfo",
|
|
1439
|
+
method: "GET",
|
|
1440
|
+
headers: {
|
|
1441
|
+
"Content-Type": "application/json",
|
|
1442
|
+
Accept: "application/json"
|
|
1443
|
+
}
|
|
1444
|
+
}).then(function(response) {
|
|
1445
|
+
return coerceBody(response);
|
|
1446
|
+
})
|
|
1447
|
+
];
|
|
1448
|
+
case 1:
|
|
1449
|
+
user = _state.sent();
|
|
1450
|
+
return [
|
|
1451
|
+
2,
|
|
1452
|
+
user
|
|
1453
|
+
];
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
}).call(this);
|
|
1457
|
+
}
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
key: "logout",
|
|
1461
|
+
value: /**
|
|
1462
|
+
* Performs a request to `/auth/logout`.
|
|
1463
|
+
*
|
|
1464
|
+
* @group Aidbox methods
|
|
1465
|
+
*/ function logout() {
|
|
1466
|
+
return _async_to_generator(function() {
|
|
1467
|
+
return _ts_generator(this, function(_state) {
|
|
1468
|
+
switch(_state.label){
|
|
1469
|
+
case 0:
|
|
1470
|
+
return [
|
|
1471
|
+
4,
|
|
1472
|
+
this.rawRequest({
|
|
1473
|
+
url: "/auth/logout",
|
|
1474
|
+
method: "POST",
|
|
1475
|
+
headers: {
|
|
1476
|
+
"Content-Type": "application/json",
|
|
1477
|
+
Accept: "application/json"
|
|
1478
|
+
}
|
|
1479
|
+
})
|
|
1480
|
+
];
|
|
1481
|
+
case 1:
|
|
1482
|
+
return [
|
|
1483
|
+
2,
|
|
1484
|
+
_state.sent().response
|
|
1485
|
+
];
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
}).call(this);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
key: "request",
|
|
1493
|
+
value: /**
|
|
1494
|
+
* Typed request
|
|
1495
|
+
*
|
|
1496
|
+
* Example usage:
|
|
1497
|
+
*
|
|
1498
|
+
* ```typescript
|
|
1499
|
+
* const result = client.request<Patient>({
|
|
1500
|
+
* method: "GET",
|
|
1501
|
+
* url: "/fhir/Patient/pt-1",
|
|
1502
|
+
* })
|
|
1503
|
+
*
|
|
1504
|
+
* if (isOk(result)) {
|
|
1505
|
+
* const { value } = result;
|
|
1506
|
+
* // work with value as a Patient type
|
|
1507
|
+
* } else {
|
|
1508
|
+
* const { error } = result;
|
|
1509
|
+
* // work with error as an OperationOutcome type.
|
|
1510
|
+
* }
|
|
1511
|
+
* ```
|
|
1512
|
+
*
|
|
1513
|
+
* @group Client methods
|
|
1514
|
+
*/ function request(params) {
|
|
1515
|
+
return _async_to_generator(function() {
|
|
1516
|
+
var response, body;
|
|
1517
|
+
return _ts_generator(this, function(_state) {
|
|
1518
|
+
switch(_state.label){
|
|
1519
|
+
case 0:
|
|
1520
|
+
return [
|
|
1521
|
+
4,
|
|
1522
|
+
_class_private_method_get(this, _internalRawRequest, internalRawRequest).call(this, params)
|
|
1523
|
+
];
|
|
1524
|
+
case 1:
|
|
1525
|
+
response = _state.sent();
|
|
1526
|
+
if (isInternalErrorResponse(response)) throw response.error;
|
|
1527
|
+
return [
|
|
1528
|
+
4,
|
|
1529
|
+
coerceBody(response)
|
|
1530
|
+
];
|
|
1531
|
+
case 2:
|
|
1532
|
+
body = _state.sent();
|
|
1533
|
+
if (!response.response.ok) {
|
|
1534
|
+
if (body.resourceType === "OperationOutcome") return [
|
|
1535
|
+
2,
|
|
1536
|
+
Err(_object_spread({
|
|
1537
|
+
resource: body
|
|
1538
|
+
}, response))
|
|
1539
|
+
];
|
|
1540
|
+
throw new ErrorResponse("HTTP ".concat(response.response.status, ": ").concat(response.response.statusText), response);
|
|
1541
|
+
}
|
|
1542
|
+
return [
|
|
1543
|
+
2,
|
|
1544
|
+
Ok(_object_spread({
|
|
1545
|
+
resource: body
|
|
1546
|
+
}, response))
|
|
1547
|
+
];
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
}).call(this);
|
|
1551
|
+
}
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
key: "rawRequest",
|
|
1555
|
+
value: /**
|
|
1556
|
+
* Untyped request.
|
|
1557
|
+
*
|
|
1558
|
+
* Example usage:
|
|
1559
|
+
*
|
|
1560
|
+
* ```typescript
|
|
1561
|
+
* const result = client.rawRequest({
|
|
1562
|
+
* method: "GET",
|
|
1563
|
+
* url: "/fhir/Patient/pt-1",
|
|
1564
|
+
* })
|
|
1565
|
+
* ```
|
|
1566
|
+
*
|
|
1567
|
+
* @group Client methods
|
|
1568
|
+
*/ function rawRequest(requestParams) {
|
|
1569
|
+
return _async_to_generator(function() {
|
|
1570
|
+
var result;
|
|
1571
|
+
return _ts_generator(this, function(_state) {
|
|
1572
|
+
switch(_state.label){
|
|
1573
|
+
case 0:
|
|
1574
|
+
return [
|
|
1575
|
+
4,
|
|
1576
|
+
_class_private_method_get(this, _internalRawRequest, internalRawRequest).call(this, requestParams)
|
|
1577
|
+
];
|
|
1578
|
+
case 1:
|
|
1579
|
+
result = _state.sent();
|
|
1580
|
+
if (isInternalErrorResponse(result)) throw result.error;
|
|
1581
|
+
if (!result.response.ok) throw new ErrorResponse("HTTP ".concat(result.response.status, ": ").concat(result.response.statusText), result);
|
|
1582
|
+
return [
|
|
1583
|
+
2,
|
|
1584
|
+
result
|
|
1585
|
+
];
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
}).call(this);
|
|
1589
|
+
}
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
key: "getBaseUrl",
|
|
1593
|
+
value: /**
|
|
1594
|
+
* Obtain server's base URL.
|
|
1595
|
+
*
|
|
1596
|
+
* @group Client methods
|
|
1597
|
+
*/ function getBaseUrl() {
|
|
1598
|
+
return this.baseUrl;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
]);
|
|
1602
|
+
return AidboxClient;
|
|
1603
|
+
}();
|
|
1604
|
+
function internalRawRequest(requestParams) {
|
|
1605
|
+
return _async_to_generator(function() {
|
|
1606
|
+
var startTime, baseUrl, method, url, _requestParams_headers, headers, _requestParams_params, params, body, urlObj, requestHeaders, request, response, responseHeaders, e;
|
|
1607
|
+
return _ts_generator(this, function(_state) {
|
|
1608
|
+
switch(_state.label){
|
|
1609
|
+
case 0:
|
|
1610
|
+
startTime = performance.now();
|
|
1611
|
+
baseUrl = this.getBaseUrl();
|
|
1612
|
+
if (!requestParams.url.startsWith("/")) return [
|
|
1613
|
+
2,
|
|
1614
|
+
{
|
|
1615
|
+
error: new RequestError("URL must start with a forward slash", {
|
|
1616
|
+
request: requestParams
|
|
1617
|
+
}),
|
|
1618
|
+
duration: performance.now() - startTime,
|
|
1619
|
+
request: requestParams
|
|
1620
|
+
}
|
|
1621
|
+
];
|
|
1622
|
+
method = requestParams.method, url = requestParams.url, _requestParams_headers = requestParams.headers, headers = _requestParams_headers === void 0 ? {} : _requestParams_headers, _requestParams_params = requestParams.params, params = _requestParams_params === void 0 ? [] : _requestParams_params, body = requestParams.body;
|
|
1623
|
+
urlObj = new URL(url, baseUrl);
|
|
1624
|
+
params.forEach(function(param) {
|
|
1625
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
1626
|
+
urlObj.searchParams.append(key, value);
|
|
1627
|
+
});
|
|
1628
|
+
requestHeaders = {
|
|
1629
|
+
"content-type": "application/json",
|
|
1630
|
+
accept: "application/json"
|
|
1631
|
+
};
|
|
1632
|
+
Object.entries(headers).forEach(function(param) {
|
|
1633
|
+
var _param = _sliced_to_array(param, 2), header = _param[0], value = _param[1];
|
|
1634
|
+
requestHeaders[header.toLowerCase()] = value;
|
|
1635
|
+
});
|
|
1636
|
+
request = {
|
|
1637
|
+
method: method,
|
|
1638
|
+
url: url,
|
|
1639
|
+
params: params,
|
|
1640
|
+
headers: requestHeaders,
|
|
1641
|
+
body: body !== null && body !== void 0 ? body : ""
|
|
1642
|
+
};
|
|
1643
|
+
_state.label = 1;
|
|
1644
|
+
case 1:
|
|
1645
|
+
_state.trys.push([
|
|
1646
|
+
1,
|
|
1647
|
+
3,
|
|
1648
|
+
,
|
|
1649
|
+
4
|
|
1650
|
+
]);
|
|
1651
|
+
return [
|
|
1652
|
+
4,
|
|
1653
|
+
this.authProvider.fetch(urlObj.toString(), {
|
|
1654
|
+
method: method,
|
|
1655
|
+
headers: requestHeaders,
|
|
1656
|
+
body: body || null,
|
|
1657
|
+
cache: "no-store"
|
|
1658
|
+
})
|
|
1659
|
+
];
|
|
1660
|
+
case 2:
|
|
1661
|
+
response = _state.sent();
|
|
1662
|
+
responseHeaders = {};
|
|
1663
|
+
response.headers.forEach(function(value, key) {
|
|
1664
|
+
responseHeaders[key] = value;
|
|
1665
|
+
});
|
|
1666
|
+
return [
|
|
1667
|
+
2,
|
|
1668
|
+
{
|
|
1669
|
+
response: response,
|
|
1670
|
+
responseHeaders: responseHeaders,
|
|
1671
|
+
duration: performance.now() - startTime,
|
|
1672
|
+
request: request
|
|
1673
|
+
}
|
|
1674
|
+
];
|
|
1675
|
+
case 3:
|
|
1676
|
+
e = _state.sent();
|
|
1677
|
+
return [
|
|
1678
|
+
2,
|
|
1679
|
+
{
|
|
1680
|
+
error: new RequestError(e && (typeof e === "undefined" ? "undefined" : _type_of(e)) === "object" && "message" in e ? "error during request: ".concat(e.message) : "unknown error during request", {
|
|
1681
|
+
cause: e,
|
|
1682
|
+
request: request
|
|
1683
|
+
}),
|
|
1684
|
+
duration: performance.now() - startTime,
|
|
1685
|
+
request: request
|
|
1686
|
+
}
|
|
1687
|
+
];
|
|
1688
|
+
case 4:
|
|
1689
|
+
return [
|
|
1690
|
+
2
|
|
1691
|
+
];
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}).call(this);
|
|
1174
1695
|
}
|