@nsshunt/ststestrunner 1.1.148 → 1.1.149

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.
@@ -1444,20 +1444,57 @@ var TestCaseFhir01 = class extends TestCaseFhirQueryBase {
1444
1444
  //#endregion
1445
1445
  //#region src/libmodule/testCaseFhir02.ts
1446
1446
  var TestCaseFhir02 = class extends TestCaseFhirQueryBase {
1447
+ bundleBatch;
1448
+ personRecords = [];
1447
1449
  PerformExecuteQuery = async () => {
1448
1450
  const __snapshot1 = performance.now();
1449
1451
  const client = await this.GetClient();
1450
1452
  const __snapshot2 = this._CheckOutputLongDurationError(__snapshot1, "await this.GetClient()");
1451
1453
  const prefix = this.runner.options.personPrefix;
1454
+ const bundleSize = this.runner.options.bundleSize;
1455
+ if (this.runner.iteration === 0) this.bundleBatch = {
1456
+ "resourceType": "Bundle",
1457
+ "type": "transaction",
1458
+ "entry": []
1459
+ };
1452
1460
  const personRecord = await this.GetPersonRecord(prefix, this.runner.iteration, "1");
1453
1461
  const __snapshot3 = this._CheckOutputLongDurationError(__snapshot2, "await this.GetPersonRecord()");
1454
- const retVal = await client.PostResource("Person", personRecord);
1455
- this._CheckOutputLongDurationError(__snapshot3, "await this.PostResource()");
1456
- if (retVal.status === StatusCodes.UNAUTHORIZED) throw new Error("UNAUTHORIZED");
1457
- delete personRecord.meta;
1458
- delete retVal.body.meta;
1459
- this.CheckReturnData(personRecord, retVal.body);
1460
- return retVal.body;
1462
+ const foundIndexPersonRecords = this.personRecords.findIndex((p) => p.id?.localeCompare(personRecord.id) === 0);
1463
+ const foundIndexBindlePersonRecords = this.bundleBatch.entry.findIndex((p) => p.resource.id?.localeCompare(personRecord.id) === 0);
1464
+ if (foundIndexPersonRecords === -1) {
1465
+ if (foundIndexBindlePersonRecords !== -1) throw new Error(`TestCaseFhir02:PerformExecuteQuery(): Invalid record state for batch transaction, foundIndexPersonRecords: [${foundIndexPersonRecords}], foundIndexBindlePersonRecords: [${foundIndexBindlePersonRecords}], personRecord.id: [${personRecord.id}]`);
1466
+ this.personRecords.push(personRecord);
1467
+ this.bundleBatch.entry.push({
1468
+ fullUrl: personRecord.id,
1469
+ resource: personRecord,
1470
+ request: {
1471
+ method: "POST",
1472
+ url: "Person"
1473
+ }
1474
+ });
1475
+ }
1476
+ let retVal = void 0;
1477
+ if (this.runner.iteration % bundleSize === bundleSize - 1) {
1478
+ retVal = await client.ProcessBatchOrTransactionResources(this.bundleBatch);
1479
+ this._CheckOutputLongDurationError(__snapshot3, "await this.PostResource()");
1480
+ this.bundleBatch.entry = [];
1481
+ } else if (this.runner.iteration === this.runner.options.executionProfile.iterations - 1) {
1482
+ retVal = await client.ProcessBatchOrTransactionResources(this.bundleBatch);
1483
+ this._CheckOutputLongDurationError(__snapshot3, "await this.PostResource()");
1484
+ this.bundleBatch.entry = [];
1485
+ }
1486
+ if (retVal && retVal.status === StatusCodes.UNAUTHORIZED) throw new Error("UNAUTHORIZED");
1487
+ if (retVal) {
1488
+ for (let i = 0; i < retVal.body.entry.length - 1; i++) {
1489
+ const personRecord = this.personRecords[i];
1490
+ delete personRecord.meta;
1491
+ const retPersonData = { ...retVal.body.entry[i].resource };
1492
+ delete retPersonData.meta;
1493
+ this.CheckReturnData(personRecord, retPersonData);
1494
+ }
1495
+ this.personRecords = [];
1496
+ }
1497
+ return personRecord;
1461
1498
  };
1462
1499
  };
1463
1500
  //#endregion