@nsshunt/stsfhirpg 1.2.12 → 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 +121 -29
- package/dist/stsfhirpg.cjs.map +1 -1
- package/dist/stsfhirpg.mjs +121 -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() {
|
|
@@ -7682,7 +7738,8 @@ class ResourceHelper {
|
|
|
7682
7738
|
});
|
|
7683
7739
|
await this._LoadSearchParameters();
|
|
7684
7740
|
await this.PreLoadSearchParameterData();
|
|
7685
|
-
|
|
7741
|
+
this.#loaded = true;
|
|
7742
|
+
this.#definitions = void 0;
|
|
7686
7743
|
};
|
|
7687
7744
|
PreLoadSearchParameterData = async () => {
|
|
7688
7745
|
console.log(`PreLoadSearchParameterData(): Start ...`);
|
|
@@ -7693,25 +7750,22 @@ class ResourceHelper {
|
|
|
7693
7750
|
autoRenew: true,
|
|
7694
7751
|
heartbeatMs: 1e4
|
|
7695
7752
|
});
|
|
7696
|
-
await this.searchParameterManager.EnsureSearchParameterDataLoaded();
|
|
7753
|
+
await this.searchParameterManager.EnsureSearchParameterDataLoaded(this.#definitions);
|
|
7697
7754
|
console.log(`PreLoadSearchParameterData(): End`);
|
|
7698
7755
|
};
|
|
7699
7756
|
GetDefinitions = async () => {
|
|
7700
|
-
if (!this.#
|
|
7701
|
-
|
|
7757
|
+
if (!this.#loaded) {
|
|
7758
|
+
if (!this.#definitions) {
|
|
7759
|
+
await this.#LoadDefinitions();
|
|
7760
|
+
}
|
|
7702
7761
|
}
|
|
7703
|
-
return this.#definitions;
|
|
7704
7762
|
};
|
|
7705
|
-
|
|
7706
|
-
await this.GetDefinitions();
|
|
7707
|
-
return this.#definitions.types[typeName];
|
|
7708
|
-
};
|
|
7709
|
-
GetResource = async (resourceType) => {
|
|
7763
|
+
_GetResource = async (resourceType) => {
|
|
7710
7764
|
await this.GetDefinitions();
|
|
7711
7765
|
return this.#definitions.resources[resourceType];
|
|
7712
7766
|
};
|
|
7713
|
-
|
|
7714
|
-
const resource = await this.
|
|
7767
|
+
_GetResourceField = async (resourceType, fieldPath) => {
|
|
7768
|
+
const resource = await this._GetResource(resourceType);
|
|
7715
7769
|
if (resource) {
|
|
7716
7770
|
const foundRecord = resource.filter((o) => o.id === fieldPath);
|
|
7717
7771
|
if (foundRecord.length > 0) {
|
|
@@ -7720,18 +7774,53 @@ class ResourceHelper {
|
|
|
7720
7774
|
return void 0;
|
|
7721
7775
|
}
|
|
7722
7776
|
};
|
|
7723
|
-
|
|
7777
|
+
_GetSearchParam = async (url) => {
|
|
7724
7778
|
await this.GetDefinitions();
|
|
7725
7779
|
return this.#definitions.searchParametersByUrl[url];
|
|
7726
7780
|
};
|
|
7727
|
-
|
|
7781
|
+
_GetSearchParams = async () => {
|
|
7728
7782
|
await this.GetDefinitions();
|
|
7729
7783
|
return this.#definitions.searchParametersByUrl;
|
|
7730
7784
|
};
|
|
7731
|
-
|
|
7785
|
+
GetType = async (typeName) => {
|
|
7786
|
+
await this.GetDefinitions();
|
|
7787
|
+
return await this.searchParameterManager.GetType(typeName);
|
|
7788
|
+
};
|
|
7789
|
+
GetResource = async (resourceType) => {
|
|
7732
7790
|
await this.GetDefinitions();
|
|
7733
|
-
return
|
|
7791
|
+
return await this.searchParameterManager.GetResource(resourceType);
|
|
7734
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
|
+
*/
|
|
7735
7824
|
// ------------------------------------------------------------------------------------------------------------------
|
|
7736
7825
|
// Remove ( ) when either are present
|
|
7737
7826
|
#RemoveOuterParentheses = (input) => {
|
|
@@ -7854,7 +7943,7 @@ class ResourceHelper {
|
|
|
7854
7943
|
};
|
|
7855
7944
|
};
|
|
7856
7945
|
_LoadSearchParameters = async () => {
|
|
7857
|
-
for (const [key, val] of Object.entries(await this.
|
|
7946
|
+
for (const [key, val] of Object.entries(await this._GetSearchParams())) {
|
|
7858
7947
|
const { id, url, code, base, type, expression, component, target } = val;
|
|
7859
7948
|
for (let i = 0; i < base.length; i++) {
|
|
7860
7949
|
const resourceName = base[i];
|
|
@@ -7885,10 +7974,10 @@ class ResourceHelper {
|
|
|
7885
7974
|
SP_TARGET,
|
|
7886
7975
|
expressions,
|
|
7887
7976
|
original_expressions,
|
|
7888
|
-
SP_DEFINITION: await this.
|
|
7977
|
+
SP_DEFINITION: await this._GetSearchParam(SP_URL)
|
|
7889
7978
|
};
|
|
7890
7979
|
for (let i2 = 0; i2 < record.expressions.length; i2++) {
|
|
7891
|
-
const rf = await this.
|
|
7980
|
+
const rf = await this._GetResourceField(resourceName, record.expressions[i2].path);
|
|
7892
7981
|
if (rf) {
|
|
7893
7982
|
expressions[i2].RES_FIELD = rf;
|
|
7894
7983
|
}
|
|
@@ -7899,7 +7988,7 @@ class ResourceHelper {
|
|
|
7899
7988
|
const retVal = this.ProcessExpressions("", c.expression);
|
|
7900
7989
|
c.expressions = retVal.expressions;
|
|
7901
7990
|
c.original_expressions = retVal.original_expressions;
|
|
7902
|
-
const def = await this.
|
|
7991
|
+
const def = await this._GetSearchParam(c.definition);
|
|
7903
7992
|
if (def && def.type) {
|
|
7904
7993
|
c.type = def.type;
|
|
7905
7994
|
}
|
|
@@ -7911,21 +8000,24 @@ class ResourceHelper {
|
|
|
7911
8000
|
};
|
|
7912
8001
|
GetSearchParamFromResourceTypeUrl = async (resourceType, url) => {
|
|
7913
8002
|
await this.GetDefinitions();
|
|
7914
|
-
const
|
|
8003
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8004
|
+
const filterByNameAndUrl = rt.params.filter((rt2) => rt2.SP_URL.localeCompare(url) === 0);
|
|
7915
8005
|
if (filterByNameAndUrl.length > 0) {
|
|
7916
8006
|
return filterByNameAndUrl[0];
|
|
7917
8007
|
}
|
|
7918
8008
|
};
|
|
7919
8009
|
GetSearchParamFromResourceType = async (resourceType, name) => {
|
|
7920
8010
|
await this.GetDefinitions();
|
|
7921
|
-
const
|
|
8011
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8012
|
+
const filterByName = rt.params.filter((rt2) => rt2.SP_NAME.localeCompare(name) === 0);
|
|
7922
8013
|
if (filterByName.length > 0) {
|
|
7923
8014
|
return filterByName[0];
|
|
7924
8015
|
}
|
|
7925
8016
|
};
|
|
7926
8017
|
GetSearchParamsFromResourceType = async (resourceType) => {
|
|
7927
8018
|
await this.GetDefinitions();
|
|
7928
|
-
|
|
8019
|
+
const rt = await this.searchParameterManager?.GetSearchParamFromResourceType(resourceType);
|
|
8020
|
+
return rt.params;
|
|
7929
8021
|
};
|
|
7930
8022
|
}
|
|
7931
8023
|
var ansiStyles = { exports: {} };
|