@nsshunt/stsfhirclient 1.1.3 → 1.1.4
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 +679 -720
- package/dist/stsfhirclient.mjs.map +1 -1
- package/dist/stsfhirclient.umd.js +680 -721
- package/dist/stsfhirclient.umd.js.map +1 -1
- package/package.json +14 -15
- package/types/FhirClient.d.ts +1 -1
- package/types/FhirClient.d.ts.map +1 -1
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("axios"), require("@nsshunt/stsutils")) : typeof define === "function" && define.amd ? define(["exports", "axios", "@nsshunt/stsutils"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nsshunt/stsfhirclient"] = {}, global.axios, global.stsutils));
|
|
3
3
|
})(this, (function(exports2, axios, stsutils) {
|
|
4
|
-
"use strict";
|
|
5
|
-
var __typeError = (msg) => {
|
|
6
|
-
throw TypeError(msg);
|
|
7
|
-
};
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
11
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
12
|
-
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);
|
|
13
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
14
|
-
|
|
15
|
-
var _socketUtils, _id, _options2, _clientName, _debug, _error, _info, _SetupWSSClient, _OnSocketConnected, _options3, _DUMMY_USER, _stsfhirapiroot, _fhirSocketClient, _LogDebugMessage, _HandleError, _BuildQueryString, _InvokeResourceAPI;
|
|
4
|
+
"use strict";
|
|
16
5
|
const isNode$1 = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
17
6
|
function getDefaultExportFromCjs(x) {
|
|
18
7
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -4830,25 +4819,23 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
4830
4819
|
io: lookup,
|
|
4831
4820
|
connect: lookup
|
|
4832
4821
|
});
|
|
4833
|
-
var __typeError2 = (msg) => {
|
|
4834
|
-
throw TypeError(msg);
|
|
4835
|
-
};
|
|
4836
|
-
var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
|
|
4837
|
-
var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
4838
|
-
var __privateAdd2 = (obj, member, value2) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value2);
|
|
4839
|
-
var __privateSet2 = (obj, member, value2, setter) => (__accessCheck2(obj, member, "write to private field"), member.set(obj, value2), value2);
|
|
4840
|
-
var __privateMethod = (obj, member, method) => (__accessCheck2(obj, member, "access private method"), method);
|
|
4841
|
-
var _options, _sockets, _SocketIoClientHelper_instances, LogDebugMessage_fn, LogErrorMessage_fn, EstablishSocketConnect_fn;
|
|
4842
4822
|
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
4843
4823
|
class SocketIoClientHelper {
|
|
4824
|
+
#options;
|
|
4825
|
+
#sockets = {};
|
|
4844
4826
|
constructor(options) {
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4827
|
+
this.#options = options;
|
|
4828
|
+
}
|
|
4829
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4830
|
+
#LogDebugMessage(message) {
|
|
4831
|
+
if (this.#options.logger) this.#options.logger.debug(message);
|
|
4832
|
+
}
|
|
4833
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4834
|
+
#LogErrorMessage(message) {
|
|
4835
|
+
if (this.#options.logger) this.#options.logger.error(message);
|
|
4849
4836
|
}
|
|
4850
4837
|
get sockets() {
|
|
4851
|
-
return
|
|
4838
|
+
return this.#sockets;
|
|
4852
4839
|
}
|
|
4853
4840
|
SetupClientSideSocket(name, address, socketIoCustomPath, onConnectCallBack, socketEventsCallBack, errorCallBack) {
|
|
4854
4841
|
this.sockets[name] = {
|
|
@@ -4857,7 +4844,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
4857
4844
|
socket: null,
|
|
4858
4845
|
errorCallBack
|
|
4859
4846
|
};
|
|
4860
|
-
|
|
4847
|
+
this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack);
|
|
4861
4848
|
return this.sockets[name].socket;
|
|
4862
4849
|
}
|
|
4863
4850
|
GetSocket(name) {
|
|
@@ -4866,127 +4853,117 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
4866
4853
|
GetSocketDetail(name) {
|
|
4867
4854
|
return this.sockets[name];
|
|
4868
4855
|
}
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
if (socketDetail.socket.connected === true) {
|
|
4883
|
-
socketDetail.socket.disconnect();
|
|
4856
|
+
#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack) {
|
|
4857
|
+
const socketDetail = this.sockets[name];
|
|
4858
|
+
if (socketDetail.socket !== null) {
|
|
4859
|
+
if (socketDetail.socket.connected === true) {
|
|
4860
|
+
socketDetail.socket.disconnect();
|
|
4861
|
+
}
|
|
4862
|
+
socketDetail.socket = null;
|
|
4863
|
+
if (isNode) {
|
|
4864
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
4865
|
+
} else {
|
|
4866
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100);
|
|
4867
|
+
}
|
|
4868
|
+
return;
|
|
4884
4869
|
}
|
|
4885
|
-
|
|
4870
|
+
let socketOptions;
|
|
4886
4871
|
if (isNode) {
|
|
4887
|
-
|
|
4872
|
+
socketOptions = {
|
|
4873
|
+
transports: ["websocket"]
|
|
4874
|
+
};
|
|
4875
|
+
if (this.#options.agentManager) {
|
|
4876
|
+
socketOptions.agent = this.#options.agentManager.GetAgent(socketDetail.address);
|
|
4877
|
+
}
|
|
4888
4878
|
} else {
|
|
4889
|
-
|
|
4879
|
+
socketOptions = {
|
|
4880
|
+
transports: ["websocket"]
|
|
4881
|
+
};
|
|
4890
4882
|
}
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
let socketOptions;
|
|
4894
|
-
if (isNode) {
|
|
4895
|
-
socketOptions = {
|
|
4896
|
-
transports: ["websocket"]
|
|
4897
|
-
};
|
|
4898
|
-
if (__privateGet2(this, _options).agentManager) {
|
|
4899
|
-
socketOptions.agent = __privateGet2(this, _options).agentManager.GetAgent(socketDetail.address);
|
|
4883
|
+
if (socketIoCustomPath && socketIoCustomPath.localeCompare("") !== 0) {
|
|
4884
|
+
socketOptions.path = socketIoCustomPath;
|
|
4900
4885
|
}
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
};
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
}
|
|
4933
|
-
if (socketEventsCallBack) {
|
|
4934
|
-
socketEventsCallBack(socketDetail.socket);
|
|
4886
|
+
socketDetail.socket = lookup(socketDetail.address, socketOptions);
|
|
4887
|
+
socketDetail.socket.io.on("error", (err) => {
|
|
4888
|
+
this.#LogErrorMessage(`SocketIoClientHelper(): socketDetail.socket.io.on('error'): [${err}]`);
|
|
4889
|
+
});
|
|
4890
|
+
socketDetail.socket.io.on("reconnect_error", (err) => {
|
|
4891
|
+
this.#LogErrorMessage(`SocketIoClientHelper(): socketDetail.socket.io.on('reconnect_error'): [${err}]`);
|
|
4892
|
+
});
|
|
4893
|
+
socketDetail.socket.io.on("reconnect", (attempt) => {
|
|
4894
|
+
this.#LogErrorMessage(`SocketIoClientHelper(): socketDetail.socket.io.on('reconnect'): Number: [${attempt}]`);
|
|
4895
|
+
});
|
|
4896
|
+
socketDetail.socket.on("connect_error", (err) => {
|
|
4897
|
+
this.#LogErrorMessage(`SocketIoClientHelper(): socketDetail.socket.on('connect_error'): [${err}]`);
|
|
4898
|
+
});
|
|
4899
|
+
socketDetail.socket.on("connect_timeout", () => {
|
|
4900
|
+
this.#LogErrorMessage(`SocketIoClientHelper(): socketDetail.socket.on('connect_timeout')`);
|
|
4901
|
+
});
|
|
4902
|
+
socketDetail.socket.on("connect", () => {
|
|
4903
|
+
if (socketDetail.socket) {
|
|
4904
|
+
this.#LogDebugMessage(`SocketIoClientHelper(): Socket: [${socketDetail.socket.id}]: connected`);
|
|
4905
|
+
if (onConnectCallBack) {
|
|
4906
|
+
setTimeout(() => {
|
|
4907
|
+
onConnectCallBack(socketDetail.socket);
|
|
4908
|
+
}, 0);
|
|
4909
|
+
}
|
|
4910
|
+
if (socketEventsCallBack) {
|
|
4911
|
+
socketEventsCallBack(socketDetail.socket);
|
|
4912
|
+
}
|
|
4913
|
+
} else {
|
|
4914
|
+
const errorMessage = "SocketIoClientHelper(): Could not get socket object from socket.io";
|
|
4915
|
+
this.#LogErrorMessage(errorMessage);
|
|
4916
|
+
socketDetail.errorCallBack(new Error(errorMessage));
|
|
4935
4917
|
}
|
|
4936
|
-
}
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
if (__privateGet2(this, _options).agentManager) {
|
|
4954
|
-
__privateGet2(this, _options).agentManager.ResetAgent();
|
|
4918
|
+
});
|
|
4919
|
+
socketDetail.socket.on("disconnect", (reason) => {
|
|
4920
|
+
this.#LogDebugMessage("SocketIoClientHelper(): socket disconnect: " + reason);
|
|
4921
|
+
switch (reason) {
|
|
4922
|
+
case "io server disconnect":
|
|
4923
|
+
{
|
|
4924
|
+
this.#LogDebugMessage("SocketIoClientHelper(): The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
|
|
4925
|
+
this.#LogDebugMessage("SocketIoClientHelper(): The connection will be re-established when the server becomes available.");
|
|
4926
|
+
const socketDetail2 = this.sockets[name];
|
|
4927
|
+
socketDetail2.socket = null;
|
|
4928
|
+
if (isNode) {
|
|
4929
|
+
if (this.#options.agentManager) {
|
|
4930
|
+
this.#options.agentManager.ResetAgent();
|
|
4931
|
+
}
|
|
4932
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
4933
|
+
} else {
|
|
4934
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100);
|
|
4955
4935
|
}
|
|
4956
|
-
setTimeout(() => __privateMethod(this, _SocketIoClientHelper_instances, EstablishSocketConnect_fn).call(this, name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
4957
|
-
} else {
|
|
4958
|
-
setTimeout(() => __privateMethod(this, _SocketIoClientHelper_instances, EstablishSocketConnect_fn).call(this, name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100);
|
|
4959
4936
|
}
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4937
|
+
break;
|
|
4938
|
+
case "io client disconnect":
|
|
4939
|
+
this.#LogDebugMessage("SocketIoClientHelper(): The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
|
|
4940
|
+
this.#LogDebugMessage("SocketIoClientHelper(): The connection will not be re-established automatically.");
|
|
4941
|
+
break;
|
|
4942
|
+
case "transport close":
|
|
4943
|
+
case "ping timeout":
|
|
4944
|
+
case "transport error":
|
|
4945
|
+
{
|
|
4946
|
+
this.#LogDebugMessage(`SocketIoClientHelper(): Server unexpectedly disconnected. Reason: [${reason}]`);
|
|
4947
|
+
this.#LogDebugMessage("SocketIoClientHelper(): The connection will be re-established when the server becomes available.");
|
|
4948
|
+
const socketDetail2 = this.sockets[name];
|
|
4949
|
+
if (socketDetail2.socket) {
|
|
4950
|
+
socketDetail2.socket.disconnect();
|
|
4951
|
+
}
|
|
4952
|
+
socketDetail2.socket = null;
|
|
4953
|
+
if (isNode) {
|
|
4954
|
+
if (this.#options.agentManager) {
|
|
4955
|
+
this.#options.agentManager?.ResetAgent();
|
|
4956
|
+
}
|
|
4957
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
4958
|
+
} else {
|
|
4959
|
+
setTimeout(() => this.#EstablishSocketConnect(name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100);
|
|
4980
4960
|
}
|
|
4981
|
-
setTimeout(() => __privateMethod(this, _SocketIoClientHelper_instances, EstablishSocketConnect_fn).call(this, name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100).unref();
|
|
4982
|
-
} else {
|
|
4983
|
-
setTimeout(() => __privateMethod(this, _SocketIoClientHelper_instances, EstablishSocketConnect_fn).call(this, name, socketIoCustomPath, onConnectCallBack, socketEventsCallBack), 100);
|
|
4984
4961
|
}
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
}
|
|
4962
|
+
break;
|
|
4963
|
+
}
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4990
4967
|
const byteToHex = [];
|
|
4991
4968
|
for (let i = 0; i < 256; ++i) {
|
|
4992
4969
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -5007,13 +4984,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5007
4984
|
}
|
|
5008
4985
|
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
5009
4986
|
const native = { randomUUID };
|
|
5010
|
-
function
|
|
5011
|
-
var _a;
|
|
5012
|
-
if (native.randomUUID && true && !options) {
|
|
5013
|
-
return native.randomUUID();
|
|
5014
|
-
}
|
|
4987
|
+
function _v4(options, buf, offset) {
|
|
5015
4988
|
options = options || {};
|
|
5016
|
-
const rnds = options.random ??
|
|
4989
|
+
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
5017
4990
|
if (rnds.length < 16) {
|
|
5018
4991
|
throw new Error("Random bytes length must be >= 16");
|
|
5019
4992
|
}
|
|
@@ -5021,332 +4994,329 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5021
4994
|
rnds[8] = rnds[8] & 63 | 128;
|
|
5022
4995
|
return unsafeStringify(rnds);
|
|
5023
4996
|
}
|
|
4997
|
+
function v4(options, buf, offset) {
|
|
4998
|
+
if (native.randomUUID && true && !options) {
|
|
4999
|
+
return native.randomUUID();
|
|
5000
|
+
}
|
|
5001
|
+
return _v4(options);
|
|
5002
|
+
}
|
|
5024
5003
|
class FhirSocketClient {
|
|
5004
|
+
#socketUtils;
|
|
5005
|
+
#id = v4();
|
|
5006
|
+
#options;
|
|
5007
|
+
#clientName;
|
|
5025
5008
|
constructor(options) {
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5009
|
+
this.#options = options;
|
|
5010
|
+
this.#socketUtils = new SocketIoClientHelper(this.#options.socketIoClientHelperOptions);
|
|
5011
|
+
const clientName = v4();
|
|
5012
|
+
this.#clientName = clientName;
|
|
5013
|
+
this.#SetupWSSClient(clientName, []);
|
|
5014
|
+
}
|
|
5015
|
+
#debug = (message) => stsutils.defaultLogger.debug(message);
|
|
5016
|
+
#error = (error) => stsutils.defaultLogger.error(error);
|
|
5017
|
+
#info = (message) => stsutils.defaultLogger.info(message);
|
|
5018
|
+
#SetupWSSClient = async (clientName, joinRooms) => {
|
|
5019
|
+
console.log(chalk.yellow(`FhirSocketClient:#SetupWSSClient(): ID: [${this.#id}] clientName: [${clientName}] Starting ...`));
|
|
5020
|
+
const cstr = `${this.#options.fhirServerEndpoint}/nsstsfhir/`;
|
|
5021
|
+
console.log(chalk.yellow(`FhirSocketClient:#SetupWSSClient(): Socket connection string: [${cstr}]`));
|
|
5022
|
+
this.#socketUtils.SetupClientSideSocket(
|
|
5023
|
+
this.#options.socketClientName,
|
|
5024
|
+
// 'ststestrunner',
|
|
5025
|
+
cstr,
|
|
5026
|
+
// `https://stscore.stsmda.org:3005/nsstsfhir/` this.#options.ststccendpoint, stsfhir as the namespace
|
|
5027
|
+
this.#options.socketIoCustomPath,
|
|
5028
|
+
// '/stsfhirsocket/socket.io/',
|
|
5029
|
+
// Connected Callback
|
|
5030
|
+
(socket2) => this.#OnSocketConnected(socket2, clientName, joinRooms),
|
|
5031
|
+
// Events Registration
|
|
5032
|
+
(socket2) => {
|
|
5033
|
+
},
|
|
5034
|
+
// Error Callback
|
|
5035
|
+
(error) => this.#error(`FhirSocketClient:#SetupWSSClient(): Error clientName: [${clientName}]: SetupClientSideSocket call back: Error: [${error}]`)
|
|
5036
|
+
);
|
|
5037
|
+
console.log(chalk.yellow(`FhirSocketClient:#SetupWSSClient(): ID: [${this.#id}] clientName: [${clientName}] Started`));
|
|
5038
|
+
};
|
|
5039
|
+
// Handle connection logic separately
|
|
5040
|
+
#OnSocketConnected = (socket, clientName, joinRooms) => {
|
|
5041
|
+
this.#debug(chalk.green(`FhirSocketClient:#OnSocketConnected(): ID: [${this.#id}] clientName: [${clientName}]: --> connected`));
|
|
5042
|
+
if (joinRooms.length > 0) {
|
|
5043
|
+
socket.emit("__STSjoinRoom", joinRooms);
|
|
5044
|
+
}
|
|
5045
|
+
};
|
|
5046
|
+
WaitForSocketConnected = async () => {
|
|
5047
|
+
const socket = this.#socketUtils.GetSocket(this.#options.socketClientName);
|
|
5048
|
+
if (socket && socket.connected === true) {
|
|
5049
|
+
return;
|
|
5050
|
+
}
|
|
5051
|
+
console.log(chalk.yellow(`FhirSocketClient:#WaitForSocketConnected(): ID: [${this.#id}] clientName: [${this.#clientName}] Waiting for connection ...`));
|
|
5052
|
+
let connected = false;
|
|
5053
|
+
let attempts = 0;
|
|
5054
|
+
while (!connected) {
|
|
5055
|
+
attempts++;
|
|
5056
|
+
if (attempts % 10 === 0) {
|
|
5057
|
+
console.log(chalk.yellow(`FhirSocketClient:#WaitForSocketConnected(): ID: [${this.#id}] clientName: [${this.#clientName}] waiting for connection attempts: [${attempts}].`));
|
|
5065
5058
|
}
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
if (attempts % 10 === 0) {
|
|
5072
|
-
console.log(chalk.yellow(`FhirSocketClient:#WaitForSocketConnected(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] waiting for connection attempts: [${attempts}].`));
|
|
5073
|
-
}
|
|
5074
|
-
const socketRetVal = __privateGet(this, _socketUtils).GetSocket(__privateGet(this, _options2).socketClientName);
|
|
5075
|
-
if (socketRetVal && socketRetVal.connected === true) {
|
|
5076
|
-
connected = true;
|
|
5077
|
-
console.log(chalk.yellow(`FhirSocketClient:#WaitForSocketConnected(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Connection completed after: [${attempts}] attempts.`));
|
|
5078
|
-
break;
|
|
5079
|
-
}
|
|
5080
|
-
await stsutils.Sleep(100);
|
|
5059
|
+
const socketRetVal = this.#socketUtils.GetSocket(this.#options.socketClientName);
|
|
5060
|
+
if (socketRetVal && socketRetVal.connected === true) {
|
|
5061
|
+
connected = true;
|
|
5062
|
+
console.log(chalk.yellow(`FhirSocketClient:#WaitForSocketConnected(): ID: [${this.#id}] clientName: [${this.#clientName}] Connection completed after: [${attempts}] attempts.`));
|
|
5063
|
+
break;
|
|
5081
5064
|
}
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
reject(err);
|
|
5099
|
-
} else {
|
|
5100
|
-
resolve(res);
|
|
5101
|
-
}
|
|
5102
|
-
});
|
|
5103
|
-
});
|
|
5065
|
+
await stsutils.Sleep(100);
|
|
5066
|
+
}
|
|
5067
|
+
};
|
|
5068
|
+
get socket() {
|
|
5069
|
+
return this.#socketUtils.GetSocket(this.#options.socketClientName);
|
|
5070
|
+
}
|
|
5071
|
+
CreateResource = async (resource, domainResource) => {
|
|
5072
|
+
await this.WaitForSocketConnected();
|
|
5073
|
+
const promCreate = () => {
|
|
5074
|
+
const request = {
|
|
5075
|
+
headers: {
|
|
5076
|
+
"x-sts_user_id": "someuser"
|
|
5077
|
+
},
|
|
5078
|
+
params: {},
|
|
5079
|
+
query: {},
|
|
5080
|
+
body: domainResource
|
|
5104
5081
|
};
|
|
5105
|
-
return
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
},
|
|
5114
|
-
params: {},
|
|
5115
|
-
query: {},
|
|
5116
|
-
body: domainResources
|
|
5117
|
-
};
|
|
5118
|
-
return new Promise((resolve, reject) => {
|
|
5119
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("createFhirResources", resource, request, (err, res) => {
|
|
5120
|
-
if (err) {
|
|
5121
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:CreateResources(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5122
|
-
reject(err);
|
|
5123
|
-
} else {
|
|
5124
|
-
resolve(res);
|
|
5125
|
-
}
|
|
5126
|
-
});
|
|
5082
|
+
return new Promise((resolve, reject) => {
|
|
5083
|
+
this.socket.timeout(this.#options.timeout).emit("createFhirResource", resource, request, (err, res) => {
|
|
5084
|
+
if (err) {
|
|
5085
|
+
this.#error(`FhirSocketClient:CreateResource(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5086
|
+
reject(err);
|
|
5087
|
+
} else {
|
|
5088
|
+
resolve(res);
|
|
5089
|
+
}
|
|
5127
5090
|
});
|
|
5091
|
+
});
|
|
5092
|
+
};
|
|
5093
|
+
return promCreate();
|
|
5094
|
+
};
|
|
5095
|
+
CreateResources = async (resource, domainResources) => {
|
|
5096
|
+
await this.WaitForSocketConnected();
|
|
5097
|
+
const promCreate = () => {
|
|
5098
|
+
const request = {
|
|
5099
|
+
headers: {
|
|
5100
|
+
"x-sts_user_id": "someuser"
|
|
5101
|
+
},
|
|
5102
|
+
params: {},
|
|
5103
|
+
query: {},
|
|
5104
|
+
body: domainResources
|
|
5128
5105
|
};
|
|
5129
|
-
return (
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
},
|
|
5138
|
-
params: {},
|
|
5139
|
-
query: {
|
|
5140
|
-
fhirResource: resourceId
|
|
5141
|
-
},
|
|
5142
|
-
body: {}
|
|
5143
|
-
};
|
|
5144
|
-
return new Promise((resolve, reject) => {
|
|
5145
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("getFhirResource", resource, request, (err, res) => {
|
|
5146
|
-
if (err) {
|
|
5147
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:GetResource(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5148
|
-
reject(err);
|
|
5149
|
-
} else {
|
|
5150
|
-
resolve(res);
|
|
5151
|
-
}
|
|
5152
|
-
});
|
|
5106
|
+
return new Promise((resolve, reject) => {
|
|
5107
|
+
this.socket.timeout(this.#options.timeout).emit("createFhirResources", resource, request, (err, res) => {
|
|
5108
|
+
if (err) {
|
|
5109
|
+
this.#error(`FhirSocketClient:CreateResources(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5110
|
+
reject(err);
|
|
5111
|
+
} else {
|
|
5112
|
+
resolve(res);
|
|
5113
|
+
}
|
|
5153
5114
|
});
|
|
5115
|
+
});
|
|
5116
|
+
};
|
|
5117
|
+
return (await promCreate()).value;
|
|
5118
|
+
};
|
|
5119
|
+
GetResource = async (resource, resourceId) => {
|
|
5120
|
+
await this.WaitForSocketConnected();
|
|
5121
|
+
const promGet = () => {
|
|
5122
|
+
const request = {
|
|
5123
|
+
headers: {
|
|
5124
|
+
"x-sts_user_id": "someuser"
|
|
5125
|
+
},
|
|
5126
|
+
params: {},
|
|
5127
|
+
query: {
|
|
5128
|
+
fhirResource: resourceId
|
|
5129
|
+
},
|
|
5130
|
+
body: {}
|
|
5154
5131
|
};
|
|
5155
|
-
return
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
},
|
|
5164
|
-
params: {},
|
|
5165
|
-
query: searchParams ? searchParams : {},
|
|
5166
|
-
body: {}
|
|
5167
|
-
};
|
|
5168
|
-
return new Promise((resolve, reject) => {
|
|
5169
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("getFhirResources", resource, request, (err, res) => {
|
|
5170
|
-
if (err) {
|
|
5171
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:GetResources(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5172
|
-
reject(err);
|
|
5173
|
-
} else {
|
|
5174
|
-
resolve(res);
|
|
5175
|
-
}
|
|
5176
|
-
});
|
|
5132
|
+
return new Promise((resolve, reject) => {
|
|
5133
|
+
this.socket.timeout(this.#options.timeout).emit("getFhirResource", resource, request, (err, res) => {
|
|
5134
|
+
if (err) {
|
|
5135
|
+
this.#error(`FhirSocketClient:GetResource(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5136
|
+
reject(err);
|
|
5137
|
+
} else {
|
|
5138
|
+
resolve(res);
|
|
5139
|
+
}
|
|
5177
5140
|
});
|
|
5141
|
+
});
|
|
5142
|
+
};
|
|
5143
|
+
return promGet();
|
|
5144
|
+
};
|
|
5145
|
+
GetResources = async (resource, searchParams) => {
|
|
5146
|
+
await this.WaitForSocketConnected();
|
|
5147
|
+
const promGet = () => {
|
|
5148
|
+
const request = {
|
|
5149
|
+
headers: {
|
|
5150
|
+
"x-sts_user_id": "someuser"
|
|
5151
|
+
},
|
|
5152
|
+
params: {},
|
|
5153
|
+
query: searchParams ? searchParams : {},
|
|
5154
|
+
body: {}
|
|
5178
5155
|
};
|
|
5179
|
-
return (
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
},
|
|
5188
|
-
params: {},
|
|
5189
|
-
query: {
|
|
5190
|
-
fhirResource: domainResource.id
|
|
5191
|
-
},
|
|
5192
|
-
body: domainResource
|
|
5193
|
-
};
|
|
5194
|
-
return new Promise((resolve, reject) => {
|
|
5195
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("updateFhirResource", resource, request, (err, res) => {
|
|
5196
|
-
if (err) {
|
|
5197
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:UpdateResource(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5198
|
-
reject(err);
|
|
5199
|
-
} else {
|
|
5200
|
-
resolve(res);
|
|
5201
|
-
}
|
|
5202
|
-
});
|
|
5156
|
+
return new Promise((resolve, reject) => {
|
|
5157
|
+
this.socket.timeout(this.#options.timeout).emit("getFhirResources", resource, request, (err, res) => {
|
|
5158
|
+
if (err) {
|
|
5159
|
+
this.#error(`FhirSocketClient:GetResources(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5160
|
+
reject(err);
|
|
5161
|
+
} else {
|
|
5162
|
+
resolve(res);
|
|
5163
|
+
}
|
|
5203
5164
|
});
|
|
5165
|
+
});
|
|
5166
|
+
};
|
|
5167
|
+
return (await promGet()).value;
|
|
5168
|
+
};
|
|
5169
|
+
UpdateResource = async (resource, domainResource) => {
|
|
5170
|
+
await this.WaitForSocketConnected();
|
|
5171
|
+
const promCreate = () => {
|
|
5172
|
+
const request = {
|
|
5173
|
+
headers: {
|
|
5174
|
+
"x-sts_user_id": "someuser"
|
|
5175
|
+
},
|
|
5176
|
+
params: {},
|
|
5177
|
+
query: {
|
|
5178
|
+
fhirResource: domainResource.id
|
|
5179
|
+
},
|
|
5180
|
+
body: domainResource
|
|
5204
5181
|
};
|
|
5205
|
-
return (
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
},
|
|
5214
|
-
params: {},
|
|
5215
|
-
query: {},
|
|
5216
|
-
body: domainResources
|
|
5217
|
-
};
|
|
5218
|
-
return new Promise((resolve, reject) => {
|
|
5219
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("updateFhirResources", resource, request, (err, res) => {
|
|
5220
|
-
if (err) {
|
|
5221
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:UpdateResources(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5222
|
-
reject(err);
|
|
5223
|
-
} else {
|
|
5224
|
-
resolve(res);
|
|
5225
|
-
}
|
|
5226
|
-
});
|
|
5182
|
+
return new Promise((resolve, reject) => {
|
|
5183
|
+
this.socket.timeout(this.#options.timeout).emit("updateFhirResource", resource, request, (err, res) => {
|
|
5184
|
+
if (err) {
|
|
5185
|
+
this.#error(`FhirSocketClient:UpdateResource(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5186
|
+
reject(err);
|
|
5187
|
+
} else {
|
|
5188
|
+
resolve(res);
|
|
5189
|
+
}
|
|
5227
5190
|
});
|
|
5191
|
+
});
|
|
5192
|
+
};
|
|
5193
|
+
return (await promCreate()).value;
|
|
5194
|
+
};
|
|
5195
|
+
UpdateResources = async (resource, domainResources) => {
|
|
5196
|
+
await this.WaitForSocketConnected();
|
|
5197
|
+
const promCreate = () => {
|
|
5198
|
+
const request = {
|
|
5199
|
+
headers: {
|
|
5200
|
+
"x-sts_user_id": "someuser"
|
|
5201
|
+
},
|
|
5202
|
+
params: {},
|
|
5203
|
+
query: {},
|
|
5204
|
+
body: domainResources
|
|
5228
5205
|
};
|
|
5229
|
-
return (
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
},
|
|
5238
|
-
params: {},
|
|
5239
|
-
query: {
|
|
5240
|
-
fhirResource: domainResource.id
|
|
5241
|
-
},
|
|
5242
|
-
body: domainResource
|
|
5243
|
-
};
|
|
5244
|
-
return new Promise((resolve, reject) => {
|
|
5245
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("patchFhirResource", resource, request, (err, res) => {
|
|
5246
|
-
if (err) {
|
|
5247
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:PatchResource(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5248
|
-
reject(err);
|
|
5249
|
-
} else {
|
|
5250
|
-
resolve(res);
|
|
5251
|
-
}
|
|
5252
|
-
});
|
|
5206
|
+
return new Promise((resolve, reject) => {
|
|
5207
|
+
this.socket.timeout(this.#options.timeout).emit("updateFhirResources", resource, request, (err, res) => {
|
|
5208
|
+
if (err) {
|
|
5209
|
+
this.#error(`FhirSocketClient:UpdateResources(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5210
|
+
reject(err);
|
|
5211
|
+
} else {
|
|
5212
|
+
resolve(res);
|
|
5213
|
+
}
|
|
5253
5214
|
});
|
|
5215
|
+
});
|
|
5216
|
+
};
|
|
5217
|
+
return (await promCreate()).value;
|
|
5218
|
+
};
|
|
5219
|
+
PatchResource = async (resource, domainResource) => {
|
|
5220
|
+
await this.WaitForSocketConnected();
|
|
5221
|
+
const promCreate = () => {
|
|
5222
|
+
const request = {
|
|
5223
|
+
headers: {
|
|
5224
|
+
"x-sts_user_id": "someuser"
|
|
5225
|
+
},
|
|
5226
|
+
params: {},
|
|
5227
|
+
query: {
|
|
5228
|
+
fhirResource: domainResource.id
|
|
5229
|
+
},
|
|
5230
|
+
body: domainResource
|
|
5254
5231
|
};
|
|
5255
|
-
return (
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
},
|
|
5264
|
-
params: {},
|
|
5265
|
-
query: {},
|
|
5266
|
-
body: domainResources
|
|
5267
|
-
};
|
|
5268
|
-
return new Promise((resolve, reject) => {
|
|
5269
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("patchFhirResources", resource, request, (err, res) => {
|
|
5270
|
-
if (err) {
|
|
5271
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:PatchResources(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5272
|
-
reject(err);
|
|
5273
|
-
} else {
|
|
5274
|
-
resolve(res);
|
|
5275
|
-
}
|
|
5276
|
-
});
|
|
5232
|
+
return new Promise((resolve, reject) => {
|
|
5233
|
+
this.socket.timeout(this.#options.timeout).emit("patchFhirResource", resource, request, (err, res) => {
|
|
5234
|
+
if (err) {
|
|
5235
|
+
this.#error(`FhirSocketClient:PatchResource(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5236
|
+
reject(err);
|
|
5237
|
+
} else {
|
|
5238
|
+
resolve(res);
|
|
5239
|
+
}
|
|
5277
5240
|
});
|
|
5241
|
+
});
|
|
5242
|
+
};
|
|
5243
|
+
return (await promCreate()).value;
|
|
5244
|
+
};
|
|
5245
|
+
PatchResources = async (resource, domainResources) => {
|
|
5246
|
+
await this.WaitForSocketConnected();
|
|
5247
|
+
const promCreate = () => {
|
|
5248
|
+
const request = {
|
|
5249
|
+
headers: {
|
|
5250
|
+
"x-sts_user_id": "someuser"
|
|
5251
|
+
},
|
|
5252
|
+
params: {},
|
|
5253
|
+
query: {},
|
|
5254
|
+
body: domainResources
|
|
5278
5255
|
};
|
|
5279
|
-
return (
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
},
|
|
5288
|
-
params: {},
|
|
5289
|
-
query: {
|
|
5290
|
-
fhirResource: resourceId
|
|
5291
|
-
},
|
|
5292
|
-
body: {}
|
|
5293
|
-
};
|
|
5294
|
-
return new Promise((resolve, reject) => {
|
|
5295
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("deleteFhirResource", resource, request, (err, res) => {
|
|
5296
|
-
if (err) {
|
|
5297
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:DeleteResource(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5298
|
-
reject(err);
|
|
5299
|
-
} else {
|
|
5300
|
-
resolve(res);
|
|
5301
|
-
}
|
|
5302
|
-
});
|
|
5256
|
+
return new Promise((resolve, reject) => {
|
|
5257
|
+
this.socket.timeout(this.#options.timeout).emit("patchFhirResources", resource, request, (err, res) => {
|
|
5258
|
+
if (err) {
|
|
5259
|
+
this.#error(`FhirSocketClient:PatchResources(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5260
|
+
reject(err);
|
|
5261
|
+
} else {
|
|
5262
|
+
resolve(res);
|
|
5263
|
+
}
|
|
5303
5264
|
});
|
|
5265
|
+
});
|
|
5266
|
+
};
|
|
5267
|
+
return (await promCreate()).value;
|
|
5268
|
+
};
|
|
5269
|
+
DeleteResource = async (resource, resourceId) => {
|
|
5270
|
+
await this.WaitForSocketConnected();
|
|
5271
|
+
const promCreate = () => {
|
|
5272
|
+
const request = {
|
|
5273
|
+
headers: {
|
|
5274
|
+
"x-sts_user_id": "someuser"
|
|
5275
|
+
},
|
|
5276
|
+
params: {},
|
|
5277
|
+
query: {
|
|
5278
|
+
fhirResource: resourceId
|
|
5279
|
+
},
|
|
5280
|
+
body: {}
|
|
5304
5281
|
};
|
|
5305
|
-
return (
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
},
|
|
5314
|
-
params: {},
|
|
5315
|
-
query: {},
|
|
5316
|
-
body: domainResource
|
|
5317
|
-
};
|
|
5318
|
-
return new Promise((resolve, reject) => {
|
|
5319
|
-
this.socket.timeout(__privateGet(this, _options2).timeout).emit("deleteFhirResources", resource, delRequest, (err, res) => {
|
|
5320
|
-
if (err) {
|
|
5321
|
-
__privateGet(this, _error).call(this, `FhirSocketClient:DeleteResources(): ID: [${__privateGet(this, _id)}] clientName: [${__privateGet(this, _clientName)}] Error: [${err}]`);
|
|
5322
|
-
reject(err);
|
|
5323
|
-
} else {
|
|
5324
|
-
resolve(res);
|
|
5325
|
-
}
|
|
5326
|
-
});
|
|
5282
|
+
return new Promise((resolve, reject) => {
|
|
5283
|
+
this.socket.timeout(this.#options.timeout).emit("deleteFhirResource", resource, request, (err, res) => {
|
|
5284
|
+
if (err) {
|
|
5285
|
+
this.#error(`FhirSocketClient:DeleteResource(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5286
|
+
reject(err);
|
|
5287
|
+
} else {
|
|
5288
|
+
resolve(res);
|
|
5289
|
+
}
|
|
5327
5290
|
});
|
|
5291
|
+
});
|
|
5292
|
+
};
|
|
5293
|
+
return (await promCreate()).value;
|
|
5294
|
+
};
|
|
5295
|
+
DeleteResources = async (resource, domainResource) => {
|
|
5296
|
+
await this.WaitForSocketConnected();
|
|
5297
|
+
const prom = () => {
|
|
5298
|
+
const delRequest = {
|
|
5299
|
+
headers: {
|
|
5300
|
+
"x-sts_user_id": "someuser"
|
|
5301
|
+
},
|
|
5302
|
+
params: {},
|
|
5303
|
+
query: {},
|
|
5304
|
+
body: domainResource
|
|
5328
5305
|
};
|
|
5329
|
-
return (
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5306
|
+
return new Promise((resolve, reject) => {
|
|
5307
|
+
this.socket.timeout(this.#options.timeout).emit("deleteFhirResources", resource, delRequest, (err, res) => {
|
|
5308
|
+
if (err) {
|
|
5309
|
+
this.#error(`FhirSocketClient:DeleteResources(): ID: [${this.#id}] clientName: [${this.#clientName}] Error: [${err}]`);
|
|
5310
|
+
reject(err);
|
|
5311
|
+
} else {
|
|
5312
|
+
resolve(res);
|
|
5313
|
+
}
|
|
5314
|
+
});
|
|
5315
|
+
});
|
|
5316
|
+
};
|
|
5317
|
+
return (await prom()).value;
|
|
5318
|
+
};
|
|
5340
5319
|
}
|
|
5341
|
-
_socketUtils = new WeakMap();
|
|
5342
|
-
_id = new WeakMap();
|
|
5343
|
-
_options2 = new WeakMap();
|
|
5344
|
-
_clientName = new WeakMap();
|
|
5345
|
-
_debug = new WeakMap();
|
|
5346
|
-
_error = new WeakMap();
|
|
5347
|
-
_info = new WeakMap();
|
|
5348
|
-
_SetupWSSClient = new WeakMap();
|
|
5349
|
-
_OnSocketConnected = new WeakMap();
|
|
5350
5320
|
function sleep(ms) {
|
|
5351
5321
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5352
5322
|
}
|
|
@@ -5390,7 +5360,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5390
5360
|
instance.interceptors.response.use(
|
|
5391
5361
|
(response) => response,
|
|
5392
5362
|
async (error) => {
|
|
5393
|
-
var _a;
|
|
5394
5363
|
const config = error.config;
|
|
5395
5364
|
if (!config || !config.method || !config.metadata) {
|
|
5396
5365
|
return Promise.reject(error);
|
|
@@ -5398,7 +5367,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5398
5367
|
const now = Date.now();
|
|
5399
5368
|
const elapsed = now - config.metadata.startTime;
|
|
5400
5369
|
const method = config.method.toLowerCase();
|
|
5401
|
-
const status =
|
|
5370
|
+
const status = error.response?.status;
|
|
5402
5371
|
const code = error.code;
|
|
5403
5372
|
const isRetryable = retryMethods.includes(method) && (retryErrorCodes.includes(code || "") || retryStatusCodes.includes(status || 0));
|
|
5404
5373
|
if (config.metadata.__retryCount < maxRetries && isRetryable && elapsed < maxRetryDurationMs) {
|
|
@@ -5417,317 +5386,307 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
5417
5386
|
return instance;
|
|
5418
5387
|
}
|
|
5419
5388
|
class FhirClient {
|
|
5389
|
+
#options;
|
|
5390
|
+
#DUMMY_USER = "USR_user01@stsmda.com.au";
|
|
5391
|
+
//@@ needs to come from headers ??
|
|
5392
|
+
#stsfhirapiroot = "/stsfhirv2/r5";
|
|
5393
|
+
// Default value
|
|
5394
|
+
#fhirSocketClient = void 0;
|
|
5420
5395
|
constructor(options) {
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5396
|
+
this.#options = options;
|
|
5397
|
+
if (this.#options.stsfhirapiroot !== void 0) {
|
|
5398
|
+
this.#stsfhirapiroot = this.#options.stsfhirapiroot;
|
|
5399
|
+
}
|
|
5400
|
+
if (this.#options.useSocketClient === true && this.#options.socketClientOptions) {
|
|
5401
|
+
this.#fhirSocketClient = new FhirSocketClient(this.#options.socketClientOptions);
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
get options() {
|
|
5405
|
+
return this.#options;
|
|
5406
|
+
}
|
|
5407
|
+
#LogDebugMessage = (message) => {
|
|
5408
|
+
this.#options.logger.debug(message);
|
|
5409
|
+
};
|
|
5410
|
+
#HandleError = (error) => {
|
|
5411
|
+
this.#LogDebugMessage(chalk.red(`HandleError(): Error: [${error}]`));
|
|
5412
|
+
let responseCode = 500;
|
|
5413
|
+
if (axios.isAxiosError(error)) {
|
|
5414
|
+
const axiosError = error;
|
|
5415
|
+
if (axiosError.response) {
|
|
5416
|
+
responseCode = axiosError.response.status;
|
|
5417
|
+
this.#LogDebugMessage(chalk.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
5418
|
+
} else {
|
|
5419
|
+
this.#LogDebugMessage(chalk.red(`AXIOS Error = [${axiosError}]`));
|
|
5441
5420
|
}
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5421
|
+
}
|
|
5422
|
+
return responseCode;
|
|
5423
|
+
};
|
|
5424
|
+
#BuildQueryString = (baseUrl, queryParams) => {
|
|
5425
|
+
const url2 = new URL(baseUrl);
|
|
5426
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
5427
|
+
url2.search = searchParams.toString();
|
|
5428
|
+
return url2.toString();
|
|
5429
|
+
};
|
|
5430
|
+
#InvokeResourceAPI = async (url2, httpVerb, domainResource, filters) => {
|
|
5431
|
+
const accessToken = await this.#options.GetAccessToken();
|
|
5432
|
+
const requestConfig = new stsutils.STSAxiosConfig(url2, httpVerb).withAuthHeaders(accessToken, this.#DUMMY_USER).withData(filters ? filters : domainResource ? domainResource : void 0);
|
|
5433
|
+
if (isNode$1 && this.#options.agentManager) {
|
|
5434
|
+
requestConfig.withAgentManager(this.#options.agentManager);
|
|
5435
|
+
}
|
|
5436
|
+
const api = createRetryAxiosClient({
|
|
5437
|
+
maxRetries: 4,
|
|
5438
|
+
retryDelayMs: 300,
|
|
5439
|
+
retryJitterMs: 150,
|
|
5440
|
+
maxRetryDurationMs: 5e3,
|
|
5441
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5442
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
|
|
5455
5443
|
}
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
retryDelayMs: 300,
|
|
5459
|
-
retryJitterMs: 150,
|
|
5460
|
-
maxRetryDurationMs: 5e3,
|
|
5461
|
-
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5462
|
-
var _a;
|
|
5463
|
-
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5464
|
-
}
|
|
5465
|
-
// Below works also ...
|
|
5466
|
-
//stsAxiosConfig: requestConfig
|
|
5467
|
-
});
|
|
5468
|
-
return await api(url2, requestConfig.config);
|
|
5444
|
+
// Below works also ...
|
|
5445
|
+
//stsAxiosConfig: requestConfig
|
|
5469
5446
|
});
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
errorResponse.response = {
|
|
5479
|
-
status: retVal.status
|
|
5480
|
-
};
|
|
5481
|
-
throw errorResponse;
|
|
5482
|
-
}
|
|
5483
|
-
} catch (error) {
|
|
5484
|
-
const errorResponse = new Error(`GetResource(): Error: [${error}]`);
|
|
5485
|
-
errorResponse.response = {
|
|
5486
|
-
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5487
|
-
};
|
|
5488
|
-
throw errorResponse;
|
|
5489
|
-
}
|
|
5490
|
-
} else {
|
|
5491
|
-
const url2 = `${__privateGet(this, _options3).fhirEndpoint}${__privateGet(this, _stsfhirapiroot)}/${resource}/${id}`;
|
|
5492
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
5493
|
-
if (response) {
|
|
5494
|
-
return response.data;
|
|
5447
|
+
return await api(url2, requestConfig.config);
|
|
5448
|
+
};
|
|
5449
|
+
GetResource = async (resource, id, filters) => {
|
|
5450
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5451
|
+
try {
|
|
5452
|
+
const retVal = await this.#fhirSocketClient.GetResource(resource, id);
|
|
5453
|
+
if (retVal.status === StatusCodes.OK) {
|
|
5454
|
+
return retVal.value;
|
|
5495
5455
|
} else {
|
|
5496
|
-
|
|
5497
|
-
}
|
|
5498
|
-
}
|
|
5499
|
-
});
|
|
5500
|
-
__publicField(this, "GetResources", async (resource, filters, searchParams) => {
|
|
5501
|
-
if (__privateGet(this, _options3).useSocketClient === true && __privateGet(this, _fhirSocketClient)) {
|
|
5502
|
-
try {
|
|
5503
|
-
return __privateGet(this, _fhirSocketClient).GetResources(resource, searchParams);
|
|
5504
|
-
} catch (error) {
|
|
5505
|
-
const errorResponse = new Error(`GetResources(): Error: [${error}]`);
|
|
5456
|
+
const errorResponse = new Error(`GetResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.OK}]`);
|
|
5506
5457
|
errorResponse.response = {
|
|
5507
|
-
status:
|
|
5458
|
+
status: retVal.status
|
|
5508
5459
|
};
|
|
5509
5460
|
throw errorResponse;
|
|
5510
5461
|
}
|
|
5462
|
+
} catch (error) {
|
|
5463
|
+
const errorResponse = new Error(`GetResource(): Error: [${error}]`);
|
|
5464
|
+
errorResponse.response = {
|
|
5465
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5466
|
+
};
|
|
5467
|
+
throw errorResponse;
|
|
5468
|
+
}
|
|
5469
|
+
} else {
|
|
5470
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}/${id}`;
|
|
5471
|
+
const response = await this.#InvokeResourceAPI(url2, "get", null, filters);
|
|
5472
|
+
if (response) {
|
|
5473
|
+
return response.data;
|
|
5511
5474
|
} else {
|
|
5512
|
-
|
|
5513
|
-
if (searchParams) {
|
|
5514
|
-
url2 = __privateGet(this, _BuildQueryString).call(this, url2, searchParams);
|
|
5515
|
-
}
|
|
5516
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "get", null, filters);
|
|
5517
|
-
if (response) {
|
|
5518
|
-
return response.data;
|
|
5519
|
-
} else {
|
|
5520
|
-
return null;
|
|
5521
|
-
}
|
|
5475
|
+
return null;
|
|
5522
5476
|
}
|
|
5523
|
-
}
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5477
|
+
}
|
|
5478
|
+
};
|
|
5479
|
+
GetResources = async (resource, filters, searchParams) => {
|
|
5480
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5481
|
+
try {
|
|
5482
|
+
return this.#fhirSocketClient.GetResources(resource, searchParams);
|
|
5483
|
+
} catch (error) {
|
|
5484
|
+
const errorResponse = new Error(`GetResources(): Error: [${error}]`);
|
|
5485
|
+
errorResponse.response = {
|
|
5486
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5487
|
+
};
|
|
5488
|
+
throw errorResponse;
|
|
5489
|
+
}
|
|
5490
|
+
} else {
|
|
5491
|
+
let url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}`;
|
|
5492
|
+
if (searchParams) {
|
|
5493
|
+
url2 = this.#BuildQueryString(url2, searchParams);
|
|
5494
|
+
}
|
|
5495
|
+
const response = await this.#InvokeResourceAPI(url2, "get", null, filters);
|
|
5496
|
+
if (response) {
|
|
5497
|
+
return response.data;
|
|
5544
5498
|
} else {
|
|
5545
|
-
|
|
5546
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "post", domainResource, null);
|
|
5547
|
-
if (response) {
|
|
5548
|
-
if (response.status === StatusCodes.CREATED) {
|
|
5549
|
-
return response.data;
|
|
5550
|
-
} else {
|
|
5551
|
-
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5552
|
-
}
|
|
5553
|
-
} else {
|
|
5554
|
-
return null;
|
|
5555
|
-
}
|
|
5499
|
+
return null;
|
|
5556
5500
|
}
|
|
5557
|
-
}
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5501
|
+
}
|
|
5502
|
+
};
|
|
5503
|
+
CreateResource = async (resource, domainResource) => {
|
|
5504
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5505
|
+
try {
|
|
5506
|
+
const retVal = await this.#fhirSocketClient.CreateResource(resource, domainResource);
|
|
5507
|
+
if (retVal.status === StatusCodes.CREATED) {
|
|
5508
|
+
return retVal.value;
|
|
5509
|
+
} else {
|
|
5510
|
+
const errorResponse = new Error(`CreateResource(): Invalid response status code: [${retVal.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5564
5511
|
errorResponse.response = {
|
|
5565
|
-
status:
|
|
5512
|
+
status: retVal.status
|
|
5566
5513
|
};
|
|
5567
5514
|
throw errorResponse;
|
|
5568
5515
|
}
|
|
5569
|
-
}
|
|
5570
|
-
const
|
|
5571
|
-
|
|
5572
|
-
|
|
5516
|
+
} catch (error) {
|
|
5517
|
+
const errorResponse = new Error(`CreateResource(): Error: [${error}]`);
|
|
5518
|
+
errorResponse.response = {
|
|
5519
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5520
|
+
};
|
|
5521
|
+
throw errorResponse;
|
|
5522
|
+
}
|
|
5523
|
+
} else {
|
|
5524
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}`;
|
|
5525
|
+
const response = await this.#InvokeResourceAPI(url2, "post", domainResource, null);
|
|
5526
|
+
if (response) {
|
|
5527
|
+
if (response.status === StatusCodes.CREATED) {
|
|
5573
5528
|
return response.data;
|
|
5574
5529
|
} else {
|
|
5575
|
-
|
|
5530
|
+
throw new Error(`CreateResource(): Invalid response status code: [${response.status}] expected: [${StatusCodes.CREATED}]`);
|
|
5576
5531
|
}
|
|
5532
|
+
} else {
|
|
5533
|
+
return null;
|
|
5577
5534
|
}
|
|
5578
|
-
}
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5535
|
+
}
|
|
5536
|
+
};
|
|
5537
|
+
UpdateResource = async (resource, domainResource) => {
|
|
5538
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5539
|
+
try {
|
|
5540
|
+
return this.#fhirSocketClient.UpdateResource(resource, domainResource);
|
|
5541
|
+
} catch (error) {
|
|
5542
|
+
const errorResponse = new Error(`UpdateResource(): Error: [${error}]`);
|
|
5543
|
+
errorResponse.response = {
|
|
5544
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5545
|
+
};
|
|
5546
|
+
throw errorResponse;
|
|
5547
|
+
}
|
|
5548
|
+
} else {
|
|
5549
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
5550
|
+
const response = await this.#InvokeResourceAPI(url2, "put", domainResource, null);
|
|
5551
|
+
if (response) {
|
|
5552
|
+
return response.data;
|
|
5590
5553
|
} else {
|
|
5591
|
-
|
|
5592
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "put", domainResources, null);
|
|
5593
|
-
if (response) {
|
|
5594
|
-
return response.data;
|
|
5595
|
-
} else {
|
|
5596
|
-
return null;
|
|
5597
|
-
}
|
|
5554
|
+
return null;
|
|
5598
5555
|
}
|
|
5599
|
-
}
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5556
|
+
}
|
|
5557
|
+
};
|
|
5558
|
+
UpdateResources = async (resource, domainResources) => {
|
|
5559
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5560
|
+
try {
|
|
5561
|
+
return this.#fhirSocketClient.UpdateResources(resource, domainResources);
|
|
5562
|
+
} catch (error) {
|
|
5563
|
+
const errorResponse = new Error(`UpdateResources(): Error: [${error}]`);
|
|
5564
|
+
errorResponse.response = {
|
|
5565
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5566
|
+
};
|
|
5567
|
+
throw errorResponse;
|
|
5568
|
+
}
|
|
5569
|
+
} else {
|
|
5570
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}`;
|
|
5571
|
+
const response = await this.#InvokeResourceAPI(url2, "put", domainResources, null);
|
|
5572
|
+
if (response) {
|
|
5573
|
+
return response.data;
|
|
5611
5574
|
} else {
|
|
5612
|
-
|
|
5613
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResource, null);
|
|
5614
|
-
if (response) {
|
|
5615
|
-
return response.data;
|
|
5616
|
-
} else {
|
|
5617
|
-
return null;
|
|
5618
|
-
}
|
|
5575
|
+
return null;
|
|
5619
5576
|
}
|
|
5620
|
-
}
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5577
|
+
}
|
|
5578
|
+
};
|
|
5579
|
+
PatchResource = async (resource, domainResource) => {
|
|
5580
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5581
|
+
try {
|
|
5582
|
+
return this.#fhirSocketClient.PatchResource(resource, domainResource);
|
|
5583
|
+
} catch (error) {
|
|
5584
|
+
const errorResponse = new Error(`PatchResource(): Error: [${error}]`);
|
|
5585
|
+
errorResponse.response = {
|
|
5586
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5587
|
+
};
|
|
5588
|
+
throw errorResponse;
|
|
5589
|
+
}
|
|
5590
|
+
} else {
|
|
5591
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}/${domainResource.id}`;
|
|
5592
|
+
const response = await this.#InvokeResourceAPI(url2, "patch", domainResource, null);
|
|
5593
|
+
if (response) {
|
|
5594
|
+
return response.data;
|
|
5632
5595
|
} else {
|
|
5633
|
-
|
|
5634
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "patch", domainResources, null);
|
|
5635
|
-
if (response) {
|
|
5636
|
-
return response.data;
|
|
5637
|
-
} else {
|
|
5638
|
-
return null;
|
|
5639
|
-
}
|
|
5596
|
+
return null;
|
|
5640
5597
|
}
|
|
5641
|
-
}
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5598
|
+
}
|
|
5599
|
+
};
|
|
5600
|
+
PatchResources = async (resource, domainResources) => {
|
|
5601
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5602
|
+
try {
|
|
5603
|
+
return this.#fhirSocketClient.PatchResources(resource, domainResources);
|
|
5604
|
+
} catch (error) {
|
|
5605
|
+
const errorResponse = new Error(`PatchResources(): Error: [${error}]`);
|
|
5606
|
+
errorResponse.response = {
|
|
5607
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5608
|
+
};
|
|
5609
|
+
throw errorResponse;
|
|
5610
|
+
}
|
|
5611
|
+
} else {
|
|
5612
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}`;
|
|
5613
|
+
const response = await this.#InvokeResourceAPI(url2, "patch", domainResources, null);
|
|
5614
|
+
if (response) {
|
|
5615
|
+
return response.data;
|
|
5653
5616
|
} else {
|
|
5654
|
-
|
|
5655
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", null, null);
|
|
5656
|
-
if (response) {
|
|
5657
|
-
return response.data;
|
|
5658
|
-
} else {
|
|
5659
|
-
return null;
|
|
5660
|
-
}
|
|
5617
|
+
return null;
|
|
5661
5618
|
}
|
|
5662
|
-
}
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5619
|
+
}
|
|
5620
|
+
};
|
|
5621
|
+
DeleteResource = async (resource, id) => {
|
|
5622
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5623
|
+
try {
|
|
5624
|
+
return this.#fhirSocketClient.DeleteResource(resource, id);
|
|
5625
|
+
} catch (error) {
|
|
5626
|
+
const errorResponse = new Error(`DeleteResource(): Error: [${error}]`);
|
|
5627
|
+
errorResponse.response = {
|
|
5628
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5629
|
+
};
|
|
5630
|
+
throw errorResponse;
|
|
5631
|
+
}
|
|
5632
|
+
} else {
|
|
5633
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}/${id}`;
|
|
5634
|
+
const response = await this.#InvokeResourceAPI(url2, "delete", null, null);
|
|
5635
|
+
if (response) {
|
|
5636
|
+
return response.data;
|
|
5674
5637
|
} else {
|
|
5675
|
-
|
|
5676
|
-
const response = await __privateGet(this, _InvokeResourceAPI).call(this, url2, "delete", domainResources, null);
|
|
5677
|
-
if (response) {
|
|
5678
|
-
return response.data;
|
|
5679
|
-
} else {
|
|
5680
|
-
return null;
|
|
5681
|
-
}
|
|
5638
|
+
return null;
|
|
5682
5639
|
}
|
|
5683
|
-
}
|
|
5684
|
-
|
|
5685
|
-
|
|
5640
|
+
}
|
|
5641
|
+
};
|
|
5642
|
+
DeleteResources = async (resource, domainResources) => {
|
|
5643
|
+
if (this.#options.useSocketClient === true && this.#fhirSocketClient) {
|
|
5686
5644
|
try {
|
|
5687
|
-
|
|
5688
|
-
if (isNode$1 && __privateGet(this, _options3).agentManager) {
|
|
5689
|
-
requestConfig.withAgentManager(__privateGet(this, _options3).agentManager);
|
|
5690
|
-
}
|
|
5691
|
-
const api = createRetryAxiosClient({
|
|
5692
|
-
maxRetries: 4,
|
|
5693
|
-
retryDelayMs: 300,
|
|
5694
|
-
retryJitterMs: 150,
|
|
5695
|
-
maxRetryDurationMs: 5e3,
|
|
5696
|
-
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5697
|
-
var _a;
|
|
5698
|
-
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || ((_a = error.response) == null ? void 0 : _a.status)}`);
|
|
5699
|
-
}
|
|
5700
|
-
});
|
|
5701
|
-
return await api(url2, requestConfig.config);
|
|
5645
|
+
return this.#fhirSocketClient.DeleteResources(resource, domainResources);
|
|
5702
5646
|
} catch (error) {
|
|
5703
|
-
|
|
5647
|
+
const errorResponse = new Error(`DeleteResources(): Error: [${error}]`);
|
|
5648
|
+
errorResponse.response = {
|
|
5649
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR
|
|
5650
|
+
};
|
|
5651
|
+
throw errorResponse;
|
|
5704
5652
|
}
|
|
5705
|
-
}
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5653
|
+
} else {
|
|
5654
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/${resource}`;
|
|
5655
|
+
const response = await this.#InvokeResourceAPI(url2, "delete", domainResources, null);
|
|
5656
|
+
if (response) {
|
|
5657
|
+
return response.data;
|
|
5658
|
+
} else {
|
|
5659
|
+
return null;
|
|
5709
5660
|
}
|
|
5710
|
-
});
|
|
5711
|
-
__privateSet(this, _options3, options);
|
|
5712
|
-
if (__privateGet(this, _options3).stsfhirapiroot !== void 0) {
|
|
5713
|
-
__privateSet(this, _stsfhirapiroot, __privateGet(this, _options3).stsfhirapiroot);
|
|
5714
5661
|
}
|
|
5715
|
-
|
|
5716
|
-
|
|
5662
|
+
};
|
|
5663
|
+
GetLatency = async () => {
|
|
5664
|
+
const url2 = `${this.#options.fhirEndpoint}${this.#stsfhirapiroot}/latency`;
|
|
5665
|
+
try {
|
|
5666
|
+
const requestConfig = new stsutils.STSAxiosConfig(url2, "get").withDefaultHeaders();
|
|
5667
|
+
if (isNode$1 && this.#options.agentManager) {
|
|
5668
|
+
requestConfig.withAgentManager(this.#options.agentManager);
|
|
5669
|
+
}
|
|
5670
|
+
const api = createRetryAxiosClient({
|
|
5671
|
+
maxRetries: 4,
|
|
5672
|
+
retryDelayMs: 300,
|
|
5673
|
+
retryJitterMs: 150,
|
|
5674
|
+
maxRetryDurationMs: 5e3,
|
|
5675
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
5676
|
+
console.warn(`Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
|
|
5677
|
+
}
|
|
5678
|
+
});
|
|
5679
|
+
return await api(url2, requestConfig.config);
|
|
5680
|
+
} catch (error) {
|
|
5681
|
+
this.#HandleError(error);
|
|
5717
5682
|
}
|
|
5718
|
-
}
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5683
|
+
};
|
|
5684
|
+
Terminate = () => {
|
|
5685
|
+
if (this.#fhirSocketClient) {
|
|
5686
|
+
this.#fhirSocketClient.socket.disconnect();
|
|
5687
|
+
}
|
|
5688
|
+
};
|
|
5722
5689
|
}
|
|
5723
|
-
_options3 = new WeakMap();
|
|
5724
|
-
_DUMMY_USER = new WeakMap();
|
|
5725
|
-
_stsfhirapiroot = new WeakMap();
|
|
5726
|
-
_fhirSocketClient = new WeakMap();
|
|
5727
|
-
_LogDebugMessage = new WeakMap();
|
|
5728
|
-
_HandleError = new WeakMap();
|
|
5729
|
-
_BuildQueryString = new WeakMap();
|
|
5730
|
-
_InvokeResourceAPI = new WeakMap();
|
|
5731
5690
|
exports2.FhirClient = FhirClient;
|
|
5732
5691
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
5733
5692
|
}));
|