@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/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -69,6 +69,9 @@ class LRUCache {
|
|
|
69
69
|
}
|
|
70
70
|
__classPrivateFieldGet(this, _LRUCache_cache, "f").set(key, val);
|
|
71
71
|
}
|
|
72
|
+
delete(key) {
|
|
73
|
+
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
_LRUCache_max = new WeakMap(), _LRUCache_cache = new WeakMap(), _LRUCache_instances = new WeakSet(), _LRUCache_first = function _LRUCache_first() {
|
|
74
77
|
// This works because the Map class maintains ordered keys.
|
|
@@ -309,6 +312,47 @@ function calculateAgeString(birthDateStr, endDateStr) {
|
|
|
309
312
|
return days.toString().padStart(3, '0') + 'D';
|
|
310
313
|
}
|
|
311
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns all questionnaire answers as a map by link ID.
|
|
317
|
+
* @param response The questionnaire response resource.
|
|
318
|
+
* @returns Questionnaire answers mapped by link ID.
|
|
319
|
+
*/
|
|
320
|
+
function getQuestionnaireAnswers(response) {
|
|
321
|
+
const result = {};
|
|
322
|
+
buildQuestionnaireAnswerItems(response.item, result);
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Recursively builds the questionnaire answer items map.
|
|
327
|
+
* @param item The current questionnaire response item.
|
|
328
|
+
* @param result The cumulative result map.
|
|
329
|
+
*/
|
|
330
|
+
function buildQuestionnaireAnswerItems(items, result) {
|
|
331
|
+
if (items) {
|
|
332
|
+
for (const item of items) {
|
|
333
|
+
if (item.linkId && item.answer && item.answer.length > 0) {
|
|
334
|
+
result[item.linkId] = item.answer[0];
|
|
335
|
+
}
|
|
336
|
+
buildQuestionnaireAnswerItems(item.item, result);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Returns an extension value by extension URLs.
|
|
342
|
+
* @param resource The base resource.
|
|
343
|
+
* @param urls Array of extension URLs. Each entry represents a nested extension.
|
|
344
|
+
* @returns The extension value if found; undefined otherwise.
|
|
345
|
+
*/
|
|
346
|
+
function getExtensionValue(resource, ...urls) {
|
|
347
|
+
var _a;
|
|
348
|
+
// Let curr be the current resource or extension. Extensions can be nested.
|
|
349
|
+
let curr = resource;
|
|
350
|
+
// For each of the urls, try to find a matching nested extension.
|
|
351
|
+
for (let i = 0; i < urls.length && curr; i++) {
|
|
352
|
+
curr = (_a = curr === null || curr === void 0 ? void 0 : curr.extension) === null || _a === void 0 ? void 0 : _a.find((e) => e.url === urls[i]);
|
|
353
|
+
}
|
|
354
|
+
return curr === null || curr === void 0 ? void 0 : curr.valueString;
|
|
355
|
+
}
|
|
312
356
|
/**
|
|
313
357
|
* FHIR JSON stringify.
|
|
314
358
|
* Removes properties with empty string values.
|
|
@@ -354,39 +398,86 @@ function isEmpty(v) {
|
|
|
354
398
|
/**
|
|
355
399
|
* Resource equality.
|
|
356
400
|
* Ignores meta.versionId and meta.lastUpdated.
|
|
357
|
-
* See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality
|
|
358
401
|
* @param object1 The first object.
|
|
359
402
|
* @param object2 The second object.
|
|
360
403
|
* @returns True if the objects are equal.
|
|
361
404
|
*/
|
|
362
405
|
function deepEquals(object1, object2, path) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
406
|
+
if (object1 === object2) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
if (isEmpty(object1) && isEmpty(object2)) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
if (isEmpty(object1) || isEmpty(object2)) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
if (Array.isArray(object1) && Array.isArray(object2)) {
|
|
416
|
+
return deepEqualsArray(object1, object2);
|
|
417
|
+
}
|
|
418
|
+
if (Array.isArray(object1) || Array.isArray(object2)) {
|
|
419
|
+
return false;
|
|
368
420
|
}
|
|
369
|
-
if (
|
|
421
|
+
if (isObject(object1) && isObject(object2)) {
|
|
422
|
+
return deepEqualsObject(object1, object2, path);
|
|
423
|
+
}
|
|
424
|
+
if (isObject(object1) || isObject(object2)) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
function deepEqualsArray(array1, array2) {
|
|
430
|
+
if (array1.length !== array2.length) {
|
|
370
431
|
return false;
|
|
371
432
|
}
|
|
372
|
-
for (
|
|
433
|
+
for (let i = 0; i < array1.length; i++) {
|
|
434
|
+
if (!deepEquals(array1[i], array2[i])) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
function deepEqualsObject(object1, object2, path) {
|
|
441
|
+
const keySet = new Set();
|
|
442
|
+
Object.keys(object1).forEach((k) => keySet.add(k));
|
|
443
|
+
Object.keys(object2).forEach((k) => keySet.add(k));
|
|
444
|
+
if (path === 'meta') {
|
|
445
|
+
keySet.delete('versionId');
|
|
446
|
+
keySet.delete('lastUpdated');
|
|
447
|
+
keySet.delete('author');
|
|
448
|
+
}
|
|
449
|
+
for (const key of keySet) {
|
|
373
450
|
const val1 = object1[key];
|
|
374
451
|
const val2 = object2[key];
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
if (val1 !== val2) {
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
452
|
+
if (!deepEquals(val1, val2, key)) {
|
|
453
|
+
return false;
|
|
384
454
|
}
|
|
385
455
|
}
|
|
386
456
|
return true;
|
|
387
457
|
}
|
|
388
|
-
|
|
389
|
-
|
|
458
|
+
/**
|
|
459
|
+
* Returns true if the input string is a UUID.
|
|
460
|
+
* @param input The input string.
|
|
461
|
+
* @returns True if the input string matches the UUID format.
|
|
462
|
+
*/
|
|
463
|
+
function isUUID(input) {
|
|
464
|
+
return !!input.match(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Returns true if the input is an object.
|
|
468
|
+
* @param object The candidate object.
|
|
469
|
+
* @returns True if the input is a non-null non-undefined object.
|
|
470
|
+
*/
|
|
471
|
+
function isObject(obj) {
|
|
472
|
+
return obj !== null && typeof obj === 'object';
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Returns true if the input array is an array of strings.
|
|
476
|
+
* @param arr Input array.
|
|
477
|
+
* @returns True if the input array is an array of strings.
|
|
478
|
+
*/
|
|
479
|
+
function isStringArray(arr) {
|
|
480
|
+
return arr.every((e) => typeof e === 'string');
|
|
390
481
|
}
|
|
391
482
|
// Precompute hex octets
|
|
392
483
|
// See: https://stackoverflow.com/a/55200387
|
|
@@ -422,7 +513,7 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
422
513
|
return window.btoa(result.join(''));
|
|
423
514
|
}
|
|
424
515
|
function capitalize(word) {
|
|
425
|
-
return word.charAt(0).toUpperCase() + word.
|
|
516
|
+
return word.charAt(0).toUpperCase() + word.substring(1);
|
|
426
517
|
}
|
|
427
518
|
function isLowerCase(c) {
|
|
428
519
|
return c === c.toLowerCase();
|
|
@@ -665,6 +756,83 @@ class OperationOutcomeError extends Error {
|
|
|
665
756
|
}
|
|
666
757
|
}
|
|
667
758
|
|
|
759
|
+
var _ReadablePromise_suspender, _ReadablePromise_status, _ReadablePromise_response, _ReadablePromise_error, _a;
|
|
760
|
+
/**
|
|
761
|
+
* The ReadablePromise class wraps a request promise suitable for React Suspense.
|
|
762
|
+
* See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js
|
|
763
|
+
* See: https://github.com/ovieokeh/suspense-data-fetching/blob/master/lib/api/wrapPromise.js
|
|
764
|
+
*/
|
|
765
|
+
class ReadablePromise {
|
|
766
|
+
constructor(requestPromise) {
|
|
767
|
+
this[_a] = 'ReadablePromise';
|
|
768
|
+
_ReadablePromise_suspender.set(this, void 0);
|
|
769
|
+
_ReadablePromise_status.set(this, 'pending');
|
|
770
|
+
_ReadablePromise_response.set(this, void 0);
|
|
771
|
+
_ReadablePromise_error.set(this, void 0);
|
|
772
|
+
__classPrivateFieldSet(this, _ReadablePromise_suspender, requestPromise.then((res) => {
|
|
773
|
+
__classPrivateFieldSet(this, _ReadablePromise_status, 'success', "f");
|
|
774
|
+
__classPrivateFieldSet(this, _ReadablePromise_response, res, "f");
|
|
775
|
+
return res;
|
|
776
|
+
}, (err) => {
|
|
777
|
+
__classPrivateFieldSet(this, _ReadablePromise_status, 'error', "f");
|
|
778
|
+
__classPrivateFieldSet(this, _ReadablePromise_error, err, "f");
|
|
779
|
+
throw err;
|
|
780
|
+
}), "f");
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Returns true if the promise is pending.
|
|
784
|
+
* @returns True if the Promise is pending.
|
|
785
|
+
*/
|
|
786
|
+
isPending() {
|
|
787
|
+
return __classPrivateFieldGet(this, _ReadablePromise_status, "f") === 'pending';
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Attempts to read the value of the promise.
|
|
791
|
+
* If the promise is pending, this method will throw a promise.
|
|
792
|
+
* If the promise rejected, this method will throw the rejection reason.
|
|
793
|
+
* If the promise resolved, this method will return the resolved value.
|
|
794
|
+
* @returns The resolved value of the Promise.
|
|
795
|
+
*/
|
|
796
|
+
read() {
|
|
797
|
+
switch (__classPrivateFieldGet(this, _ReadablePromise_status, "f")) {
|
|
798
|
+
case 'pending':
|
|
799
|
+
throw __classPrivateFieldGet(this, _ReadablePromise_suspender, "f");
|
|
800
|
+
case 'error':
|
|
801
|
+
throw __classPrivateFieldGet(this, _ReadablePromise_error, "f");
|
|
802
|
+
default:
|
|
803
|
+
return __classPrivateFieldGet(this, _ReadablePromise_response, "f");
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
808
|
+
* @param onfulfilled The callback to execute when the Promise is resolved.
|
|
809
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
810
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
811
|
+
*/
|
|
812
|
+
then(onfulfilled, onrejected) {
|
|
813
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").then(onfulfilled, onrejected);
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
817
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
818
|
+
* @returns A Promise for the completion of the callback.
|
|
819
|
+
*/
|
|
820
|
+
catch(onrejected) {
|
|
821
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").catch(onrejected);
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
825
|
+
* resolved value cannot be modified from the callback.
|
|
826
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
827
|
+
* @returns A Promise for the completion of the callback.
|
|
828
|
+
*/
|
|
829
|
+
finally(onfinally) {
|
|
830
|
+
return __classPrivateFieldGet(this, _ReadablePromise_suspender, "f").finally(onfinally);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
_ReadablePromise_suspender = new WeakMap(), _ReadablePromise_status = new WeakMap(), _ReadablePromise_response = new WeakMap(), _ReadablePromise_error = new WeakMap(), _a = Symbol.toStringTag;
|
|
834
|
+
|
|
835
|
+
const DEFAULT_SEARCH_COUNT = 20;
|
|
668
836
|
/**
|
|
669
837
|
* Search operators.
|
|
670
838
|
* These operators represent "modifiers" and "prefixes" in FHIR search.
|
|
@@ -732,15 +900,15 @@ function parseSearchDefinition(url) {
|
|
|
732
900
|
let filters = undefined;
|
|
733
901
|
let sortRules = undefined;
|
|
734
902
|
let fields = undefined;
|
|
735
|
-
let
|
|
903
|
+
let offset = undefined;
|
|
736
904
|
let count = undefined;
|
|
737
905
|
let total = undefined;
|
|
738
906
|
params.forEach((value, key) => {
|
|
739
907
|
if (key === '_fields') {
|
|
740
908
|
fields = value.split(',');
|
|
741
909
|
}
|
|
742
|
-
else if (key === '
|
|
743
|
-
|
|
910
|
+
else if (key === '_offset') {
|
|
911
|
+
offset = parseInt(value);
|
|
744
912
|
}
|
|
745
913
|
else if (key === '_count') {
|
|
746
914
|
count = parseInt(value);
|
|
@@ -761,7 +929,7 @@ function parseSearchDefinition(url) {
|
|
|
761
929
|
resourceType,
|
|
762
930
|
filters,
|
|
763
931
|
fields,
|
|
764
|
-
|
|
932
|
+
offset,
|
|
765
933
|
count,
|
|
766
934
|
total,
|
|
767
935
|
sortRules,
|
|
@@ -837,13 +1005,13 @@ function formatSearchQuery(definition) {
|
|
|
837
1005
|
if (definition.sortRules && definition.sortRules.length > 0) {
|
|
838
1006
|
params.push(formatSortRules(definition.sortRules));
|
|
839
1007
|
}
|
|
840
|
-
if (definition.
|
|
841
|
-
params.push('
|
|
1008
|
+
if (definition.offset !== undefined) {
|
|
1009
|
+
params.push('_offset=' + definition.offset);
|
|
842
1010
|
}
|
|
843
|
-
if (definition.count
|
|
1011
|
+
if (definition.count !== undefined) {
|
|
844
1012
|
params.push('_count=' + definition.count);
|
|
845
1013
|
}
|
|
846
|
-
if (definition.total) {
|
|
1014
|
+
if (definition.total !== undefined) {
|
|
847
1015
|
params.push('_total=' + encodeURIComponent(definition.total));
|
|
848
1016
|
}
|
|
849
1017
|
if (params.length === 0) {
|
|
@@ -1152,7 +1320,7 @@ function getPropertyDisplayName(property) {
|
|
|
1152
1320
|
|
|
1153
1321
|
// PKCE auth ased on:
|
|
1154
1322
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
1155
|
-
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_storage, _MedplumClient_schema,
|
|
1323
|
+
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;
|
|
1156
1324
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
1157
1325
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
1158
1326
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
@@ -1215,7 +1383,7 @@ class MedplumClient extends EventTarget {
|
|
|
1215
1383
|
_MedplumClient_fetch.set(this, void 0);
|
|
1216
1384
|
_MedplumClient_storage.set(this, void 0);
|
|
1217
1385
|
_MedplumClient_schema.set(this, void 0);
|
|
1218
|
-
|
|
1386
|
+
_MedplumClient_requestCache.set(this, void 0);
|
|
1219
1387
|
_MedplumClient_baseUrl.set(this, void 0);
|
|
1220
1388
|
_MedplumClient_clientId.set(this, void 0);
|
|
1221
1389
|
_MedplumClient_authorizeUrl.set(this, void 0);
|
|
@@ -1239,7 +1407,7 @@ class MedplumClient extends EventTarget {
|
|
|
1239
1407
|
__classPrivateFieldSet(this, _MedplumClient_fetch, (options === null || options === void 0 ? void 0 : options.fetch) || window.fetch.bind(window), "f");
|
|
1240
1408
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
1241
1409
|
__classPrivateFieldSet(this, _MedplumClient_schema, createSchema(), "f");
|
|
1242
|
-
__classPrivateFieldSet(this,
|
|
1410
|
+
__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");
|
|
1243
1411
|
__classPrivateFieldSet(this, _MedplumClient_baseUrl, (options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
1244
1412
|
__classPrivateFieldSet(this, _MedplumClient_clientId, (options === null || options === void 0 ? void 0 : options.clientId) || '', "f");
|
|
1245
1413
|
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, (options === null || options === void 0 ? void 0 : options.authorizeUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
@@ -1259,7 +1427,7 @@ class MedplumClient extends EventTarget {
|
|
|
1259
1427
|
*/
|
|
1260
1428
|
clear() {
|
|
1261
1429
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").clear();
|
|
1262
|
-
__classPrivateFieldGet(this,
|
|
1430
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1263
1431
|
__classPrivateFieldSet(this, _MedplumClient_accessToken, undefined, "f");
|
|
1264
1432
|
__classPrivateFieldSet(this, _MedplumClient_refreshToken, undefined, "f");
|
|
1265
1433
|
__classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
|
|
@@ -1278,7 +1446,15 @@ class MedplumClient extends EventTarget {
|
|
|
1278
1446
|
* @returns Promise to the response content.
|
|
1279
1447
|
*/
|
|
1280
1448
|
get(url, options = {}) {
|
|
1281
|
-
|
|
1449
|
+
if (!(options === null || options === void 0 ? void 0 : options.cache)) {
|
|
1450
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(url);
|
|
1451
|
+
if (cached) {
|
|
1452
|
+
return cached;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
const promise = new ReadablePromise(__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'GET', url, options));
|
|
1456
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").set(url, promise);
|
|
1457
|
+
return promise;
|
|
1282
1458
|
}
|
|
1283
1459
|
/**
|
|
1284
1460
|
* Makes an HTTP POST request to the specified URL.
|
|
@@ -1300,6 +1476,7 @@ class MedplumClient extends EventTarget {
|
|
|
1300
1476
|
if (contentType) {
|
|
1301
1477
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1302
1478
|
}
|
|
1479
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1303
1480
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'POST', url, options);
|
|
1304
1481
|
}
|
|
1305
1482
|
/**
|
|
@@ -1322,6 +1499,7 @@ class MedplumClient extends EventTarget {
|
|
|
1322
1499
|
if (contentType) {
|
|
1323
1500
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1324
1501
|
}
|
|
1502
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1325
1503
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PUT', url, options);
|
|
1326
1504
|
}
|
|
1327
1505
|
/**
|
|
@@ -1339,6 +1517,7 @@ class MedplumClient extends EventTarget {
|
|
|
1339
1517
|
patch(url, operations, options = {}) {
|
|
1340
1518
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestBody).call(this, options, operations);
|
|
1341
1519
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, PATCH_CONTENT_TYPE);
|
|
1520
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1342
1521
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PATCH', url, options);
|
|
1343
1522
|
}
|
|
1344
1523
|
/**
|
|
@@ -1353,6 +1532,7 @@ class MedplumClient extends EventTarget {
|
|
|
1353
1532
|
* @returns Promise to the response content.
|
|
1354
1533
|
*/
|
|
1355
1534
|
delete(url, options = {}) {
|
|
1535
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1356
1536
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'DELETE', url, options);
|
|
1357
1537
|
}
|
|
1358
1538
|
/**
|
|
@@ -1572,11 +1752,8 @@ class MedplumClient extends EventTarget {
|
|
|
1572
1752
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1573
1753
|
*/
|
|
1574
1754
|
getCached(resourceType, id) {
|
|
1575
|
-
const cached = __classPrivateFieldGet(this,
|
|
1576
|
-
|
|
1577
|
-
return cached;
|
|
1578
|
-
}
|
|
1579
|
-
return undefined;
|
|
1755
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id));
|
|
1756
|
+
return cached && !cached.isPending() ? cached.read() : undefined;
|
|
1580
1757
|
}
|
|
1581
1758
|
/**
|
|
1582
1759
|
* Returns a cached resource if it is available.
|
|
@@ -1585,11 +1762,9 @@ class MedplumClient extends EventTarget {
|
|
|
1585
1762
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1586
1763
|
*/
|
|
1587
1764
|
getCachedReference(reference) {
|
|
1588
|
-
const
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
}
|
|
1592
|
-
return undefined;
|
|
1765
|
+
const refString = reference.reference;
|
|
1766
|
+
const [resourceType, id] = refString.split('/');
|
|
1767
|
+
return this.getCached(resourceType, id);
|
|
1593
1768
|
}
|
|
1594
1769
|
/**
|
|
1595
1770
|
* Reads a resource by resource type and ID.
|
|
@@ -1608,13 +1783,7 @@ class MedplumClient extends EventTarget {
|
|
|
1608
1783
|
* @returns The resource if available; undefined otherwise.
|
|
1609
1784
|
*/
|
|
1610
1785
|
readResource(resourceType, id) {
|
|
1611
|
-
|
|
1612
|
-
const promise = this.get(this.fhirUrl(resourceType, id)).then((resource) => {
|
|
1613
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, resource);
|
|
1614
|
-
return resource;
|
|
1615
|
-
});
|
|
1616
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, promise);
|
|
1617
|
-
return promise;
|
|
1786
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1618
1787
|
}
|
|
1619
1788
|
/**
|
|
1620
1789
|
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
@@ -1635,8 +1804,7 @@ class MedplumClient extends EventTarget {
|
|
|
1635
1804
|
* @returns The resource if available; undefined otherwise.
|
|
1636
1805
|
*/
|
|
1637
1806
|
readCached(resourceType, id) {
|
|
1638
|
-
|
|
1639
|
-
return cached ? Promise.resolve(cached) : this.readResource(resourceType, id);
|
|
1807
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1640
1808
|
}
|
|
1641
1809
|
/**
|
|
1642
1810
|
* Reads a resource by `Reference`.
|
|
@@ -1659,7 +1827,7 @@ class MedplumClient extends EventTarget {
|
|
|
1659
1827
|
readReference(reference) {
|
|
1660
1828
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1661
1829
|
if (!refString) {
|
|
1662
|
-
return Promise.reject('Missing reference');
|
|
1830
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1663
1831
|
}
|
|
1664
1832
|
const [resourceType, id] = refString.split('/');
|
|
1665
1833
|
return this.readResource(resourceType, id);
|
|
@@ -1687,7 +1855,7 @@ class MedplumClient extends EventTarget {
|
|
|
1687
1855
|
readCachedReference(reference) {
|
|
1688
1856
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1689
1857
|
if (!refString) {
|
|
1690
|
-
return Promise.reject('Missing reference');
|
|
1858
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1691
1859
|
}
|
|
1692
1860
|
const [resourceType, id] = refString.split('/');
|
|
1693
1861
|
return this.readCached(resourceType, id);
|
|
@@ -1842,11 +2010,45 @@ class MedplumClient extends EventTarget {
|
|
|
1842
2010
|
*
|
|
1843
2011
|
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
1844
2012
|
*
|
|
1845
|
-
* @param
|
|
2013
|
+
* @param data The binary data to upload.
|
|
2014
|
+
* @param filename Optional filename for the binary.
|
|
2015
|
+
* @param contentType Content type for the binary.
|
|
1846
2016
|
* @returns The result of the create operation.
|
|
1847
2017
|
*/
|
|
1848
2018
|
createBinary(data, filename, contentType) {
|
|
1849
|
-
|
|
2019
|
+
let url = this.fhirUrl('Binary');
|
|
2020
|
+
if (filename) {
|
|
2021
|
+
url += '?_filename=' + encodeURIComponent(filename);
|
|
2022
|
+
}
|
|
2023
|
+
return this.post(url, data, contentType);
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
2027
|
+
*
|
|
2028
|
+
* The return value is the newly created resource, including the ID and meta.
|
|
2029
|
+
*
|
|
2030
|
+
* The `docDefinition` parameter is a pdfmake document definition.
|
|
2031
|
+
*
|
|
2032
|
+
* Example:
|
|
2033
|
+
*
|
|
2034
|
+
* ```typescript
|
|
2035
|
+
* const result = await medplum.createPdf({
|
|
2036
|
+
* content: ['Hello world']
|
|
2037
|
+
* });
|
|
2038
|
+
* console.log(result.id);
|
|
2039
|
+
* ```
|
|
2040
|
+
*
|
|
2041
|
+
* See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
|
|
2042
|
+
*
|
|
2043
|
+
* @param docDefinition The FHIR resource to create.
|
|
2044
|
+
* @returns The result of the create operation.
|
|
2045
|
+
*/
|
|
2046
|
+
createPdf(docDefinition, filename) {
|
|
2047
|
+
let url = this.fhirUrl('Binary') + '/$pdf';
|
|
2048
|
+
if (filename) {
|
|
2049
|
+
url += '?_filename=' + encodeURIComponent(filename);
|
|
2050
|
+
}
|
|
2051
|
+
return this.post(url, docDefinition, 'application/json');
|
|
1850
2052
|
}
|
|
1851
2053
|
/**
|
|
1852
2054
|
* Updates a FHIR resource.
|
|
@@ -1939,7 +2141,7 @@ class MedplumClient extends EventTarget {
|
|
|
1939
2141
|
__classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
|
|
1940
2142
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('activeLogin', login);
|
|
1941
2143
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addLogin).call(this, login);
|
|
1942
|
-
__classPrivateFieldGet(this,
|
|
2144
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1943
2145
|
__classPrivateFieldSet(this, _MedplumClient_refreshPromise, undefined, "f");
|
|
1944
2146
|
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
1945
2147
|
});
|
|
@@ -2021,7 +2223,7 @@ class MedplumClient extends EventTarget {
|
|
|
2021
2223
|
});
|
|
2022
2224
|
}
|
|
2023
2225
|
}
|
|
2024
|
-
_MedplumClient_fetch = new WeakMap(), _MedplumClient_storage = new WeakMap(), _MedplumClient_schema = new WeakMap(),
|
|
2226
|
+
_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) {
|
|
2025
2227
|
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); });
|
|
2026
2228
|
logins.push(newLogin);
|
|
2027
2229
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
|
|
@@ -2060,7 +2262,7 @@ _MedplumClient_fetch = new WeakMap(), _MedplumClient_storage = new WeakMap(), _M
|
|
|
2060
2262
|
return undefined;
|
|
2061
2263
|
}
|
|
2062
2264
|
const obj = yield response.json();
|
|
2063
|
-
if (obj.resourceType === 'OperationOutcome' && !isOk(obj)) {
|
|
2265
|
+
if ((obj === null || obj === void 0 ? void 0 : obj.resourceType) === 'OperationOutcome' && !isOk(obj)) {
|
|
2064
2266
|
return Promise.reject(obj);
|
|
2065
2267
|
}
|
|
2066
2268
|
return obj;
|
|
@@ -2215,208 +2417,112 @@ function getBaseUrl() {
|
|
|
2215
2417
|
return window.location.protocol + '//' + window.location.host + '/';
|
|
2216
2418
|
}
|
|
2217
2419
|
|
|
2218
|
-
|
|
2420
|
+
const SEGMENT_SEPARATOR = '\r';
|
|
2421
|
+
const FIELD_SEPARATOR = '|';
|
|
2422
|
+
const COMPONENT_SEPARATOR = '^';
|
|
2219
2423
|
/**
|
|
2220
|
-
* The
|
|
2221
|
-
*
|
|
2222
|
-
*
|
|
2223
|
-
* @deprecated
|
|
2424
|
+
* The Hl7Message class represents one HL7 message.
|
|
2425
|
+
* A message is a collection of segments.
|
|
2426
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2224
2427
|
*/
|
|
2225
|
-
class
|
|
2226
|
-
constructor(
|
|
2227
|
-
|
|
2228
|
-
__classPrivateFieldSet(this, _LegacyRepositoryClient_client, client, "f");
|
|
2428
|
+
class Hl7Message {
|
|
2429
|
+
constructor(segments) {
|
|
2430
|
+
this.segments = segments;
|
|
2229
2431
|
}
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
return
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2432
|
+
get(index) {
|
|
2433
|
+
if (typeof index === 'number') {
|
|
2434
|
+
return this.segments[index];
|
|
2435
|
+
}
|
|
2436
|
+
return this.segments.find((s) => s.name === index);
|
|
2437
|
+
}
|
|
2438
|
+
getAll(name) {
|
|
2439
|
+
return this.segments.filter((s) => s.name === name);
|
|
2440
|
+
}
|
|
2441
|
+
toString() {
|
|
2442
|
+
return this.segments.map((s) => s.toString()).join(SEGMENT_SEPARATOR);
|
|
2443
|
+
}
|
|
2444
|
+
buildAck() {
|
|
2445
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2446
|
+
const now = new Date();
|
|
2447
|
+
const msh = this.get('MSH');
|
|
2448
|
+
const sendingApp = ((_a = msh === null || msh === void 0 ? void 0 : msh.get(2)) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
2449
|
+
const sendingFacility = ((_b = msh === null || msh === void 0 ? void 0 : msh.get(3)) === null || _b === void 0 ? void 0 : _b.toString()) || '';
|
|
2450
|
+
const receivingApp = ((_c = msh === null || msh === void 0 ? void 0 : msh.get(4)) === null || _c === void 0 ? void 0 : _c.toString()) || '';
|
|
2451
|
+
const receivingFacility = ((_d = msh === null || msh === void 0 ? void 0 : msh.get(5)) === null || _d === void 0 ? void 0 : _d.toString()) || '';
|
|
2452
|
+
const controlId = ((_e = msh === null || msh === void 0 ? void 0 : msh.get(9)) === null || _e === void 0 ? void 0 : _e.toString()) || '';
|
|
2453
|
+
const versionId = ((_f = msh === null || msh === void 0 ? void 0 : msh.get(12)) === null || _f === void 0 ? void 0 : _f.toString()) || '2.5.1';
|
|
2454
|
+
return new Hl7Message([
|
|
2455
|
+
new Hl7Segment([
|
|
2456
|
+
'MSH',
|
|
2457
|
+
'^~\\&',
|
|
2458
|
+
receivingApp,
|
|
2459
|
+
receivingFacility,
|
|
2460
|
+
sendingApp,
|
|
2461
|
+
sendingFacility,
|
|
2462
|
+
now.toISOString(),
|
|
2463
|
+
'',
|
|
2464
|
+
'ACK',
|
|
2465
|
+
now.getTime().toString(),
|
|
2466
|
+
'P',
|
|
2467
|
+
versionId,
|
|
2468
|
+
]),
|
|
2469
|
+
new Hl7Segment(['MSA', 'AA', controlId, 'OK']),
|
|
2470
|
+
]);
|
|
2471
|
+
}
|
|
2472
|
+
static parse(text) {
|
|
2473
|
+
if (!text.startsWith('MSH|^~\\&')) {
|
|
2474
|
+
const err = new Error('Invalid HL7 message');
|
|
2475
|
+
err.type = 'entity.parse.failed';
|
|
2476
|
+
throw err;
|
|
2477
|
+
}
|
|
2478
|
+
return new Hl7Message(text.split(/[\r\n]+/).map((line) => Hl7Segment.parse(line)));
|
|
2249
2479
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
catch (error) {
|
|
2267
|
-
return [error, undefined];
|
|
2268
|
-
}
|
|
2269
|
-
});
|
|
2480
|
+
}
|
|
2481
|
+
/**
|
|
2482
|
+
* The Hl7Segment class represents one HL7 segment.
|
|
2483
|
+
* A segment is a collection of fields.
|
|
2484
|
+
* The name field is the first field.
|
|
2485
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2486
|
+
*/
|
|
2487
|
+
class Hl7Segment {
|
|
2488
|
+
constructor(fields) {
|
|
2489
|
+
if (isStringArray(fields)) {
|
|
2490
|
+
this.fields = fields.map((f) => Hl7Field.parse(f));
|
|
2491
|
+
}
|
|
2492
|
+
else {
|
|
2493
|
+
this.fields = fields;
|
|
2494
|
+
}
|
|
2495
|
+
this.name = this.fields[0].components[0];
|
|
2270
2496
|
}
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
*
|
|
2274
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2275
|
-
*
|
|
2276
|
-
* @param reference The FHIR reference.
|
|
2277
|
-
* @returns Operation outcome and a resource.
|
|
2278
|
-
* @deprecated
|
|
2279
|
-
*/
|
|
2280
|
-
readReference(reference) {
|
|
2281
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2282
|
-
try {
|
|
2283
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readReference(reference);
|
|
2284
|
-
return [allOk, resource];
|
|
2285
|
-
}
|
|
2286
|
-
catch (error) {
|
|
2287
|
-
return [error, undefined];
|
|
2288
|
-
}
|
|
2289
|
-
});
|
|
2497
|
+
get(index) {
|
|
2498
|
+
return this.fields[index];
|
|
2290
2499
|
}
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
*
|
|
2294
|
-
* See: https://www.hl7.org/fhir/http.html#history
|
|
2295
|
-
*
|
|
2296
|
-
* @param resourceType The FHIR resource type.
|
|
2297
|
-
* @param id The FHIR resource ID.
|
|
2298
|
-
* @returns Operation outcome and a history bundle.
|
|
2299
|
-
* @deprecated
|
|
2300
|
-
*/
|
|
2301
|
-
readHistory(resourceType, id) {
|
|
2302
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2303
|
-
try {
|
|
2304
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readHistory(resourceType, id);
|
|
2305
|
-
return [allOk, resource];
|
|
2306
|
-
}
|
|
2307
|
-
catch (error) {
|
|
2308
|
-
return [error, undefined];
|
|
2309
|
-
}
|
|
2310
|
-
});
|
|
2500
|
+
toString() {
|
|
2501
|
+
return this.fields.map((f) => f.toString()).join(FIELD_SEPARATOR);
|
|
2311
2502
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
*
|
|
2315
|
-
* See: https://www.hl7.org/fhir/http.html#vread
|
|
2316
|
-
*
|
|
2317
|
-
* @param resourceType The FHIR resource type.
|
|
2318
|
-
* @param id The FHIR resource ID.
|
|
2319
|
-
* @param vid The version ID.
|
|
2320
|
-
* @returns Operation outcome and a resource.
|
|
2321
|
-
* @deprecated
|
|
2322
|
-
*/
|
|
2323
|
-
readVersion(resourceType, id, vid) {
|
|
2324
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2325
|
-
try {
|
|
2326
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readVersion(resourceType, id, vid);
|
|
2327
|
-
return [allOk, resource];
|
|
2328
|
-
}
|
|
2329
|
-
catch (error) {
|
|
2330
|
-
return [error, undefined];
|
|
2331
|
-
}
|
|
2332
|
-
});
|
|
2503
|
+
static parse(text) {
|
|
2504
|
+
return new Hl7Segment(text.split(FIELD_SEPARATOR).map((f) => Hl7Field.parse(f)));
|
|
2333
2505
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
updateResource(resource) {
|
|
2344
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2345
|
-
try {
|
|
2346
|
-
const updated = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").updateResource(resource);
|
|
2347
|
-
return [allOk, updated];
|
|
2348
|
-
}
|
|
2349
|
-
catch (error) {
|
|
2350
|
-
return [error, undefined];
|
|
2351
|
-
}
|
|
2352
|
-
});
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* The Hl7Field class represents one HL7 field.
|
|
2509
|
+
* A field is a collection of components.
|
|
2510
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
2511
|
+
*/
|
|
2512
|
+
class Hl7Field {
|
|
2513
|
+
constructor(components) {
|
|
2514
|
+
this.components = components;
|
|
2353
2515
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
*
|
|
2357
|
-
* See: https://www.hl7.org/fhir/http.html#delete
|
|
2358
|
-
*
|
|
2359
|
-
* @param resourceType The FHIR resource type.
|
|
2360
|
-
* @param id The resource ID.
|
|
2361
|
-
* @returns Operation outcome.
|
|
2362
|
-
* @deprecated
|
|
2363
|
-
*/
|
|
2364
|
-
deleteResource(resourceType, id) {
|
|
2365
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2366
|
-
try {
|
|
2367
|
-
yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").deleteResource(resourceType, id);
|
|
2368
|
-
return [allOk, undefined];
|
|
2369
|
-
}
|
|
2370
|
-
catch (error) {
|
|
2371
|
-
return [error, undefined];
|
|
2372
|
-
}
|
|
2373
|
-
});
|
|
2516
|
+
get(index) {
|
|
2517
|
+
return this.components[index];
|
|
2374
2518
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
*
|
|
2378
|
-
* See: https://www.hl7.org/fhir/http.html#patch
|
|
2379
|
-
*
|
|
2380
|
-
* @param resourceType The FHIR resource type.
|
|
2381
|
-
* @param id The resource ID.
|
|
2382
|
-
* @param patch Array of JSONPatch operations.
|
|
2383
|
-
* @returns Operation outcome and the resource.
|
|
2384
|
-
* @deprecated
|
|
2385
|
-
*/
|
|
2386
|
-
patchResource(resourceType, id, patch) {
|
|
2387
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2388
|
-
try {
|
|
2389
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").patchResource(resourceType, id, patch);
|
|
2390
|
-
return [allOk, resource];
|
|
2391
|
-
}
|
|
2392
|
-
catch (error) {
|
|
2393
|
-
return [error, undefined];
|
|
2394
|
-
}
|
|
2395
|
-
});
|
|
2519
|
+
toString() {
|
|
2520
|
+
return this.components.join(COMPONENT_SEPARATOR);
|
|
2396
2521
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
*
|
|
2400
|
-
* See: https://www.hl7.org/fhir/http.html#search
|
|
2401
|
-
*
|
|
2402
|
-
* @param searchRequest The search request.
|
|
2403
|
-
* @returns The search result bundle.
|
|
2404
|
-
* @deprecated
|
|
2405
|
-
*/
|
|
2406
|
-
search(query) {
|
|
2407
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2408
|
-
const searchRequest = typeof query === 'string' ? parseSearchDefinition(query) : query;
|
|
2409
|
-
try {
|
|
2410
|
-
const bundle = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").search(searchRequest);
|
|
2411
|
-
return [allOk, bundle];
|
|
2412
|
-
}
|
|
2413
|
-
catch (error) {
|
|
2414
|
-
return [error, undefined];
|
|
2415
|
-
}
|
|
2416
|
-
});
|
|
2522
|
+
static parse(text) {
|
|
2523
|
+
return new Hl7Field(text.split(COMPONENT_SEPARATOR));
|
|
2417
2524
|
}
|
|
2418
|
-
}
|
|
2419
|
-
_LegacyRepositoryClient_client = new WeakMap();
|
|
2525
|
+
}
|
|
2420
2526
|
|
|
2421
2527
|
var SearchParameterType;
|
|
2422
2528
|
(function (SearchParameterType) {
|
|
@@ -2544,5 +2650,5 @@ function simplifyExpression(input) {
|
|
|
2544
2650
|
return result;
|
|
2545
2651
|
}
|
|
2546
2652
|
|
|
2547
|
-
export {
|
|
2653
|
+
export { COMPONENT_SEPARATOR, DEFAULT_SEARCH_COUNT, FIELD_SEPARATOR, Hl7Field, Hl7Message, Hl7Segment, LRUCache, MedplumClient, OperationOutcomeError, Operator, PropertyType, ReadablePromise, SEGMENT_SEPARATOR, SearchParameterType, accessDenied, allOk, arrayBufferToBase64, arrayBufferToHex, assertOk, badRequest, buildTypeName, calculateAge, calculateAgeString, capitalize, createReference, createSchema, createTypeSchema, created, deepEquals, formatAddress, formatFamilyName, formatGivenName, formatHumanName, formatSearchQuery, getDateProperty, getDisplayString, getExpressionForResourceType, getExtensionValue, getImageSrc, getPropertyDisplayName, getQuestionnaireAnswers, getReferenceString, getSearchParameterDetails, getStatus, gone, indexSearchParameter, indexStructureDefinition, isGone, isLowerCase, isNotFound, isObject, isOk, isProfileResource, isStringArray, isUUID, notFound, notModified, parseSearchDefinition, resolveId, stringify };
|
|
2548
2654
|
//# sourceMappingURL=index.js.map
|