@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
@@ -7000,6 +7000,7 @@ const typesPath = "fhir-spec/profiles-types.json";
7000
7000
  const searchParamsPath = "fhir-spec/search-parameters.json";
7001
7001
  class ResourceHelper {
7002
7002
  #definitions;
7003
+ searchParameterManager;
7003
7004
  static instance;
7004
7005
  constructor() {
7005
7006
  }
@@ -7009,7 +7010,7 @@ class ResourceHelper {
7009
7010
  }
7010
7011
  return ResourceHelper.instance;
7011
7012
  }
7012
- #LoadDefinitions = () => {
7013
+ #LoadDefinitions = async () => {
7013
7014
  let usePath = "";
7014
7015
  if (fs.existsSync(`${specPath1}${resourcesPath}`)) {
7015
7016
  usePath = specPath1;
@@ -7043,23 +7044,25 @@ class ResourceHelper {
7043
7044
  __searchParams.entry.forEach((entry) => {
7044
7045
  this.#definitions.searchParametersByUrl[entry.fullUrl] = entry.resource;
7045
7046
  });
7046
- this._LoadSearchParameters();
7047
+ await this._LoadSearchParameters();
7047
7048
  return this.#definitions;
7048
7049
  };
7049
- get definitions() {
7050
+ GetDefinitions = async () => {
7050
7051
  if (!this.#definitions) {
7051
- this.#LoadDefinitions();
7052
+ await this.#LoadDefinitions();
7052
7053
  }
7053
7054
  return this.#definitions;
7054
- }
7055
- GetType = (typeName) => {
7056
- return this.definitions.types[typeName];
7057
7055
  };
7058
- GetResource = (resourceType) => {
7059
- return this.definitions.resources[resourceType];
7056
+ GetType = async (typeName) => {
7057
+ await this.GetDefinitions();
7058
+ return this.#definitions.types[typeName];
7059
+ };
7060
+ GetResource = async (resourceType) => {
7061
+ await this.GetDefinitions();
7062
+ return this.#definitions.resources[resourceType];
7060
7063
  };
7061
- GetResourceField = (resourceType, fieldPath) => {
7062
- const resource = this.GetResource(resourceType);
7064
+ GetResourceField = async (resourceType, fieldPath) => {
7065
+ const resource = await this.GetResource(resourceType);
7063
7066
  if (resource) {
7064
7067
  const foundRecord = resource.filter((o) => o.id === fieldPath);
7065
7068
  if (foundRecord.length > 0) {
@@ -7068,14 +7071,17 @@ class ResourceHelper {
7068
7071
  return void 0;
7069
7072
  }
7070
7073
  };
7071
- GetSearchParam = (url) => {
7072
- return this.definitions.searchParametersByUrl[url];
7074
+ GetSearchParam = async (url) => {
7075
+ await this.GetDefinitions();
7076
+ return this.#definitions.searchParametersByUrl[url];
7073
7077
  };
7074
- GetSearchParams = () => {
7075
- return this.definitions.searchParametersByUrl;
7078
+ GetSearchParams = async () => {
7079
+ await this.GetDefinitions();
7080
+ return this.#definitions.searchParametersByUrl;
7076
7081
  };
7077
- GetSearchParamsByResource = (resource) => {
7078
- return Object.values(this.definitions.searchParametersByUrl).filter((sp) => sp.base.includes(resource)).map((sp) => sp);
7082
+ GetSearchParamsByResource = async (resource) => {
7083
+ await this.GetDefinitions();
7084
+ return Object.values(this.#definitions.searchParametersByUrl).filter((sp) => sp.base.includes(resource)).map((sp) => sp);
7079
7085
  };
7080
7086
  // ------------------------------------------------------------------------------------------------------------------
7081
7087
  // Remove ( ) when either are present
@@ -7198,8 +7204,8 @@ class ResourceHelper {
7198
7204
  original_expressions
7199
7205
  };
7200
7206
  };
7201
- _LoadSearchParameters = () => {
7202
- for (const [key, val] of Object.entries(this.GetSearchParams())) {
7207
+ _LoadSearchParameters = async () => {
7208
+ for (const [key, val] of Object.entries(await this.GetSearchParams())) {
7203
7209
  const { id, url, code, base, type, expression, component, target } = val;
7204
7210
  for (let i = 0; i < base.length; i++) {
7205
7211
  const resourceName = base[i];
@@ -7230,44 +7236,47 @@ class ResourceHelper {
7230
7236
  SP_TARGET,
7231
7237
  expressions,
7232
7238
  original_expressions,
7233
- SP_DEFINITION: this.GetSearchParam(SP_URL)
7239
+ SP_DEFINITION: await this.GetSearchParam(SP_URL)
7234
7240
  };
7235
7241
  for (let i2 = 0; i2 < record.expressions.length; i2++) {
7236
- const rf = this.GetResourceField(resourceName, record.expressions[i2].path);
7242
+ const rf = await this.GetResourceField(resourceName, record.expressions[i2].path);
7237
7243
  if (rf) {
7238
7244
  expressions[i2].RES_FIELD = rf;
7239
7245
  }
7240
7246
  }
7241
7247
  if (component) {
7242
7248
  record.component = [...component];
7243
- record.component.forEach((c) => {
7249
+ for (const c of record.component) {
7244
7250
  const retVal = this.ProcessExpressions("", c.expression);
7245
7251
  c.expressions = retVal.expressions;
7246
7252
  c.original_expressions = retVal.original_expressions;
7247
- const def = this.GetSearchParam(c.definition);
7253
+ const def = await this.GetSearchParam(c.definition);
7248
7254
  if (def && def.type) {
7249
7255
  c.type = def.type;
7250
7256
  }
7251
- });
7257
+ }
7252
7258
  }
7253
7259
  this.#definitions.searchParametersByResourceType[resourceName].params.push(record);
7254
7260
  }
7255
7261
  }
7256
7262
  };
7257
- GetSearchParamFromResourceTypeUrl = (resourceType, url) => {
7258
- const filterByNameAndUrl = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
7263
+ GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
7264
+ await this.GetDefinitions();
7265
+ const filterByNameAndUrl = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
7259
7266
  if (filterByNameAndUrl.length > 0) {
7260
7267
  return filterByNameAndUrl[0];
7261
7268
  }
7262
7269
  };
7263
- GetSearchParamFromResourceType = (resourceType, name) => {
7264
- const filterByName = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
7270
+ GetSearchParamFromResourceType = async (resourceType, name) => {
7271
+ await this.GetDefinitions();
7272
+ const filterByName = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
7265
7273
  if (filterByName.length > 0) {
7266
7274
  return filterByName[0];
7267
7275
  }
7268
7276
  };
7269
- GetSearchParamsFromResourceType = (resourceType) => {
7270
- return this.definitions.searchParametersByResourceType[resourceType].params;
7277
+ GetSearchParamsFromResourceType = async (resourceType) => {
7278
+ await this.GetDefinitions();
7279
+ return this.#definitions.searchParametersByResourceType[resourceType].params;
7271
7280
  };
7272
7281
  }
7273
7282
  var ansiStyles = { exports: {} };
@@ -10669,7 +10678,7 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10669
10678
  }
10670
10679
  }
10671
10680
  };
10672
- OutputIndexRecordFromFhirElement = (path, inputTokens, tir) => {
10681
+ OutputIndexRecordFromFhirElement = async (path, inputTokens, tir) => {
10673
10682
  const _OutputMissingParamater = () => {
10674
10683
  const tirc = this.GetNewBaseIndexRecord(tir);
10675
10684
  tirc.SP_MISSING = true;
@@ -10701,12 +10710,12 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10701
10710
  }
10702
10711
  return retVal;
10703
10712
  };
10704
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10713
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10705
10714
  let retVal = [];
10706
- searchFieldRecord.expressions.forEach((expression) => {
10715
+ for (const expression of searchFieldRecord.expressions) {
10707
10716
  let tokens = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10708
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, tokens, tir));
10709
- });
10717
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, tokens, tir));
10718
+ }
10710
10719
  return retVal;
10711
10720
  };
10712
10721
  OutputIndexRecordToConsole = (tir) => {
@@ -10722,7 +10731,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10722
10731
  #warn = (message) => {
10723
10732
  };
10724
10733
  // This method is empty becuase the composite processor will not call itself recursively
10725
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir) => {
10734
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir) => {
10726
10735
  this.#warn(`DBSearchIndexComposite:__OutputIndexRecordFromFhirElement(): composite (recursive) not supported within a composite expression. inputReferenceVal: [${inputReferenceVal}], tir: [${tir}]`);
10727
10736
  return [];
10728
10737
  };
@@ -10737,15 +10746,15 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10737
10746
  // / root level code and quantity, i.e. Observation.code + Observation.value[x]Quantity
10738
10747
  // /component_0 component level at index 0 Observation.component[0].code + Observation.component[0].value[x]Quantity
10739
10748
  // /component_1 component level at index 1 Observation.component[1].code + Observation.component[1].value[x]Quantity
10740
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10749
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10741
10750
  let comboNonUniqueRecords = [];
10742
10751
  const searchIndex = DBSearchIndex.getInstance();
10743
10752
  let index = 0;
10744
10753
  let components = [];
10745
- searchFieldRecord.component.forEach((searchParamComponentRecord) => {
10754
+ for (const searchParamComponentRecord of searchFieldRecord.component) {
10746
10755
  components.push([]);
10747
10756
  const url = searchParamComponentRecord.definition;
10748
- const sp = searchIndex.resourceHelper.GetSearchParamFromResourceTypeUrl(resource.resourceType, url);
10757
+ const sp = await searchIndex.resourceHelper.GetSearchParamFromResourceTypeUrl(resource.resourceType, url);
10749
10758
  if (this.IsDefined(sp)) {
10750
10759
  const tir2 = {
10751
10760
  PID: v4(),
@@ -10761,7 +10770,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10761
10770
  COMPOSITE: null,
10762
10771
  COMPOSITE_HASH_EXACT: null
10763
10772
  };
10764
- const retVal = SearchRegistry.getInstance().searchIndexBaseRegistry[sp.SP_TYPE].OutputIndexRecord(resource, tir2, sp);
10773
+ const retVal = await SearchRegistry.getInstance().searchIndexBaseRegistry[sp.SP_TYPE].OutputIndexRecord(resource, tir2, sp);
10765
10774
  retVal.forEach((rv) => {
10766
10775
  if (!(rv.SP_MISSING && rv.SP_MISSING === true)) {
10767
10776
  if (rv.SP_STR && rv.SP_STR !== void 0) {
@@ -10771,7 +10780,7 @@ class DBSearchIndexComposite extends DBSearchIndexBase {
10771
10780
  });
10772
10781
  index++;
10773
10782
  }
10774
- });
10783
+ }
10775
10784
  for (let i = 0; i < components[0].length; i++) {
10776
10785
  for (let j = 0; j < components[1].length; j++) {
10777
10786
  const idxString = `${components[0][i].SP_STR}|${components[1][j].SP_STR}`;
@@ -10805,7 +10814,7 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10805
10814
  | `Period` | Explicit, though the upper or lower bound might not actually be specified in resources. |
10806
10815
  | `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. |
10807
10816
  */
10808
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir) => {
10817
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir) => {
10809
10818
  let retVal = [];
10810
10819
  const _OutputDate = (referenceVal, tir2, index) => {
10811
10820
  let parsedDate;
@@ -10884,12 +10893,12 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10884
10893
  }
10885
10894
  return retVal;
10886
10895
  };
10887
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10896
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10888
10897
  let retVal = [];
10889
- searchFieldRecord.expressions.forEach((expression) => {
10898
+ for (const expression of searchFieldRecord.expressions) {
10890
10899
  let referenceVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10891
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir));
10892
- });
10900
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir));
10901
+ }
10893
10902
  return retVal;
10894
10903
  };
10895
10904
  OutputIndexRecordToConsole = (tir) => {
@@ -10944,7 +10953,7 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10944
10953
  }
10945
10954
  return quantityIndexRecords;
10946
10955
  };
10947
- OutputIndexRecordFromFhirElement = (path, inputQuantityVal, tir) => {
10956
+ OutputIndexRecordFromFhirElement = async (path, inputQuantityVal, tir) => {
10948
10957
  const retVal = [];
10949
10958
  if (this.IsDefined(inputQuantityVal)) {
10950
10959
  const _PushQty = (qVal, index) => {
@@ -10972,12 +10981,12 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10972
10981
  }
10973
10982
  return retVal;
10974
10983
  };
10975
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
10984
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
10976
10985
  const retVal = [];
10977
- searchFieldRecord.expressions.forEach((expression) => {
10986
+ for (const expression of searchFieldRecord.expressions) {
10978
10987
  let quantityVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
10979
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, quantityVal, tir));
10980
- });
10988
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, quantityVal, tir));
10989
+ }
10981
10990
  return retVal;
10982
10991
  };
10983
10992
  OutputIndexRecordToConsole = (tir) => {
@@ -11037,7 +11046,7 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11037
11046
  throw error;
11038
11047
  }
11039
11048
  };
11040
- OutputIndexRecordFromFhirElement = (path, inputReferenceVal, tir, searchParamExpressionRecord, resource) => {
11049
+ OutputIndexRecordFromFhirElement = async (path, inputReferenceVal, tir, searchParamExpressionRecord, resource) => {
11041
11050
  const _OutputReferencesFromFhirElement = (referenceVal, index) => {
11042
11051
  let resourceReference;
11043
11052
  if (this.IsDefined(referenceVal) && this.IsDefined(referenceVal.identifier) && this.IsDefined(referenceVal.identifier.value)) {
@@ -11079,12 +11088,12 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11079
11088
  }
11080
11089
  return retVal;
11081
11090
  };
11082
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11091
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11083
11092
  let retVal = [];
11084
- searchFieldRecord.expressions.forEach((expression) => {
11093
+ for (const expression of searchFieldRecord.expressions) {
11085
11094
  const referenceVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11086
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir, expression, resource));
11087
- });
11095
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, referenceVal, tir, expression, resource));
11096
+ }
11088
11097
  return retVal;
11089
11098
  };
11090
11099
  OutputIndexRecordToConsole = (tir) => {
@@ -11099,7 +11108,7 @@ class DBSearchIndexString extends DBSearchIndexBase {
11099
11108
  }
11100
11109
  #debug = (message) => {
11101
11110
  };
11102
- #OutputString = (stringInputVal, tir, expression) => {
11111
+ #OutputString = async (stringInputVal, tir, expression) => {
11103
11112
  const stringIndexRecords = [];
11104
11113
  if (this.IsDefined(expression) && typeof stringInputVal === "object") {
11105
11114
  let fields = [];
@@ -11112,9 +11121,9 @@ class DBSearchIndexString extends DBSearchIndexBase {
11112
11121
  }
11113
11122
  let res;
11114
11123
  if (this.IsDefined(expressionType) && this.IsDefined(expressionType.code)) {
11115
- res = this.#resourceHelper.GetType(expressionType.code);
11124
+ res = await this.#resourceHelper.GetType(expressionType.code);
11116
11125
  } else {
11117
- res = this.#resourceHelper.GetType(expressionType);
11126
+ res = await this.#resourceHelper.GetType(expressionType);
11118
11127
  }
11119
11128
  if (this.IsDefined(res)) {
11120
11129
  for (let i = 0; i < res.length; i++) {
@@ -11169,20 +11178,20 @@ class DBSearchIndexString extends DBSearchIndexBase {
11169
11178
  }
11170
11179
  }
11171
11180
  };
11172
- OutputIndexRecordFromFhirElement = (path, inputStringVal, tir, expression) => {
11181
+ OutputIndexRecordFromFhirElement = async (path, inputStringVal, tir, expression) => {
11173
11182
  const retVal = [];
11174
11183
  if (this.IsDefined(inputStringVal)) {
11175
- const _PushStrings = (stringVals, index) => {
11184
+ const _PushStrings = async (stringVals, index) => {
11176
11185
  if (Array.isArray(stringVals)) {
11177
11186
  for (let i = 0; i < stringVals.length; i++) {
11178
- _PushStrings(stringVals[i], i);
11187
+ await _PushStrings(stringVals[i], i);
11179
11188
  }
11180
11189
  } else {
11181
11190
  this.ComputeCompositeHash(path, index, tir);
11182
- retVal.push(...this.#OutputString(stringVals, tir, expression));
11191
+ retVal.push(...await this.#OutputString(stringVals, tir, expression));
11183
11192
  }
11184
11193
  };
11185
- _PushStrings(inputStringVal, 0);
11194
+ await _PushStrings(inputStringVal, 0);
11186
11195
  } else {
11187
11196
  const tirc = this.GetNewBaseIndexRecord(tir);
11188
11197
  tirc.SP_MISSING = true;
@@ -11195,12 +11204,12 @@ class DBSearchIndexString extends DBSearchIndexBase {
11195
11204
  }
11196
11205
  return retVal;
11197
11206
  };
11198
- OutputIndexRecord = (resource, tir, searchParamRecord) => {
11207
+ OutputIndexRecord = async (resource, tir, searchParamRecord) => {
11199
11208
  const retVal = [];
11200
- searchParamRecord.expressions.forEach((expression) => {
11209
+ for (const expression of searchParamRecord.expressions) {
11201
11210
  let stringVal = this.GetValueFromPath(resource, expression.path, searchParamRecord, expression);
11202
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, stringVal, tir, expression));
11203
- });
11211
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, stringVal, tir, expression));
11212
+ }
11204
11213
  return retVal;
11205
11214
  };
11206
11215
  OutputIndexRecordToConsole = (tir) => {
@@ -11225,7 +11234,7 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11225
11234
  }
11226
11235
  return quantityIndexRecords;
11227
11236
  };
11228
- OutputIndexRecordFromFhirElement = (path, inputNumberVal, tir) => {
11237
+ OutputIndexRecordFromFhirElement = async (path, inputNumberVal, tir) => {
11229
11238
  const retVal = [];
11230
11239
  if (this.IsDefined(inputNumberVal)) {
11231
11240
  const _PushNumberVal = (numberVal, index) => {
@@ -11249,12 +11258,12 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11249
11258
  }
11250
11259
  return retVal;
11251
11260
  };
11252
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11261
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11253
11262
  const retVal = [];
11254
- searchFieldRecord.expressions.forEach((expression) => {
11263
+ for (const expression of searchFieldRecord.expressions) {
11255
11264
  let numberVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11256
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, numberVal, tir));
11257
- });
11265
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, numberVal, tir));
11266
+ }
11258
11267
  return retVal;
11259
11268
  };
11260
11269
  OutputIndexRecordToConsole = (tir) => {
@@ -11284,7 +11293,7 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11284
11293
  }
11285
11294
  return uriIndexRecords;
11286
11295
  };
11287
- OutputIndexRecordFromFhirElement = (path, inputUriVal, tir) => {
11296
+ OutputIndexRecordFromFhirElement = async (path, inputUriVal, tir) => {
11288
11297
  const retVal = [];
11289
11298
  const _processUriVal = (uriVal, index) => {
11290
11299
  if (Array.isArray(uriVal)) {
@@ -11309,12 +11318,12 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11309
11318
  }
11310
11319
  return retVal;
11311
11320
  };
11312
- OutputIndexRecord = (resource, tir, searchFieldRecord) => {
11321
+ OutputIndexRecord = async (resource, tir, searchFieldRecord) => {
11313
11322
  const retVal = [];
11314
- searchFieldRecord.expressions.forEach((expression) => {
11323
+ for (const expression of searchFieldRecord.expressions) {
11315
11324
  let uriVal = this.GetValueFromPath(resource, expression.path, searchFieldRecord, expression);
11316
- retVal.push(...this.OutputIndexRecordFromFhirElement(expression.path, uriVal, tir));
11317
- });
11325
+ retVal.push(...await this.OutputIndexRecordFromFhirElement(expression.path, uriVal, tir));
11326
+ }
11318
11327
  return retVal;
11319
11328
  };
11320
11329
  OutputIndexRecordToConsole = (tir) => {
@@ -11368,7 +11377,7 @@ class DBSearchIndex {
11368
11377
  this.#debug("------------------");
11369
11378
  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)}]`);
11370
11379
  };
11371
- UpdateIndex = (resource, searchFieldRecord) => {
11380
+ UpdateIndex = async (resource, searchFieldRecord) => {
11372
11381
  try {
11373
11382
  const tir = {
11374
11383
  PID: v4(),
@@ -11387,7 +11396,7 @@ class DBSearchIndex {
11387
11396
  let saveRecord;
11388
11397
  const searchIndexBaseProcessor = this.searchRegistry.searchIndexBaseRegistry[searchFieldRecord.SP_TYPE];
11389
11398
  if (searchIndexBaseProcessor) {
11390
- saveRecord = searchIndexBaseProcessor.OutputIndexRecord(resource, tir, searchFieldRecord);
11399
+ saveRecord = await searchIndexBaseProcessor.OutputIndexRecord(resource, tir, searchFieldRecord);
11391
11400
  } else if (searchFieldRecord.SP_TYPE.localeCompare("special") === 0) {
11392
11401
  } else {
11393
11402
  const message = `DBSearchIndex:UpdateIndex(): Error: Search field paramater type: [${searchFieldRecord.SP_TYPE}] unknown.`;
@@ -11400,14 +11409,14 @@ class DBSearchIndex {
11400
11409
  return [];
11401
11410
  }
11402
11411
  };
11403
- GetSearchIndexData = (resource) => {
11412
+ GetSearchIndexData = async (resource) => {
11404
11413
  try {
11405
- const searchParamRecords = this.resourceHelper.GetSearchParamsFromResourceType(resource.resourceType);
11414
+ const searchParamRecords = await this.resourceHelper.GetSearchParamsFromResourceType(resource.resourceType);
11406
11415
  const searchIndexData = [];
11407
11416
  for (let i = 0; i < searchParamRecords.length; i++) {
11408
11417
  const searchRecord = searchParamRecords[i];
11409
11418
  try {
11410
- const retVal = this.UpdateIndex(resource, searchRecord);
11419
+ const retVal = await this.UpdateIndex(resource, searchRecord);
11411
11420
  if (retVal && retVal.length > 0) {
11412
11421
  searchIndexData.push(...retVal);
11413
11422
  }
@@ -11421,10 +11430,10 @@ class DBSearchIndex {
11421
11430
  return [];
11422
11431
  }
11423
11432
  };
11424
- GetSearchParamFromResourceType = (resourceType, name) => {
11433
+ GetSearchParamFromResourceType = async (resourceType, name) => {
11425
11434
  return this.resourceHelper.GetSearchParamFromResourceType(resourceType, name);
11426
11435
  };
11427
- GetSearchParamFromResourceTypeUrl = (resourceType, url) => {
11436
+ GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
11428
11437
  return this.resourceHelper.GetSearchParamFromResourceTypeUrl(resourceType, url);
11429
11438
  };
11430
11439
  }
@@ -18202,7 +18211,7 @@ class PGFhirAccessLayer extends tinyEmitterExports.TinyEmitter {
18202
18211
  UpdateIndexes = async (client2, resource) => {
18203
18212
  let start = performance.now();
18204
18213
  const oa = start;
18205
- const searchIndexData = this.#dbSearchIndex.GetSearchIndexData(resource);
18214
+ const searchIndexData = await this.#dbSearchIndex.GetSearchIndexData(resource);
18206
18215
  const lap1 = performance.now() - start;
18207
18216
  start = performance.now();
18208
18217
  const InsertResourceLinkRecord = async (client22, resourceLinkIndexRecord) => {