@nsshunt/stsfhirpg 1.2.6 → 1.2.8

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 (29) hide show
  1. package/dist/stsfhirpg.cjs +72 -63
  2. package/dist/stsfhirpg.cjs.map +1 -1
  3. package/dist/stsfhirpg.mjs +72 -63
  4. package/dist/stsfhirpg.mjs.map +1 -1
  5. package/package.json +2 -1
  6. package/types/fhir-database/dbsearchindexbase.d.ts +1 -1
  7. package/types/fhir-database/dbsearchindexbase.d.ts.map +1 -1
  8. package/types/fhir-database/dbsearchindexcomposite.d.ts +1 -1
  9. package/types/fhir-database/dbsearchindexcomposite.d.ts.map +1 -1
  10. package/types/fhir-database/dbsearchindexdates.d.ts +1 -1
  11. package/types/fhir-database/dbsearchindexdates.d.ts.map +1 -1
  12. package/types/fhir-database/dbsearchindexnumber.d.ts +1 -1
  13. package/types/fhir-database/dbsearchindexnumber.d.ts.map +1 -1
  14. package/types/fhir-database/dbsearchindexquantity.d.ts +1 -1
  15. package/types/fhir-database/dbsearchindexquantity.d.ts.map +1 -1
  16. package/types/fhir-database/dbsearchindexreference.d.ts +1 -1
  17. package/types/fhir-database/dbsearchindexreference.d.ts.map +1 -1
  18. package/types/fhir-database/dbsearchindexstring.d.ts +1 -1
  19. package/types/fhir-database/dbsearchindexstring.d.ts.map +1 -1
  20. package/types/fhir-database/dbsearchindextoken.d.ts +1 -1
  21. package/types/fhir-database/dbsearchindextoken.d.ts.map +1 -1
  22. package/types/fhir-database/dbsearchindexuri.d.ts +1 -1
  23. package/types/fhir-database/dbsearchindexuri.d.ts.map +1 -1
  24. package/types/fhir-utils/resourceHelper.d.ts +8 -7
  25. package/types/fhir-utils/resourceHelper.d.ts.map +1 -1
  26. package/types/redisDistributedLock.d.ts +36 -0
  27. package/types/redisDistributedLock.d.ts.map +1 -0
  28. package/types/searchParameterManager.d.ts +38 -0
  29. 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
7263
  GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
7258
- const filterByNameAndUrl = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
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
7270
  GetSearchParamFromResourceType = async (resourceType, name) => {
7264
- const filterByName = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
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
7277
  GetSearchParamsFromResourceType = async (resourceType) => {
7270
- return this.definitions.searchParametersByResourceType[resourceType].params;
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;
@@ -10703,10 +10712,10 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10703
10712
  };
10704
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
  };
@@ -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;
@@ -10886,10 +10895,10 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10886
10895
  };
10887
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) => {
@@ -10974,10 +10983,10 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10974
10983
  };
10975
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)) {
@@ -11081,10 +11090,10 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11081
11090
  };
11082
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;
@@ -11197,10 +11206,10 @@ class DBSearchIndexString extends DBSearchIndexBase {
11197
11206
  };
11198
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) => {
@@ -11251,10 +11260,10 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11251
11260
  };
11252
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)) {
@@ -11311,10 +11320,10 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11311
11320
  };
11312
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) => {