@medplum/core 0.9.0 → 0.9.3
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 +158 -29
- package/dist/cjs/index.js +370 -251
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -15
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +357 -251
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -15
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/cache.d.ts +1 -0
- package/dist/types/client.d.ts +33 -8
- package/dist/types/hl7.d.ts +43 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/readablepromise.d.ts +43 -0
- package/dist/types/search.d.ts +2 -1
- package/dist/types/utils.d.ts +33 -3
- package/package.json +2 -2
- package/dist/types/repo.d.ts +0 -116
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -92
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/LegacyRepositoryClient.html +0 -71
- package/docs/classes/MedplumClient.html +0 -324
- package/docs/classes/OperationOutcomeError.html +0 -6
- package/docs/enums/Operator.html +0 -5
- package/docs/enums/PropertyType.html +0 -5
- package/docs/enums/SearchParameterType.html +0 -1
- package/docs/index.html +0 -89
- package/docs/interfaces/AddressFormatOptions.html +0 -1
- package/docs/interfaces/FetchLike.html +0 -1
- package/docs/interfaces/Filter.html +0 -1
- package/docs/interfaces/GoogleCredentialResponse.html +0 -1
- package/docs/interfaces/HumanNameFormatOptions.html +0 -1
- package/docs/interfaces/IndexedStructureDefinition.html +0 -19
- package/docs/interfaces/LoginAuthenticationResponse.html +0 -1
- package/docs/interfaces/LoginProfileResponse.html +0 -1
- package/docs/interfaces/LoginScopeResponse.html +0 -1
- package/docs/interfaces/LoginState.html +0 -1
- package/docs/interfaces/MedplumClientOptions.html +0 -33
- package/docs/interfaces/RegisterRequest.html +0 -1
- package/docs/interfaces/SearchParameterDetails.html +0 -1
- package/docs/interfaces/SearchRequest.html +0 -1
- package/docs/interfaces/SortRule.html +0 -1
- package/docs/interfaces/TokenResponse.html +0 -1
- package/docs/interfaces/TypeSchema.html +0 -10
- package/docs/modules.html +0 -138
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.medplum = global.medplum || {}, global.medplum.core = {})));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/******************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
9
9
|
|
|
10
10
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -75,6 +75,9 @@
|
|
|
75
75
|
}
|
|
76
76
|
__classPrivateFieldGet(this, _LRUCache_cache, "f").set(key, val);
|
|
77
77
|
}
|
|
78
|
+
delete(key) {
|
|
79
|
+
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
_LRUCache_max = new WeakMap(), _LRUCache_cache = new WeakMap(), _LRUCache_instances = new WeakSet(), _LRUCache_first = function _LRUCache_first() {
|
|
80
83
|
// This works because the Map class maintains ordered keys.
|
|
@@ -315,6 +318,47 @@
|
|
|
315
318
|
return days.toString().padStart(3, '0') + 'D';
|
|
316
319
|
}
|
|
317
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Returns all questionnaire answers as a map by link ID.
|
|
323
|
+
* @param response The questionnaire response resource.
|
|
324
|
+
* @returns Questionnaire answers mapped by link ID.
|
|
325
|
+
*/
|
|
326
|
+
function getQuestionnaireAnswers(response) {
|
|
327
|
+
const result = {};
|
|
328
|
+
buildQuestionnaireAnswerItems(response.item, result);
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Recursively builds the questionnaire answer items map.
|
|
333
|
+
* @param item The current questionnaire response item.
|
|
334
|
+
* @param result The cumulative result map.
|
|
335
|
+
*/
|
|
336
|
+
function buildQuestionnaireAnswerItems(items, result) {
|
|
337
|
+
if (items) {
|
|
338
|
+
for (const item of items) {
|
|
339
|
+
if (item.linkId && item.answer && item.answer.length > 0) {
|
|
340
|
+
result[item.linkId] = item.answer[0];
|
|
341
|
+
}
|
|
342
|
+
buildQuestionnaireAnswerItems(item.item, result);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Returns an extension value by extension URLs.
|
|
348
|
+
* @param resource The base resource.
|
|
349
|
+
* @param urls Array of extension URLs. Each entry represents a nested extension.
|
|
350
|
+
* @returns The extension value if found; undefined otherwise.
|
|
351
|
+
*/
|
|
352
|
+
function getExtensionValue(resource, ...urls) {
|
|
353
|
+
var _a;
|
|
354
|
+
// Let curr be the current resource or extension. Extensions can be nested.
|
|
355
|
+
let curr = resource;
|
|
356
|
+
// For each of the urls, try to find a matching nested extension.
|
|
357
|
+
for (let i = 0; i < urls.length && curr; i++) {
|
|
358
|
+
curr = (_a = curr === null || curr === void 0 ? void 0 : curr.extension) === null || _a === void 0 ? void 0 : _a.find((e) => e.url === urls[i]);
|
|
359
|
+
}
|
|
360
|
+
return curr === null || curr === void 0 ? void 0 : curr.valueString;
|
|
361
|
+
}
|
|
318
362
|
/**
|
|
319
363
|
* FHIR JSON stringify.
|
|
320
364
|
* Removes properties with empty string values.
|
|
@@ -360,39 +404,86 @@
|
|
|
360
404
|
/**
|
|
361
405
|
* Resource equality.
|
|
362
406
|
* Ignores meta.versionId and meta.lastUpdated.
|
|
363
|
-
* See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality
|
|
364
407
|
* @param object1 The first object.
|
|
365
408
|
* @param object2 The second object.
|
|
366
409
|
* @returns True if the objects are equal.
|
|
367
410
|
*/
|
|
368
411
|
function deepEquals(object1, object2, path) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
412
|
+
if (object1 === object2) {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
if (isEmpty(object1) && isEmpty(object2)) {
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
if (isEmpty(object1) || isEmpty(object2)) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
if (Array.isArray(object1) && Array.isArray(object2)) {
|
|
422
|
+
return deepEqualsArray(object1, object2);
|
|
423
|
+
}
|
|
424
|
+
if (Array.isArray(object1) || Array.isArray(object2)) {
|
|
425
|
+
return false;
|
|
374
426
|
}
|
|
375
|
-
if (
|
|
427
|
+
if (isObject(object1) && isObject(object2)) {
|
|
428
|
+
return deepEqualsObject(object1, object2, path);
|
|
429
|
+
}
|
|
430
|
+
if (isObject(object1) || isObject(object2)) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
function deepEqualsArray(array1, array2) {
|
|
436
|
+
if (array1.length !== array2.length) {
|
|
376
437
|
return false;
|
|
377
438
|
}
|
|
378
|
-
for (
|
|
439
|
+
for (let i = 0; i < array1.length; i++) {
|
|
440
|
+
if (!deepEquals(array1[i], array2[i])) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
function deepEqualsObject(object1, object2, path) {
|
|
447
|
+
const keySet = new Set();
|
|
448
|
+
Object.keys(object1).forEach((k) => keySet.add(k));
|
|
449
|
+
Object.keys(object2).forEach((k) => keySet.add(k));
|
|
450
|
+
if (path === 'meta') {
|
|
451
|
+
keySet.delete('versionId');
|
|
452
|
+
keySet.delete('lastUpdated');
|
|
453
|
+
keySet.delete('author');
|
|
454
|
+
}
|
|
455
|
+
for (const key of keySet) {
|
|
379
456
|
const val1 = object1[key];
|
|
380
457
|
const val2 = object2[key];
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
if (val1 !== val2) {
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
458
|
+
if (!deepEquals(val1, val2, key)) {
|
|
459
|
+
return false;
|
|
390
460
|
}
|
|
391
461
|
}
|
|
392
462
|
return true;
|
|
393
463
|
}
|
|
394
|
-
|
|
395
|
-
|
|
464
|
+
/**
|
|
465
|
+
* Returns true if the input string is a UUID.
|
|
466
|
+
* @param input The input string.
|
|
467
|
+
* @returns True if the input string matches the UUID format.
|
|
468
|
+
*/
|
|
469
|
+
function isUUID(input) {
|
|
470
|
+
return !!input.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Returns true if the input is an object.
|
|
474
|
+
* @param object The candidate object.
|
|
475
|
+
* @returns True if the input is a non-null non-undefined object.
|
|
476
|
+
*/
|
|
477
|
+
function isObject(obj) {
|
|
478
|
+
return obj !== null && typeof obj === 'object';
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Returns true if the input array is an array of strings.
|
|
482
|
+
* @param arr Input array.
|
|
483
|
+
* @returns True if the input array is an array of strings.
|
|
484
|
+
*/
|
|
485
|
+
function isStringArray(arr) {
|
|
486
|
+
return arr.every((e) => typeof e === 'string');
|
|
396
487
|
}
|
|
397
488
|
// Precompute hex octets
|
|
398
489
|
// See: https://stackoverflow.com/a/55200387
|
|
@@ -428,7 +519,7 @@
|
|
|
428
519
|
return window.btoa(result.join(''));
|
|
429
520
|
}
|
|
430
521
|
function capitalize(word) {
|
|
431
|
-
return word.charAt(0).toUpperCase() + word.
|
|
522
|
+
return word.charAt(0).toUpperCase() + word.substring(1);
|
|
432
523
|
}
|
|
433
524
|
function isLowerCase(c) {
|
|
434
525
|
return c === c.toLowerCase();
|
|
@@ -671,6 +762,83 @@
|
|
|
671
762
|
}
|
|
672
763
|
}
|
|
673
764
|
|
|
765
|
+
var _ReadablePromise_suspender, _ReadablePromise_status, _ReadablePromise_response, _ReadablePromise_error, _a;
|
|
766
|
+
/**
|
|
767
|
+
* The ReadablePromise class wraps a request promise suitable for React Suspense.
|
|
768
|
+
* See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js
|
|
769
|
+
* See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js
|
|
770
|
+
*/
|
|
771
|
+
class ReadablePromise {
|
|
772
|
+
constructor(requestPromise) {
|
|
773
|
+
this[_a] = 'ReadablePromise';
|
|
774
|
+
_ReadablePromise_suspender.set(this, void 0);
|
|
775
|
+
_ReadablePromise_status.set(this, 'pending');
|
|
776
|
+
_ReadablePromise_response.set(this, void 0);
|
|
777
|
+
_ReadablePromise_error.set(this, void 0);
|
|
778
|
+
__classPrivateFieldSet(this, _ReadablePromise_suspender, requestPromise.then((res) => {
|
|
779
|
+
__classPrivateFieldSet(this, _ReadablePromise_status, 'success', "f");
|
|
780
|
+
__classPrivateFieldSet(this, _ReadablePromise_response, res, "f");
|
|
781
|
+
return res;
|
|
782
|
+
}, (err) => {
|
|
783
|
+
__classPrivateFieldSet(this, _ReadablePromise_status, 'error', "f");
|
|
784
|
+
__classPrivateFieldSet(this, _ReadablePromise_error, err, "f");
|
|
785
|
+
throw err;
|
|
786
|
+
}), "f");
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Returns true if the promise is pending.
|
|
790
|
+
* @returns True if the Promise is pending.
|
|
791
|
+
*/
|
|
792
|
+
isPending() {
|
|
793
|
+
return __classPrivateFieldGet(this, _ReadablePromise_status, "f") === 'pending';
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Attempts to read the value of the promise.
|
|
797
|
+
* If the promise is pending, this method will throw a promise.
|
|
798
|
+
* If the promise rejected, this method will throw the rejection reason.
|
|
799
|
+
* If the promise resolved, this method will return the resolved value.
|
|
800
|
+
* @returns The resolved value of the Promise.
|
|
801
|
+
*/
|
|
802
|
+
read() {
|
|
803
|
+
switch (__classPrivateFieldGet(this, _ReadablePromise_status, "f")) {
|
|
804
|
+
case 'pending':
|
|
805
|
+
throw __classPrivateFieldGet(this, _ReadablePromise_suspender, "f");
|
|
806
|
+
case 'error':
|
|
807
|
+
throw __classPrivateFieldGet(this, _ReadablePromise_error, "f");
|
|
808
|
+
default:
|
|
809
|
+
return __classPrivateFieldGet(this, _ReadablePromise_response, "f");
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
814
|
+
* @param onfulfilled The callback to execute when the Promise is resolved.
|
|
815
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
816
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
817
|
+
*/
|
|
818
|
+
then(onfulfilled, onrejected) {
|
|
819
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").then(onfulfilled, onrejected);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
823
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
824
|
+
* @returns A Promise for the completion of the callback.
|
|
825
|
+
*/
|
|
826
|
+
catch(onrejected) {
|
|
827
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").catch(onrejected);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
831
|
+
* resolved value cannot be modified from the callback.
|
|
832
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
833
|
+
* @returns A Promise for the completion of the callback.
|
|
834
|
+
*/
|
|
835
|
+
finally(onfinally) {
|
|
836
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").finally(onfinally);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
_ReadablePromise_suspender = new WeakMap(), _ReadablePromise_status = new WeakMap(), _ReadablePromise_response = new WeakMap(), _ReadablePromise_error = new WeakMap(), _a = Symbol.toStringTag;
|
|
840
|
+
|
|
841
|
+
const DEFAULT_SEARCH_COUNT = 20;
|
|
674
842
|
/**
|
|
675
843
|
* Search operators.
|
|
676
844
|
* These operators represent "modifiers" and "prefixes" in FHIR search.
|
|
@@ -738,15 +906,15 @@
|
|
|
738
906
|
let filters = undefined;
|
|
739
907
|
let sortRules = undefined;
|
|
740
908
|
let fields = undefined;
|
|
741
|
-
let
|
|
909
|
+
let offset = undefined;
|
|
742
910
|
let count = undefined;
|
|
743
911
|
let total = undefined;
|
|
744
912
|
params.forEach((value, key) => {
|
|
745
913
|
if (key === '_fields') {
|
|
746
914
|
fields = value.split(',');
|
|
747
915
|
}
|
|
748
|
-
else if (key === '
|
|
749
|
-
|
|
916
|
+
else if (key === '_offset') {
|
|
917
|
+
offset = parseInt(value);
|
|
750
918
|
}
|
|
751
919
|
else if (key === '_count') {
|
|
752
920
|
count = parseInt(value);
|
|
@@ -767,7 +935,7 @@
|
|
|
767
935
|
resourceType,
|
|
768
936
|
filters,
|
|
769
937
|
fields,
|
|
770
|
-
|
|
938
|
+
offset,
|
|
771
939
|
count,
|
|
772
940
|
total,
|
|
773
941
|
sortRules,
|
|
@@ -843,13 +1011,13 @@
|
|
|
843
1011
|
if (definition.sortRules && definition.sortRules.length > 0) {
|
|
844
1012
|
params.push(formatSortRules(definition.sortRules));
|
|
845
1013
|
}
|
|
846
|
-
if (definition.
|
|
847
|
-
params.push('
|
|
1014
|
+
if (definition.offset !== undefined) {
|
|
1015
|
+
params.push('_offset=' + definition.offset);
|
|
848
1016
|
}
|
|
849
|
-
if (definition.count
|
|
1017
|
+
if (definition.count !== undefined) {
|
|
850
1018
|
params.push('_count=' + definition.count);
|
|
851
1019
|
}
|
|
852
|
-
if (definition.total) {
|
|
1020
|
+
if (definition.total !== undefined) {
|
|
853
1021
|
params.push('_total=' + encodeURIComponent(definition.total));
|
|
854
1022
|
}
|
|
855
1023
|
if (params.length === 0) {
|
|
@@ -1158,7 +1326,7 @@
|
|
|
1158
1326
|
|
|
1159
1327
|
// PKCE auth ased on:
|
|
1160
1328
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
1161
|
-
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_storage, _MedplumClient_schema,
|
|
1329
|
+
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_storage, _MedplumClient_schema, _MedplumClient_requestCache, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_startPkce, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
1162
1330
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
1163
1331
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
1164
1332
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
@@ -1221,7 +1389,7 @@
|
|
|
1221
1389
|
_MedplumClient_fetch.set(this, void 0);
|
|
1222
1390
|
_MedplumClient_storage.set(this, void 0);
|
|
1223
1391
|
_MedplumClient_schema.set(this, void 0);
|
|
1224
|
-
|
|
1392
|
+
_MedplumClient_requestCache.set(this, void 0);
|
|
1225
1393
|
_MedplumClient_baseUrl.set(this, void 0);
|
|
1226
1394
|
_MedplumClient_clientId.set(this, void 0);
|
|
1227
1395
|
_MedplumClient_authorizeUrl.set(this, void 0);
|
|
@@ -1245,7 +1413,7 @@
|
|
|
1245
1413
|
__classPrivateFieldSet(this, _MedplumClient_fetch, (options === null || options === void 0 ? void 0 : options.fetch) || window.fetch.bind(window), "f");
|
|
1246
1414
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
1247
1415
|
__classPrivateFieldSet(this, _MedplumClient_schema, createSchema(), "f");
|
|
1248
|
-
__classPrivateFieldSet(this,
|
|
1416
|
+
__classPrivateFieldSet(this, _MedplumClient_requestCache, new LRUCache((_a = options === null || options === void 0 ? void 0 : options.resourceCacheSize) !== null && _a !== void 0 ? _a : DEFAULT_RESOURCE_CACHE_SIZE), "f");
|
|
1249
1417
|
__classPrivateFieldSet(this, _MedplumClient_baseUrl, (options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
1250
1418
|
__classPrivateFieldSet(this, _MedplumClient_clientId, (options === null || options === void 0 ? void 0 : options.clientId) || '', "f");
|
|
1251
1419
|
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, (options === null || options === void 0 ? void 0 : options.authorizeUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
@@ -1265,7 +1433,7 @@
|
|
|
1265
1433
|
*/
|
|
1266
1434
|
clear() {
|
|
1267
1435
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").clear();
|
|
1268
|
-
__classPrivateFieldGet(this,
|
|
1436
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1269
1437
|
__classPrivateFieldSet(this, _MedplumClient_accessToken, undefined, "f");
|
|
1270
1438
|
__classPrivateFieldSet(this, _MedplumClient_refreshToken, undefined, "f");
|
|
1271
1439
|
__classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
|
|
@@ -1284,7 +1452,15 @@
|
|
|
1284
1452
|
* @returns Promise to the response content.
|
|
1285
1453
|
*/
|
|
1286
1454
|
get(url, options = {}) {
|
|
1287
|
-
|
|
1455
|
+
if (!(options === null || options === void 0 ? void 0 : options.cache)) {
|
|
1456
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(url);
|
|
1457
|
+
if (cached) {
|
|
1458
|
+
return cached;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
const promise = new ReadablePromise(__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'GET', url, options));
|
|
1462
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").set(url, promise);
|
|
1463
|
+
return promise;
|
|
1288
1464
|
}
|
|
1289
1465
|
/**
|
|
1290
1466
|
* Makes an HTTP POST request to the specified URL.
|
|
@@ -1306,6 +1482,7 @@
|
|
|
1306
1482
|
if (contentType) {
|
|
1307
1483
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1308
1484
|
}
|
|
1485
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1309
1486
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'POST', url, options);
|
|
1310
1487
|
}
|
|
1311
1488
|
/**
|
|
@@ -1328,6 +1505,7 @@
|
|
|
1328
1505
|
if (contentType) {
|
|
1329
1506
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1330
1507
|
}
|
|
1508
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1331
1509
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PUT', url, options);
|
|
1332
1510
|
}
|
|
1333
1511
|
/**
|
|
@@ -1345,6 +1523,7 @@
|
|
|
1345
1523
|
patch(url, operations, options = {}) {
|
|
1346
1524
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestBody).call(this, options, operations);
|
|
1347
1525
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, PATCH_CONTENT_TYPE);
|
|
1526
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1348
1527
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PATCH', url, options);
|
|
1349
1528
|
}
|
|
1350
1529
|
/**
|
|
@@ -1359,6 +1538,7 @@
|
|
|
1359
1538
|
* @returns Promise to the response content.
|
|
1360
1539
|
*/
|
|
1361
1540
|
delete(url, options = {}) {
|
|
1541
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1362
1542
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'DELETE', url, options);
|
|
1363
1543
|
}
|
|
1364
1544
|
/**
|
|
@@ -1578,11 +1758,8 @@
|
|
|
1578
1758
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1579
1759
|
*/
|
|
1580
1760
|
getCached(resourceType, id) {
|
|
1581
|
-
const cached = __classPrivateFieldGet(this,
|
|
1582
|
-
|
|
1583
|
-
return cached;
|
|
1584
|
-
}
|
|
1585
|
-
return undefined;
|
|
1761
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id));
|
|
1762
|
+
return cached && !cached.isPending() ? cached.read() : undefined;
|
|
1586
1763
|
}
|
|
1587
1764
|
/**
|
|
1588
1765
|
* Returns a cached resource if it is available.
|
|
@@ -1591,11 +1768,9 @@
|
|
|
1591
1768
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1592
1769
|
*/
|
|
1593
1770
|
getCachedReference(reference) {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}
|
|
1598
|
-
return undefined;
|
|
1771
|
+
const refString = reference.reference;
|
|
1772
|
+
const [resourceType, id] = refString.split('/');
|
|
1773
|
+
return this.getCached(resourceType, id);
|
|
1599
1774
|
}
|
|
1600
1775
|
/**
|
|
1601
1776
|
* Reads a resource by resource type and ID.
|
|
@@ -1614,13 +1789,7 @@
|
|
|
1614
1789
|
* @returns The resource if available; undefined otherwise.
|
|
1615
1790
|
*/
|
|
1616
1791
|
readResource(resourceType, id) {
|
|
1617
|
-
|
|
1618
|
-
const promise = this.get(this.fhirUrl(resourceType, id)).then((resource) => {
|
|
1619
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, resource);
|
|
1620
|
-
return resource;
|
|
1621
|
-
});
|
|
1622
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, promise);
|
|
1623
|
-
return promise;
|
|
1792
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1624
1793
|
}
|
|
1625
1794
|
/**
|
|
1626
1795
|
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
@@ -1641,8 +1810,7 @@
|
|
|
1641
1810
|
* @returns The resource if available; undefined otherwise.
|
|
1642
1811
|
*/
|
|
1643
1812
|
readCached(resourceType, id) {
|
|
1644
|
-
|
|
1645
|
-
return cached ? Promise.resolve(cached) : this.readResource(resourceType, id);
|
|
1813
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1646
1814
|
}
|
|
1647
1815
|
/**
|
|
1648
1816
|
* Reads a resource by `Reference`.
|
|
@@ -1665,7 +1833,7 @@
|
|
|
1665
1833
|
readReference(reference) {
|
|
1666
1834
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1667
1835
|
if (!refString) {
|
|
1668
|
-
return Promise.reject('Missing reference');
|
|
1836
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1669
1837
|
}
|
|
1670
1838
|
const [resourceType, id] = refString.split('/');
|
|
1671
1839
|
return this.readResource(resourceType, id);
|
|
@@ -1693,7 +1861,7 @@
|
|
|
1693
1861
|
readCachedReference(reference) {
|
|
1694
1862
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1695
1863
|
if (!refString) {
|
|
1696
|
-
return Promise.reject('Missing reference');
|
|
1864
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1697
1865
|
}
|
|
1698
1866
|
const [resourceType, id] = refString.split('/');
|
|
1699
1867
|
return this.readCached(resourceType, id);
|
|
@@ -1848,11 +2016,45 @@
|
|
|
1848
2016
|
*
|
|
1849
2017
|
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
1850
2018
|
*
|
|
1851
|
-
* @param
|
|
2019
|
+
* @param data The binary data to upload.
|
|
2020
|
+
* @param filename Optional filename for the binary.
|
|
2021
|
+
* @param contentType Content type for the binary.
|
|
1852
2022
|
* @returns The result of the create operation.
|
|
1853
2023
|
*/
|
|
1854
2024
|
createBinary(data, filename, contentType) {
|
|
1855
|
-
|
|
2025
|
+
let url = this.fhirUrl('Binary');
|
|
2026
|
+
if (filename) {
|
|
2027
|
+
url += '?_filename=' + encodeURIComponent(filename);
|
|
2028
|
+
}
|
|
2029
|
+
return this.post(url, data, contentType);
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
2033
|
+
*
|
|
2034
|
+
* The return value is the newly created resource, including the ID and meta.
|
|
2035
|
+
*
|
|
2036
|
+
* The `docDefinition` parameter is a pdfmake document definition.
|
|
2037
|
+
*
|
|
2038
|
+
* Example:
|
|
2039
|
+
*
|
|
2040
|
+
* ```typescript
|
|
2041
|
+
* const result = await medplum.createPdf({
|
|
2042
|
+
* content: ['Hello world']
|
|
2043
|
+
* });
|
|
2044
|
+
* console.log(result.id);
|
|
2045
|
+
* ```
|
|
2046
|
+
*
|
|
2047
|
+
* See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
|
|
2048
|
+
*
|
|
2049
|
+
* @param docDefinition The FHIR resource to create.
|
|
2050
|
+
* @returns The result of the create operation.
|
|
2051
|
+
*/
|
|
2052
|
+
createPdf(docDefinition, filename) {
|
|
2053
|
+
let url = this.fhirUrl('Binary') + '/$pdf';
|
|
2054
|
+
if (filename) {
|
|
2055
|
+
url += '?_filename=' + encodeURIComponent(filename);
|
|
2056
|
+
}
|
|
2057
|
+
return this.post(url, docDefinition, 'application/json');
|
|
1856
2058
|
}
|
|
1857
2059
|
/**
|
|
1858
2060
|
* Updates a FHIR resource.
|
|
@@ -1945,7 +2147,7 @@
|
|
|
1945
2147
|
__classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
|
|
1946
2148
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('activeLogin', login);
|
|
1947
2149
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addLogin).call(this, login);
|
|
1948
|
-
__classPrivateFieldGet(this,
|
|
2150
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1949
2151
|
__classPrivateFieldSet(this, _MedplumClient_refreshPromise, undefined, "f");
|
|
1950
2152
|
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
1951
2153
|
});
|
|
@@ -2027,7 +2229,7 @@
|
|
|
2027
2229
|
});
|
|
2028
2230
|
}
|
|
2029
2231
|
}
|
|
2030
|
-
_MedplumClient_fetch = new WeakMap(), _MedplumClient_storage = new WeakMap(), _MedplumClient_schema = new WeakMap(),
|
|
2232
|
+
_MedplumClient_fetch = new WeakMap(), _MedplumClient_storage = new WeakMap(), _MedplumClient_schema = new WeakMap(), _MedplumClient_requestCache = new WeakMap(), _MedplumClient_baseUrl = new WeakMap(), _MedplumClient_clientId = new WeakMap(), _MedplumClient_authorizeUrl = new WeakMap(), _MedplumClient_tokenUrl = new WeakMap(), _MedplumClient_logoutUrl = new WeakMap(), _MedplumClient_onUnauthenticated = new WeakMap(), _MedplumClient_accessToken = new WeakMap(), _MedplumClient_refreshToken = new WeakMap(), _MedplumClient_refreshPromise = new WeakMap(), _MedplumClient_profilePromise = new WeakMap(), _MedplumClient_profile = new WeakMap(), _MedplumClient_config = new WeakMap(), _MedplumClient_instances = new WeakSet(), _MedplumClient_addLogin = function _MedplumClient_addLogin(newLogin) {
|
|
2031
2233
|
const logins = this.getLogins().filter((login) => { var _a, _b; return ((_a = login.profile) === null || _a === void 0 ? void 0 : _a.reference) !== ((_b = newLogin.profile) === null || _b === void 0 ? void 0 : _b.reference); });
|
|
2032
2234
|
logins.push(newLogin);
|
|
2033
2235
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
|
|
@@ -2066,7 +2268,7 @@
|
|
|
2066
2268
|
return undefined;
|
|
2067
2269
|
}
|
|
2068
2270
|
const obj = yield response.json();
|
|
2069
|
-
if (obj.resourceType === 'OperationOutcome' && !isOk(obj)) {
|
|
2271
|
+
if ((obj === null || obj === void 0 ? void 0 : obj.resourceType) === 'OperationOutcome' && !isOk(obj)) {
|
|
2070
2272
|
return Promise.reject(obj);
|
|
2071
2273
|
}
|
|
2072
2274
|
return obj;
|
|
@@ -2221,208 +2423,112 @@
|
|
|
2221
2423
|
return window.location.protocol + '//' + window.location.host + '/';
|
|
2222
2424
|
}
|
|
2223
2425
|
|
|
2224
|
-
|
|
2426
|
+
const SEGMENT_SEPARATOR = '\r';
|
|
2427
|
+
const FIELD_SEPARATOR = '|';
|
|
2428
|
+
const COMPONENT_SEPARATOR = '^';
|
|
2225
2429
|
/**
|
|
2226
|
-
* The
|
|
2227
|
-
*
|
|
2228
|
-
*
|
|
2229
|
-
* @deprecated
|
|
2430
|
+
* The Hl7Message class represents one HL7 message.
|
|
2431
|
+
* A message is a collection of segments.
|
|
2432
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2230
2433
|
*/
|
|
2231
|
-
class
|
|
2232
|
-
constructor(
|
|
2233
|
-
|
|
2234
|
-
__classPrivateFieldSet(this, _LegacyRepositoryClient_client, client, "f");
|
|
2434
|
+
class Hl7Message {
|
|
2435
|
+
constructor(segments) {
|
|
2436
|
+
this.segments = segments;
|
|
2235
2437
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
return
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2438
|
+
get(index) {
|
|
2439
|
+
if (typeof index === 'number') {
|
|
2440
|
+
return this.segments[index];
|
|
2441
|
+
}
|
|
2442
|
+
return this.segments.find((s) => s.name === index);
|
|
2443
|
+
}
|
|
2444
|
+
getAll(name) {
|
|
2445
|
+
return this.segments.filter((s) => s.name === name);
|
|
2446
|
+
}
|
|
2447
|
+
toString() {
|
|
2448
|
+
return this.segments.map((s) => s.toString()).join(SEGMENT_SEPARATOR);
|
|
2449
|
+
}
|
|
2450
|
+
buildAck() {
|
|
2451
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2452
|
+
const now = new Date();
|
|
2453
|
+
const msh = this.get('MSH');
|
|
2454
|
+
const sendingApp = ((_a = msh === null || msh === void 0 ? void 0 : msh.get(2)) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
2455
|
+
const sendingFacility = ((_b = msh === null || msh === void 0 ? void 0 : msh.get(3)) === null || _b === void 0 ? void 0 : _b.toString()) || '';
|
|
2456
|
+
const receivingApp = ((_c = msh === null || msh === void 0 ? void 0 : msh.get(4)) === null || _c === void 0 ? void 0 : _c.toString()) || '';
|
|
2457
|
+
const receivingFacility = ((_d = msh === null || msh === void 0 ? void 0 : msh.get(5)) === null || _d === void 0 ? void 0 : _d.toString()) || '';
|
|
2458
|
+
const controlId = ((_e = msh === null || msh === void 0 ? void 0 : msh.get(9)) === null || _e === void 0 ? void 0 : _e.toString()) || '';
|
|
2459
|
+
const versionId = ((_f = msh === null || msh === void 0 ? void 0 : msh.get(12)) === null || _f === void 0 ? void 0 : _f.toString()) || '2.5.1';
|
|
2460
|
+
return new Hl7Message([
|
|
2461
|
+
new Hl7Segment([
|
|
2462
|
+
'MSH',
|
|
2463
|
+
'^~\\&',
|
|
2464
|
+
receivingApp,
|
|
2465
|
+
receivingFacility,
|
|
2466
|
+
sendingApp,
|
|
2467
|
+
sendingFacility,
|
|
2468
|
+
now.toISOString(),
|
|
2469
|
+
'',
|
|
2470
|
+
'ACK',
|
|
2471
|
+
now.getTime().toString(),
|
|
2472
|
+
'P',
|
|
2473
|
+
versionId,
|
|
2474
|
+
]),
|
|
2475
|
+
new Hl7Segment(['MSA', 'AA', controlId, 'OK']),
|
|
2476
|
+
]);
|
|
2477
|
+
}
|
|
2478
|
+
static parse(text) {
|
|
2479
|
+
if (!text.startsWith('MSH|^~\\&')) {
|
|
2480
|
+
const err = new Error('Invalid HL7 message');
|
|
2481
|
+
err.type = 'entity.parse.failed';
|
|
2482
|
+
throw err;
|
|
2483
|
+
}
|
|
2484
|
+
return new Hl7Message(text.split(/[\r\n]+/).map((line) => Hl7Segment.parse(line)));
|
|
2255
2485
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
catch (error) {
|
|
2273
|
-
return [error, undefined];
|
|
2274
|
-
}
|
|
2275
|
-
});
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* The Hl7Segment class represents one HL7 segment.
|
|
2489
|
+
* A segment is a collection of fields.
|
|
2490
|
+
* The name field is the first field.
|
|
2491
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2492
|
+
*/
|
|
2493
|
+
class Hl7Segment {
|
|
2494
|
+
constructor(fields) {
|
|
2495
|
+
if (isStringArray(fields)) {
|
|
2496
|
+
this.fields = fields.map((f) => Hl7Field.parse(f));
|
|
2497
|
+
}
|
|
2498
|
+
else {
|
|
2499
|
+
this.fields = fields;
|
|
2500
|
+
}
|
|
2501
|
+
this.name = this.fields[0].components[0];
|
|
2276
2502
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
*
|
|
2280
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2281
|
-
*
|
|
2282
|
-
* @param reference The FHIR reference.
|
|
2283
|
-
* @returns Operation outcome and a resource.
|
|
2284
|
-
* @deprecated
|
|
2285
|
-
*/
|
|
2286
|
-
readReference(reference) {
|
|
2287
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2288
|
-
try {
|
|
2289
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readReference(reference);
|
|
2290
|
-
return [allOk, resource];
|
|
2291
|
-
}
|
|
2292
|
-
catch (error) {
|
|
2293
|
-
return [error, undefined];
|
|
2294
|
-
}
|
|
2295
|
-
});
|
|
2503
|
+
get(index) {
|
|
2504
|
+
return this.fields[index];
|
|
2296
2505
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
*
|
|
2300
|
-
* See: https://www.hl7.org/fhir/http.html#history
|
|
2301
|
-
*
|
|
2302
|
-
* @param resourceType The FHIR resource type.
|
|
2303
|
-
* @param id The FHIR resource ID.
|
|
2304
|
-
* @returns Operation outcome and a history bundle.
|
|
2305
|
-
* @deprecated
|
|
2306
|
-
*/
|
|
2307
|
-
readHistory(resourceType, id) {
|
|
2308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2309
|
-
try {
|
|
2310
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readHistory(resourceType, id);
|
|
2311
|
-
return [allOk, resource];
|
|
2312
|
-
}
|
|
2313
|
-
catch (error) {
|
|
2314
|
-
return [error, undefined];
|
|
2315
|
-
}
|
|
2316
|
-
});
|
|
2506
|
+
toString() {
|
|
2507
|
+
return this.fields.map((f) => f.toString()).join(FIELD_SEPARATOR);
|
|
2317
2508
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
*
|
|
2321
|
-
* See: https://www.hl7.org/fhir/http.html#vread
|
|
2322
|
-
*
|
|
2323
|
-
* @param resourceType The FHIR resource type.
|
|
2324
|
-
* @param id The FHIR resource ID.
|
|
2325
|
-
* @param vid The version ID.
|
|
2326
|
-
* @returns Operation outcome and a resource.
|
|
2327
|
-
* @deprecated
|
|
2328
|
-
*/
|
|
2329
|
-
readVersion(resourceType, id, vid) {
|
|
2330
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2331
|
-
try {
|
|
2332
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readVersion(resourceType, id, vid);
|
|
2333
|
-
return [allOk, resource];
|
|
2334
|
-
}
|
|
2335
|
-
catch (error) {
|
|
2336
|
-
return [error, undefined];
|
|
2337
|
-
}
|
|
2338
|
-
});
|
|
2509
|
+
static parse(text) {
|
|
2510
|
+
return new Hl7Segment(text.split(FIELD_SEPARATOR).map((f) => Hl7Field.parse(f)));
|
|
2339
2511
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
updateResource(resource) {
|
|
2350
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2351
|
-
try {
|
|
2352
|
-
const updated = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").updateResource(resource);
|
|
2353
|
-
return [allOk, updated];
|
|
2354
|
-
}
|
|
2355
|
-
catch (error) {
|
|
2356
|
-
return [error, undefined];
|
|
2357
|
-
}
|
|
2358
|
-
});
|
|
2512
|
+
}
|
|
2513
|
+
/**
|
|
2514
|
+
* The Hl7Field class represents one HL7 field.
|
|
2515
|
+
* A field is a collection of components.
|
|
2516
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2517
|
+
*/
|
|
2518
|
+
class Hl7Field {
|
|
2519
|
+
constructor(components) {
|
|
2520
|
+
this.components = components;
|
|
2359
2521
|
}
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
*
|
|
2363
|
-
* See: https://www.hl7.org/fhir/http.html#delete
|
|
2364
|
-
*
|
|
2365
|
-
* @param resourceType The FHIR resource type.
|
|
2366
|
-
* @param id The resource ID.
|
|
2367
|
-
* @returns Operation outcome.
|
|
2368
|
-
* @deprecated
|
|
2369
|
-
*/
|
|
2370
|
-
deleteResource(resourceType, id) {
|
|
2371
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2372
|
-
try {
|
|
2373
|
-
yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").deleteResource(resourceType, id);
|
|
2374
|
-
return [allOk, undefined];
|
|
2375
|
-
}
|
|
2376
|
-
catch (error) {
|
|
2377
|
-
return [error, undefined];
|
|
2378
|
-
}
|
|
2379
|
-
});
|
|
2522
|
+
get(index) {
|
|
2523
|
+
return this.components[index];
|
|
2380
2524
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
*
|
|
2384
|
-
* See: https://www.hl7.org/fhir/http.html#patch
|
|
2385
|
-
*
|
|
2386
|
-
* @param resourceType The FHIR resource type.
|
|
2387
|
-
* @param id The resource ID.
|
|
2388
|
-
* @param patch Array of JSONPatch operations.
|
|
2389
|
-
* @returns Operation outcome and the resource.
|
|
2390
|
-
* @deprecated
|
|
2391
|
-
*/
|
|
2392
|
-
patchResource(resourceType, id, patch) {
|
|
2393
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2394
|
-
try {
|
|
2395
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").patchResource(resourceType, id, patch);
|
|
2396
|
-
return [allOk, resource];
|
|
2397
|
-
}
|
|
2398
|
-
catch (error) {
|
|
2399
|
-
return [error, undefined];
|
|
2400
|
-
}
|
|
2401
|
-
});
|
|
2525
|
+
toString() {
|
|
2526
|
+
return this.components.join(COMPONENT_SEPARATOR);
|
|
2402
2527
|
}
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
*
|
|
2406
|
-
* See: https://www.hl7.org/fhir/http.html#search
|
|
2407
|
-
*
|
|
2408
|
-
* @param searchRequest The search request.
|
|
2409
|
-
* @returns The search result bundle.
|
|
2410
|
-
* @deprecated
|
|
2411
|
-
*/
|
|
2412
|
-
search(query) {
|
|
2413
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2414
|
-
const searchRequest = typeof query === 'string' ? parseSearchDefinition(query) : query;
|
|
2415
|
-
try {
|
|
2416
|
-
const bundle = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").search(searchRequest);
|
|
2417
|
-
return [allOk, bundle];
|
|
2418
|
-
}
|
|
2419
|
-
catch (error) {
|
|
2420
|
-
return [error, undefined];
|
|
2421
|
-
}
|
|
2422
|
-
});
|
|
2528
|
+
static parse(text) {
|
|
2529
|
+
return new Hl7Field(text.split(COMPONENT_SEPARATOR));
|
|
2423
2530
|
}
|
|
2424
|
-
}
|
|
2425
|
-
_LegacyRepositoryClient_client = new WeakMap();
|
|
2531
|
+
}
|
|
2426
2532
|
|
|
2427
2533
|
exports.SearchParameterType = void 0;
|
|
2428
2534
|
(function (SearchParameterType) {
|
|
@@ -2550,9 +2656,17 @@
|
|
|
2550
2656
|
return result;
|
|
2551
2657
|
}
|
|
2552
2658
|
|
|
2553
|
-
exports.
|
|
2659
|
+
exports.COMPONENT_SEPARATOR = COMPONENT_SEPARATOR;
|
|
2660
|
+
exports.DEFAULT_SEARCH_COUNT = DEFAULT_SEARCH_COUNT;
|
|
2661
|
+
exports.FIELD_SEPARATOR = FIELD_SEPARATOR;
|
|
2662
|
+
exports.Hl7Field = Hl7Field;
|
|
2663
|
+
exports.Hl7Message = Hl7Message;
|
|
2664
|
+
exports.Hl7Segment = Hl7Segment;
|
|
2665
|
+
exports.LRUCache = LRUCache;
|
|
2554
2666
|
exports.MedplumClient = MedplumClient;
|
|
2555
2667
|
exports.OperationOutcomeError = OperationOutcomeError;
|
|
2668
|
+
exports.ReadablePromise = ReadablePromise;
|
|
2669
|
+
exports.SEGMENT_SEPARATOR = SEGMENT_SEPARATOR;
|
|
2556
2670
|
exports.accessDenied = accessDenied;
|
|
2557
2671
|
exports.allOk = allOk;
|
|
2558
2672
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
@@ -2576,8 +2690,10 @@
|
|
|
2576
2690
|
exports.getDateProperty = getDateProperty;
|
|
2577
2691
|
exports.getDisplayString = getDisplayString;
|
|
2578
2692
|
exports.getExpressionForResourceType = getExpressionForResourceType;
|
|
2693
|
+
exports.getExtensionValue = getExtensionValue;
|
|
2579
2694
|
exports.getImageSrc = getImageSrc;
|
|
2580
2695
|
exports.getPropertyDisplayName = getPropertyDisplayName;
|
|
2696
|
+
exports.getQuestionnaireAnswers = getQuestionnaireAnswers;
|
|
2581
2697
|
exports.getReferenceString = getReferenceString;
|
|
2582
2698
|
exports.getSearchParameterDetails = getSearchParameterDetails;
|
|
2583
2699
|
exports.getStatus = getStatus;
|
|
@@ -2587,8 +2703,11 @@
|
|
|
2587
2703
|
exports.isGone = isGone;
|
|
2588
2704
|
exports.isLowerCase = isLowerCase;
|
|
2589
2705
|
exports.isNotFound = isNotFound;
|
|
2706
|
+
exports.isObject = isObject;
|
|
2590
2707
|
exports.isOk = isOk;
|
|
2591
2708
|
exports.isProfileResource = isProfileResource;
|
|
2709
|
+
exports.isStringArray = isStringArray;
|
|
2710
|
+
exports.isUUID = isUUID;
|
|
2592
2711
|
exports.notFound = notFound;
|
|
2593
2712
|
exports.notModified = notModified;
|
|
2594
2713
|
exports.parseSearchDefinition = parseSearchDefinition;
|