@nsshunt/ststestrunner 1.1.148 → 1.1.150

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