@nsshunt/stsfhirclient 1.0.7 → 1.0.8
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/stsfhirclient.mjs
CHANGED
|
@@ -8,12 +8,11 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
8
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
11
|
+
var _options, _DUMMY_USER, _httpsAgent, _invokeMethods, _maxRetries, _sleepDuration, _NoRetryStatusCodes, _stsfhirapiroot, _LogDebugMessage, _LogErrorMessage, _GetHttpsAgent, _HandleError, _InvokeResourceAPI, _TestMode, ___InvokeResourceAPI;
|
|
12
12
|
import https from "node:https";
|
|
13
13
|
import axios from "axios";
|
|
14
14
|
import { Sleep } from "@nsshunt/stsutils";
|
|
15
15
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
16
|
-
import { goptions } from "@nsshunt/stsconfig";
|
|
17
16
|
var IFhirPersistenceType = /* @__PURE__ */ ((IFhirPersistenceType2) => {
|
|
18
17
|
IFhirPersistenceType2["postgresResources"] = "postgresResources";
|
|
19
18
|
IFhirPersistenceType2["postgresResourcesEntities"] = "postgresResourcesEntities";
|
|
@@ -1543,6 +1542,7 @@ var StatusCodes;
|
|
|
1543
1542
|
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
1544
1543
|
})(StatusCodes || (StatusCodes = {}));
|
|
1545
1544
|
class FhirClient {
|
|
1545
|
+
// Default value
|
|
1546
1546
|
constructor(options) {
|
|
1547
1547
|
__privateAdd(this, _options);
|
|
1548
1548
|
__privateAdd(this, _DUMMY_USER, "USR_user01@stsmda.com.au");
|
|
@@ -1555,6 +1555,7 @@ class FhirClient {
|
|
|
1555
1555
|
StatusCodes.NOT_FOUND,
|
|
1556
1556
|
StatusCodes.CONFLICT
|
|
1557
1557
|
]);
|
|
1558
|
+
__privateAdd(this, _stsfhirapiroot, "/stsfhir/r5");
|
|
1558
1559
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1559
1560
|
__privateAdd(this, _LogDebugMessage, (message) => {
|
|
1560
1561
|
__privateGet(this, _options).logger.debug(message);
|
|
@@ -1565,14 +1566,18 @@ class FhirClient {
|
|
|
1565
1566
|
});
|
|
1566
1567
|
__privateAdd(this, _GetHttpsAgent, () => {
|
|
1567
1568
|
if (__privateGet(this, _httpsAgent) === null) {
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1569
|
+
if (__privateGet(this, _options).agentOptions) {
|
|
1570
|
+
__privateSet(this, _httpsAgent, new https.Agent({
|
|
1571
|
+
keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
|
|
1572
|
+
maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
|
|
1573
|
+
maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
|
|
1574
|
+
maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
|
|
1575
|
+
timeout: __privateGet(this, _options).agentOptions.timeout,
|
|
1576
|
+
rejectUnauthorized: __privateGet(this, _options).agentOptions.rejectUnauthorized
|
|
1577
|
+
}));
|
|
1578
|
+
} else {
|
|
1579
|
+
__privateSet(this, _httpsAgent, new https.Agent());
|
|
1580
|
+
}
|
|
1576
1581
|
}
|
|
1577
1582
|
return __privateGet(this, _httpsAgent);
|
|
1578
1583
|
});
|
|
@@ -1728,7 +1733,7 @@ class FhirClient {
|
|
|
1728
1733
|
}
|
|
1729
1734
|
});
|
|
1730
1735
|
__publicField(this, "GetResource", async (resource, id, filters, errorCb) => {
|
|
1731
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1736
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
1732
1737
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
1733
1738
|
if (response) {
|
|
1734
1739
|
return response.data;
|
|
@@ -1737,7 +1742,7 @@ class FhirClient {
|
|
|
1737
1742
|
}
|
|
1738
1743
|
});
|
|
1739
1744
|
__publicField(this, "GetResources", async (resource, filters, errorCb) => {
|
|
1740
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1745
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1741
1746
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "get", null, filters, errorCb);
|
|
1742
1747
|
if (response) {
|
|
1743
1748
|
return response.data;
|
|
@@ -1746,7 +1751,7 @@ class FhirClient {
|
|
|
1746
1751
|
}
|
|
1747
1752
|
});
|
|
1748
1753
|
__publicField(this, "CreateResource", async (resource, domainResource, errorCb) => {
|
|
1749
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1754
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1750
1755
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "post", domainResource, null, errorCb);
|
|
1751
1756
|
if (response) {
|
|
1752
1757
|
if (response.status === StatusCodes.CREATED) {
|
|
@@ -1760,7 +1765,7 @@ class FhirClient {
|
|
|
1760
1765
|
}
|
|
1761
1766
|
});
|
|
1762
1767
|
__publicField(this, "UpdateResource", async (resource, domainResource, errorCb) => {
|
|
1763
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1768
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
1764
1769
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResource, null, errorCb);
|
|
1765
1770
|
if (response) {
|
|
1766
1771
|
return response.data;
|
|
@@ -1769,7 +1774,7 @@ class FhirClient {
|
|
|
1769
1774
|
}
|
|
1770
1775
|
});
|
|
1771
1776
|
__publicField(this, "UpdateResources", async (resource, domainResources, errorCb) => {
|
|
1772
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1777
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1773
1778
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "put", domainResources, null, errorCb);
|
|
1774
1779
|
if (response) {
|
|
1775
1780
|
return response.data;
|
|
@@ -1778,7 +1783,7 @@ class FhirClient {
|
|
|
1778
1783
|
}
|
|
1779
1784
|
});
|
|
1780
1785
|
__publicField(this, "PatchResource", async (resource, domainResource, errorCb) => {
|
|
1781
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1786
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${domainResource.id}`;
|
|
1782
1787
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResource, null, errorCb);
|
|
1783
1788
|
if (response) {
|
|
1784
1789
|
return response.data;
|
|
@@ -1787,7 +1792,7 @@ class FhirClient {
|
|
|
1787
1792
|
}
|
|
1788
1793
|
});
|
|
1789
1794
|
__publicField(this, "PatchResources", async (resource, domainResources, errorCb) => {
|
|
1790
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1795
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1791
1796
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "patch", domainResources, null, errorCb);
|
|
1792
1797
|
if (response) {
|
|
1793
1798
|
return response.data;
|
|
@@ -1796,7 +1801,7 @@ class FhirClient {
|
|
|
1796
1801
|
}
|
|
1797
1802
|
});
|
|
1798
1803
|
__publicField(this, "DeleteResource", async (resource, id, errorCb) => {
|
|
1799
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1804
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
1800
1805
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", null, null, errorCb);
|
|
1801
1806
|
if (response) {
|
|
1802
1807
|
return response.data;
|
|
@@ -1805,7 +1810,7 @@ class FhirClient {
|
|
|
1805
1810
|
}
|
|
1806
1811
|
});
|
|
1807
1812
|
__publicField(this, "DeleteResources", async (resource, domainResources, errorCb) => {
|
|
1808
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1813
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}`;
|
|
1809
1814
|
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url, "delete", domainResources, null, errorCb);
|
|
1810
1815
|
if (response) {
|
|
1811
1816
|
return response.data;
|
|
@@ -1814,7 +1819,7 @@ class FhirClient {
|
|
|
1814
1819
|
}
|
|
1815
1820
|
});
|
|
1816
1821
|
__publicField(this, "GetLatency", async () => {
|
|
1817
|
-
const url = `${__privateGet(this, _options).fhirEndpoint}${
|
|
1822
|
+
const url = `${__privateGet(this, _options).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/latency`;
|
|
1818
1823
|
try {
|
|
1819
1824
|
const headers = {
|
|
1820
1825
|
"Content-Type": "application/json"
|
|
@@ -1834,6 +1839,9 @@ class FhirClient {
|
|
|
1834
1839
|
}
|
|
1835
1840
|
});
|
|
1836
1841
|
__privateSet(this, _options, options);
|
|
1842
|
+
if (__privateGet(this, _options).stsfhirapiroot !== void 0) {
|
|
1843
|
+
__privateSet(this, _stsfhirapiroot, __privateGet(this, _options).stsfhirapiroot);
|
|
1844
|
+
}
|
|
1837
1845
|
}
|
|
1838
1846
|
get options() {
|
|
1839
1847
|
return __privateGet(this, _options);
|
|
@@ -1846,6 +1854,7 @@ _invokeMethods = new WeakMap();
|
|
|
1846
1854
|
_maxRetries = new WeakMap();
|
|
1847
1855
|
_sleepDuration = new WeakMap();
|
|
1848
1856
|
_NoRetryStatusCodes = new WeakMap();
|
|
1857
|
+
_stsfhirapiroot = new WeakMap();
|
|
1849
1858
|
_LogDebugMessage = new WeakMap();
|
|
1850
1859
|
_LogErrorMessage = new WeakMap();
|
|
1851
1860
|
_GetHttpsAgent = new WeakMap();
|