@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/cjs/index.js
CHANGED
|
@@ -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.
|
|
@@ -458,6 +461,14 @@
|
|
|
458
461
|
}
|
|
459
462
|
return true;
|
|
460
463
|
}
|
|
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
|
+
}
|
|
461
472
|
/**
|
|
462
473
|
* Returns true if the input is an object.
|
|
463
474
|
* @param object The candidate object.
|
|
@@ -508,7 +519,7 @@
|
|
|
508
519
|
return window.btoa(result.join(''));
|
|
509
520
|
}
|
|
510
521
|
function capitalize(word) {
|
|
511
|
-
return word.charAt(0).toUpperCase() + word.
|
|
522
|
+
return word.charAt(0).toUpperCase() + word.substring(1);
|
|
512
523
|
}
|
|
513
524
|
function isLowerCase(c) {
|
|
514
525
|
return c === c.toLowerCase();
|
|
@@ -751,6 +762,82 @@
|
|
|
751
762
|
}
|
|
752
763
|
}
|
|
753
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
|
+
|
|
754
841
|
const DEFAULT_SEARCH_COUNT = 20;
|
|
755
842
|
/**
|
|
756
843
|
* Search operators.
|
|
@@ -1239,7 +1326,7 @@
|
|
|
1239
1326
|
|
|
1240
1327
|
// PKCE auth ased on:
|
|
1241
1328
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
1242
|
-
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;
|
|
1243
1330
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
1244
1331
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
1245
1332
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
@@ -1302,7 +1389,7 @@
|
|
|
1302
1389
|
_MedplumClient_fetch.set(this, void 0);
|
|
1303
1390
|
_MedplumClient_storage.set(this, void 0);
|
|
1304
1391
|
_MedplumClient_schema.set(this, void 0);
|
|
1305
|
-
|
|
1392
|
+
_MedplumClient_requestCache.set(this, void 0);
|
|
1306
1393
|
_MedplumClient_baseUrl.set(this, void 0);
|
|
1307
1394
|
_MedplumClient_clientId.set(this, void 0);
|
|
1308
1395
|
_MedplumClient_authorizeUrl.set(this, void 0);
|
|
@@ -1326,7 +1413,7 @@
|
|
|
1326
1413
|
__classPrivateFieldSet(this, _MedplumClient_fetch, (options === null || options === void 0 ? void 0 : options.fetch) || window.fetch.bind(window), "f");
|
|
1327
1414
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
1328
1415
|
__classPrivateFieldSet(this, _MedplumClient_schema, createSchema(), "f");
|
|
1329
|
-
__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");
|
|
1330
1417
|
__classPrivateFieldSet(this, _MedplumClient_baseUrl, (options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
1331
1418
|
__classPrivateFieldSet(this, _MedplumClient_clientId, (options === null || options === void 0 ? void 0 : options.clientId) || '', "f");
|
|
1332
1419
|
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, (options === null || options === void 0 ? void 0 : options.authorizeUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
@@ -1346,7 +1433,7 @@
|
|
|
1346
1433
|
*/
|
|
1347
1434
|
clear() {
|
|
1348
1435
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").clear();
|
|
1349
|
-
__classPrivateFieldGet(this,
|
|
1436
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1350
1437
|
__classPrivateFieldSet(this, _MedplumClient_accessToken, undefined, "f");
|
|
1351
1438
|
__classPrivateFieldSet(this, _MedplumClient_refreshToken, undefined, "f");
|
|
1352
1439
|
__classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
|
|
@@ -1365,7 +1452,15 @@
|
|
|
1365
1452
|
* @returns Promise to the response content.
|
|
1366
1453
|
*/
|
|
1367
1454
|
get(url, options = {}) {
|
|
1368
|
-
|
|
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;
|
|
1369
1464
|
}
|
|
1370
1465
|
/**
|
|
1371
1466
|
* Makes an HTTP POST request to the specified URL.
|
|
@@ -1387,6 +1482,7 @@
|
|
|
1387
1482
|
if (contentType) {
|
|
1388
1483
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1389
1484
|
}
|
|
1485
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1390
1486
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'POST', url, options);
|
|
1391
1487
|
}
|
|
1392
1488
|
/**
|
|
@@ -1409,6 +1505,7 @@
|
|
|
1409
1505
|
if (contentType) {
|
|
1410
1506
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, contentType);
|
|
1411
1507
|
}
|
|
1508
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1412
1509
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PUT', url, options);
|
|
1413
1510
|
}
|
|
1414
1511
|
/**
|
|
@@ -1426,6 +1523,7 @@
|
|
|
1426
1523
|
patch(url, operations, options = {}) {
|
|
1427
1524
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestBody).call(this, options, operations);
|
|
1428
1525
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setRequestContentType).call(this, options, PATCH_CONTENT_TYPE);
|
|
1526
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1429
1527
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'PATCH', url, options);
|
|
1430
1528
|
}
|
|
1431
1529
|
/**
|
|
@@ -1440,6 +1538,7 @@
|
|
|
1440
1538
|
* @returns Promise to the response content.
|
|
1441
1539
|
*/
|
|
1442
1540
|
delete(url, options = {}) {
|
|
1541
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").delete(url);
|
|
1443
1542
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'DELETE', url, options);
|
|
1444
1543
|
}
|
|
1445
1544
|
/**
|
|
@@ -1659,11 +1758,8 @@
|
|
|
1659
1758
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1660
1759
|
*/
|
|
1661
1760
|
getCached(resourceType, id) {
|
|
1662
|
-
const cached = __classPrivateFieldGet(this,
|
|
1663
|
-
|
|
1664
|
-
return cached;
|
|
1665
|
-
}
|
|
1666
|
-
return undefined;
|
|
1761
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id));
|
|
1762
|
+
return cached && !cached.isPending() ? cached.read() : undefined;
|
|
1667
1763
|
}
|
|
1668
1764
|
/**
|
|
1669
1765
|
* Returns a cached resource if it is available.
|
|
@@ -1672,11 +1768,9 @@
|
|
|
1672
1768
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
1673
1769
|
*/
|
|
1674
1770
|
getCachedReference(reference) {
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
return undefined;
|
|
1771
|
+
const refString = reference.reference;
|
|
1772
|
+
const [resourceType, id] = refString.split('/');
|
|
1773
|
+
return this.getCached(resourceType, id);
|
|
1680
1774
|
}
|
|
1681
1775
|
/**
|
|
1682
1776
|
* Reads a resource by resource type and ID.
|
|
@@ -1695,13 +1789,7 @@
|
|
|
1695
1789
|
* @returns The resource if available; undefined otherwise.
|
|
1696
1790
|
*/
|
|
1697
1791
|
readResource(resourceType, id) {
|
|
1698
|
-
|
|
1699
|
-
const promise = this.get(this.fhirUrl(resourceType, id)).then((resource) => {
|
|
1700
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, resource);
|
|
1701
|
-
return resource;
|
|
1702
|
-
});
|
|
1703
|
-
__classPrivateFieldGet(this, _MedplumClient_resourceCache, "f").set(cacheKey, promise);
|
|
1704
|
-
return promise;
|
|
1792
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1705
1793
|
}
|
|
1706
1794
|
/**
|
|
1707
1795
|
* Reads a resource by resource type and ID using the in-memory resource cache.
|
|
@@ -1722,8 +1810,7 @@
|
|
|
1722
1810
|
* @returns The resource if available; undefined otherwise.
|
|
1723
1811
|
*/
|
|
1724
1812
|
readCached(resourceType, id) {
|
|
1725
|
-
|
|
1726
|
-
return cached ? Promise.resolve(cached) : this.readResource(resourceType, id);
|
|
1813
|
+
return this.get(this.fhirUrl(resourceType, id));
|
|
1727
1814
|
}
|
|
1728
1815
|
/**
|
|
1729
1816
|
* Reads a resource by `Reference`.
|
|
@@ -1746,7 +1833,7 @@
|
|
|
1746
1833
|
readReference(reference) {
|
|
1747
1834
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1748
1835
|
if (!refString) {
|
|
1749
|
-
return Promise.reject('Missing reference');
|
|
1836
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1750
1837
|
}
|
|
1751
1838
|
const [resourceType, id] = refString.split('/');
|
|
1752
1839
|
return this.readResource(resourceType, id);
|
|
@@ -1774,7 +1861,7 @@
|
|
|
1774
1861
|
readCachedReference(reference) {
|
|
1775
1862
|
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
1776
1863
|
if (!refString) {
|
|
1777
|
-
return Promise.reject('Missing reference');
|
|
1864
|
+
return new ReadablePromise(Promise.reject('Missing reference'));
|
|
1778
1865
|
}
|
|
1779
1866
|
const [resourceType, id] = refString.split('/');
|
|
1780
1867
|
return this.readCached(resourceType, id);
|
|
@@ -1929,11 +2016,45 @@
|
|
|
1929
2016
|
*
|
|
1930
2017
|
* See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
|
|
1931
2018
|
*
|
|
1932
|
-
* @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.
|
|
1933
2022
|
* @returns The result of the create operation.
|
|
1934
2023
|
*/
|
|
1935
2024
|
createBinary(data, filename, contentType) {
|
|
1936
|
-
|
|
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');
|
|
1937
2058
|
}
|
|
1938
2059
|
/**
|
|
1939
2060
|
* Updates a FHIR resource.
|
|
@@ -2026,7 +2147,7 @@
|
|
|
2026
2147
|
__classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
|
|
2027
2148
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('activeLogin', login);
|
|
2028
2149
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addLogin).call(this, login);
|
|
2029
|
-
__classPrivateFieldGet(this,
|
|
2150
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
2030
2151
|
__classPrivateFieldSet(this, _MedplumClient_refreshPromise, undefined, "f");
|
|
2031
2152
|
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
2032
2153
|
});
|
|
@@ -2108,7 +2229,7 @@
|
|
|
2108
2229
|
});
|
|
2109
2230
|
}
|
|
2110
2231
|
}
|
|
2111
|
-
_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) {
|
|
2112
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); });
|
|
2113
2234
|
logins.push(newLogin);
|
|
2114
2235
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
|
|
@@ -2409,209 +2530,6 @@
|
|
|
2409
2530
|
}
|
|
2410
2531
|
}
|
|
2411
2532
|
|
|
2412
|
-
var _LegacyRepositoryClient_client;
|
|
2413
|
-
/**
|
|
2414
|
-
* The LegacyRepositoryClient is a supplementary API client that matches the legacy "Repository" API.
|
|
2415
|
-
* The "Repository" API is deprecated and will be removed in a future release.
|
|
2416
|
-
* This LegacyRepositoryClient is also deprecated and will be removed in a future release.
|
|
2417
|
-
* @deprecated
|
|
2418
|
-
*/
|
|
2419
|
-
class LegacyRepositoryClient {
|
|
2420
|
-
constructor(client) {
|
|
2421
|
-
_LegacyRepositoryClient_client.set(this, void 0);
|
|
2422
|
-
__classPrivateFieldSet(this, _LegacyRepositoryClient_client, client, "f");
|
|
2423
|
-
}
|
|
2424
|
-
/**
|
|
2425
|
-
* Creates a resource.
|
|
2426
|
-
*
|
|
2427
|
-
* See: https://www.hl7.org/fhir/http.html#create
|
|
2428
|
-
*
|
|
2429
|
-
* @param resource The resource to create.
|
|
2430
|
-
* @returns Operation outcome and the new resource.
|
|
2431
|
-
* @deprecated
|
|
2432
|
-
*/
|
|
2433
|
-
createResource(resource) {
|
|
2434
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2435
|
-
try {
|
|
2436
|
-
const result = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").createResource(resource);
|
|
2437
|
-
return [created, result];
|
|
2438
|
-
}
|
|
2439
|
-
catch (error) {
|
|
2440
|
-
return [error, undefined];
|
|
2441
|
-
}
|
|
2442
|
-
});
|
|
2443
|
-
}
|
|
2444
|
-
/**
|
|
2445
|
-
* Returns a resource.
|
|
2446
|
-
*
|
|
2447
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2448
|
-
*
|
|
2449
|
-
* @param resourceType The FHIR resource type.
|
|
2450
|
-
* @param id The FHIR resource ID.
|
|
2451
|
-
* @returns Operation outcome and a resource.
|
|
2452
|
-
* @deprecated
|
|
2453
|
-
*/
|
|
2454
|
-
readResource(resourceType, id) {
|
|
2455
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2456
|
-
try {
|
|
2457
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readResource(resourceType, id);
|
|
2458
|
-
return [allOk, resource];
|
|
2459
|
-
}
|
|
2460
|
-
catch (error) {
|
|
2461
|
-
return [error, undefined];
|
|
2462
|
-
}
|
|
2463
|
-
});
|
|
2464
|
-
}
|
|
2465
|
-
/**
|
|
2466
|
-
* Returns a resource by FHIR reference.
|
|
2467
|
-
*
|
|
2468
|
-
* See: https://www.hl7.org/fhir/http.html#read
|
|
2469
|
-
*
|
|
2470
|
-
* @param reference The FHIR reference.
|
|
2471
|
-
* @returns Operation outcome and a resource.
|
|
2472
|
-
* @deprecated
|
|
2473
|
-
*/
|
|
2474
|
-
readReference(reference) {
|
|
2475
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2476
|
-
try {
|
|
2477
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readReference(reference);
|
|
2478
|
-
return [allOk, resource];
|
|
2479
|
-
}
|
|
2480
|
-
catch (error) {
|
|
2481
|
-
return [error, undefined];
|
|
2482
|
-
}
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2485
|
-
/**
|
|
2486
|
-
* Returns resource history.
|
|
2487
|
-
*
|
|
2488
|
-
* See: https://www.hl7.org/fhir/http.html#history
|
|
2489
|
-
*
|
|
2490
|
-
* @param resourceType The FHIR resource type.
|
|
2491
|
-
* @param id The FHIR resource ID.
|
|
2492
|
-
* @returns Operation outcome and a history bundle.
|
|
2493
|
-
* @deprecated
|
|
2494
|
-
*/
|
|
2495
|
-
readHistory(resourceType, id) {
|
|
2496
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2497
|
-
try {
|
|
2498
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readHistory(resourceType, id);
|
|
2499
|
-
return [allOk, resource];
|
|
2500
|
-
}
|
|
2501
|
-
catch (error) {
|
|
2502
|
-
return [error, undefined];
|
|
2503
|
-
}
|
|
2504
|
-
});
|
|
2505
|
-
}
|
|
2506
|
-
/**
|
|
2507
|
-
* Returns a resource version.
|
|
2508
|
-
*
|
|
2509
|
-
* See: https://www.hl7.org/fhir/http.html#vread
|
|
2510
|
-
*
|
|
2511
|
-
* @param resourceType The FHIR resource type.
|
|
2512
|
-
* @param id The FHIR resource ID.
|
|
2513
|
-
* @param vid The version ID.
|
|
2514
|
-
* @returns Operation outcome and a resource.
|
|
2515
|
-
* @deprecated
|
|
2516
|
-
*/
|
|
2517
|
-
readVersion(resourceType, id, vid) {
|
|
2518
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2519
|
-
try {
|
|
2520
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").readVersion(resourceType, id, vid);
|
|
2521
|
-
return [allOk, resource];
|
|
2522
|
-
}
|
|
2523
|
-
catch (error) {
|
|
2524
|
-
return [error, undefined];
|
|
2525
|
-
}
|
|
2526
|
-
});
|
|
2527
|
-
}
|
|
2528
|
-
/**
|
|
2529
|
-
* Updates a resource.
|
|
2530
|
-
*
|
|
2531
|
-
* See: https://www.hl7.org/fhir/http.html#update
|
|
2532
|
-
*
|
|
2533
|
-
* @param resource The resource to update.
|
|
2534
|
-
* @returns Operation outcome and the updated resource.
|
|
2535
|
-
* @deprecated
|
|
2536
|
-
*/
|
|
2537
|
-
updateResource(resource) {
|
|
2538
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2539
|
-
try {
|
|
2540
|
-
const updated = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").updateResource(resource);
|
|
2541
|
-
return [allOk, updated];
|
|
2542
|
-
}
|
|
2543
|
-
catch (error) {
|
|
2544
|
-
return [error, undefined];
|
|
2545
|
-
}
|
|
2546
|
-
});
|
|
2547
|
-
}
|
|
2548
|
-
/**
|
|
2549
|
-
* Deletes a resource.
|
|
2550
|
-
*
|
|
2551
|
-
* See: https://www.hl7.org/fhir/http.html#delete
|
|
2552
|
-
*
|
|
2553
|
-
* @param resourceType The FHIR resource type.
|
|
2554
|
-
* @param id The resource ID.
|
|
2555
|
-
* @returns Operation outcome.
|
|
2556
|
-
* @deprecated
|
|
2557
|
-
*/
|
|
2558
|
-
deleteResource(resourceType, id) {
|
|
2559
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2560
|
-
try {
|
|
2561
|
-
yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").deleteResource(resourceType, id);
|
|
2562
|
-
return [allOk, undefined];
|
|
2563
|
-
}
|
|
2564
|
-
catch (error) {
|
|
2565
|
-
return [error, undefined];
|
|
2566
|
-
}
|
|
2567
|
-
});
|
|
2568
|
-
}
|
|
2569
|
-
/**
|
|
2570
|
-
* Patches a resource.
|
|
2571
|
-
*
|
|
2572
|
-
* See: https://www.hl7.org/fhir/http.html#patch
|
|
2573
|
-
*
|
|
2574
|
-
* @param resourceType The FHIR resource type.
|
|
2575
|
-
* @param id The resource ID.
|
|
2576
|
-
* @param patch Array of JSONPatch operations.
|
|
2577
|
-
* @returns Operation outcome and the resource.
|
|
2578
|
-
* @deprecated
|
|
2579
|
-
*/
|
|
2580
|
-
patchResource(resourceType, id, patch) {
|
|
2581
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2582
|
-
try {
|
|
2583
|
-
const resource = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").patchResource(resourceType, id, patch);
|
|
2584
|
-
return [allOk, resource];
|
|
2585
|
-
}
|
|
2586
|
-
catch (error) {
|
|
2587
|
-
return [error, undefined];
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
2590
|
-
}
|
|
2591
|
-
/**
|
|
2592
|
-
* Searches for resources.
|
|
2593
|
-
*
|
|
2594
|
-
* See: https://www.hl7.org/fhir/http.html#search
|
|
2595
|
-
*
|
|
2596
|
-
* @param searchRequest The search request.
|
|
2597
|
-
* @returns The search result bundle.
|
|
2598
|
-
* @deprecated
|
|
2599
|
-
*/
|
|
2600
|
-
search(query) {
|
|
2601
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2602
|
-
const searchRequest = typeof query === 'string' ? parseSearchDefinition(query) : query;
|
|
2603
|
-
try {
|
|
2604
|
-
const bundle = yield __classPrivateFieldGet(this, _LegacyRepositoryClient_client, "f").search(searchRequest);
|
|
2605
|
-
return [allOk, bundle];
|
|
2606
|
-
}
|
|
2607
|
-
catch (error) {
|
|
2608
|
-
return [error, undefined];
|
|
2609
|
-
}
|
|
2610
|
-
});
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
_LegacyRepositoryClient_client = new WeakMap();
|
|
2614
|
-
|
|
2615
2533
|
exports.SearchParameterType = void 0;
|
|
2616
2534
|
(function (SearchParameterType) {
|
|
2617
2535
|
SearchParameterType["BOOLEAN"] = "BOOLEAN";
|
|
@@ -2744,9 +2662,10 @@
|
|
|
2744
2662
|
exports.Hl7Field = Hl7Field;
|
|
2745
2663
|
exports.Hl7Message = Hl7Message;
|
|
2746
2664
|
exports.Hl7Segment = Hl7Segment;
|
|
2747
|
-
exports.
|
|
2665
|
+
exports.LRUCache = LRUCache;
|
|
2748
2666
|
exports.MedplumClient = MedplumClient;
|
|
2749
2667
|
exports.OperationOutcomeError = OperationOutcomeError;
|
|
2668
|
+
exports.ReadablePromise = ReadablePromise;
|
|
2750
2669
|
exports.SEGMENT_SEPARATOR = SEGMENT_SEPARATOR;
|
|
2751
2670
|
exports.accessDenied = accessDenied;
|
|
2752
2671
|
exports.allOk = allOk;
|
|
@@ -2788,6 +2707,7 @@
|
|
|
2788
2707
|
exports.isOk = isOk;
|
|
2789
2708
|
exports.isProfileResource = isProfileResource;
|
|
2790
2709
|
exports.isStringArray = isStringArray;
|
|
2710
|
+
exports.isUUID = isUUID;
|
|
2791
2711
|
exports.notFound = notFound;
|
|
2792
2712
|
exports.notModified = notModified;
|
|
2793
2713
|
exports.parseSearchDefinition = parseSearchDefinition;
|