@nsshunt/stsfhirpg 1.2.11 → 1.2.13
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.
- package/dist/stsfhirpg.cjs +122 -29
- package/dist/stsfhirpg.cjs.map +1 -1
- package/dist/stsfhirpg.mjs +122 -29
- package/dist/stsfhirpg.mjs.map +1 -1
- package/package.json +1 -1
- package/types/fhir-utils/resourceHelper.d.ts +4 -2
- package/types/fhir-utils/resourceHelper.d.ts.map +1 -1
- package/types/searchParameterManager.d.ts +8 -1
- package/types/searchParameterManager.d.ts.map +1 -1
package/dist/stsfhirpg.mjs
CHANGED
|
@@ -7128,7 +7128,7 @@ class SearchParameterManager {
|
|
|
7128
7128
|
constructor(options) {
|
|
7129
7129
|
this.options = options;
|
|
7130
7130
|
}
|
|
7131
|
-
EnsureSearchParameterDataLoaded = async () => {
|
|
7131
|
+
EnsureSearchParameterDataLoaded = async (resources) => {
|
|
7132
7132
|
if (this.alreadyComplete) {
|
|
7133
7133
|
return this.alreadyComplete;
|
|
7134
7134
|
}
|
|
@@ -7184,7 +7184,7 @@ class SearchParameterManager {
|
|
|
7184
7184
|
return;
|
|
7185
7185
|
}
|
|
7186
7186
|
try {
|
|
7187
|
-
await this.#LoadDefinitions();
|
|
7187
|
+
await this.#LoadDefinitions(resources);
|
|
7188
7188
|
} catch (error) {
|
|
7189
7189
|
console.error(error);
|
|
7190
7190
|
throw error;
|
|
@@ -7232,14 +7232,69 @@ class SearchParameterManager {
|
|
|
7232
7232
|
console.log(`SearchParameterManager(): redis closed`);
|
|
7233
7233
|
}
|
|
7234
7234
|
};
|
|
7235
|
-
|
|
7235
|
+
/*
|
|
7236
|
+
private GetTypeKey(typeName: string) {
|
|
7237
|
+
return `stsfhir_type_${typeName}`;
|
|
7238
|
+
}
|
|
7239
|
+
|
|
7240
|
+
private GetSearchParameterByFullUrlKey(fullUrl: string) {
|
|
7241
|
+
return `stsfhir_sp_${fullUrl}`;
|
|
7242
|
+
}
|
|
7243
|
+
|
|
7244
|
+
private GetResourceKey(resourceType: string) {
|
|
7245
|
+
return `stsfhir_resource_${resourceType}`;
|
|
7246
|
+
}
|
|
7247
|
+
|
|
7248
|
+
private GetSearchParameterByResourceTypeKey(resourceType: string) {
|
|
7249
|
+
return `stsfhir_sp_resource_${resourceType}`;
|
|
7250
|
+
}
|
|
7251
|
+
|
|
7252
|
+
private GetSTSCustomSearchParameterByResourceTypeKey(resourceType: string) {
|
|
7253
|
+
return `stsfhir_stscustom_sp_resource_${resourceType}`;
|
|
7254
|
+
}
|
|
7255
|
+
*/
|
|
7256
|
+
#LoadDefinitions = async (resources) => {
|
|
7236
7257
|
console.log("Data Load Starting ...");
|
|
7237
|
-
for (
|
|
7238
|
-
|
|
7239
|
-
|
|
7258
|
+
for (const [key, value] of Object.entries(resources.searchParametersByResourceType)) {
|
|
7259
|
+
await this.redis.hSet(`__stsfhir__searchParametersByResourceType`, key, JSON.stringify(value));
|
|
7260
|
+
}
|
|
7261
|
+
for (const [key, value] of Object.entries(resources.searchParametersByUrl)) {
|
|
7262
|
+
await this.redis.hSet(`__stsfhir__searchParametersByUrl`, key, JSON.stringify(value));
|
|
7263
|
+
}
|
|
7264
|
+
for (const [key, value] of Object.entries(resources.resources)) {
|
|
7265
|
+
await this.redis.hSet(`__stsfhir__resources`, key, JSON.stringify(value));
|
|
7266
|
+
}
|
|
7267
|
+
for (const [key, value] of Object.entries(resources.types)) {
|
|
7268
|
+
await this.redis.hSet(`__stsfhir__types`, key, JSON.stringify(value));
|
|
7240
7269
|
}
|
|
7241
7270
|
console.log("All Done ***********************************************************************************");
|
|
7242
7271
|
};
|
|
7272
|
+
GetSearchParamFromResourceType = async (resourceType) => {
|
|
7273
|
+
const retVal = await this.redis.hGet(`__stsfhir__searchParametersByResourceType`, resourceType);
|
|
7274
|
+
return JSON.parse(retVal);
|
|
7275
|
+
};
|
|
7276
|
+
GetType = async (typeName) => {
|
|
7277
|
+
const retVal = await this.redis.hGet(`__stsfhir__types`, typeName);
|
|
7278
|
+
return JSON.parse(retVal);
|
|
7279
|
+
};
|
|
7280
|
+
GetResource = async (resourceType) => {
|
|
7281
|
+
const retVal = await this.redis.hGet(`__stsfhir__resources`, resourceType);
|
|
7282
|
+
return JSON.parse(retVal);
|
|
7283
|
+
};
|
|
7284
|
+
GetSearchParam = async (url) => {
|
|
7285
|
+
const retVal = await this.redis.hGet(`__stsfhir__searchParametersByUrl`, url);
|
|
7286
|
+
return JSON.parse(retVal);
|
|
7287
|
+
};
|
|
7288
|
+
/*
|
|
7289
|
+
GetSearchParams = async (): Promise<SearchParameter[]> => {
|
|
7290
|
+
const retVal = await this.redis!.hGetAll(`__stsfhir__searchParametersByUrl`);
|
|
7291
|
+
const searchParameters: SearchParameter[] = [ ];
|
|
7292
|
+
for (const [key, value] of Object.entries(retVal)) {
|
|
7293
|
+
searchParameters.push(JSON.parse(value));
|
|
7294
|
+
}
|
|
7295
|
+
return searchParameters;
|
|
7296
|
+
}
|
|
7297
|
+
*/
|
|
7243
7298
|
/*
|
|
7244
7299
|
private GetTypeKey(typeName: string) {
|
|
7245
7300
|
return `stsfhir_type_${typeName}`;
|
|
@@ -7630,6 +7685,7 @@ const typesPath = "fhir-spec/profiles-types.json";
|
|
|
7630
7685
|
const searchParamsPath = "fhir-spec/search-parameters.json";
|
|
7631
7686
|
class ResourceHelper {
|
|
7632
7687
|
#definitions;
|
|
7688
|
+
#loaded = false;
|
|
7633
7689
|
searchParameterManager;
|
|
7634
7690
|
static instance;
|
|
7635
7691
|
constructor() {
|
|
@@ -7681,7 +7737,9 @@ class ResourceHelper {
|
|
|
7681
7737
|
this.#definitions.searchParametersByUrl[entry.fullUrl] = entry.resource;
|
|
7682
7738
|
});
|
|
7683
7739
|
await this._LoadSearchParameters();
|
|
7684
|
-
|
|
7740
|
+
await this.PreLoadSearchParameterData();
|
|
7741
|
+
this.#loaded = true;
|
|
7742
|
+
this.#definitions = void 0;
|
|
7685
7743
|
};
|
|
7686
7744
|
PreLoadSearchParameterData = async () => {
|
|
7687
7745
|
console.log(`PreLoadSearchParameterData(): Start ...`);
|
|
@@ -7692,25 +7750,22 @@ class ResourceHelper {
|
|
|
7692
7750
|
autoRenew: true,
|
|
7693
7751
|
heartbeatMs: 1e4
|
|
7694
7752
|
});
|
|
7695
|
-
await this.searchParameterManager.EnsureSearchParameterDataLoaded();
|
|
7753
|
+
await this.searchParameterManager.EnsureSearchParameterDataLoaded(this.#definitions);
|
|
7696
7754
|
console.log(`PreLoadSearchParameterData(): End`);
|
|
7697
7755
|
};
|
|
7698
7756
|
GetDefinitions = async () => {
|
|
7699
|
-
if (!this.#
|
|
7700
|
-
|
|
7757
|
+
if (!this.#loaded) {
|
|
7758
|
+
if (!this.#definitions) {
|
|
7759
|
+
await this.#LoadDefinitions();
|
|
7760
|
+
}
|
|
7701
7761
|
}
|
|
7702
|
-
return this.#definitions;
|
|
7703
7762
|
};
|
|
7704
|
-
|
|
7705
|
-
await this.GetDefinitions();
|
|
7706
|
-
return this.#definitions.types[typeName];
|
|
7707
|
-
};
|
|
7708
|
-
GetResource = async (resourceType) => {
|
|
7763
|
+
_GetResource = async (resourceType) => {
|
|
7709
7764
|
await this.GetDefinitions();
|
|
7710
7765
|
return this.#definitions.resources[resourceType];
|
|
7711
7766
|
};
|
|
7712
|
-
|
|
7713
|
-
const resource = await this.
|
|
7767
|
+
_GetResourceField = async (resourceType, fieldPath) => {
|
|
7768
|
+
const resource = await this._GetResource(resourceType);
|
|
7714
7769
|
if (resource) {
|
|
7715
7770
|
const foundRecord = resource.filter((o) => o.id === fieldPath);
|
|
7716
7771
|
if (foundRecord.length > 0) {
|
|
@@ -7719,18 +7774,53 @@ class ResourceHelper {
|
|
|
7719
7774
|
return void 0;
|
|
7720
7775
|
}
|
|
7721
7776
|
};
|
|
7722
|
-
|
|
7777
|
+
_GetSearchParam = async (url) => {
|
|
7723
7778
|
await this.GetDefinitions();
|
|
7724
7779
|
return this.#definitions.searchParametersByUrl[url];
|
|
7725
7780
|
};
|
|
7726
|
-
|
|
7781
|
+
_GetSearchParams = async () => {
|
|
7727
7782
|
await this.GetDefinitions();
|
|
7728
7783
|
return this.#definitions.searchParametersByUrl;
|
|
7729
7784
|
};
|
|
7730
|
-
|
|
7785
|
+
GetType = async (typeName) => {
|
|
7786
|
+
await this.GetDefinitions();
|
|
7787
|
+
return await this.searchParameterManager.GetType(typeName);
|
|
7788
|
+
};
|
|
7789
|
+
GetResource = async (resourceType) => {
|
|
7731
7790
|
await this.GetDefinitions();
|
|
7732
|
-
return
|
|
7791
|
+
return await this.searchParameterManager.GetResource(resourceType);
|
|
7733
7792
|
};
|
|
7793
|
+
GetResourceField = async (resourceType, fieldPath) => {
|
|
7794
|
+
const resource = await this.GetResource(resourceType);
|
|
7795
|
+
if (resource) {
|
|
7796
|
+
const foundRecord = resource.filter((o) => o.id === fieldPath);
|
|
7797
|
+
if (foundRecord.length > 0) {
|
|
7798
|
+
return foundRecord[0];
|
|
7799
|
+
}
|
|
7800
|
+
return void 0;
|
|
7801
|
+
}
|
|
7802
|
+
};
|
|
7803
|
+
GetSearchParam = async (url) => {
|
|
7804
|
+
await this.GetDefinitions();
|
|
7805
|
+
return await this.searchParameterManager.GetSearchParam(url);
|
|
7806
|
+
};
|
|
7807
|
+
/*
|
|
7808
|
+
private GetSearchParams = async (): Promise<SearchParameter[]> => {
|
|
7809
|
+
await this.GetDefinitions();
|
|
7810
|
+
return await this.searchParameterManager!.GetSearchParams();
|
|
7811
|
+
}
|
|
7812
|
+
|
|
7813
|
+
GetSearchParamsByResource = async (resource: string): Promise<SearchParameter[]> => {
|
|
7814
|
+
await this.GetDefinitions();
|
|
7815
|
+
const searchParams = await this.GetSearchParams();
|
|
7816
|
+
return searchParams
|
|
7817
|
+
.filter(sp => sp.base.includes(resource))
|
|
7818
|
+
.map(sp => sp)
|
|
7819
|
+
//return Object.values(this.#definitions!.searchParametersByUrl)
|
|
7820
|
+
//.filter(sp => sp.base.includes(resource))
|
|
7821
|
+
//.map(sp => sp)
|
|
7822
|
+
}
|
|
7823
|
+
*/
|
|
7734
7824
|
// ------------------------------------------------------------------------------------------------------------------
|
|
7735
7825
|
// Remove ( ) when either are present
|
|
7736
7826
|
#RemoveOuterParentheses = (input) => {
|
|
@@ -7853,7 +7943,7 @@ class ResourceHelper {
|
|
|
7853
7943
|
};
|
|
7854
7944
|
};
|
|
7855
7945
|
_LoadSearchParameters = async () => {
|
|
7856
|
-
for (const [key, val] of Object.entries(await this.
|
|
7946
|
+
for (const [key, val] of Object.entries(await this._GetSearchParams())) {
|
|
7857
7947
|
const { id, url, code, base, type, expression, component, target } = val;
|
|
7858
7948
|
for (let i = 0; i < base.length; i++) {
|
|
7859
7949
|
const resourceName = base[i];
|
|
@@ -7884,10 +7974,10 @@ class ResourceHelper {
|
|
|
7884
7974
|
SP_TARGET,
|
|
7885
7975
|
expressions,
|
|
7886
7976
|
original_expressions,
|
|
7887
|
-
SP_DEFINITION: await this.
|
|
7977
|
+
SP_DEFINITION: await this._GetSearchParam(SP_URL)
|
|
7888
7978
|
};
|
|
7889
7979
|
for (let i2 = 0; i2 < record.expressions.length; i2++) {
|
|
7890
|
-
const rf = await this.
|
|
7980
|
+
const rf = await this._GetResourceField(resourceName, record.expressions[i2].path);
|
|
7891
7981
|
if (rf) {
|
|
7892
7982
|
expressions[i2].RES_FIELD = rf;
|
|
7893
7983
|
}
|
|
@@ -7898,7 +7988,7 @@ class ResourceHelper {
|
|
|
7898
7988
|
const retVal = this.ProcessExpressions("", c.expression);
|
|
7899
7989
|
c.expressions = retVal.expressions;
|
|
7900
7990
|
c.original_expressions = retVal.original_expressions;
|
|
7901
|
-
const def = await this.
|
|
7991
|
+
const def = await this._GetSearchParam(c.definition);
|
|
7902
7992
|
if (def && def.type) {
|
|
7903
7993
|
c.type = def.type;
|
|
7904
7994
|
}
|
|
@@ -7910,21 +8000,24 @@ class ResourceHelper {
|
|
|
7910
8000
|
};
|
|
7911
8001
|
GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
|
|
7912
8002
|
await this.GetDefinitions();
|
|
7913
|
-
const
|
|
8003
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8004
|
+
const filterByNameAndUrl = rt.params.filter((rt2) => rt2.SP_URL.localeCompare(url) === 0);
|
|
7914
8005
|
if (filterByNameAndUrl.length > 0) {
|
|
7915
8006
|
return filterByNameAndUrl[0];
|
|
7916
8007
|
}
|
|
7917
8008
|
};
|
|
7918
8009
|
GetSearchParamFromResourceType = async (resourceType, name) => {
|
|
7919
8010
|
await this.GetDefinitions();
|
|
7920
|
-
const
|
|
8011
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8012
|
+
const filterByName = rt.params.filter((rt2) => rt2.SP_NAME.localeCompare(name) === 0);
|
|
7921
8013
|
if (filterByName.length > 0) {
|
|
7922
8014
|
return filterByName[0];
|
|
7923
8015
|
}
|
|
7924
8016
|
};
|
|
7925
8017
|
GetSearchParamsFromResourceType = async (resourceType) => {
|
|
7926
8018
|
await this.GetDefinitions();
|
|
7927
|
-
|
|
8019
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8020
|
+
return rt.params;
|
|
7928
8021
|
};
|
|
7929
8022
|
}
|
|
7930
8023
|
var ansiStyles = { exports: {} };
|