@nsshunt/stsfhirpg 1.2.12 → 1.2.14

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.
@@ -7127,10 +7127,11 @@ class SearchParameterManager {
7127
7127
  redis;
7128
7128
  alreadyComplete = null;
7129
7129
  options;
7130
+ cache = {};
7130
7131
  constructor(options) {
7131
7132
  this.options = options;
7132
7133
  }
7133
- EnsureSearchParameterDataLoaded = async () => {
7134
+ EnsureSearchParameterDataLoaded = async (resources) => {
7134
7135
  if (this.alreadyComplete) {
7135
7136
  return this.alreadyComplete;
7136
7137
  }
@@ -7186,7 +7187,7 @@ class SearchParameterManager {
7186
7187
  return;
7187
7188
  }
7188
7189
  try {
7189
- await this.#LoadDefinitions();
7190
+ await this.#LoadDefinitions(resources);
7190
7191
  } catch (error) {
7191
7192
  console.error(error);
7192
7193
  throw error;
@@ -7234,396 +7235,62 @@ class SearchParameterManager {
7234
7235
  console.log(`SearchParameterManager(): redis closed`);
7235
7236
  }
7236
7237
  };
7237
- #LoadDefinitions = async () => {
7238
+ #searchParametersByResourceTypeKey = `__stsfhir__searchParametersByResourceType`;
7239
+ #searchParametersByUrlKey = `__stsfhir__searchParametersByUrl`;
7240
+ #resourcesKey = `__stsfhir__resources`;
7241
+ #typesKey = `__stsfhir__types`;
7242
+ #LoadDefinitions = async (resources) => {
7238
7243
  console.log("Data Load Starting ...");
7239
- for (let i = 0; i < 10; i++) {
7240
- console.log(`Loading ...: [${i}]`);
7241
- await stsutils.Sleep(500);
7244
+ for (const [key, value] of Object.entries(resources.searchParametersByResourceType)) {
7245
+ await this.redis.hSet(this.#searchParametersByResourceTypeKey, key, JSON.stringify(value));
7246
+ }
7247
+ for (const [key, value] of Object.entries(resources.searchParametersByUrl)) {
7248
+ await this.redis.hSet(this.#searchParametersByUrlKey, key, JSON.stringify(value));
7249
+ }
7250
+ for (const [key, value] of Object.entries(resources.resources)) {
7251
+ await this.redis.hSet(this.#resourcesKey, key, JSON.stringify(value));
7252
+ }
7253
+ for (const [key, value] of Object.entries(resources.types)) {
7254
+ await this.redis.hSet(this.#typesKey, key, JSON.stringify(value));
7242
7255
  }
7243
7256
  console.log("All Done ***********************************************************************************");
7244
7257
  };
7245
- /*
7246
- private GetTypeKey(typeName: string) {
7247
- return `stsfhir_type_${typeName}`;
7248
- }
7249
-
7250
- private GetSearchParameterByFullUrlKey(fullUrl: string) {
7251
- return `stsfhir_sp_${fullUrl}`;
7252
- }
7253
-
7254
- private GetResourceKey(resourceType: string) {
7255
- return `stsfhir_resource_${resourceType}`;
7256
- }
7257
-
7258
- private GetSearchParameterByResourceTypeKey(resourceType: string) {
7259
- return `stsfhir_sp_resource_${resourceType}`;
7260
- }
7261
-
7262
- private GetSTSCustomSearchParameterByResourceTypeKey(resourceType: string) {
7263
- return `stsfhir_stscustom_sp_resource_${resourceType}`;
7264
- }
7265
-
7266
- // Remove ( ) when either are present
7267
- private _RemoveOuterParentheses = (input: string): string => {
7268
- return input.replace(/^\(|\)$/g, '');
7269
- }
7270
-
7271
- // Remove ( ) only when both are present
7272
- private _RemoveSurroundingParentheses = (input: string): string => {
7273
- return input.replace(/^\((.*)\)$/, '$1').trim();
7274
- }
7275
- */
7276
- /*
7277
- NamingSystem derived-from reference NamingSystem.relatedArtifact.where(type='derived-from').resource
7278
-
7279
- NamingSystem predecessor reference NamingSystem.relatedArtifact.where(type='predecessor').resource
7280
-
7281
- ClinicalUseDefinition product reference ClinicalUseDefinition.subject.where(resolve() is MedicinalProductDefinition)
7282
-
7283
- OrganizationAffiliation email token OrganizationAffiliation.contact.telecom.where(system='email')
7284
- OrganizationAffiliation phone token OrganizationAffiliation.contact.telecom.where(system='phone')
7285
-
7286
- PackagedProductDefinition biological reference PackagedProductDefinition.packaging.containedItem.item.reference
7287
- PackagedProductDefinition contained-item reference PackagedProductDefinition.packaging.containedItem.item.reference
7288
-
7289
- Patient deceased token Patient.deceased.exists() and Patient.deceased != false
7290
- Practitioner deceased token Practitioner.deceased.exists() and Practitioner.deceased != false
7291
-
7292
- Location contains special Location.extension('http://hl7.org/fhir/StructureDefinition/location-boundary-geojson').value
7293
-
7294
- QuestionnaireResponse item-subject reference QuestionnaireResponse.item.where(extension('http://hl7.org/fhir/StructureDefinition/questionnaireresponse-isSubject').exists()).answer.valueReference
7295
- */
7296
- /*
7297
- private _ProcessExpressions = (resourceName: string, SP_EXPRESSION: string): any => {
7298
- let expressions: any[] = [];
7299
-
7300
- //SP_EXPRESSION = this.#RemoveSurroundingParentheses(val2.expression);
7301
- expressions = SP_EXPRESSION.split('|').map(e => e.trim());
7302
-
7303
- expressions = expressions.map(e => this._RemoveSurroundingParentheses(e).trim());
7304
-
7305
- if (resourceName !== '') {
7306
- expressions = expressions.filter(e => e.split('.')[0].trim().localeCompare(resourceName) === 0);
7307
- }
7308
-
7309
- let original_expressions = [ ...expressions ];
7310
-
7311
- // ofType processing
7312
- expressions = expressions.map((e: string) => {
7313
- let capturedTypeOf = undefined;
7314
- return {
7315
- path: e.replace(
7316
- /\.ofType\(([^)]+)\)/g,
7317
- (_: string, typeName: string) => {
7318
- capturedTypeOf = true;
7319
- return typeName.charAt(0).toUpperCase() + typeName.slice(1)
7320
- }),
7321
- typeOf: capturedTypeOf
7322
- }
7323
- });
7324
-
7325
- //@@ exists processing here is more or less hard coded to the deceased attribute.
7326
- //@@ in future, we need an actual fhir language parser.
7327
- expressions.forEach(expression => {
7328
- try {
7329
- const sp = expression as ISearchParamExpressionRecord;
7330
- if (sp.path.indexOf('exists()') >= 0) {
7331
- // Person.deceased.exists() and Person.deceased != false
7332
- const parts = sp.path.split(' ');
7333
- const i = parts[0].indexOf('exists()');
7334
- if (i >= 0) {
7335
- let fieldExistsEx = parts[0].substring(0, i-1);
7336
- let op = parts[1];
7337
- let fieldTestEx = parts[2];
7338
- let comparator = parts[3];
7339
- let value = parts[4];
7340
-
7341
- const fieldExistsParts = fieldExistsEx.split('.');
7342
- let fieldExists = fieldExistsParts.slice(1).join('.');
7343
-
7344
- const fieldTestParts = fieldTestEx.split('.');
7345
- let fieldTest = fieldTestParts.slice(1).join('.');
7346
-
7347
- sp.exists = {
7348
- fieldExists: [ `${fieldExists}Boolean`, `${fieldExists}DataTime` ], // [x]Boolean or [x]DateTime
7349
- op,
7350
- fieldTest: [ `${fieldTest}Boolean`, `${fieldTest}DataTime` ],
7351
- comparator,
7352
- value: [ value, undefined ]
7353
- }
7354
- }
7355
- }
7356
- } catch (error) {
7357
-
7358
- }
7359
- });
7360
-
7361
- // where(resolve()) processing
7362
- let capturedType: string | undefined;
7363
- expressions = expressions.map((obj: any) => {
7364
- capturedType = undefined;
7365
- const { path, typeOf, exists } = obj;
7366
- return {
7367
- path: path.replace(
7368
- /\.where\(resolve\(\)\s+is\s+([^)]+)\)/,
7369
- (_: string, typeName: string) => {
7370
- capturedType = typeName;
7371
- //return ` // reference = ${capturedType}`; // remove the .where(...) part (you can put ` // ${capturedType}` if you want to keep a comment)
7372
- return '';
7373
- }),
7374
- typeOf,
7375
- reference: capturedType,
7376
- exists
7377
- }
7378
- });
7379
-
7380
- // .where processing
7381
- // The element before the .where will be an array. So this test checks which element(s) from that array are satisifed.
7382
- let capturedWhere: any = undefined;
7383
- expressions = expressions.map((obj: any) => {
7384
- capturedWhere = undefined;
7385
- const { path, reference, typeOf, exists } = obj;
7386
- const retVal: any = {
7387
- path: path.replace(/([^.]+)\.where\(([^=]+)='([^']+)'\)/g, (_: string, field: string, subfield: string, value: string) => {
7388
- capturedWhere = { field, subfield, value }
7389
- return field;
7390
- }),
7391
- typeOf,
7392
- reference,
7393
- exists
7394
- }
7395
- if (capturedWhere) {
7396
- capturedWhere.full = `${capturedWhere.field}[*].${capturedWhere.subfield}=${capturedWhere.value}`;
7397
- retVal.where = capturedWhere;
7398
- }
7399
- return retVal;
7400
- });
7401
-
7402
-
7403
- return {
7404
- expressions,
7405
- original_expressions
7406
- };
7407
- }
7408
-
7409
- #LoadDefinitions = async (): Promise<void> => {
7410
- try {
7411
- let usePath = '';
7412
- if (fs.existsSync(`${specPath1}${resourcesPath}`)) {
7413
- usePath = specPath1;
7414
- } else {
7415
- usePath = specPath2;
7416
- }
7417
- const __resources: any = JSON.parse(fs.readFileSync(`${usePath}${resourcesPath}`, 'utf-8'));
7418
- const __types: any = JSON.parse(fs.readFileSync(`${usePath}${typesPath}`, 'utf-8'));
7419
- const __searchParams: any = JSON.parse(fs.readFileSync(`${usePath}${searchParamsPath}`, 'utf-8'));
7420
-
7421
- for (let i=0; i < (__resources.entry as any[]).length; i++) {
7422
- const entry = __resources.entry[i];
7423
- const resource: any = entry.resource;
7424
- if (resource?.snapshot?.element) {
7425
- const rt = resource.type as string;
7426
- await this.redis!.set(this.GetResourceKey(rt), JSON.stringify(resource.snapshot.element));
7427
- }
7428
- };
7429
-
7430
- for (let i=0; i < (__types.entry as any[]).length; i++) {
7431
- const entry = __types.entry[i];
7432
- const type = entry.resource;
7433
- if (type?.snapshot?.element) {
7434
- await this.redis!.set(this.GetTypeKey(type.type), JSON.stringify(type.snapshot.element));
7435
- }
7436
- };
7437
-
7438
- for (let i=0; i < (__searchParams.entry as any[]).length; i++) {
7439
- const entry = __searchParams.entry[i];
7440
- await this.redis!.set(this.GetSearchParameterByFullUrlKey(entry.fullUrl), JSON.stringify(entry.resource));
7441
- const { code, base } = entry.resource;
7442
- if (base) {
7443
- for (let j=0; j < base.length; j++) {
7444
- const resourceType = base[j];
7445
- await this.redis!.hSet(this.GetSearchParameterByResourceTypeKey(resourceType), code, JSON.stringify(entry.resource));
7446
- }
7447
- }
7448
- };
7449
-
7450
- //await this.#LoadDefinitionsPass2(__searchParams);
7451
-
7452
- console.log(`All completed ...`);
7453
- } catch (error) {
7454
- console.error(error);
7455
- throw error;
7456
- }
7457
- }
7458
- */
7459
- /*
7460
- #LoadDefinitionsPass2 = async (__searchParams: any): Promise<void> => {
7461
- try {
7462
- for (let i=0; i < (__searchParams.entry as any[]).length; i++) {
7463
-
7464
- console.log(`Processing (i) entry: [${i}]`);
7465
-
7466
- if (i === 47 ) {
7467
- console.log(`here...`)
7468
- }
7469
-
7470
- const entry = __searchParams.entry[i];
7471
-
7472
- const { id, url, code, base, type, expression, component, target } = entry.resource;
7473
-
7474
- if (base) {
7475
- for (let j=0; j < base.length; j++) {
7476
- const resourceType = base[j];
7477
- const SP_ID = id;
7478
- const SP_NAME = code; // code is the true SP name (but in the spec, name is usually the same as code)
7479
- const SP_TYPE = type;
7480
- const SP_URL = url;
7481
- const SP_TARGET = target;
7482
- let SP_EXPRESSION: string = expression;
7483
- let expressions: any[] = [];
7484
- let original_expressions: any[] = [];
7485
- if (SP_EXPRESSION) {
7486
- const retVal = this._ProcessExpressions(code, SP_EXPRESSION);
7487
- expressions = retVal.expressions;
7488
- original_expressions = retVal.original_expressions;
7489
- }
7490
-
7491
- const record: ISearchParamRecord = {
7492
- SP_ID,
7493
- SP_NAME,
7494
- SP_TYPE,
7495
- SP_URL,
7496
- SP_TARGET,
7497
- expressions,
7498
- original_expressions,
7499
- SP_DEFINITION: entry.resource // this.resourceHelper.GetSearchParam(SP_URL)
7500
- };
7501
-
7502
- for (let i=0; i < record.expressions.length; i++) {
7503
- //console.log(record.expressions[i]);
7504
- const rf = await this.GetResourceField(resourceType, record.expressions[i].path);
7505
- if (rf) {
7506
- expressions[i].RES_FIELD = rf;
7507
- }
7508
- }
7509
-
7510
- if (component) {
7511
- record.component = [ ...component ];
7512
- for (let k=0; k < record.component.length; k++) {
7513
- const c = record.component[k] as any;
7514
- //c.SP_RAW_PATHS = (c.expression.split('|') as any[]).map(rp => rp.trim());
7515
- //c.SP_PATHS = (c.SP_RAW_PATHS as any[]).map(rawPath => this.ResolveFhirChoiceType(rawPath));
7516
- const retVal = this._ProcessExpressions('', c.expression);
7517
- c.expressions = retVal.expressions;
7518
- c.original_expressions = retVal.original_expressions;
7519
-
7520
- let def = null;
7521
- const foundSearchParameter = await this.redis!.get(this.GetSearchParameterByFullUrlKey(c.definition));
7522
- if (foundSearchParameter) {
7523
- def = JSON.parse(foundSearchParameter);
7524
- }
7525
- //const def = await this.GetSearchParam(c.definition); //@@ fails here ...
7526
-
7527
- if (def && def.type) {
7528
- c.type = def.type
7529
- }
7530
- }
7531
- }
7532
-
7533
- await this.redis!.hSet(this.GetSTSCustomSearchParameterByResourceTypeKey(resourceType),
7534
- code, JSON.stringify(record));
7535
-
7536
- console.log(`Loaded...(j): [${j}]`);
7537
- }
7538
- console.log(`All Loaded...`);
7539
- }
7540
- console.log(`Loaded...(i): [${i}]`);
7541
- };
7542
- console.log(`Loaded...`);
7543
- } catch (error) {
7544
- console.error(error);
7545
- throw error;
7546
- }
7547
- }
7548
- */
7549
- /*
7550
- GetType = async (typeName: string): Promise<any[]> => {
7551
- await this.EnsureSearchParameterDataLoaded();
7552
- const foundType = await this.redis!.get(this.GetTypeKey(typeName));
7553
- if (foundType) {
7554
- return JSON.parse(foundType);
7555
- }
7556
- return [ ];
7557
- }
7558
-
7559
- GetResource = async (resourceType: string): Promise<any[]> => {
7560
- await this.EnsureSearchParameterDataLoaded();
7561
- const foundResourceType = await this.redis!.get(this.GetResourceKey(resourceType));
7562
- if (foundResourceType) {
7563
- return JSON.parse(foundResourceType);
7564
- }
7565
- return [ ];
7566
- }
7567
-
7568
- GetResourceField = async (resourceType: string, fieldPath: string): Promise<any> => {
7569
- const resource: any[] = await this.GetResource(resourceType);
7570
- if (resource) {
7571
- const foundRecord = resource.filter(o => o.id === fieldPath);
7572
- if (foundRecord.length > 0) {
7573
- return foundRecord[0];
7574
- }
7575
- return undefined;
7576
- }
7577
- }
7578
-
7579
- GetSearchParam = async (fullUrl: string): Promise<any> => {
7580
- await this.EnsureSearchParameterDataLoaded();
7581
- const foundSearchParameter = await this.redis!.get(this.GetSearchParameterByFullUrlKey(fullUrl));
7582
- if (foundSearchParameter) {
7583
- return JSON.parse(foundSearchParameter);
7584
- }
7585
- return null;
7586
- }
7587
-
7588
- GetSearchParamsByResourceType = async (resourceType: string): Promise<SearchParameter[]> => {
7589
- await this.EnsureSearchParameterDataLoaded();
7590
- const all = await this.redis!.hGetAll(this.GetSearchParameterByResourceTypeKey(resourceType));
7591
- const parsed = Object.values(all).map(v => JSON.parse(v));
7592
- return parsed;
7593
- }
7594
-
7595
- GetSTSCustomSearchParametersByResourceType = async (resourceType: string): Promise<ISearchParamRecord[]> => {
7596
- await this.EnsureSearchParameterDataLoaded();
7597
- const all = await this.redis!.hGetAll(this.GetSTSCustomSearchParameterByResourceTypeKey(resourceType));
7598
- const parsed = Object.values(all).map(v => JSON.parse(v));
7599
- return parsed;
7600
- }
7601
-
7602
- GetSearchParamFromResourceTypeUrl = async (resourceType: string, url: string): Promise<ISearchParamRecord | undefined> => {
7603
- const customSearchParameters = await this.GetSTSCustomSearchParametersByResourceType(resourceType);
7604
- const filterByNameAndUrl = customSearchParameters.filter(rt => rt.SP_URL.localeCompare(url) === 0);
7605
- if (filterByNameAndUrl.length > 0) {
7606
- return filterByNameAndUrl[0];
7607
- }
7608
- }
7609
-
7610
- GetSearchParamFromResourceType = async (resourceType: string, name: string): Promise<ISearchParamRecord | undefined> => {
7611
- const customSearchParameters = await this.GetSTSCustomSearchParametersByResourceType(resourceType);
7612
- const filterByName = customSearchParameters.filter(rt => rt.SP_NAME.localeCompare(name) === 0);
7613
- if (filterByName.length > 0) {
7614
- return filterByName[0];
7615
- }
7616
- }
7617
-
7618
- GetPathsFromResourceType = async (resourceType: string, name: string): Promise<string[]> => {
7619
- const customSearchParameters = await this.GetSTSCustomSearchParametersByResourceType(resourceType);
7620
- const filterByName = customSearchParameters.filter(rt => rt.SP_NAME.localeCompare(name) === 0);
7621
- if (filterByName.length > 0) {
7622
- return filterByName[0].expressions.map(e => e.path)
7623
- }
7624
- return [ ];
7625
- }
7626
- */
7258
+ GetSearchParamFromResourceType = async (resourceType) => {
7259
+ const key = `${this.#searchParametersByResourceTypeKey}_${resourceType}`;
7260
+ if (this.cache[key]) {
7261
+ return this.cache[key];
7262
+ }
7263
+ const retVal = await this.redis.hGet(this.#searchParametersByResourceTypeKey, resourceType);
7264
+ this.cache[key] = JSON.parse(retVal);
7265
+ return this.cache[key];
7266
+ };
7267
+ GetType = async (typeName) => {
7268
+ const key = `${this.#typesKey}_${typeName}`;
7269
+ if (this.cache[key]) {
7270
+ return this.cache[key];
7271
+ }
7272
+ const retVal = await this.redis.hGet(this.#typesKey, typeName);
7273
+ this.cache[key] = JSON.parse(retVal);
7274
+ return this.cache[key];
7275
+ };
7276
+ GetResource = async (resourceType) => {
7277
+ const key = `${this.#resourcesKey}_${resourceType}`;
7278
+ if (this.cache[key]) {
7279
+ return this.cache[key];
7280
+ }
7281
+ const retVal = await this.redis.hGet(this.#resourcesKey, resourceType);
7282
+ this.cache[key] = JSON.parse(retVal);
7283
+ return this.cache[key];
7284
+ };
7285
+ GetSearchParam = async (url) => {
7286
+ const key = `${this.#searchParametersByUrlKey}_${url}`;
7287
+ if (this.cache[key]) {
7288
+ return this.cache[key];
7289
+ }
7290
+ const retVal = await this.redis.hGet(this.#searchParametersByUrlKey, url);
7291
+ this.cache[key] = JSON.parse(retVal);
7292
+ return this.cache[key];
7293
+ };
7627
7294
  }
7628
7295
  const specPath1 = "./dist/";
7629
7296
  const specPath2 = "./node_modules/@nsshunt/stsfhirpg/dist/";
@@ -7632,6 +7299,7 @@ const typesPath = "fhir-spec/profiles-types.json";
7632
7299
  const searchParamsPath = "fhir-spec/search-parameters.json";
7633
7300
  class ResourceHelper {
7634
7301
  #definitions;
7302
+ #loaded = false;
7635
7303
  searchParameterManager;
7636
7304
  static instance;
7637
7305
  constructor() {
@@ -7684,7 +7352,8 @@ class ResourceHelper {
7684
7352
  });
7685
7353
  await this._LoadSearchParameters();
7686
7354
  await this.PreLoadSearchParameterData();
7687
- return this.#definitions;
7355
+ this.#loaded = true;
7356
+ this.#definitions = void 0;
7688
7357
  };
7689
7358
  PreLoadSearchParameterData = async () => {
7690
7359
  console.log(`PreLoadSearchParameterData(): Start ...`);
@@ -7695,25 +7364,22 @@ class ResourceHelper {
7695
7364
  autoRenew: true,
7696
7365
  heartbeatMs: 1e4
7697
7366
  });
7698
- await this.searchParameterManager.EnsureSearchParameterDataLoaded();
7367
+ await this.searchParameterManager.EnsureSearchParameterDataLoaded(this.#definitions);
7699
7368
  console.log(`PreLoadSearchParameterData(): End`);
7700
7369
  };
7701
7370
  GetDefinitions = async () => {
7702
- if (!this.#definitions) {
7703
- await this.#LoadDefinitions();
7371
+ if (!this.#loaded) {
7372
+ if (!this.#definitions) {
7373
+ await this.#LoadDefinitions();
7374
+ }
7704
7375
  }
7705
- return this.#definitions;
7706
7376
  };
7707
- GetType = async (typeName) => {
7708
- await this.GetDefinitions();
7709
- return this.#definitions.types[typeName];
7710
- };
7711
- GetResource = async (resourceType) => {
7377
+ _GetResource = async (resourceType) => {
7712
7378
  await this.GetDefinitions();
7713
7379
  return this.#definitions.resources[resourceType];
7714
7380
  };
7715
- GetResourceField = async (resourceType, fieldPath) => {
7716
- const resource = await this.GetResource(resourceType);
7381
+ _GetResourceField = async (resourceType, fieldPath) => {
7382
+ const resource = await this._GetResource(resourceType);
7717
7383
  if (resource) {
7718
7384
  const foundRecord = resource.filter((o) => o.id === fieldPath);
7719
7385
  if (foundRecord.length > 0) {
@@ -7722,18 +7388,53 @@ class ResourceHelper {
7722
7388
  return void 0;
7723
7389
  }
7724
7390
  };
7725
- GetSearchParam = async (url) => {
7391
+ _GetSearchParam = async (url) => {
7726
7392
  await this.GetDefinitions();
7727
7393
  return this.#definitions.searchParametersByUrl[url];
7728
7394
  };
7729
- GetSearchParams = async () => {
7395
+ _GetSearchParams = async () => {
7730
7396
  await this.GetDefinitions();
7731
7397
  return this.#definitions.searchParametersByUrl;
7732
7398
  };
7733
- GetSearchParamsByResource = async (resource) => {
7399
+ GetType = async (typeName) => {
7400
+ await this.GetDefinitions();
7401
+ return await this.searchParameterManager.GetType(typeName);
7402
+ };
7403
+ GetResource = async (resourceType) => {
7404
+ await this.GetDefinitions();
7405
+ return await this.searchParameterManager.GetResource(resourceType);
7406
+ };
7407
+ GetResourceField = async (resourceType, fieldPath) => {
7408
+ const resource = await this.GetResource(resourceType);
7409
+ if (resource) {
7410
+ const foundRecord = resource.filter((o) => o.id === fieldPath);
7411
+ if (foundRecord.length > 0) {
7412
+ return foundRecord[0];
7413
+ }
7414
+ return void 0;
7415
+ }
7416
+ };
7417
+ GetSearchParam = async (url) => {
7734
7418
  await this.GetDefinitions();
7735
- return Object.values(this.#definitions.searchParametersByUrl).filter((sp) => sp.base.includes(resource)).map((sp) => sp);
7419
+ return await this.searchParameterManager.GetSearchParam(url);
7736
7420
  };
7421
+ /*
7422
+ private GetSearchParams = async (): Promise<SearchParameter[]> => {
7423
+ await this.GetDefinitions();
7424
+ return await this.searchParameterManager!.GetSearchParams();
7425
+ }
7426
+
7427
+ GetSearchParamsByResource = async (resource: string): Promise<SearchParameter[]> => {
7428
+ await this.GetDefinitions();
7429
+ const searchParams = await this.GetSearchParams();
7430
+ return searchParams
7431
+ .filter(sp => sp.base.includes(resource))
7432
+ .map(sp => sp)
7433
+ //return Object.values(this.#definitions!.searchParametersByUrl)
7434
+ //.filter(sp => sp.base.includes(resource))
7435
+ //.map(sp => sp)
7436
+ }
7437
+ */
7737
7438
  // ------------------------------------------------------------------------------------------------------------------
7738
7439
  // Remove ( ) when either are present
7739
7440
  #RemoveOuterParentheses = (input) => {
@@ -7856,7 +7557,7 @@ class ResourceHelper {
7856
7557
  };
7857
7558
  };
7858
7559
  _LoadSearchParameters = async () => {
7859
- for (const [key, val] of Object.entries(await this.GetSearchParams())) {
7560
+ for (const [key, val] of Object.entries(await this._GetSearchParams())) {
7860
7561
  const { id, url, code, base, type, expression, component, target } = val;
7861
7562
  for (let i = 0; i < base.length; i++) {
7862
7563
  const resourceName = base[i];
@@ -7887,10 +7588,10 @@ class ResourceHelper {
7887
7588
  SP_TARGET,
7888
7589
  expressions,
7889
7590
  original_expressions,
7890
- SP_DEFINITION: await this.GetSearchParam(SP_URL)
7591
+ SP_DEFINITION: await this._GetSearchParam(SP_URL)
7891
7592
  };
7892
7593
  for (let i2 = 0; i2 < record.expressions.length; i2++) {
7893
- const rf = await this.GetResourceField(resourceName, record.expressions[i2].path);
7594
+ const rf = await this._GetResourceField(resourceName, record.expressions[i2].path);
7894
7595
  if (rf) {
7895
7596
  expressions[i2].RES_FIELD = rf;
7896
7597
  }
@@ -7901,7 +7602,7 @@ class ResourceHelper {
7901
7602
  const retVal = this.ProcessExpressions("", c.expression);
7902
7603
  c.expressions = retVal.expressions;
7903
7604
  c.original_expressions = retVal.original_expressions;
7904
- const def = await this.GetSearchParam(c.definition);
7605
+ const def = await this._GetSearchParam(c.definition);
7905
7606
  if (def && def.type) {
7906
7607
  c.type = def.type;
7907
7608
  }
@@ -7913,21 +7614,24 @@ class ResourceHelper {
7913
7614
  };
7914
7615
  GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
7915
7616
  await this.GetDefinitions();
7916
- const filterByNameAndUrl = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_URL.localeCompare(url) === 0);
7617
+ const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
7618
+ const filterByNameAndUrl = rt.params.filter((rt2) => rt2.SP_URL.localeCompare(url) === 0);
7917
7619
  if (filterByNameAndUrl.length > 0) {
7918
7620
  return filterByNameAndUrl[0];
7919
7621
  }
7920
7622
  };
7921
7623
  GetSearchParamFromResourceType = async (resourceType, name) => {
7922
7624
  await this.GetDefinitions();
7923
- const filterByName = this.#definitions.searchParametersByResourceType[resourceType].params.filter((rt) => rt.SP_NAME.localeCompare(name) === 0);
7625
+ const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
7626
+ const filterByName = rt.params.filter((rt2) => rt2.SP_NAME.localeCompare(name) === 0);
7924
7627
  if (filterByName.length > 0) {
7925
7628
  return filterByName[0];
7926
7629
  }
7927
7630
  };
7928
7631
  GetSearchParamsFromResourceType = async (resourceType) => {
7929
7632
  await this.GetDefinitions();
7930
- return this.#definitions.searchParametersByResourceType[resourceType].params;
7633
+ const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
7634
+ return rt.params;
7931
7635
  };
7932
7636
  }
7933
7637
  var ansiStyles = { exports: {} };