@nsshunt/stsfhirclient 2.0.28 → 2.0.30
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
|
@@ -9220,261 +9220,6 @@ function createRetryAxiosClient(retryConfig) {
|
|
|
9220
9220
|
return instance;
|
|
9221
9221
|
}
|
|
9222
9222
|
//#endregion
|
|
9223
|
-
//#region src/cv2/fhirRESTClient.ts
|
|
9224
|
-
var FhirRESTClient = class {
|
|
9225
|
-
#options;
|
|
9226
|
-
constructor(options) {
|
|
9227
|
-
this.#options = options;
|
|
9228
|
-
}
|
|
9229
|
-
BaseUrl() {
|
|
9230
|
-
return `${this.#options.endpoint}:${this.#options.stsfhirport}${this.#options.stsfhirapiroot}`;
|
|
9231
|
-
}
|
|
9232
|
-
LogError = (method, error) => {
|
|
9233
|
-
this.#options.logger.error(`FhirRESTClient:${method}(): Error: [${error}]`);
|
|
9234
|
-
this.#options.logger.error(error);
|
|
9235
|
-
};
|
|
9236
|
-
LogWarning = (method, message) => {
|
|
9237
|
-
this.#options.logger.warn(`FhirRESTClient:${method}(): Warn: [${message}]`);
|
|
9238
|
-
};
|
|
9239
|
-
/**
|
|
9240
|
-
*
|
|
9241
|
-
* @param url
|
|
9242
|
-
* @param httpVerb
|
|
9243
|
-
* @param versionIdETag Format "W/<versionNumber", e.g. "W/3"
|
|
9244
|
-
* @param resource
|
|
9245
|
-
* @returns
|
|
9246
|
-
*/
|
|
9247
|
-
#InvokeResourceAPI = async (url, httpVerb, versionIdETag, resource, contentType) => {
|
|
9248
|
-
const accessToken = await this.#options.GetAccessToken();
|
|
9249
|
-
let requestConfig;
|
|
9250
|
-
const headers = {
|
|
9251
|
-
Prefer: "return=representation",
|
|
9252
|
-
Accept: "application/fhir+json"
|
|
9253
|
-
};
|
|
9254
|
-
if (versionIdETag && versionIdETag !== "") headers["If-Match"] = versionIdETag;
|
|
9255
|
-
if (httpVerb === "patch") {
|
|
9256
|
-
requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationMergePatchAndJsonContentTypeHeaders();
|
|
9257
|
-
if (resource && contentType) {
|
|
9258
|
-
if (contentType.localeCompare("application/merge-patch+json") === 0) requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationMergePatchAndJsonContentTypeHeaders();
|
|
9259
|
-
else if (contentType.localeCompare("application/json-patch+json") === 0) requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationJsonPatchAndJsonContentTypeHeaders();
|
|
9260
|
-
}
|
|
9261
|
-
} else requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationFhirAndJsonContentTypeHeaders();
|
|
9262
|
-
requestConfig.withAuthHeaders(accessToken, this.#options.user).withHeaders(headers);
|
|
9263
|
-
if (resource) requestConfig.withData(resource);
|
|
9264
|
-
if (this.#options.agentManager) requestConfig.withAgentManager(this.#options.agentManager);
|
|
9265
|
-
return await createRetryAxiosClient({
|
|
9266
|
-
maxRetries: 4,
|
|
9267
|
-
retryDelayMs: 300,
|
|
9268
|
-
retryJitterMs: 150,
|
|
9269
|
-
maxRetryDurationMs: 5e3,
|
|
9270
|
-
onRetryAttempt: (attempt, error, delayMs) => {
|
|
9271
|
-
this.LogWarning("#InvokeResourceAPI", `Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
|
|
9272
|
-
if (this.#options.onRetryAttempt) this.#options.onRetryAttempt(attempt, error, delayMs);
|
|
9273
|
-
}
|
|
9274
|
-
})(url, requestConfig.config);
|
|
9275
|
-
};
|
|
9276
|
-
ProcessBatchOrTransactionResources = async (bundle) => {
|
|
9277
|
-
try {
|
|
9278
|
-
let url = `${this.BaseUrl()}`;
|
|
9279
|
-
const retVal = await this.#InvokeResourceAPI(url, "post", null, bundle);
|
|
9280
|
-
if (retVal) return {
|
|
9281
|
-
status: retVal.status,
|
|
9282
|
-
body: retVal.data
|
|
9283
|
-
};
|
|
9284
|
-
else throw new Error(`FhirRESTClient:ProcessBatchOrTransactionResources(): No response from #InvokeResourceAPI`);
|
|
9285
|
-
} catch (error) {
|
|
9286
|
-
this.LogError("ProcessBatchOrTransactionResources", error);
|
|
9287
|
-
throw error;
|
|
9288
|
-
}
|
|
9289
|
-
};
|
|
9290
|
-
GetResources = async (searchUrl) => {
|
|
9291
|
-
try {
|
|
9292
|
-
const retVal = await this.#InvokeResourceAPI(searchUrl.toString(), "get", null, null);
|
|
9293
|
-
if (retVal) return {
|
|
9294
|
-
status: retVal.status,
|
|
9295
|
-
body: retVal.data
|
|
9296
|
-
};
|
|
9297
|
-
else throw new Error(`FhirRESTClient:GetResources(): No response from #InvokeResourceAPI`);
|
|
9298
|
-
} catch (error) {
|
|
9299
|
-
this.LogError("GetResources", error);
|
|
9300
|
-
throw error;
|
|
9301
|
-
}
|
|
9302
|
-
};
|
|
9303
|
-
GetHistoryFhirResources = async (searchUrl) => {
|
|
9304
|
-
try {
|
|
9305
|
-
return await this.GetResources(searchUrl);
|
|
9306
|
-
} catch (error) {
|
|
9307
|
-
this.LogError("GetHistoryFhirResources", error);
|
|
9308
|
-
throw error;
|
|
9309
|
-
}
|
|
9310
|
-
};
|
|
9311
|
-
GetHistoryFhirResource = async (searchUrl) => {
|
|
9312
|
-
try {
|
|
9313
|
-
return await this.GetResources(searchUrl);
|
|
9314
|
-
} catch (error) {
|
|
9315
|
-
this.LogError("GetHistoryFhirResource", error);
|
|
9316
|
-
throw error;
|
|
9317
|
-
}
|
|
9318
|
-
};
|
|
9319
|
-
GetAllFhirResources = async (searchUrl) => {
|
|
9320
|
-
try {
|
|
9321
|
-
return await this.GetResources(searchUrl);
|
|
9322
|
-
} catch (error) {
|
|
9323
|
-
this.LogError("GetAllFhirResources", error);
|
|
9324
|
-
throw error;
|
|
9325
|
-
}
|
|
9326
|
-
};
|
|
9327
|
-
GetResource = async (resourceType, resourceId) => {
|
|
9328
|
-
try {
|
|
9329
|
-
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9330
|
-
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9331
|
-
if (retVal) return {
|
|
9332
|
-
status: retVal.status,
|
|
9333
|
-
body: retVal.data
|
|
9334
|
-
};
|
|
9335
|
-
else throw new Error(`FhirRESTClient:GetResource(): No response from #InvokeResourceAPI`);
|
|
9336
|
-
} catch (error) {
|
|
9337
|
-
if (axios.isAxiosError(error)) {
|
|
9338
|
-
const axiosError = error;
|
|
9339
|
-
return {
|
|
9340
|
-
status: axiosError.response.status,
|
|
9341
|
-
body: axiosError.response.data,
|
|
9342
|
-
headers: { ETag: axiosError.response.headers["etag"] }
|
|
9343
|
-
};
|
|
9344
|
-
} else throw error;
|
|
9345
|
-
}
|
|
9346
|
-
};
|
|
9347
|
-
PutResource = async (resourceType, domainResource, versionIdETag) => {
|
|
9348
|
-
try {
|
|
9349
|
-
let url = `${`${this.BaseUrl()}/${resourceType}`}/${domainResource.id}`;
|
|
9350
|
-
const retVal = await this.#InvokeResourceAPI(url, "put", versionIdETag, domainResource);
|
|
9351
|
-
if (retVal) return {
|
|
9352
|
-
status: retVal.status,
|
|
9353
|
-
body: retVal.data
|
|
9354
|
-
};
|
|
9355
|
-
else throw new Error(`FhirRESTClient:PutResource(): No response from #InvokeResourceAPI`);
|
|
9356
|
-
} catch (error) {
|
|
9357
|
-
this.LogError("PutResource", error);
|
|
9358
|
-
throw error;
|
|
9359
|
-
}
|
|
9360
|
-
};
|
|
9361
|
-
PatchResource = async (resourceType, resourceId, domainResource, contentType, versionIdETag) => {
|
|
9362
|
-
try {
|
|
9363
|
-
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9364
|
-
const retVal = await this.#InvokeResourceAPI(url, "patch", versionIdETag, domainResource, contentType);
|
|
9365
|
-
if (retVal) return {
|
|
9366
|
-
status: retVal.status,
|
|
9367
|
-
body: retVal.data
|
|
9368
|
-
};
|
|
9369
|
-
else throw new Error(`FhirRESTClient:PatchResource(): No response from #InvokeResourceAPI`);
|
|
9370
|
-
} catch (error) {
|
|
9371
|
-
this.LogError("PatchResource", error);
|
|
9372
|
-
throw error;
|
|
9373
|
-
}
|
|
9374
|
-
};
|
|
9375
|
-
PostResource = async (resourceType, domainResource) => {
|
|
9376
|
-
try {
|
|
9377
|
-
const url = `${this.BaseUrl()}/${resourceType}`;
|
|
9378
|
-
const retVal = await this.#InvokeResourceAPI(url, "post", null, domainResource);
|
|
9379
|
-
if (retVal) return {
|
|
9380
|
-
status: retVal.status,
|
|
9381
|
-
body: retVal.data
|
|
9382
|
-
};
|
|
9383
|
-
else throw new Error(`FhirRESTClient:PostResource(): No response from #InvokeResourceAPI`);
|
|
9384
|
-
} catch (error) {
|
|
9385
|
-
this.LogError("PostResource", error);
|
|
9386
|
-
throw error;
|
|
9387
|
-
}
|
|
9388
|
-
};
|
|
9389
|
-
GetHistoryInstanceFhirResource = async (resourceType, resourceId, versionId) => {
|
|
9390
|
-
try {
|
|
9391
|
-
const url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}/_history/${versionId.toString()}`;
|
|
9392
|
-
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9393
|
-
if (retVal) return {
|
|
9394
|
-
status: retVal.status,
|
|
9395
|
-
body: retVal.data
|
|
9396
|
-
};
|
|
9397
|
-
else throw new Error(`FhirRESTClient:GetHistoryInstanceFhirResource(): No response from #InvokeResourceAPI`);
|
|
9398
|
-
} catch (error) {
|
|
9399
|
-
if (axios.isAxiosError(error)) {
|
|
9400
|
-
const axiosError = error;
|
|
9401
|
-
return {
|
|
9402
|
-
status: axiosError.response.status,
|
|
9403
|
-
body: axiosError.response.data,
|
|
9404
|
-
headers: { ETag: axiosError.response.headers["etag"] }
|
|
9405
|
-
};
|
|
9406
|
-
} else throw error;
|
|
9407
|
-
}
|
|
9408
|
-
};
|
|
9409
|
-
ExtractNumber(str) {
|
|
9410
|
-
if (typeof str !== "string") return null;
|
|
9411
|
-
const match = str.match(/^\s*(?:W\/\s*)?"\s*([\d.]+)\s*"$/i);
|
|
9412
|
-
return match ? Number(match[1]) : null;
|
|
9413
|
-
}
|
|
9414
|
-
DeleteResource = async (resourceType, resourceId, versionIdETag) => {
|
|
9415
|
-
try {
|
|
9416
|
-
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9417
|
-
const retVal = await this.#InvokeResourceAPI(url, "delete", versionIdETag, null);
|
|
9418
|
-
if (retVal) return {
|
|
9419
|
-
status: retVal.status,
|
|
9420
|
-
body: retVal.data
|
|
9421
|
-
};
|
|
9422
|
-
else throw new Error(`FhirRESTClient:DeleteResource(): No response from #InvokeResourceAPI`);
|
|
9423
|
-
} catch (error) {
|
|
9424
|
-
if (axios.isAxiosError(error)) {
|
|
9425
|
-
const axiosError = error;
|
|
9426
|
-
const versionNumber = this.ExtractNumber(versionIdETag) + 1;
|
|
9427
|
-
return {
|
|
9428
|
-
status: axiosError.response.status,
|
|
9429
|
-
body: axiosError.response.data,
|
|
9430
|
-
headers: { ETag: `W/"${versionNumber}"` }
|
|
9431
|
-
};
|
|
9432
|
-
} else throw error;
|
|
9433
|
-
}
|
|
9434
|
-
};
|
|
9435
|
-
GetMetadata = async () => {
|
|
9436
|
-
try {
|
|
9437
|
-
const resourceUrl = `${this.BaseUrl()}/metadata`;
|
|
9438
|
-
const retVal = await this.#InvokeResourceAPI(resourceUrl, "get", null, null);
|
|
9439
|
-
if (retVal) return {
|
|
9440
|
-
status: retVal.status,
|
|
9441
|
-
body: retVal.data
|
|
9442
|
-
};
|
|
9443
|
-
else throw new Error(`FhirRESTClient:GetMetadata(): No response from #InvokeResourceAPI`);
|
|
9444
|
-
} catch (error) {
|
|
9445
|
-
this.LogError("GetMetadata", error);
|
|
9446
|
-
throw error;
|
|
9447
|
-
}
|
|
9448
|
-
};
|
|
9449
|
-
GetLatency = async (params) => {
|
|
9450
|
-
try {
|
|
9451
|
-
const url = `${this.BaseUrl()}/latency`;
|
|
9452
|
-
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9453
|
-
if (retVal) return {
|
|
9454
|
-
status: retVal.status,
|
|
9455
|
-
body: retVal.data
|
|
9456
|
-
};
|
|
9457
|
-
else throw new Error(`FhirRESTClient:GetLatency(): No response from #InvokeResourceAPI`);
|
|
9458
|
-
} catch (error) {
|
|
9459
|
-
this.LogError("GetLatency", error);
|
|
9460
|
-
throw error;
|
|
9461
|
-
}
|
|
9462
|
-
};
|
|
9463
|
-
GenericSearchTesting = async (resourceType, params) => {
|
|
9464
|
-
try {
|
|
9465
|
-
const retVal = await this.#InvokeResourceAPI(`${this.BaseUrl()}/${resourceType}/_genericSearchTesting`, "post", null, params);
|
|
9466
|
-
if (retVal) return {
|
|
9467
|
-
status: retVal.status,
|
|
9468
|
-
body: retVal.data
|
|
9469
|
-
};
|
|
9470
|
-
else throw new Error(`FhirRESTClient:GenericSearchTesting(): No response from #InvokeResourceAPI`);
|
|
9471
|
-
} catch (error) {
|
|
9472
|
-
this.LogError("GenericSearchTesting", error);
|
|
9473
|
-
throw error;
|
|
9474
|
-
}
|
|
9475
|
-
};
|
|
9476
|
-
};
|
|
9477
|
-
//#endregion
|
|
9478
9223
|
//#region node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
9479
9224
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
9480
9225
|
var wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
|
|
@@ -9810,6 +9555,280 @@ Object.defineProperties(createChalk.prototype, styles);
|
|
|
9810
9555
|
var chalk = createChalk();
|
|
9811
9556
|
createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
9812
9557
|
//#endregion
|
|
9558
|
+
//#region src/cv2/fhirRESTClient.ts
|
|
9559
|
+
var FhirRESTClient = class {
|
|
9560
|
+
#options;
|
|
9561
|
+
constructor(options) {
|
|
9562
|
+
this.#options = options;
|
|
9563
|
+
}
|
|
9564
|
+
BaseUrl() {
|
|
9565
|
+
return `${this.#options.endpoint}:${this.#options.stsfhirport}${this.#options.stsfhirapiroot}`;
|
|
9566
|
+
}
|
|
9567
|
+
HandleError = (error) => {
|
|
9568
|
+
this.#options.logger.error(chalk.red(`HandleError(): Error: [${error}]`));
|
|
9569
|
+
if (axios.isAxiosError(error)) {
|
|
9570
|
+
const axiosError = error;
|
|
9571
|
+
if (axiosError.response) {
|
|
9572
|
+
this.#options.logger.error(chalk.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
9573
|
+
if (axiosError.response.headers) this.#options.logger.error(chalk.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
9574
|
+
if (axiosError.response.data) this.#options.logger.error(chalk.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
9575
|
+
try {
|
|
9576
|
+
if (axiosError.response.config) this.#options.logger.error(chalk.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
9577
|
+
} catch (innererror) {
|
|
9578
|
+
this.#options.logger.error(chalk.red(` could not get response config, error: [${innererror}]`));
|
|
9579
|
+
}
|
|
9580
|
+
} else this.#options.logger.error(chalk.red(`AXIOS Error = [${axiosError}]`));
|
|
9581
|
+
}
|
|
9582
|
+
};
|
|
9583
|
+
LogError = (method, error) => {
|
|
9584
|
+
this.#options.logger.error(`FhirRESTClient:${method}(): Error: [${error}]`);
|
|
9585
|
+
this.#options.logger.error(error);
|
|
9586
|
+
console.error(error);
|
|
9587
|
+
this.HandleError(error);
|
|
9588
|
+
process.exit(0);
|
|
9589
|
+
};
|
|
9590
|
+
LogWarning = (method, message) => {
|
|
9591
|
+
this.#options.logger.warn(`FhirRESTClient:${method}(): Warn: [${message}]`);
|
|
9592
|
+
};
|
|
9593
|
+
/**
|
|
9594
|
+
*
|
|
9595
|
+
* @param url
|
|
9596
|
+
* @param httpVerb
|
|
9597
|
+
* @param versionIdETag Format "W/<versionNumber", e.g. "W/3"
|
|
9598
|
+
* @param resource
|
|
9599
|
+
* @returns
|
|
9600
|
+
*/
|
|
9601
|
+
#InvokeResourceAPI = async (url, httpVerb, versionIdETag, resource, contentType) => {
|
|
9602
|
+
const accessToken = await this.#options.GetAccessToken();
|
|
9603
|
+
let requestConfig;
|
|
9604
|
+
const headers = {
|
|
9605
|
+
Prefer: "return=representation",
|
|
9606
|
+
Accept: "application/fhir+json"
|
|
9607
|
+
};
|
|
9608
|
+
if (versionIdETag && versionIdETag !== "") headers["If-Match"] = versionIdETag;
|
|
9609
|
+
if (httpVerb === "patch") {
|
|
9610
|
+
requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationMergePatchAndJsonContentTypeHeaders();
|
|
9611
|
+
if (resource && contentType) {
|
|
9612
|
+
if (contentType.localeCompare("application/merge-patch+json") === 0) requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationMergePatchAndJsonContentTypeHeaders();
|
|
9613
|
+
else if (contentType.localeCompare("application/json-patch+json") === 0) requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationJsonPatchAndJsonContentTypeHeaders();
|
|
9614
|
+
}
|
|
9615
|
+
} else requestConfig = new STSAxiosConfig(url, httpVerb).withApplicationFhirAndJsonContentTypeHeaders();
|
|
9616
|
+
requestConfig.withAuthHeaders(accessToken, this.#options.user).withHeaders(headers);
|
|
9617
|
+
if (resource) requestConfig.withData(resource);
|
|
9618
|
+
if (this.#options.agentManager) requestConfig.withAgentManager(this.#options.agentManager);
|
|
9619
|
+
return await createRetryAxiosClient({
|
|
9620
|
+
maxRetries: 4,
|
|
9621
|
+
retryDelayMs: 300,
|
|
9622
|
+
retryJitterMs: 150,
|
|
9623
|
+
maxRetryDurationMs: 5e3,
|
|
9624
|
+
onRetryAttempt: (attempt, error, delayMs) => {
|
|
9625
|
+
this.LogWarning("#InvokeResourceAPI", `Retry #${attempt} after ${delayMs}ms due to ${error.code || error.response?.status}`);
|
|
9626
|
+
if (this.#options.onRetryAttempt) this.#options.onRetryAttempt(attempt, error, delayMs);
|
|
9627
|
+
}
|
|
9628
|
+
})(url, requestConfig.config);
|
|
9629
|
+
};
|
|
9630
|
+
ProcessBatchOrTransactionResources = async (bundle) => {
|
|
9631
|
+
try {
|
|
9632
|
+
let url = `${this.BaseUrl()}`;
|
|
9633
|
+
const retVal = await this.#InvokeResourceAPI(url, "post", null, bundle);
|
|
9634
|
+
if (retVal) return {
|
|
9635
|
+
status: retVal.status,
|
|
9636
|
+
body: retVal.data
|
|
9637
|
+
};
|
|
9638
|
+
else throw new Error(`FhirRESTClient:ProcessBatchOrTransactionResources(): No response from #InvokeResourceAPI`);
|
|
9639
|
+
} catch (error) {
|
|
9640
|
+
this.LogError("ProcessBatchOrTransactionResources", error);
|
|
9641
|
+
throw error;
|
|
9642
|
+
}
|
|
9643
|
+
};
|
|
9644
|
+
GetResources = async (searchUrl) => {
|
|
9645
|
+
try {
|
|
9646
|
+
const retVal = await this.#InvokeResourceAPI(searchUrl.toString(), "get", null, null);
|
|
9647
|
+
if (retVal) return {
|
|
9648
|
+
status: retVal.status,
|
|
9649
|
+
body: retVal.data
|
|
9650
|
+
};
|
|
9651
|
+
else throw new Error(`FhirRESTClient:GetResources(): No response from #InvokeResourceAPI`);
|
|
9652
|
+
} catch (error) {
|
|
9653
|
+
this.LogError("GetResources", error);
|
|
9654
|
+
throw error;
|
|
9655
|
+
}
|
|
9656
|
+
};
|
|
9657
|
+
GetHistoryFhirResources = async (searchUrl) => {
|
|
9658
|
+
try {
|
|
9659
|
+
return await this.GetResources(searchUrl);
|
|
9660
|
+
} catch (error) {
|
|
9661
|
+
this.LogError("GetHistoryFhirResources", error);
|
|
9662
|
+
throw error;
|
|
9663
|
+
}
|
|
9664
|
+
};
|
|
9665
|
+
GetHistoryFhirResource = async (searchUrl) => {
|
|
9666
|
+
try {
|
|
9667
|
+
return await this.GetResources(searchUrl);
|
|
9668
|
+
} catch (error) {
|
|
9669
|
+
this.LogError("GetHistoryFhirResource", error);
|
|
9670
|
+
throw error;
|
|
9671
|
+
}
|
|
9672
|
+
};
|
|
9673
|
+
GetAllFhirResources = async (searchUrl) => {
|
|
9674
|
+
try {
|
|
9675
|
+
return await this.GetResources(searchUrl);
|
|
9676
|
+
} catch (error) {
|
|
9677
|
+
this.LogError("GetAllFhirResources", error);
|
|
9678
|
+
throw error;
|
|
9679
|
+
}
|
|
9680
|
+
};
|
|
9681
|
+
GetResource = async (resourceType, resourceId) => {
|
|
9682
|
+
try {
|
|
9683
|
+
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9684
|
+
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9685
|
+
if (retVal) return {
|
|
9686
|
+
status: retVal.status,
|
|
9687
|
+
body: retVal.data
|
|
9688
|
+
};
|
|
9689
|
+
else throw new Error(`FhirRESTClient:GetResource(): No response from #InvokeResourceAPI`);
|
|
9690
|
+
} catch (error) {
|
|
9691
|
+
if (axios.isAxiosError(error)) {
|
|
9692
|
+
const axiosError = error;
|
|
9693
|
+
return {
|
|
9694
|
+
status: axiosError.response.status,
|
|
9695
|
+
body: axiosError.response.data,
|
|
9696
|
+
headers: { ETag: axiosError.response.headers["etag"] }
|
|
9697
|
+
};
|
|
9698
|
+
} else throw error;
|
|
9699
|
+
}
|
|
9700
|
+
};
|
|
9701
|
+
PutResource = async (resourceType, domainResource, versionIdETag) => {
|
|
9702
|
+
try {
|
|
9703
|
+
let url = `${`${this.BaseUrl()}/${resourceType}`}/${domainResource.id}`;
|
|
9704
|
+
const retVal = await this.#InvokeResourceAPI(url, "put", versionIdETag, domainResource);
|
|
9705
|
+
if (retVal) return {
|
|
9706
|
+
status: retVal.status,
|
|
9707
|
+
body: retVal.data
|
|
9708
|
+
};
|
|
9709
|
+
else throw new Error(`FhirRESTClient:PutResource(): No response from #InvokeResourceAPI`);
|
|
9710
|
+
} catch (error) {
|
|
9711
|
+
this.LogError("PutResource", error);
|
|
9712
|
+
throw error;
|
|
9713
|
+
}
|
|
9714
|
+
};
|
|
9715
|
+
PatchResource = async (resourceType, resourceId, domainResource, contentType, versionIdETag) => {
|
|
9716
|
+
try {
|
|
9717
|
+
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9718
|
+
const retVal = await this.#InvokeResourceAPI(url, "patch", versionIdETag, domainResource, contentType);
|
|
9719
|
+
if (retVal) return {
|
|
9720
|
+
status: retVal.status,
|
|
9721
|
+
body: retVal.data
|
|
9722
|
+
};
|
|
9723
|
+
else throw new Error(`FhirRESTClient:PatchResource(): No response from #InvokeResourceAPI`);
|
|
9724
|
+
} catch (error) {
|
|
9725
|
+
this.LogError("PatchResource", error);
|
|
9726
|
+
throw error;
|
|
9727
|
+
}
|
|
9728
|
+
};
|
|
9729
|
+
PostResource = async (resourceType, domainResource) => {
|
|
9730
|
+
try {
|
|
9731
|
+
const url = `${this.BaseUrl()}/${resourceType}`;
|
|
9732
|
+
const retVal = await this.#InvokeResourceAPI(url, "post", null, domainResource);
|
|
9733
|
+
if (retVal) return {
|
|
9734
|
+
status: retVal.status,
|
|
9735
|
+
body: retVal.data
|
|
9736
|
+
};
|
|
9737
|
+
else throw new Error(`FhirRESTClient:PostResource(): No response from #InvokeResourceAPI`);
|
|
9738
|
+
} catch (error) {
|
|
9739
|
+
this.LogError("PostResource", error);
|
|
9740
|
+
throw error;
|
|
9741
|
+
}
|
|
9742
|
+
};
|
|
9743
|
+
GetHistoryInstanceFhirResource = async (resourceType, resourceId, versionId) => {
|
|
9744
|
+
try {
|
|
9745
|
+
const url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}/_history/${versionId.toString()}`;
|
|
9746
|
+
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9747
|
+
if (retVal) return {
|
|
9748
|
+
status: retVal.status,
|
|
9749
|
+
body: retVal.data
|
|
9750
|
+
};
|
|
9751
|
+
else throw new Error(`FhirRESTClient:GetHistoryInstanceFhirResource(): No response from #InvokeResourceAPI`);
|
|
9752
|
+
} catch (error) {
|
|
9753
|
+
if (axios.isAxiosError(error)) {
|
|
9754
|
+
const axiosError = error;
|
|
9755
|
+
return {
|
|
9756
|
+
status: axiosError.response.status,
|
|
9757
|
+
body: axiosError.response.data,
|
|
9758
|
+
headers: { ETag: axiosError.response.headers["etag"] }
|
|
9759
|
+
};
|
|
9760
|
+
} else throw error;
|
|
9761
|
+
}
|
|
9762
|
+
};
|
|
9763
|
+
ExtractNumber(str) {
|
|
9764
|
+
if (typeof str !== "string") return null;
|
|
9765
|
+
const match = str.match(/^\s*(?:W\/\s*)?"\s*([\d.]+)\s*"$/i);
|
|
9766
|
+
return match ? Number(match[1]) : null;
|
|
9767
|
+
}
|
|
9768
|
+
DeleteResource = async (resourceType, resourceId, versionIdETag) => {
|
|
9769
|
+
try {
|
|
9770
|
+
let url = `${`${this.BaseUrl()}/${resourceType}`}/${resourceId}`;
|
|
9771
|
+
const retVal = await this.#InvokeResourceAPI(url, "delete", versionIdETag, null);
|
|
9772
|
+
if (retVal) return {
|
|
9773
|
+
status: retVal.status,
|
|
9774
|
+
body: retVal.data
|
|
9775
|
+
};
|
|
9776
|
+
else throw new Error(`FhirRESTClient:DeleteResource(): No response from #InvokeResourceAPI`);
|
|
9777
|
+
} catch (error) {
|
|
9778
|
+
if (axios.isAxiosError(error)) {
|
|
9779
|
+
const axiosError = error;
|
|
9780
|
+
const versionNumber = this.ExtractNumber(versionIdETag) + 1;
|
|
9781
|
+
return {
|
|
9782
|
+
status: axiosError.response.status,
|
|
9783
|
+
body: axiosError.response.data,
|
|
9784
|
+
headers: { ETag: `W/"${versionNumber}"` }
|
|
9785
|
+
};
|
|
9786
|
+
} else throw error;
|
|
9787
|
+
}
|
|
9788
|
+
};
|
|
9789
|
+
GetMetadata = async () => {
|
|
9790
|
+
try {
|
|
9791
|
+
const resourceUrl = `${this.BaseUrl()}/metadata`;
|
|
9792
|
+
const retVal = await this.#InvokeResourceAPI(resourceUrl, "get", null, null);
|
|
9793
|
+
if (retVal) return {
|
|
9794
|
+
status: retVal.status,
|
|
9795
|
+
body: retVal.data
|
|
9796
|
+
};
|
|
9797
|
+
else throw new Error(`FhirRESTClient:GetMetadata(): No response from #InvokeResourceAPI`);
|
|
9798
|
+
} catch (error) {
|
|
9799
|
+
this.LogError("GetMetadata", error);
|
|
9800
|
+
throw error;
|
|
9801
|
+
}
|
|
9802
|
+
};
|
|
9803
|
+
GetLatency = async (params) => {
|
|
9804
|
+
try {
|
|
9805
|
+
const url = `${this.BaseUrl()}/latency`;
|
|
9806
|
+
const retVal = await this.#InvokeResourceAPI(url, "get", null, null);
|
|
9807
|
+
if (retVal) return {
|
|
9808
|
+
status: retVal.status,
|
|
9809
|
+
body: retVal.data
|
|
9810
|
+
};
|
|
9811
|
+
else throw new Error(`FhirRESTClient:GetLatency(): No response from #InvokeResourceAPI`);
|
|
9812
|
+
} catch (error) {
|
|
9813
|
+
this.LogError("GetLatency", error);
|
|
9814
|
+
throw error;
|
|
9815
|
+
}
|
|
9816
|
+
};
|
|
9817
|
+
GenericSearchTesting = async (resourceType, params) => {
|
|
9818
|
+
try {
|
|
9819
|
+
const retVal = await this.#InvokeResourceAPI(`${this.BaseUrl()}/${resourceType}/_genericSearchTesting`, "post", null, params);
|
|
9820
|
+
if (retVal) return {
|
|
9821
|
+
status: retVal.status,
|
|
9822
|
+
body: retVal.data
|
|
9823
|
+
};
|
|
9824
|
+
else throw new Error(`FhirRESTClient:GenericSearchTesting(): No response from #InvokeResourceAPI`);
|
|
9825
|
+
} catch (error) {
|
|
9826
|
+
this.LogError("GenericSearchTesting", error);
|
|
9827
|
+
throw error;
|
|
9828
|
+
}
|
|
9829
|
+
};
|
|
9830
|
+
};
|
|
9831
|
+
//#endregion
|
|
9813
9832
|
//#region node_modules/@nsshunt/stssocketioutils/dist/tiny-emitter-DcZ69ZvJ.js
|
|
9814
9833
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9815
9834
|
var require_tiny_emitter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|