@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
@@ -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
7265
  GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
7260
- const filterByNameAndUrl = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
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
7272
  GetSearchParamFromResourceType = async (resourceType, name) => {
7266
- const filterByName = this.definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
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
7279
  GetSearchParamsFromResourceType = async (resourceType) => {
7272
- return this.definitions.searchParametersByResourceType[resourceType].params;
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;
@@ -10705,10 +10714,10 @@ class DBSearchIndexToken extends DBSearchIndexBase {
10705
10714
  };
10706
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
  };
@@ -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;
@@ -10888,10 +10897,10 @@ class DBSearchIndexDates extends DBSearchIndexBase {
10888
10897
  };
10889
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) => {
@@ -10976,10 +10985,10 @@ class DBSearchIndexQuantity extends DBSearchIndexBase {
10976
10985
  };
10977
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)) {
@@ -11083,10 +11092,10 @@ class DBSearchIndexReference extends DBSearchIndexBase {
11083
11092
  };
11084
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;
@@ -11199,10 +11208,10 @@ class DBSearchIndexString extends DBSearchIndexBase {
11199
11208
  };
11200
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) => {
@@ -11253,10 +11262,10 @@ class DBSearchIndexNumber extends DBSearchIndexBase {
11253
11262
  };
11254
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)) {
@@ -11313,10 +11322,10 @@ class DBSearchIndexURI extends DBSearchIndexBase {
11313
11322
  };
11314
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) => {