@medplum/core 0.9.2 → 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/dist/cjs/index.js +155 -235
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +153 -235
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/types/cache.d.ts +1 -0
- package/dist/types/client.d.ts +32 -7
- package/dist/types/index.d.ts +2 -1
- package/dist/types/readablepromise.d.ts +43 -0
- package/dist/types/utils.d.ts +6 -0
- package/package.json +2 -2
- package/dist/types/repo.d.ts +0 -116
package/dist/esm/index.js
CHANGED
|
@@ -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.
|
|
@@ -452,6 +455,14 @@ function deepEqualsObject(object1, object2, path) {
|
|
|
452
455
|
}
|
|
453
456
|
return true;
|
|
454
457
|
}
|
|
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
|
+
}
|
|
455
466
|
/**
|
|
456
467
|
* Returns true if the input is an object.
|
|
457
468
|
* @param object The candidate object.
|
|
@@ -502,7 +513,7 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
502
513
|
return window.btoa(result.join(''));
|
|
503
514
|
}
|
|
504
515
|
function capitalize(word) {
|
|
505
|
-
return word.charAt(0).toUpperCase() + word.
|
|
516
|
+
return word.charAt(0).toUpperCase() + word.substring(1);
|
|
506
517
|
}
|
|
507
518
|
function isLowerCase(c) {
|
|
508
519
|
return c === c.toLowerCase();
|
|
@@ -745,6 +756,82 @@ class OperationOutcomeError extends Error {
|
|
|
745
756
|
}
|
|
746
757
|
}
|
|
747
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
|
+
|
|
748
835
|
const DEFAULT_SEARCH_COUNT = 20;
|
|
749
836
|
/**
|
|
750
837
|
* Search operators.
|
|
@@ -1233,7 +1320,7 @@ function getPropertyDisplayName(property) {
|
|
|
1233
1320
|
|
|
1234
1321
|
// PKCE auth ased on:
|
|
1235
1322
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
1236
|
-
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;
|
|
1237
1324
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
1238
1325
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
1239
1326
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
@@ -1296,7 +1383,7 @@ class MedplumClient extends EventTarget {
|
|
|
1296
1383
|
_MedplumClient_fetch.set(this, void 0);
|
|
1297
1384
|
_MedplumClient_storage.set(this, void 0);
|
|
1298
1385
|
_MedplumClient_schema.set(this, void 0);
|
|
1299
|
-
|
|
1386
|
+
_MedplumClient_requestCache.set(this, void 0);
|
|
1300
1387
|
_MedplumClient_baseUrl.set(this, void 0);
|
|
1301
1388
|
_MedplumClient_clientId.set(this, void 0);
|
|
1302
1389
|
_MedplumClient_authorizeUrl.set(this, void 0);
|
|
@@ -1320,7 +1407,7 @@ class MedplumClient extends EventTarget {
|
|
|
1320
1407
|
__classPrivateFieldSet(this, _MedplumClient_fetch, (options === null || options === void 0 ? void 0 : options.fetch) || window.fetch.bind(window), "f");
|
|
1321
1408
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
1322
1409
|
__classPrivateFieldSet(this, _MedplumClient_schema, createSchema(), "f");
|
|
1323
|
-
__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");
|
|
1324
1411
|
__classPrivateFieldSet(this, _MedplumClient_baseUrl, (options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
1325
1412
|
__classPrivateFieldSet(this, _MedplumClient_clientId, (options === null || options === void 0 ? void 0 : options.clientId) || '', "f");
|
|
1326
1413
|
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, (options === null || options === void 0 ? void 0 : options.authorizeUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
@@ -1340,7 +1427,7 @@ class MedplumClient extends EventTarget {
|
|
|
1340
1427
|
*/
|
|
1341
1428
|
clear() {
|
|
1342
1429
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").clear();
|
|
1343
|
-
__classPrivateFieldGet(this,
|
|
1430
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1344
1431
|
__classPrivateFieldSet(this, _MedplumClient_accessToken, undefined, "f");
|
|
1345
1432
|
__classPrivateFieldSet(this, _MedplumClient_refreshToken, undefined, "f");
|
|
1346
1433
|
__classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
|
|
@@ -1359,7 +1446,15 @@ class MedplumClient extends EventTarget {
|
|
|
1359
1446
|
* @returns Promise to the response content.
|
|
1360
1447
|
*/
|
|
1361
1448
|
get(url, options = {}) {
|
|
1362
|
-
|
|
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;
|
|
1363
1458
|
}
|
|
1364
1459
|
/**
|
|
1365
1460
|
* Makes an HTTP POST request to the specified URL.
|
|
@@ -1381,6 +1476,7 @@ class MedplumClient extends EventTarget {
|
|
|
1381
1476
|
if (contentType) {
|
|
1382
1477
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1383
1478
|
}
|
|
1479
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1384
1480
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'POST', url, options);
|
|
1385
1481
|
}
|
|
1386
1482
|
/**
|
|
@@ -1403,6 +1499,7 @@ class MedplumClient extends EventTarget {
|
|
|
1403
1499
|
if (contentType) {
|
|
1404
1500
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1405
1501
|
}
|
|
1502
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1406
1503
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PUT', url, options);
|
|
1407
1504
|
}
|
|
1408
1505
|
/**
|
|
@@ -1420,6 +1517,7 @@ class MedplumClient extends EventTarget {
|
|
|
1420
1517
|
patch(url, operations, options = {}) {
|
|
1421
1518
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestBody).call(this, options, operations);
|
|
1422
1519
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, PATCH_CONTENT_TYPE);
|
|
1520
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1423
1521
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PATCH', url, options);
|
|
1424
1522
|
}
|
|
1425
1523
|
/**
|
|
@@ -1434,6 +1532,7 @@ class MedplumClient extends EventTarget {
|
|
|
1434
1532
|
* @returns Promise to the response content.
|
|
1435
1533
|
*/
|
|
1436
1534
|
delete(url, options = {}) {
|
|
1535
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1437
1536
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'DELETE', url, options);
|
|
1438
1537
|
}
|
|
1439
1538
|
/**
|
|
@@ -1653,11 +1752,8 @@ class MedplumClient extends EventTarget {
|
|
|
1653
1752
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1654
1753
|
*/
|
|
1655
1754
|
getCached(resourceType, id) {
|
|
1656
|
-
const cached = __classPrivateFieldGet(this,
|
|
1657
|
-
|
|
1658
|
-
return cached;
|
|
1659
|
-
}
|
|
1660
|
-
return undefined;
|
|
1755
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id));
|
|
1756
|
+
return cached && !cached.isPending() ? cached.read() : undefined;
|
|
1661
1757
|
}
|
|
1662
1758
|
/**
|
|
1663
1759
|
* Returns a cached resource if it is available.
|
|
@@ -1666,11 +1762,9 @@ class MedplumClient extends EventTarget {
|
|
|
1666
1762
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1667
1763
|
*/
|
|
1668
1764
|
getCachedReference(reference) {
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
}
|
|
1673
|
-
return undefined;
|
|
1765
|
+
const refString = reference.reference;
|
|
1766
|
+
const [resourceType, id] = refString.split('/');
|
|
1767
|
+
return this.getCached(resourceType, id);
|
|
1674
1768
|
}
|
|
1675
1769
|
/**
|
|
1676
1770
|
* Reads a resource by resource type and ID.
|
|
@@ -1689,13 +1783,7 @@ class MedplumClient extends EventTarget {
|
|
|
1689
1783
|
* @returns The resource if available; undefined otherwise.
|
|
1690
1784
|
*/
|
|
1691
1785
|
readResource(resourceType, id) {
|
|
1692
|
-
|
|
1693
|
-
const promise = this.get(this.fhirUrl(resourceType, id)).then((resource) => {
|
|
1694
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, resource);
|
|
1695
|
-
return resource;
|
|
1696
|
-
});
|
|
1697
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, promise);
|
|
1698
|
-
return promise;
|
|
1786
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1699
1787
|
}
|
|
1700
1788
|
/**
|
|
1701
1789
|
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
@@ -1716,8 +1804,7 @@ class MedplumClient extends EventTarget {
|
|
|
1716
1804
|
* @returns The resource if available; undefined otherwise.
|
|
1717
1805
|
*/
|
|
1718
1806
|
readCached(resourceType, id) {
|
|
1719
|
-
|
|
1720
|
-
return cached ? Promise.resolve(cached) : this.readResource(resourceType, id);
|
|
1807
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1721
1808
|
}
|
|
1722
1809
|
/**
|
|
1723
1810
|
* Reads a resource by `Reference`.
|
|
@@ -1740,7 +1827,7 @@ class MedplumClient extends EventTarget {
|
|
|
1740
1827
|
readReference(reference) {
|
|
1741
1828
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1742
1829
|
if (!refString) {
|
|
1743
|
-
return Promise.reject('Missing reference');
|
|
1830
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1744
1831
|
}
|
|
1745
1832
|
const [resourceType, id] = refString.split('/');
|
|
1746
1833
|
return this.readResource(resourceType, id);
|
|
@@ -1768,7 +1855,7 @@ class MedplumClient extends EventTarget {
|
|
|
1768
1855
|
readCachedReference(reference) {
|
|
1769
1856
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1770
1857
|
if (!refString) {
|
|
1771
|
-
return Promise.reject('Missing reference');
|
|
1858
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1772
1859
|
}
|
|
1773
1860
|
const [resourceType, id] = refString.split('/');
|
|
1774
1861
|
return this.readCached(resourceType, id);
|
|
@@ -1923,11 +2010,45 @@ class MedplumClient extends EventTarget {
|
|
|
1923
2010
|
*
|
|
1924
2011
|
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
1925
2012
|
*
|
|
1926
|
-
* @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.
|
|
1927
2016
|
* @returns The result of the create operation.
|
|
1928
2017
|
*/
|
|
1929
2018
|
createBinary(data, filename, contentType) {
|
|
1930
|
-
|
|
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');
|
|
1931
2052
|
}
|
|
1932
2053
|
/**
|
|
1933
2054
|
* Updates a FHIR resource.
|
|
@@ -2020,7 +2141,7 @@ class MedplumClient extends EventTarget {
|
|
|
2020
2141
|
__classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
|
|
2021
2142
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('activeLogin', login);
|
|
2022
2143
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addLogin).call(this, login);
|
|
2023
|
-
__classPrivateFieldGet(this,
|
|
2144
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
2024
2145
|
__classPrivateFieldSet(this, _MedplumClient_refreshPromise, undefined, "f");
|
|
2025
2146
|
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
2026
2147
|
});
|
|
@@ -2102,7 +2223,7 @@ class MedplumClient extends EventTarget {
|
|
|
2102
2223
|
});
|
|
2103
2224
|
}
|
|
2104
2225
|
}
|
|
2105
|
-
_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) {
|
|
2106
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); });
|
|
2107
2228
|
logins.push(newLogin);
|
|
2108
2229
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
|
|
@@ -2403,209 +2524,6 @@ class Hl7Field {
|
|
|
2403
2524
|
}
|
|
2404
2525
|
}
|
|
2405
2526
|
|
|
2406
|
-
var _LegacyRepositoryClient_client;
|
|
2407
|
-
/**
|
|
2408
|
-
* The LegacyRepositoryClient is a supplementary API client that matches the legacy "Repository" API.
|
|
2409
|
-
* The "Repository" API is deprecated and will be removed in a future release.
|
|
2410
|
-
* This LegacyRepositoryClient is also deprecated and will be removed in a future release.
|
|
2411
|
-
* @deprecated
|
|
2412
|
-
*/
|
|
2413
|
-
class LegacyRepositoryClient {
|
|
2414
|
-
constructor(client) {
|
|
2415
|
-
_LegacyRepositoryClient_client.set(this, void 0);
|
|
2416
|
-
__classPrivateFieldSet(this, _LegacyRepositoryClient_client, client, "f");
|
|
2417
|
-
}
|
|
2418
|
-
/**
|
|
2419
|
-
* Creates a resource.
|
|
2420
|
-
*
|
|
2421
|
-
* See: https://www.hl7.org/fhir/http.html#create
|
|
2422
|
-
*
|
|
2423
|
-
* @param resource The resource to create.
|
|
2424
|
-
* @returns Operation outcome and the new resource.
|
|
2425
|
-
* @deprecated
|
|
2426
|
-
*/
|
|
2427
|
-
createResource(resource) {
|
|
2428
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2429
|
-
try {
|
|
2430
|
-
const result = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").createResource(resource);
|
|
2431
|
-
return [created, result];
|
|
2432
|
-
}
|
|
2433
|
-
catch (error) {
|
|
2434
|
-
return [error, undefined];
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2437
|
-
}
|
|
2438
|
-
/**
|
|
2439
|
-
* Returns a resource.
|
|
2440
|
-
*
|
|
2441
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2442
|
-
*
|
|
2443
|
-
* @param resourceType The FHIR resource type.
|
|
2444
|
-
* @param id The FHIR resource ID.
|
|
2445
|
-
* @returns Operation outcome and a resource.
|
|
2446
|
-
* @deprecated
|
|
2447
|
-
*/
|
|
2448
|
-
readResource(resourceType, id) {
|
|
2449
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2450
|
-
try {
|
|
2451
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readResource(resourceType, id);
|
|
2452
|
-
return [allOk, resource];
|
|
2453
|
-
}
|
|
2454
|
-
catch (error) {
|
|
2455
|
-
return [error, undefined];
|
|
2456
|
-
}
|
|
2457
|
-
});
|
|
2458
|
-
}
|
|
2459
|
-
/**
|
|
2460
|
-
* Returns a resource by FHIR reference.
|
|
2461
|
-
*
|
|
2462
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2463
|
-
*
|
|
2464
|
-
* @param reference The FHIR reference.
|
|
2465
|
-
* @returns Operation outcome and a resource.
|
|
2466
|
-
* @deprecated
|
|
2467
|
-
*/
|
|
2468
|
-
readReference(reference) {
|
|
2469
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2470
|
-
try {
|
|
2471
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readReference(reference);
|
|
2472
|
-
return [allOk, resource];
|
|
2473
|
-
}
|
|
2474
|
-
catch (error) {
|
|
2475
|
-
return [error, undefined];
|
|
2476
|
-
}
|
|
2477
|
-
});
|
|
2478
|
-
}
|
|
2479
|
-
/**
|
|
2480
|
-
* Returns resource history.
|
|
2481
|
-
*
|
|
2482
|
-
* See: https://www.hl7.org/fhir/http.html#history
|
|
2483
|
-
*
|
|
2484
|
-
* @param resourceType The FHIR resource type.
|
|
2485
|
-
* @param id The FHIR resource ID.
|
|
2486
|
-
* @returns Operation outcome and a history bundle.
|
|
2487
|
-
* @deprecated
|
|
2488
|
-
*/
|
|
2489
|
-
readHistory(resourceType, id) {
|
|
2490
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2491
|
-
try {
|
|
2492
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readHistory(resourceType, id);
|
|
2493
|
-
return [allOk, resource];
|
|
2494
|
-
}
|
|
2495
|
-
catch (error) {
|
|
2496
|
-
return [error, undefined];
|
|
2497
|
-
}
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
/**
|
|
2501
|
-
* Returns a resource version.
|
|
2502
|
-
*
|
|
2503
|
-
* See: https://www.hl7.org/fhir/http.html#vread
|
|
2504
|
-
*
|
|
2505
|
-
* @param resourceType The FHIR resource type.
|
|
2506
|
-
* @param id The FHIR resource ID.
|
|
2507
|
-
* @param vid The version ID.
|
|
2508
|
-
* @returns Operation outcome and a resource.
|
|
2509
|
-
* @deprecated
|
|
2510
|
-
*/
|
|
2511
|
-
readVersion(resourceType, id, vid) {
|
|
2512
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2513
|
-
try {
|
|
2514
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readVersion(resourceType, id, vid);
|
|
2515
|
-
return [allOk, resource];
|
|
2516
|
-
}
|
|
2517
|
-
catch (error) {
|
|
2518
|
-
return [error, undefined];
|
|
2519
|
-
}
|
|
2520
|
-
});
|
|
2521
|
-
}
|
|
2522
|
-
/**
|
|
2523
|
-
* Updates a resource.
|
|
2524
|
-
*
|
|
2525
|
-
* See: https://www.hl7.org/fhir/http.html#update
|
|
2526
|
-
*
|
|
2527
|
-
* @param resource The resource to update.
|
|
2528
|
-
* @returns Operation outcome and the updated resource.
|
|
2529
|
-
* @deprecated
|
|
2530
|
-
*/
|
|
2531
|
-
updateResource(resource) {
|
|
2532
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2533
|
-
try {
|
|
2534
|
-
const updated = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").updateResource(resource);
|
|
2535
|
-
return [allOk, updated];
|
|
2536
|
-
}
|
|
2537
|
-
catch (error) {
|
|
2538
|
-
return [error, undefined];
|
|
2539
|
-
}
|
|
2540
|
-
});
|
|
2541
|
-
}
|
|
2542
|
-
/**
|
|
2543
|
-
* Deletes a resource.
|
|
2544
|
-
*
|
|
2545
|
-
* See: https://www.hl7.org/fhir/http.html#delete
|
|
2546
|
-
*
|
|
2547
|
-
* @param resourceType The FHIR resource type.
|
|
2548
|
-
* @param id The resource ID.
|
|
2549
|
-
* @returns Operation outcome.
|
|
2550
|
-
* @deprecated
|
|
2551
|
-
*/
|
|
2552
|
-
deleteResource(resourceType, id) {
|
|
2553
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2554
|
-
try {
|
|
2555
|
-
yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").deleteResource(resourceType, id);
|
|
2556
|
-
return [allOk, undefined];
|
|
2557
|
-
}
|
|
2558
|
-
catch (error) {
|
|
2559
|
-
return [error, undefined];
|
|
2560
|
-
}
|
|
2561
|
-
});
|
|
2562
|
-
}
|
|
2563
|
-
/**
|
|
2564
|
-
* Patches a resource.
|
|
2565
|
-
*
|
|
2566
|
-
* See: https://www.hl7.org/fhir/http.html#patch
|
|
2567
|
-
*
|
|
2568
|
-
* @param resourceType The FHIR resource type.
|
|
2569
|
-
* @param id The resource ID.
|
|
2570
|
-
* @param patch Array of JSONPatch operations.
|
|
2571
|
-
* @returns Operation outcome and the resource.
|
|
2572
|
-
* @deprecated
|
|
2573
|
-
*/
|
|
2574
|
-
patchResource(resourceType, id, patch) {
|
|
2575
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2576
|
-
try {
|
|
2577
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").patchResource(resourceType, id, patch);
|
|
2578
|
-
return [allOk, resource];
|
|
2579
|
-
}
|
|
2580
|
-
catch (error) {
|
|
2581
|
-
return [error, undefined];
|
|
2582
|
-
}
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
/**
|
|
2586
|
-
* Searches for resources.
|
|
2587
|
-
*
|
|
2588
|
-
* See: https://www.hl7.org/fhir/http.html#search
|
|
2589
|
-
*
|
|
2590
|
-
* @param searchRequest The search request.
|
|
2591
|
-
* @returns The search result bundle.
|
|
2592
|
-
* @deprecated
|
|
2593
|
-
*/
|
|
2594
|
-
search(query) {
|
|
2595
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2596
|
-
const searchRequest = typeof query === 'string' ? parseSearchDefinition(query) : query;
|
|
2597
|
-
try {
|
|
2598
|
-
const bundle = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").search(searchRequest);
|
|
2599
|
-
return [allOk, bundle];
|
|
2600
|
-
}
|
|
2601
|
-
catch (error) {
|
|
2602
|
-
return [error, undefined];
|
|
2603
|
-
}
|
|
2604
|
-
});
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
_LegacyRepositoryClient_client = new WeakMap();
|
|
2608
|
-
|
|
2609
2527
|
var SearchParameterType;
|
|
2610
2528
|
(function (SearchParameterType) {
|
|
2611
2529
|
SearchParameterType["BOOLEAN"] = "BOOLEAN";
|
|
@@ -2732,5 +2650,5 @@ function simplifyExpression(input) {
|
|
|
2732
2650
|
return result;
|
|
2733
2651
|
}
|
|
2734
2652
|
|
|
2735
|
-
export { COMPONENT_SEPARATOR, DEFAULT_SEARCH_COUNT, FIELD_SEPARATOR, Hl7Field, Hl7Message, Hl7Segment,
|
|
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 };
|
|
2736
2654
|
//# sourceMappingURL=index.js.map
|