@nsshunt/stsfhirpg 1.2.5 → 1.2.7

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.
Files changed (33) hide show
  1. package/dist/stsfhirpg.cjs +95 -86
  2. package/dist/stsfhirpg.cjs.map +1 -1
  3. package/dist/stsfhirpg.mjs +95 -86
  4. package/dist/stsfhirpg.mjs.map +1 -1
  5. package/package.json +2 -1
  6. package/types/fhir-database/dbsearchindex.d.ts +4 -4
  7. package/types/fhir-database/dbsearchindex.d.ts.map +1 -1
  8. package/types/fhir-database/dbsearchindexbase.d.ts +2 -2
  9. package/types/fhir-database/dbsearchindexbase.d.ts.map +1 -1
  10. package/types/fhir-database/dbsearchindexcomposite.d.ts +2 -2
  11. package/types/fhir-database/dbsearchindexcomposite.d.ts.map +1 -1
  12. package/types/fhir-database/dbsearchindexdates.d.ts +2 -2
  13. package/types/fhir-database/dbsearchindexdates.d.ts.map +1 -1
  14. package/types/fhir-database/dbsearchindexnumber.d.ts +2 -2
  15. package/types/fhir-database/dbsearchindexnumber.d.ts.map +1 -1
  16. package/types/fhir-database/dbsearchindexquantity.d.ts +2 -2
  17. package/types/fhir-database/dbsearchindexquantity.d.ts.map +1 -1
  18. package/types/fhir-database/dbsearchindexreference.d.ts +2 -2
  19. package/types/fhir-database/dbsearchindexreference.d.ts.map +1 -1
  20. package/types/fhir-database/dbsearchindexstring.d.ts +2 -2
  21. package/types/fhir-database/dbsearchindexstring.d.ts.map +1 -1
  22. package/types/fhir-database/dbsearchindextesthelpers.d.ts +1 -1
  23. package/types/fhir-database/dbsearchindextesthelpers.d.ts.map +1 -1
  24. package/types/fhir-database/dbsearchindextoken.d.ts +2 -2
  25. package/types/fhir-database/dbsearchindextoken.d.ts.map +1 -1
  26. package/types/fhir-database/dbsearchindexuri.d.ts +2 -2
  27. package/types/fhir-database/dbsearchindexuri.d.ts.map +1 -1
  28. package/types/fhir-utils/resourceHelper.d.ts +11 -10
  29. package/types/fhir-utils/resourceHelper.d.ts.map +1 -1
  30. package/types/redisDistributedLock.d.ts +36 -0
  31. package/types/redisDistributedLock.d.ts.map +1 -0
  32. package/types/searchParameterManager.d.ts +38 -0
  33. package/types/searchParameterManager.d.ts.map +1 -0
@@ -7002,6 +7002,7 @@ const typesPath = "fhir-spec/profiles-types.json";
7002
7002
  const searchParamsPath = "fhir-spec/search-parameters.json";
7003
7003
  class ResourceHelper {
7004
7004
  #definitions;
7005
+ searchParameterManager;
7005
7006
  static instance;
7006
7007
  constructor() {
7007
7008
  }
@@ -7011,7 +7012,7 @@ class ResourceHelper {
7011
7012
  }
7012
7013
  return ResourceHelper.instance;
7013
7014
  }
7014
- #LoadDefinitions = () => {
7015
+ #LoadDefinitions = async () => {
7015
7016
  let usePath = "";
7016
7017
  if (fs.existsSync(`${specPath1}${resourcesPath}`)) {
7017
7018
  usePath = specPath1;
@@ -7045,23 +7046,25 @@ class ResourceHelper {
7045
7046
  __searchParams.entry.forEach((entry) => {
7046
7047
  this.#definitions.searchParametersByUrl[entry.fullUrl] = entry.resource;
7047
7048
  });
7048
- this._LoadSearchParameters();
7049
+ await this._LoadSearchParameters();
7049
7050
  return this.#definitions;
7050
7051
  };
7051
- get definitions() {
7052
+ GetDefinitions = async () => {
7052
7053
  if (!this.#definitions) {
7053
- this.#LoadDefinitions();
7054
+ await this.#LoadDefinitions();
7054
7055
  }
7055
7056
  return this.#definitions;
7056
- }
7057
- GetType = (typeName) => {
7058
- return this.definitions.types[typeName];
7059
7057
  };
7060
- GetResource = (resourceType) => {
7061
- return this.definitions.resources[resourceType];
7058
+ GetType = async (typeName) => {
7059
+ await this.GetDefinitions();
7060
+ return this.#definitions.types[typeName];
7061
+ };
7062
+ GetResource = async (resourceType) => {
7063
+ await this.GetDefinitions();
7064
+ return this.#definitions.resources[resourceType];
7062
7065
  };
7063
- GetResourceField = (resourceType, fieldPath) => {
7064
- const resource = this.GetResource(resourceType);
7066
+ GetResourceField = async (resourceType, fieldPath) => {
7067
+ const resource = await this.GetResource(resourceType);
7065
7068
  if (resource) {
7066
7069
  const foundRecord = resource.filter((o) => o.id === fieldPath);
7067
7070
  if (foundRecord.length > 0) {
@@ -7070,14 +7073,17 @@ class ResourceHelper {
7070
7073
  return void 0;
7071
7074
  }
7072
7075
  };
7073
- GetSearchParam = (url) => {
7074
- return this.definitions.searchParametersByUrl[url];
7076
+ GetSearchParam = async (url) => {
7077
+ await this.GetDefinitions();
7078
+ return this.#definitions.searchParametersByUrl[url];
7075
7079
  };
7076
- GetSearchParams = () => {
7077
- return this.definitions.searchParametersByUrl;
7080
+ GetSearchParams = async () => {
7081
+ await this.GetDefinitions();
7082
+ return this.#definitions.searchParametersByUrl;
7078
7083
  };
7079
- GetSearchParamsByResource = (resource) => {
7080
- return Object.values(this.definitions.searchParametersByUrl).filter((sp) => sp.base.includes(resource)).map((sp) => sp);
7084
+ GetSearchParamsByResource = async (resource) => {
7085
+ await this.GetDefinitions();
7086
+ return Object.values(this.#definitions.searchParametersByUrl).filter((sp) => sp.base.includes(resource)).map((sp) => sp);
7081
7087
  };
7082
7088
  // ------------------------------------------------------------------------------------------------------------------
7083
7089
  // Remove ( ) when either are present
@@ -7200,8 +7206,8 @@ class ResourceHelper {
7200
7206
  original_expressions
7201
7207
  };
7202
7208
  };
7203
- _LoadSearchParameters = () => {
7204
- for (const [key, val] of Object.entries(this.GetSearchParams())) {
7209
+ _LoadSearchParameters = async () => {
7210
+ for (const [key, val] of Object.entries(await this.GetSearchParams())) {
7205
7211
  const { id, url, code, base, type, expression, component, target } = val;
7206
7212
  for (let i = 0; i < base.length; i++) {
7207
7213
  const resourceName = base[i];
@@ -7232,44 +7238,47 @@ class ResourceHelper {
7232
7238
  SP_TARGET,
7233
7239
  expressions,
7234
7240
  original_expressions,
7235
- SP_DEFINITION: this.GetSearchParam(SP_URL)
7241
+ SP_DEFINITION: await this.GetSearchParam(SP_URL)
7236
7242
  };
7237
7243
  for (let i2 = 0; i2 < record.expressions.length; i2++) {
7238
- const rf = this.GetResourceField(resourceName, record.expressions[i2].path);
7244
+ const rf = await this.GetResourceField(resourceName, record.expressions[i2].path);
7239
7245
  if (rf) {
7240
7246
  expressions[i2].RES_FIELD = rf;
7241
7247
  }
7242
7248
  }
7243
7249
  if (component) {
7244
7250
  record.component = [...component];
7245
- record.component.forEach((c) => {
7251
+ for (const c of record.component) {
7246
7252
  const retVal = this.ProcessExpressions("", c.expression);
7247
7253
  c.expressions = retVal.expressions;
7248
7254
  c.original_expressions = retVal.original_expressions;
7249
- const def = this.GetSearchParam(c.definition);
7255
+ const def = await this.GetSearchParam(c.definition);
7250
7256
  if (def && def.type) {
7251
7257
  c.type = def.type;
7252
7258
  }
7253
- });
7259
+ }
7254
7260
  }
7255
7261
  this.#definitions.searchParametersByResourceType[resourceName].params.push(record);
7256
7262
  }
7257
7263
  }
7258
7264
  };
7259
- GetSearchParamFromResourceTypeUrl = (resourceType, url) => {
7260
- const filterByNameAndUrl = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
7265
+ GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
7266
+ await this.GetDefinitions();
7267
+ const filterByNameAndUrl = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
7261
7268
  if (filterByNameAndUrl.length > 0) {
7262
7269
  return filterByNameAndUrl[0];
7263
7270
  }
7264
7271
  };
7265
- GetSearchParamFromResourceType = (resourceType, name) => {
7266
- const filterByName = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
7272
+ GetSearchParamFromResourceType = async (resourceType, name) => {
7273
+ await this.GetDefinitions();
7274
+ const filterByName = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
7267
7275
  if (filterByName.length > 0) {
7268
7276
  return filterByName[0];
7269
7277
  }
7270
7278
  };
7271
- GetSearchParamsFromResourceType = (resourceType) => {
7272
- return this.definitions.searchParametersByResourceType[resourceType].params;
7279
+ GetSearchParamsFromResourceType = async (resourceType) => {
7280
+ await this.GetDefinitions();
7281
+ return this.#definitions.searchParametersByResourceType[resourceType].params;
7273
7282
  };
7274
7283
  }
7275
7284
  var ansiStyles = { exports: {} };
@@ -10671,7 +10680,7 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10671
10680
  }
10672
10681
  }
10673
10682
  };
10674
- OutputIndexRecordFromFhirElement = (path, inputTokens, tir) => {
10683
+ OutputIndexRecordFromFhirElement = async (path, inputTokens, tir) => {
10675
10684
  const _OutputMissingParamater = () => {
10676
10685
  const tirc = this.GetNewBaseIndexRecord(tir);
10677
10686
  tirc.SP_MISSING = true;
@@ -10703,12 +10712,12 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10703
10712
  }
10704
10713
  return retVal;
10705
10714
  };
10706
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10715
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10707
10716
  let retVal = [];
10708
- searchFieldRecord.expressions.forEach((expression) => {
10717
+ for (const expression of searchFieldRecord.expressions) {
10709
10718
  let tokens = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10710
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, tokens, tir));
10711
- });
10719
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, tokens, tir));
10720
+ }
10712
10721
  return retVal;
10713
10722
  };
10714
10723
  OutputIndexRecordToConsole = (tir) => {
@@ -10724,7 +10733,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10724
10733
  #warn = (message) => {
10725
10734
  };
10726
10735
  // This method is empty becuase the composite processor will not call itself recursively
10727
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir) => {
10736
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir) => {
10728
10737
  this.#warn(`DBSearchIndexComposite:__OutputIndexRecordFromFhirElement(): composite (recursive) not supported within a composite expression. inputReferenceVal: [${inputReferenceVal}], tir: [${tir}]`);
10729
10738
  return [];
10730
10739
  };
@@ -10739,15 +10748,15 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10739
10748
  // / root level code and quantity, i.e. Observation.code + Observation.value[x]Quantity
10740
10749
  // /component_0 component level at index 0 Observation.component[0].code + Observation.component[0].value[x]Quantity
10741
10750
  // /component_1 component level at index 1 Observation.component[1].code + Observation.component[1].value[x]Quantity
10742
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10751
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10743
10752
  let comboNonUniqueRecords = [];
10744
10753
  const searchIndex = DBSearchIndex.getInstance();
10745
10754
  let index = 0;
10746
10755
  let components = [];
10747
- searchFieldRecord.component.forEach((searchParamComponentRecord) => {
10756
+ for (const searchParamComponentRecord of searchFieldRecord.component) {
10748
10757
  components.push([]);
10749
10758
  const url = searchParamComponentRecord.definition;
10750
- const sp = searchIndex.resourceHelper.GetSearchParamFromResourceTypeUrl(resource.resourceType, url);
10759
+ const sp = await searchIndex.resourceHelper.GetSearchParamFromResourceTypeUrl(resource.resourceType, url);
10751
10760
  if (this.IsDefined(sp)) {
10752
10761
  const tir2 = {
10753
10762
  PID: v4(),
@@ -10763,7 +10772,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10763
10772
  COMPOSITE: null,
10764
10773
  COMPOSITE_HASH_EXACT: null
10765
10774
  };
10766
- const retVal = SearchRegistry.getInstance().searchIndexBaseRegistry[sp.SP_TYPE].OutputIndexRecord(resource, tir2, sp);
10775
+ const retVal = await SearchRegistry.getInstance().searchIndexBaseRegistry[sp.SP_TYPE].OutputIndexRecord(resource, tir2, sp);
10767
10776
  retVal.forEach((rv) => {
10768
10777
  if (!(rv.SP_MISSING && rv.SP_MISSING === true)) {
10769
10778
  if (rv.SP_STR && rv.SP_STR !== void 0) {
@@ -10773,7 +10782,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10773
10782
  });
10774
10783
  index++;
10775
10784
  }
10776
- });
10785
+ }
10777
10786
  for (let i = 0; i < components[0].length; i++) {
10778
10787
  for (let j = 0; j < components[1].length; j++) {
10779
10788
  const idxString = `${components[0][i].SP_STR}|${components[1][j].SP_STR}`;
@@ -10807,7 +10816,7 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10807
10816
  | `Period` | Explicit, though the upper or lower bound might not actually be specified in resources. |
10808
10817
  | `Timing` | The specified scheduling details are ignored and only the outer limits matter. For instance, a schedule that specifies every second day between 31-Jan-2013 and 24-Mar-2013 includes 1-Feb-2013, even though that is on an odd day that is not specified by the period. This is to keep the server load processing queries reasonable. |
10809
10818
  */
10810
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir) => {
10819
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir) => {
10811
10820
  let retVal = [];
10812
10821
  const _OutputDate = (referenceVal, tir2, index) => {
10813
10822
  let parsedDate;
@@ -10886,12 +10895,12 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10886
10895
  }
10887
10896
  return retVal;
10888
10897
  };
10889
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10898
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10890
10899
  let retVal = [];
10891
- searchFieldRecord.expressions.forEach((expression) => {
10900
+ for (const expression of searchFieldRecord.expressions) {
10892
10901
  let referenceVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10893
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir));
10894
- });
10902
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir));
10903
+ }
10895
10904
  return retVal;
10896
10905
  };
10897
10906
  OutputIndexRecordToConsole = (tir) => {
@@ -10946,7 +10955,7 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10946
10955
  }
10947
10956
  return quantityIndexRecords;
10948
10957
  };
10949
- OutputIndexRecordFromFhirElement = (path, inputQuantityVal, tir) => {
10958
+ OutputIndexRecordFromFhirElement = async (path, inputQuantityVal, tir) => {
10950
10959
  const retVal = [];
10951
10960
  if (this.IsDefined(inputQuantityVal)) {
10952
10961
  const _PushQty = (qVal, index) => {
@@ -10974,12 +10983,12 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10974
10983
  }
10975
10984
  return retVal;
10976
10985
  };
10977
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10986
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10978
10987
  const retVal = [];
10979
- searchFieldRecord.expressions.forEach((expression) => {
10988
+ for (const expression of searchFieldRecord.expressions) {
10980
10989
  let quantityVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10981
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, quantityVal, tir));
10982
- });
10990
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, quantityVal, tir));
10991
+ }
10983
10992
  return retVal;
10984
10993
  };
10985
10994
  OutputIndexRecordToConsole = (tir) => {
@@ -11039,7 +11048,7 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11039
11048
  throw error;
11040
11049
  }
11041
11050
  };
11042
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir, searchParamExpressionRecord, resource) => {
11051
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir, searchParamExpressionRecord, resource) => {
11043
11052
  const _OutputReferencesFromFhirElement = (referenceVal, index) => {
11044
11053
  let resourceReference;
11045
11054
  if (this.IsDefined(referenceVal) && this.IsDefined(referenceVal.identifier) && this.IsDefined(referenceVal.identifier.value)) {
@@ -11081,12 +11090,12 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11081
11090
  }
11082
11091
  return retVal;
11083
11092
  };
11084
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11093
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11085
11094
  let retVal = [];
11086
- searchFieldRecord.expressions.forEach((expression) => {
11095
+ for (const expression of searchFieldRecord.expressions) {
11087
11096
  const referenceVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11088
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir, expression, resource));
11089
- });
11097
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir, expression, resource));
11098
+ }
11090
11099
  return retVal;
11091
11100
  };
11092
11101
  OutputIndexRecordToConsole = (tir) => {
@@ -11101,7 +11110,7 @@ class DBSearchIndexString extends DBSearchIndexBase {
11101
11110
  }
11102
11111
  #debug = (message) => {
11103
11112
  };
11104
- #OutputString = (stringInputVal, tir, expression) => {
11113
+ #OutputString = async (stringInputVal, tir, expression) => {
11105
11114
  const stringIndexRecords = [];
11106
11115
  if (this.IsDefined(expression) && typeof stringInputVal === "object") {
11107
11116
  let fields = [];
@@ -11114,9 +11123,9 @@ class DBSearchIndexString extends DBSearchIndexBase {
11114
11123
  }
11115
11124
  let res;
11116
11125
  if (this.IsDefined(expressionType) && this.IsDefined(expressionType.code)) {
11117
- res = this.#resourceHelper.GetType(expressionType.code);
11126
+ res = await this.#resourceHelper.GetType(expressionType.code);
11118
11127
  } else {
11119
- res = this.#resourceHelper.GetType(expressionType);
11128
+ res = await this.#resourceHelper.GetType(expressionType);
11120
11129
  }
11121
11130
  if (this.IsDefined(res)) {
11122
11131
  for (let i = 0; i < res.length; i++) {
@@ -11171,20 +11180,20 @@ class DBSearchIndexString extends DBSearchIndexBase {
11171
11180
  }
11172
11181
  }
11173
11182
  };
11174
- OutputIndexRecordFromFhirElement = (path, inputStringVal, tir, expression) => {
11183
+ OutputIndexRecordFromFhirElement = async (path, inputStringVal, tir, expression) => {
11175
11184
  const retVal = [];
11176
11185
  if (this.IsDefined(inputStringVal)) {
11177
- const _PushStrings = (stringVals, index) => {
11186
+ const _PushStrings = async (stringVals, index) => {
11178
11187
  if (Array.isArray(stringVals)) {
11179
11188
  for (let i = 0; i < stringVals.length; i++) {
11180
- _PushStrings(stringVals[i], i);
11189
+ await _PushStrings(stringVals[i], i);
11181
11190
  }
11182
11191
  } else {
11183
11192
  this.ComputeCompositeHash(path, index, tir);
11184
- retVal.push(...this.#OutputString(stringVals, tir, expression));
11193
+ retVal.push(...await this.#OutputString(stringVals, tir, expression));
11185
11194
  }
11186
11195
  };
11187
- _PushStrings(inputStringVal, 0);
11196
+ await _PushStrings(inputStringVal, 0);
11188
11197
  } else {
11189
11198
  const tirc = this.GetNewBaseIndexRecord(tir);
11190
11199
  tirc.SP_MISSING = true;
@@ -11197,12 +11206,12 @@ class DBSearchIndexString extends DBSearchIndexBase {
11197
11206
  }
11198
11207
  return retVal;
11199
11208
  };
11200
- OutputIndexRecord = (resource, tir, searchParamRecord) => {
11209
+ OutputIndexRecord = async (resource, tir, searchParamRecord) => {
11201
11210
  const retVal = [];
11202
- searchParamRecord.expressions.forEach((expression) => {
11211
+ for (const expression of searchParamRecord.expressions) {
11203
11212
  let stringVal = this.GetValueFromPath(resource, expression.path, searchParamRecord, expression);
11204
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, stringVal, tir, expression));
11205
- });
11213
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, stringVal, tir, expression));
11214
+ }
11206
11215
  return retVal;
11207
11216
  };
11208
11217
  OutputIndexRecordToConsole = (tir) => {
@@ -11227,7 +11236,7 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11227
11236
  }
11228
11237
  return quantityIndexRecords;
11229
11238
  };
11230
- OutputIndexRecordFromFhirElement = (path, inputNumberVal, tir) => {
11239
+ OutputIndexRecordFromFhirElement = async (path, inputNumberVal, tir) => {
11231
11240
  const retVal = [];
11232
11241
  if (this.IsDefined(inputNumberVal)) {
11233
11242
  const _PushNumberVal = (numberVal, index) => {
@@ -11251,12 +11260,12 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11251
11260
  }
11252
11261
  return retVal;
11253
11262
  };
11254
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11263
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11255
11264
  const retVal = [];
11256
- searchFieldRecord.expressions.forEach((expression) => {
11265
+ for (const expression of searchFieldRecord.expressions) {
11257
11266
  let numberVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11258
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, numberVal, tir));
11259
- });
11267
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, numberVal, tir));
11268
+ }
11260
11269
  return retVal;
11261
11270
  };
11262
11271
  OutputIndexRecordToConsole = (tir) => {
@@ -11286,7 +11295,7 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11286
11295
  }
11287
11296
  return uriIndexRecords;
11288
11297
  };
11289
- OutputIndexRecordFromFhirElement = (path, inputUriVal, tir) => {
11298
+ OutputIndexRecordFromFhirElement = async (path, inputUriVal, tir) => {
11290
11299
  const retVal = [];
11291
11300
  const _processUriVal = (uriVal, index) => {
11292
11301
  if (Array.isArray(uriVal)) {
@@ -11311,12 +11320,12 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11311
11320
  }
11312
11321
  return retVal;
11313
11322
  };
11314
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11323
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11315
11324
  const retVal = [];
11316
- searchFieldRecord.expressions.forEach((expression) => {
11325
+ for (const expression of searchFieldRecord.expressions) {
11317
11326
  let uriVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11318
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, uriVal, tir));
11319
- });
11327
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, uriVal, tir));
11328
+ }
11320
11329
  return retVal;
11321
11330
  };
11322
11331
  OutputIndexRecordToConsole = (tir) => {
@@ -11370,7 +11379,7 @@ class DBSearchIndex {
11370
11379
  this.#debug("------------------");
11371
11380
  this.#debug(`resource: [${hl(resourceName)}] resourceId: [${hl(resourceId)}] SP_NAME: [${hl(searchFieldRecord.SP_NAME)}] SP_TYPE: [${hl(searchFieldRecord.SP_TYPE)}] SP_BASE: [${hl(searchFieldRecord.SP_BASE)}] path: [${hl(searchFieldRecord.path)}] RESOURCE_DATATYPE: [${hl(searchFieldRecord.RESOURCE_DATATYPE)}] subFieldDataType: [${hl(searchFieldRecord.subFieldDataType)}] stringIndexFields: [${hl(searchFieldRecord.stringIndexFields)}]`);
11372
11381
  };
11373
- UpdateIndex = (resource, searchFieldRecord) => {
11382
+ UpdateIndex = async (resource, searchFieldRecord) => {
11374
11383
  try {
11375
11384
  const tir = {
11376
11385
  PID: v4(),
@@ -11389,7 +11398,7 @@ class DBSearchIndex {
11389
11398
  let saveRecord;
11390
11399
  const searchIndexBaseProcessor = this.searchRegistry.searchIndexBaseRegistry[searchFieldRecord.SP_TYPE];
11391
11400
  if (searchIndexBaseProcessor) {
11392
- saveRecord = searchIndexBaseProcessor.OutputIndexRecord(resource, tir, searchFieldRecord);
11401
+ saveRecord = await searchIndexBaseProcessor.OutputIndexRecord(resource, tir, searchFieldRecord);
11393
11402
  } else if (searchFieldRecord.SP_TYPE.localeCompare("special") === 0) {
11394
11403
  } else {
11395
11404
  const message = `DBSearchIndex:UpdateIndex(): Error: Search field paramater type: [${searchFieldRecord.SP_TYPE}] unknown.`;
@@ -11402,14 +11411,14 @@ class DBSearchIndex {
11402
11411
  return [];
11403
11412
  }
11404
11413
  };
11405
- GetSearchIndexData = (resource) => {
11414
+ GetSearchIndexData = async (resource) => {
11406
11415
  try {
11407
- const searchParamRecords = this.resourceHelper.GetSearchParamsFromResourceType(resource.resourceType);
11416
+ const searchParamRecords = await this.resourceHelper.GetSearchParamsFromResourceType(resource.resourceType);
11408
11417
  const searchIndexData = [];
11409
11418
  for (let i = 0; i < searchParamRecords.length; i++) {
11410
11419
  const searchRecord = searchParamRecords[i];
11411
11420
  try {
11412
- const retVal = this.UpdateIndex(resource, searchRecord);
11421
+ const retVal = await this.UpdateIndex(resource, searchRecord);
11413
11422
  if (retVal && retVal.length > 0) {
11414
11423
  searchIndexData.push(...retVal);
11415
11424
  }
@@ -11423,10 +11432,10 @@ class DBSearchIndex {
11423
11432
  return [];
11424
11433
  }
11425
11434
  };
11426
- GetSearchParamFromResourceType = (resourceType, name) => {
11435
+ GetSearchParamFromResourceType = async (resourceType, name) => {
11427
11436
  return this.resourceHelper.GetSearchParamFromResourceType(resourceType, name);
11428
11437
  };
11429
- GetSearchParamFromResourceTypeUrl = (resourceType, url) => {
11438
+ GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
11430
11439
  return this.resourceHelper.GetSearchParamFromResourceTypeUrl(resourceType, url);
11431
11440
  };
11432
11441
  }
@@ -18204,7 +18213,7 @@ class PGFhirAccessLayer extends tinyEmitterExports.TinyEmitter {
18204
18213
  UpdateIndexes = async (client2, resource) => {
18205
18214
  let start = performance.now();
18206
18215
  const oa = start;
18207
- const searchIndexData = this.#dbSearchIndex.GetSearchIndexData(resource);
18216
+ const searchIndexData = await this.#dbSearchIndex.GetSearchIndexData(resource);
18208
18217
  const lap1 = performance.now() - start;
18209
18218
  start = performance.now();
18210
18219
  const InsertResourceLinkRecord = async (client22, resourceLinkIndexRecord) => {