@nsshunt/stsfhirpg 1.2.28 → 1.2.30
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/index.cjs +1266 -803
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1266 -803
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/types/fhir-database/dbsearchindexreference.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhiraccesslayer.d.ts +2 -1
- package/types/fhir-database/pg/pgfhiraccesslayer.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhircombo.d.ts +3 -1
- package/types/fhir-database/pg/pgfhircombo.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirdate.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirdate.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirdbbase.d.ts +14 -0
- package/types/fhir-database/pg/pgfhirdbbase.d.ts.map +1 -0
- package/types/fhir-database/pg/pgfhirdbparamtypebase.d.ts +11 -0
- package/types/fhir-database/pg/pgfhirdbparamtypebase.d.ts.map +1 -0
- package/types/fhir-database/pg/pgfhirnumber.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirnumber.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirquantity.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirquantity.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirresource.d.ts +9 -10
- package/types/fhir-database/pg/pgfhirresource.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirresourcelink.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirresourcelink.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirresourceversion.d.ts +5 -6
- package/types/fhir-database/pg/pgfhirresourceversion.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirstring.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirstring.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhirtoken.d.ts +3 -1
- package/types/fhir-database/pg/pgfhirtoken.d.ts.map +1 -1
- package/types/fhir-database/pg/pgfhiruri.d.ts +3 -1
- package/types/fhir-database/pg/pgfhiruri.d.ts.map +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
12
|
key = keys[i];
|
|
@@ -3272,7 +3272,8 @@ var HashUtils = class HashUtils {
|
|
|
3272
3272
|
return input.trim().replace(/\s+/g, " ").toLowerCase();
|
|
3273
3273
|
};
|
|
3274
3274
|
InitHash = async () => {
|
|
3275
|
-
|
|
3275
|
+
const api = await e();
|
|
3276
|
+
this.h64 = api.h64;
|
|
3276
3277
|
};
|
|
3277
3278
|
xxhash64Signed(input) {
|
|
3278
3279
|
if (this.h64) return BigInt.asIntN(64, this.h64(input, this.HASH_SEED));
|
|
@@ -4813,19 +4814,46 @@ var PGPoolManager = class extends tiny_emitter.TinyEmitter {
|
|
|
4813
4814
|
}
|
|
4814
4815
|
};
|
|
4815
4816
|
//#endregion
|
|
4817
|
+
//#region src/fhir-database/pg/pgfhirdbbase.ts
|
|
4818
|
+
var DBSTSFhirDBBase = class {
|
|
4819
|
+
_options;
|
|
4820
|
+
_poolManager;
|
|
4821
|
+
constructor(options) {
|
|
4822
|
+
this._options = options;
|
|
4823
|
+
this._poolManager = options.poolManager;
|
|
4824
|
+
}
|
|
4825
|
+
async withClient(fname, fn) {
|
|
4826
|
+
let client;
|
|
4827
|
+
try {
|
|
4828
|
+
client = await this._poolManager.connectReadWrite();
|
|
4829
|
+
} catch (error) {
|
|
4830
|
+
this._options.logger.error(`${fname}(): DB: Connection Error: [${error}]`);
|
|
4831
|
+
throw error;
|
|
4832
|
+
}
|
|
4833
|
+
try {
|
|
4834
|
+
return await fn(client);
|
|
4835
|
+
} catch (error) {
|
|
4836
|
+
this._options.logger.error(`${fname}(): DB: Query Error: [${error}]`);
|
|
4837
|
+
throw error;
|
|
4838
|
+
} finally {
|
|
4839
|
+
client.release();
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4843
|
+
//#endregion
|
|
4816
4844
|
//#region src/fhir-database/pg/pgfhirresource.ts
|
|
4817
|
-
var DBSTSResource = class {
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
this.#poolManager = poolManager;
|
|
4845
|
+
var DBSTSResource = class extends DBSTSFhirDBBase {
|
|
4846
|
+
constructor(options) {
|
|
4847
|
+
super(options);
|
|
4821
4848
|
}
|
|
4822
4849
|
async InsertResourceEx(client, data) {
|
|
4823
4850
|
try {
|
|
4824
|
-
await client.query(`
|
|
4851
|
+
return (await client.query(`
|
|
4825
4852
|
INSERT INTO stsresfhir (
|
|
4826
4853
|
PID, PARTITION_ID, PARTITION_DATE, RES_ID, RES_TYPE,
|
|
4827
4854
|
RES_VER, RES_VERSION, RES_PUBLISHED, RES_UPDATED
|
|
4828
4855
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
4856
|
+
RETURNING RES_VER
|
|
4829
4857
|
`, [
|
|
4830
4858
|
data.PID,
|
|
4831
4859
|
data.PARTITION_ID,
|
|
@@ -4836,146 +4864,90 @@ var DBSTSResource = class {
|
|
|
4836
4864
|
data.RES_VERSION,
|
|
4837
4865
|
BigInt(data.RES_PUBLISHED),
|
|
4838
4866
|
BigInt(data.RES_UPDATED)
|
|
4839
|
-
]);
|
|
4867
|
+
])).rows[0]?.res_ver;
|
|
4840
4868
|
} catch (error) {
|
|
4841
|
-
|
|
4869
|
+
this._options.logger.error(`DBSTSResource:InsertResource(): Query Error: [${error}]`);
|
|
4842
4870
|
throw error;
|
|
4843
4871
|
}
|
|
4844
4872
|
}
|
|
4845
4873
|
async InsertResource(data) {
|
|
4846
|
-
|
|
4847
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
4848
|
-
try {
|
|
4849
|
-
await this.InsertResourceEx(client, data);
|
|
4850
|
-
} catch (error) {
|
|
4851
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:InsertResource(): Query Error: [${error}]`);
|
|
4852
|
-
} finally {
|
|
4853
|
-
client.release();
|
|
4854
|
-
}
|
|
4855
|
-
} catch (error) {
|
|
4856
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:InsertResource(): Connection Error: [${error}]`);
|
|
4857
|
-
}
|
|
4874
|
+
return this.withClient("InsertResource", ((client) => this.InsertResourceEx(client, data)));
|
|
4858
4875
|
}
|
|
4859
4876
|
async UpdateResourceRecordEx(client, data) {
|
|
4860
4877
|
try {
|
|
4861
|
-
|
|
4878
|
+
return (await client.query(`
|
|
4862
4879
|
UPDATE stsresfhir SET
|
|
4863
4880
|
RES_VER = RES_VER + 1,
|
|
4864
4881
|
RES_UPDATED = $1,
|
|
4865
4882
|
RES_DELETED_AT = NULL
|
|
4866
4883
|
WHERE RES_ID = $2 AND RES_TYPE = $3 AND RES_VER = $4
|
|
4884
|
+
RETURNING RES_VER
|
|
4867
4885
|
`, [
|
|
4868
4886
|
BigInt(data.RES_UPDATED),
|
|
4869
4887
|
data.RES_ID,
|
|
4870
4888
|
data.RES_TYPE,
|
|
4871
4889
|
data.RES_VER
|
|
4872
|
-
]);
|
|
4873
|
-
return res.rowCount ? res.rowCount > 0 : false;
|
|
4890
|
+
])).rows[0]?.res_ver;
|
|
4874
4891
|
} catch (error) {
|
|
4875
|
-
|
|
4892
|
+
this._options.logger.error(`DBSTSResource:UpdateResourceRecordEx(): Query Error: [${error}]`);
|
|
4876
4893
|
throw error;
|
|
4877
4894
|
}
|
|
4878
4895
|
}
|
|
4879
4896
|
async UpdateResourceRecord(data) {
|
|
4880
|
-
|
|
4881
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
4882
|
-
try {
|
|
4883
|
-
return await this.UpdateResourceRecordEx(client, data);
|
|
4884
|
-
} catch (error) {
|
|
4885
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:UpdateResourceRecord-1(): Query Error: [${error}]`);
|
|
4886
|
-
} finally {
|
|
4887
|
-
client.release();
|
|
4888
|
-
}
|
|
4889
|
-
} catch (error) {
|
|
4890
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:UpdateResourceRecord-2(): Connection Error: [${error}]`);
|
|
4891
|
-
}
|
|
4897
|
+
return this.withClient("UpdateResourceRecord", ((client) => this.UpdateResourceRecordEx(client, data)));
|
|
4892
4898
|
}
|
|
4893
4899
|
async DeleteResourceRecordEx(client, data) {
|
|
4894
4900
|
try {
|
|
4895
|
-
|
|
4901
|
+
return (await client.query(`
|
|
4896
4902
|
UPDATE stsresfhir SET
|
|
4897
4903
|
RES_DELETED_AT = $1,
|
|
4898
4904
|
RES_VER = RES_VER + 1,
|
|
4899
4905
|
RES_UPDATED = $2
|
|
4900
4906
|
WHERE RES_ID = $3 AND RES_TYPE = $4 AND RES_VER = $5
|
|
4907
|
+
RETURNING RES_VER
|
|
4901
4908
|
`, [
|
|
4902
4909
|
BigInt(data.RES_DELETED_AT),
|
|
4903
4910
|
BigInt(data.RES_UPDATED),
|
|
4904
4911
|
data.RES_ID,
|
|
4905
4912
|
data.RES_TYPE,
|
|
4906
4913
|
data.RES_VER
|
|
4907
|
-
]);
|
|
4908
|
-
return res.rowCount ? res.rowCount > 0 : false;
|
|
4914
|
+
])).rows[0]?.res_ver;
|
|
4909
4915
|
} catch (error) {
|
|
4910
|
-
|
|
4916
|
+
this._options.logger.error(`DBSTSResource:DeleteResourceRecord(): Query Error: [${error}]`);
|
|
4911
4917
|
throw error;
|
|
4912
4918
|
}
|
|
4913
4919
|
}
|
|
4914
4920
|
async DeleteResourceRecord(data) {
|
|
4915
|
-
|
|
4916
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
4917
|
-
try {
|
|
4918
|
-
return await this.DeleteResourceRecordEx(client, data);
|
|
4919
|
-
} catch (error) {
|
|
4920
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:DeleteResourceRecord(): Query Error: [${error}]`);
|
|
4921
|
-
} finally {
|
|
4922
|
-
client.release();
|
|
4923
|
-
}
|
|
4924
|
-
} catch (error) {
|
|
4925
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:DeleteResourceRecord(): Connection Error: [${error}]`);
|
|
4926
|
-
}
|
|
4921
|
+
return this.withClient("DeleteResourceRecord", ((client) => this.DeleteResourceRecordEx(client, data)));
|
|
4927
4922
|
}
|
|
4928
4923
|
async ReadResourceRecordEx(client, PID) {
|
|
4929
4924
|
try {
|
|
4930
4925
|
return (await client.query(`SELECT * FROM stsresfhir WHERE PID = $1`, [PID])).rows[0];
|
|
4931
4926
|
} catch (error) {
|
|
4932
|
-
|
|
4927
|
+
this._options.logger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
4933
4928
|
throw error;
|
|
4934
4929
|
}
|
|
4935
4930
|
}
|
|
4936
4931
|
async ReadResourceRecord(PID) {
|
|
4937
|
-
|
|
4938
|
-
const client = await this.#poolManager.connectReadOnly();
|
|
4939
|
-
try {
|
|
4940
|
-
return await this.ReadResourceRecordEx(client, PID);
|
|
4941
|
-
} catch (error) {
|
|
4942
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
4943
|
-
} finally {
|
|
4944
|
-
client.release();
|
|
4945
|
-
}
|
|
4946
|
-
} catch (error) {
|
|
4947
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Connection Error: [${error}]`);
|
|
4948
|
-
}
|
|
4932
|
+
return this.withClient("ReadResourceRecord", ((client) => this.ReadResourceRecordEx(client, PID)));
|
|
4949
4933
|
}
|
|
4950
4934
|
async ReadAllResourceRecordsEx(client) {
|
|
4951
4935
|
try {
|
|
4952
4936
|
return (await client.query(`SELECT * FROM stsresfhir`)).rows;
|
|
4953
4937
|
} catch (error) {
|
|
4954
|
-
|
|
4938
|
+
this._options.logger.error(`DBSTSResource:ReadAllResourceRecords(): Query Error: [${error}]`);
|
|
4955
4939
|
throw error;
|
|
4956
4940
|
}
|
|
4957
4941
|
}
|
|
4958
4942
|
async ReadAllResourceRecords() {
|
|
4959
|
-
|
|
4960
|
-
const client = await this.#poolManager.connectReadOnly();
|
|
4961
|
-
try {
|
|
4962
|
-
return await this.ReadAllResourceRecordsEx(client);
|
|
4963
|
-
} catch (error) {
|
|
4964
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadAllResourceRecords(): Query Error: [${error}]`);
|
|
4965
|
-
} finally {
|
|
4966
|
-
client.release();
|
|
4967
|
-
}
|
|
4968
|
-
} catch (error) {
|
|
4969
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadAllResourceRecords(): Connection Error: [${error}]`);
|
|
4970
|
-
}
|
|
4943
|
+
return this.withClient("ReadAllResourceRecords", ((client) => this.ReadAllResourceRecordsEx(client)));
|
|
4971
4944
|
}
|
|
4972
4945
|
};
|
|
4973
4946
|
//#endregion
|
|
4974
4947
|
//#region src/fhir-database/pg/pgfhirresourceversion.ts
|
|
4975
|
-
var DBSTSResourceVersion = class {
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
this.#poolManager = poolManager;
|
|
4948
|
+
var DBSTSResourceVersion = class extends DBSTSFhirDBBase {
|
|
4949
|
+
constructor(options) {
|
|
4950
|
+
super(options);
|
|
4979
4951
|
}
|
|
4980
4952
|
async InsertResourceVersionEx(client, data) {
|
|
4981
4953
|
const values = [
|
|
@@ -4989,86 +4961,67 @@ var DBSTSResourceVersion = class {
|
|
|
4989
4961
|
data.RES
|
|
4990
4962
|
];
|
|
4991
4963
|
try {
|
|
4992
|
-
await client.query(`
|
|
4964
|
+
return (await client.query(`
|
|
4993
4965
|
INSERT INTO stsresfhirver (
|
|
4994
4966
|
PID, PARTITION_ID, PARTITION_DATE,
|
|
4995
4967
|
RES_ID, RES_TYPE, RES_VER, OPERATION, RES
|
|
4996
4968
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
4997
|
-
|
|
4969
|
+
RETURNING RES_VER
|
|
4970
|
+
`, values)).rows[0]?.res_ver;
|
|
4998
4971
|
} catch (error) {
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
4972
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): Query Error: [${error}]`);
|
|
4973
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values PID: [${values[0]}]`);
|
|
4974
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values PARTITION_ID: [${values[1]}]`);
|
|
4975
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values PARTITION_DATE: [${values[2]}]`);
|
|
4976
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values RES_ID: [${values[3]}]`);
|
|
4977
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values RES_TYPE: [${values[4]}]`);
|
|
4978
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values RES_VER: [${values[5]}]`);
|
|
4979
|
+
this._options.logger.error(`DBSTSResourceVersion:InsertResourceVersion(): --> Values OPERATION: [${values[6]}]`);
|
|
5007
4980
|
throw error;
|
|
5008
4981
|
}
|
|
5009
4982
|
}
|
|
5010
4983
|
async InsertResourceVersion(data) {
|
|
5011
|
-
|
|
5012
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
5013
|
-
try {
|
|
5014
|
-
await this.InsertResourceVersionEx(client, data);
|
|
5015
|
-
} catch (error) {
|
|
5016
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:InsertResourceVersion(): Query Error: [${error}]`);
|
|
5017
|
-
} finally {
|
|
5018
|
-
client.release();
|
|
5019
|
-
}
|
|
5020
|
-
} catch (error) {
|
|
5021
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:InsertResourceVersion(): Connection Error: [${error}]`);
|
|
5022
|
-
}
|
|
4984
|
+
return this.withClient("InsertResourceVersion", ((client) => this.InsertResourceVersionEx(client, data)));
|
|
5023
4985
|
}
|
|
5024
4986
|
async ReadResourceVersionRecordEx(client, PID, RES_VER) {
|
|
5025
4987
|
try {
|
|
5026
4988
|
return (await client.query(`SELECT * FROM stsresfhirver WHERE PID = $1 AND RES_VER = $2`, [PID, RES_VER])).rows[0];
|
|
5027
4989
|
} catch (error) {
|
|
5028
|
-
|
|
4990
|
+
this._options.logger.error(`DBSTSResourceVersion:ReadResourceVersionRecord(): Query Error: [${error}]`);
|
|
5029
4991
|
throw error;
|
|
5030
4992
|
}
|
|
5031
4993
|
}
|
|
5032
4994
|
async ReadResourceVersionRecord(PID, RES_VER) {
|
|
5033
|
-
|
|
5034
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
5035
|
-
try {
|
|
5036
|
-
return await this.ReadResourceVersionRecordEx(client, PID, RES_VER);
|
|
5037
|
-
} catch (error) {
|
|
5038
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:ReadResourceVersionRecord(): Query Error: [${error}]`);
|
|
5039
|
-
} finally {
|
|
5040
|
-
client.release();
|
|
5041
|
-
}
|
|
5042
|
-
} catch (error) {
|
|
5043
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:ReadResourceVersionRecord(): Connection Error: [${error}]`);
|
|
5044
|
-
}
|
|
4995
|
+
return this.withClient("ReadResourceVersionRecord", ((client) => this.ReadResourceVersionRecordEx(client, PID, RES_VER)));
|
|
5045
4996
|
}
|
|
5046
4997
|
async ReadAllResourceVersionRecordsEx(client) {
|
|
5047
4998
|
try {
|
|
5048
4999
|
return (await client.query(`SELECT * FROM stsresfhirver`)).rows;
|
|
5049
5000
|
} catch (error) {
|
|
5050
|
-
|
|
5001
|
+
this._options.logger.error(`DBSTSResourceVersion:ReadAllResourceVersionRecords(): Query Error: [${error}]`);
|
|
5051
5002
|
throw error;
|
|
5052
5003
|
}
|
|
5053
5004
|
}
|
|
5054
5005
|
async ReadAllResourceVersionRecords() {
|
|
5055
|
-
|
|
5056
|
-
const client = await this.#poolManager.connectReadWrite();
|
|
5057
|
-
try {
|
|
5058
|
-
return await this.ReadAllResourceVersionRecordsEx(client);
|
|
5059
|
-
} catch (error) {
|
|
5060
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:ReadAllResourceVersionRecords(): Query Error: [${error}]`);
|
|
5061
|
-
} finally {
|
|
5062
|
-
client.release();
|
|
5063
|
-
}
|
|
5064
|
-
} catch (error) {
|
|
5065
|
-
_nsshunt_stsutils.defaultLogger.error(`DBSTSResourceVersion:ReadAllResourceVersionRecords(): Connection Error: [${error}]`);
|
|
5066
|
-
}
|
|
5006
|
+
return this.withClient("ReadAllResourceVersionRecords", ((client) => this.ReadAllResourceVersionRecordsEx(client)));
|
|
5067
5007
|
}
|
|
5068
5008
|
};
|
|
5069
5009
|
//#endregion
|
|
5010
|
+
//#region src/fhir-database/pg/pgfhirdbparamtypebase.ts
|
|
5011
|
+
var DBSTSFhirDBParamTypeBase = class {
|
|
5012
|
+
_options;
|
|
5013
|
+
constructor(options) {
|
|
5014
|
+
this._options = options;
|
|
5015
|
+
}
|
|
5016
|
+
replacer = (_, v) => typeof v === "bigint" ? { __bigint__: v.toString() } : v;
|
|
5017
|
+
reviver = (_, v) => v && v.__bigint__ !== void 0 ? BigInt(v.__bigint__) : v;
|
|
5018
|
+
};
|
|
5019
|
+
//#endregion
|
|
5070
5020
|
//#region src/fhir-database/pg/pgfhirresourcelink.ts
|
|
5071
|
-
var DBSTSResourceLink = class {
|
|
5021
|
+
var DBSTSResourceLink = class extends DBSTSFhirDBParamTypeBase {
|
|
5022
|
+
constructor(options) {
|
|
5023
|
+
super(options);
|
|
5024
|
+
}
|
|
5072
5025
|
async InsertResourceLink(client, data) {
|
|
5073
5026
|
try {
|
|
5074
5027
|
await client.query(`
|
|
@@ -5116,327 +5069,852 @@ var DBSTSResourceLink = class {
|
|
|
5116
5069
|
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5117
5070
|
]);
|
|
5118
5071
|
} catch (error) {
|
|
5119
|
-
|
|
5120
|
-
|
|
5072
|
+
const message = `DBSTSResourceLink:InsertResourceLink(): Query Error: [${error}]`;
|
|
5073
|
+
this._options.logger.error(message);
|
|
5074
|
+
throw new Error(message);
|
|
5121
5075
|
}
|
|
5122
5076
|
}
|
|
5123
5077
|
async ReadResourceLinkByResourceIdRecord(client, RES_ID, RES_TYPE) {
|
|
5124
5078
|
try {
|
|
5125
5079
|
return (await client.query(`SELECT * FROM stsresfhirlink WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5126
5080
|
} catch (error) {
|
|
5127
|
-
|
|
5128
|
-
|
|
5081
|
+
const message = `DBSTSResourceLink:ReadResourceLinkByResourceIdRecord(): Query Error: [${error}]`;
|
|
5082
|
+
this._options.logger.error(message);
|
|
5083
|
+
throw new Error(message);
|
|
5129
5084
|
}
|
|
5130
5085
|
}
|
|
5131
5086
|
async ReadResourceLinkByPIDRecord(client, PID) {
|
|
5132
5087
|
try {
|
|
5133
5088
|
return (await client.query(`SELECT * FROM stsresfhirlink WHERE PID = $1 LIMIT 1`, [PID])).rows[0];
|
|
5134
5089
|
} catch (error) {
|
|
5135
|
-
|
|
5136
|
-
|
|
5090
|
+
const message = `DBSTSResourceLink:ReadResourceLinkByPIDRecord(): Query Error: [${error}]`;
|
|
5091
|
+
this._options.logger.error(message);
|
|
5092
|
+
throw new Error(message);
|
|
5137
5093
|
}
|
|
5138
5094
|
}
|
|
5139
5095
|
async ReadAllResourceLinkRecords(client) {
|
|
5140
5096
|
try {
|
|
5141
5097
|
return (await client.query(`SELECT * FROM stsresfhirlink`)).rows;
|
|
5142
5098
|
} catch (error) {
|
|
5143
|
-
|
|
5144
|
-
|
|
5099
|
+
const message = `DBSTSResourceLink:ReadAllResourceLinkRecords(): Query Error: [${error}]`;
|
|
5100
|
+
this._options.logger.error(message);
|
|
5101
|
+
throw new Error(message);
|
|
5145
5102
|
}
|
|
5146
5103
|
}
|
|
5147
5104
|
async DeleteResourceLinkRecord(client, data) {
|
|
5148
5105
|
try {
|
|
5149
5106
|
await client.query(`DELETE FROM stsresfhirlink WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5150
5107
|
} catch (error) {
|
|
5151
|
-
|
|
5152
|
-
|
|
5108
|
+
const message = `DBSTSResourceLink:DeleteResourceLinkRecord(): Query Error: [${error}]`;
|
|
5109
|
+
this._options.logger.error(message);
|
|
5110
|
+
throw new Error(message);
|
|
5153
5111
|
}
|
|
5154
5112
|
}
|
|
5155
5113
|
};
|
|
5156
5114
|
//#endregion
|
|
5157
5115
|
//#region src/fhir-database/pg/pgfhirstring.ts
|
|
5158
|
-
var DBSTSString = class {
|
|
5116
|
+
var DBSTSString = class extends DBSTSFhirDBParamTypeBase {
|
|
5117
|
+
constructor(options) {
|
|
5118
|
+
super(options);
|
|
5119
|
+
}
|
|
5120
|
+
async InsertRecord(client, data) {
|
|
5121
|
+
try {
|
|
5122
|
+
await client.query(`
|
|
5123
|
+
INSERT INTO stsresfhirstring (
|
|
5124
|
+
PID,
|
|
5125
|
+
PARTITION_ID,
|
|
5126
|
+
PARTITION_DATE,
|
|
5127
|
+
SP_NAME,
|
|
5128
|
+
SP_PARAM_TYPE,
|
|
5129
|
+
RES_ID,
|
|
5130
|
+
RES_TYPE,
|
|
5131
|
+
SP_MISSING,
|
|
5132
|
+
SP_STR,
|
|
5133
|
+
HASH_IDENTITY,
|
|
5134
|
+
HASH_EXACT,
|
|
5135
|
+
SP_VALUE_NORMALIZED,
|
|
5136
|
+
SP_VALUE_EXACT,
|
|
5137
|
+
UPDATED,
|
|
5138
|
+
PATH_FOR_COMP,
|
|
5139
|
+
COMPOSITE,
|
|
5140
|
+
COMPOSITE_HASH_EXACT
|
|
5141
|
+
) VALUES (
|
|
5142
|
+
$1, $2, $3,
|
|
5143
|
+
$4, $5, $6, $7,
|
|
5144
|
+
$8, $9, $10,
|
|
5145
|
+
$11, $12, $13, $14,
|
|
5146
|
+
$15, $16, $17
|
|
5147
|
+
)
|
|
5148
|
+
`, [
|
|
5149
|
+
data.PID,
|
|
5150
|
+
data.PARTITION_ID,
|
|
5151
|
+
data.PARTITION_DATE,
|
|
5152
|
+
data.SP_NAME ?? null,
|
|
5153
|
+
data.SP_PARAM_TYPE,
|
|
5154
|
+
data.RES_ID,
|
|
5155
|
+
data.RES_TYPE ?? null,
|
|
5156
|
+
data.SP_MISSING,
|
|
5157
|
+
data.SP_STR,
|
|
5158
|
+
data.HASH_IDENTITY,
|
|
5159
|
+
data.HASH_EXACT,
|
|
5160
|
+
data.SP_VALUE_NORMALIZED,
|
|
5161
|
+
data.SP_VALUE_EXACT,
|
|
5162
|
+
data.UPDATED,
|
|
5163
|
+
data.PATH_FOR_COMP,
|
|
5164
|
+
data.COMPOSITE,
|
|
5165
|
+
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5166
|
+
]);
|
|
5167
|
+
} catch (error) {
|
|
5168
|
+
const message = `DBSTSString:InsertRecord(): Error: [${error}]`;
|
|
5169
|
+
this._options.logger.error(message);
|
|
5170
|
+
throw new Error(message);
|
|
5171
|
+
}
|
|
5172
|
+
}
|
|
5173
|
+
async ReadByPIDRecord(client, PID) {
|
|
5174
|
+
try {
|
|
5175
|
+
return (await client.query(`SELECT * FROM stsresfhirstring WHERE PID = $1 LIMIT 1`, [PID])).rows[0];
|
|
5176
|
+
} catch (error) {
|
|
5177
|
+
const message = `DBSTSString:ReadByPIDRecord(): Error: [${error}]`;
|
|
5178
|
+
this._options.logger.error(message);
|
|
5179
|
+
throw new Error(message);
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
async ReadAllRecords(client) {
|
|
5183
|
+
try {
|
|
5184
|
+
return (await client.query(`SELECT * FROM stsresfhirstring`)).rows;
|
|
5185
|
+
} catch (error) {
|
|
5186
|
+
const message = `DBSTSString:ReadAllRecords(): Error: [${error}]`;
|
|
5187
|
+
this._options.logger.error(message);
|
|
5188
|
+
throw new Error(message);
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
#FilterResults(data, results) {
|
|
5192
|
+
try {
|
|
5193
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5194
|
+
} catch (error) {
|
|
5195
|
+
const message = `DBSTSString:#FilterResults(): Error: [${error}]`;
|
|
5196
|
+
this._options.logger.error(message);
|
|
5197
|
+
throw new Error(message);
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
async ReadByValueNormalized(client, searchString, parameterName, resourceName) {
|
|
5201
|
+
try {
|
|
5202
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5203
|
+
const norm = normalizeStringParam(searchString);
|
|
5204
|
+
const res = await client.query(`SELECT * FROM stsresfhirstring WHERE HASH_IDENTITY = $1 AND SP_VALUE_NORMALIZED LIKE $2`, [hash, norm]);
|
|
5205
|
+
return this.#FilterResults({
|
|
5206
|
+
SP_NAME: parameterName,
|
|
5207
|
+
RES_TYPE: resourceName
|
|
5208
|
+
}, res.rows);
|
|
5209
|
+
} catch (error) {
|
|
5210
|
+
const message = `DBSTSString:ReadByValueNormalized(): Error: [${error}]`;
|
|
5211
|
+
this._options.logger.error(message);
|
|
5212
|
+
throw new Error(message);
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
async ReadByValueExact(client, data) {
|
|
5216
|
+
try {
|
|
5217
|
+
const res = await client.query(`SELECT * FROM stsresfhirstring WHERE HASH_EXACT = $1`, [BigInt(data.HASH_EXACT)]);
|
|
5218
|
+
return this.#FilterResults(data, res.rows);
|
|
5219
|
+
} catch (error) {
|
|
5220
|
+
const message = `DBSTSString:ReadByValueExact(): Error: [${error}]`;
|
|
5221
|
+
this._options.logger.error(message);
|
|
5222
|
+
throw new Error(message);
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5226
|
+
try {
|
|
5227
|
+
return (await client.query(`SELECT * FROM stsresfhirstring WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5228
|
+
} catch (error) {
|
|
5229
|
+
const message = `DBSTSString:ReadByResID(): Error: [${error}]`;
|
|
5230
|
+
this._options.logger.error(message);
|
|
5231
|
+
throw new Error(message);
|
|
5232
|
+
}
|
|
5233
|
+
}
|
|
5234
|
+
async DeleteRecord(client, data) {
|
|
5235
|
+
try {
|
|
5236
|
+
await client.query(`DELETE FROM stsresfhirstring WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5237
|
+
} catch (error) {
|
|
5238
|
+
const message = `DBSTSString:DeleteRecord(): Error: [${error}]`;
|
|
5239
|
+
this._options.logger.error(message);
|
|
5240
|
+
throw new Error(message);
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
};
|
|
5244
|
+
//#endregion
|
|
5245
|
+
//#region src/fhir-database/pg/pgfhirtoken.ts
|
|
5246
|
+
var DBSTSToken = class extends DBSTSFhirDBParamTypeBase {
|
|
5247
|
+
constructor(options) {
|
|
5248
|
+
super(options);
|
|
5249
|
+
}
|
|
5159
5250
|
async InsertRecord(client, data) {
|
|
5160
|
-
|
|
5161
|
-
|
|
5251
|
+
try {
|
|
5252
|
+
const text = `
|
|
5253
|
+
INSERT INTO stsresfhirtoken (
|
|
5162
5254
|
PID,
|
|
5163
5255
|
PARTITION_ID,
|
|
5164
|
-
PARTITION_DATE,
|
|
5256
|
+
PARTITION_DATE,
|
|
5165
5257
|
SP_NAME,
|
|
5166
5258
|
SP_PARAM_TYPE,
|
|
5167
|
-
RES_ID,
|
|
5168
|
-
RES_TYPE,
|
|
5169
|
-
SP_MISSING,
|
|
5170
5259
|
SP_STR,
|
|
5260
|
+
RES_ID,
|
|
5261
|
+
RES_TYPE,
|
|
5262
|
+
UPDATED,
|
|
5263
|
+
SP_MISSING,
|
|
5171
5264
|
HASH_IDENTITY,
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5265
|
+
SP_SYSTEM,
|
|
5266
|
+
SP_TOKEN_TYPE,
|
|
5267
|
+
SP_VALUE,
|
|
5268
|
+
HASH_VALUE,
|
|
5269
|
+
HASH_SYS,
|
|
5270
|
+
HASH_SYS_AND_VALUE,
|
|
5176
5271
|
PATH_FOR_COMP,
|
|
5177
5272
|
COMPOSITE,
|
|
5178
5273
|
COMPOSITE_HASH_EXACT
|
|
5179
5274
|
) VALUES (
|
|
5180
|
-
$1, $2, $3,
|
|
5181
|
-
$
|
|
5182
|
-
$
|
|
5183
|
-
$
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5275
|
+
$1, $2, $3, $4, $5, $6,
|
|
5276
|
+
$7, $8, $9, $10, $11, $12,
|
|
5277
|
+
$13, $14, $15, $16, $17,
|
|
5278
|
+
$18, $19, $20
|
|
5279
|
+
)`;
|
|
5280
|
+
const values = [
|
|
5281
|
+
data.PID,
|
|
5282
|
+
data.PARTITION_ID ?? 0,
|
|
5283
|
+
data.PARTITION_DATE ?? 0,
|
|
5284
|
+
data.SP_NAME,
|
|
5285
|
+
data.SP_PARAM_TYPE,
|
|
5286
|
+
data.SP_STR,
|
|
5287
|
+
data.RES_ID,
|
|
5288
|
+
data.RES_TYPE,
|
|
5289
|
+
BigInt(data.UPDATED),
|
|
5290
|
+
data.SP_MISSING,
|
|
5291
|
+
BigInt(data.HASH_IDENTITY),
|
|
5292
|
+
data.SP_SYSTEM,
|
|
5293
|
+
data.SP_TOKEN_TYPE,
|
|
5294
|
+
data.SP_VALUE,
|
|
5295
|
+
data.HASH_VALUE,
|
|
5296
|
+
data.HASH_SYS,
|
|
5297
|
+
data.HASH_SYS_AND_VALUE,
|
|
5298
|
+
data.PATH_FOR_COMP,
|
|
5299
|
+
data.COMPOSITE,
|
|
5300
|
+
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5301
|
+
];
|
|
5302
|
+
await client.query(text, values);
|
|
5303
|
+
} catch (error) {
|
|
5304
|
+
const message = `DBSTSToken:InsertRecord(): Error: [${error}]`;
|
|
5305
|
+
this._options.logger.error(message);
|
|
5306
|
+
throw new Error(message);
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5309
|
+
async DeleteRecord(client, data) {
|
|
5310
|
+
try {
|
|
5311
|
+
await client.query(`DELETE FROM stsresfhirtoken WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5312
|
+
} catch (error) {
|
|
5313
|
+
const message = `DBSTSToken:DeleteRecord(): Error: [${error}]`;
|
|
5314
|
+
this._options.logger.error(message);
|
|
5315
|
+
throw new Error(message);
|
|
5316
|
+
}
|
|
5205
5317
|
}
|
|
5206
5318
|
async ReadByPIDRecord(client, PID) {
|
|
5207
|
-
|
|
5319
|
+
try {
|
|
5320
|
+
return (await client.query(`SELECT * FROM stsresfhirtoken WHERE PID = $1`, [PID])).rows[0];
|
|
5321
|
+
} catch (error) {
|
|
5322
|
+
const message = `DBSTSToken:ReadByPIDRecord(): Error: [${error}]`;
|
|
5323
|
+
this._options.logger.error(message);
|
|
5324
|
+
throw new Error(message);
|
|
5325
|
+
}
|
|
5208
5326
|
}
|
|
5209
5327
|
async ReadAllRecords(client) {
|
|
5210
|
-
|
|
5328
|
+
try {
|
|
5329
|
+
return (await client.query(`SELECT * FROM stsresfhirtoken`)).rows;
|
|
5330
|
+
} catch (error) {
|
|
5331
|
+
const message = `DBSTSToken:ReadAllRecords(): Error: [${error}]`;
|
|
5332
|
+
this._options.logger.error(message);
|
|
5333
|
+
throw new Error(message);
|
|
5334
|
+
}
|
|
5211
5335
|
}
|
|
5212
|
-
|
|
5213
|
-
|
|
5336
|
+
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5337
|
+
try {
|
|
5338
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5339
|
+
const res = await client.query(`SELECT * FROM stsresfhirtoken WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5340
|
+
return this.#filterResults({
|
|
5341
|
+
SP_NAME: parameterName,
|
|
5342
|
+
RES_TYPE: resourceName
|
|
5343
|
+
}, res.rows);
|
|
5344
|
+
} catch (error) {
|
|
5345
|
+
const message = `DBSTSToken:ReadByIdentity(): Error: [${error}]`;
|
|
5346
|
+
this._options.logger.error(message);
|
|
5347
|
+
throw new Error(message);
|
|
5348
|
+
}
|
|
5214
5349
|
}
|
|
5215
|
-
async
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5350
|
+
async ReadByValue(client, searchValue, parameterName, resourceName) {
|
|
5351
|
+
try {
|
|
5352
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${searchValue}`, true);
|
|
5353
|
+
const res = await client.query(`SELECT * FROM stsresfhirtoken WHERE HASH_VALUE = $1`, [hash]);
|
|
5354
|
+
return this.#filterResults({
|
|
5355
|
+
SP_NAME: parameterName,
|
|
5356
|
+
RES_TYPE: resourceName
|
|
5357
|
+
}, res.rows);
|
|
5358
|
+
} catch (error) {
|
|
5359
|
+
const message = `DBSTSToken:ReadByValue(): Error: [${error}]`;
|
|
5360
|
+
this._options.logger.error(message);
|
|
5361
|
+
throw new Error(message);
|
|
5362
|
+
}
|
|
5223
5363
|
}
|
|
5224
|
-
async
|
|
5225
|
-
|
|
5226
|
-
|
|
5364
|
+
async ReadBySystem(client, searchSystem, parameterName, resourceName) {
|
|
5365
|
+
try {
|
|
5366
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${searchSystem}`, true);
|
|
5367
|
+
const res = await client.query(`SELECT * FROM stsresfhirtoken WHERE HASH_SYS = $1`, [hash]);
|
|
5368
|
+
return this.#filterResults({
|
|
5369
|
+
SP_NAME: parameterName,
|
|
5370
|
+
RES_TYPE: resourceName
|
|
5371
|
+
}, res.rows);
|
|
5372
|
+
} catch (error) {
|
|
5373
|
+
const message = `DBSTSToken:ReadBySystem(): Error: [${error}]`;
|
|
5374
|
+
this._options.logger.error(message);
|
|
5375
|
+
throw new Error(message);
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5378
|
+
async ReadBySystemAndValue(client, searchSystem, searchValue, parameterName, resourceName) {
|
|
5379
|
+
try {
|
|
5380
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${searchSystem}|${searchValue}`, true);
|
|
5381
|
+
const res = await client.query(`SELECT * FROM stsresfhirtoken WHERE HASH_SYS_AND_VALUE = $1`, [hash]);
|
|
5382
|
+
return this.#filterResults({
|
|
5383
|
+
SP_NAME: parameterName,
|
|
5384
|
+
RES_TYPE: resourceName
|
|
5385
|
+
}, res.rows);
|
|
5386
|
+
} catch (error) {
|
|
5387
|
+
const message = `DBSTSToken:ReadBySystemAndValue(): Error: [${error}]`;
|
|
5388
|
+
this._options.logger.error(message);
|
|
5389
|
+
throw new Error(message);
|
|
5390
|
+
}
|
|
5227
5391
|
}
|
|
5228
5392
|
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5229
|
-
|
|
5393
|
+
try {
|
|
5394
|
+
return (await client.query(`SELECT * FROM stsresfhirtoken WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5395
|
+
} catch (error) {
|
|
5396
|
+
const message = `DBSTSToken:ReadByResID(): Error: [${error}]`;
|
|
5397
|
+
this._options.logger.error(message);
|
|
5398
|
+
throw new Error(message);
|
|
5399
|
+
}
|
|
5230
5400
|
}
|
|
5231
|
-
|
|
5232
|
-
|
|
5401
|
+
#filterResults(data, results) {
|
|
5402
|
+
try {
|
|
5403
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5404
|
+
} catch (error) {
|
|
5405
|
+
const message = `DBSTSToken:#filterResults(): Error: [${error}]`;
|
|
5406
|
+
this._options.logger.error(message);
|
|
5407
|
+
throw new Error(message);
|
|
5408
|
+
}
|
|
5233
5409
|
}
|
|
5234
5410
|
};
|
|
5235
5411
|
//#endregion
|
|
5236
|
-
//#region src/fhir-database/pg/
|
|
5237
|
-
var
|
|
5412
|
+
//#region src/fhir-database/pg/pgfhirquantity.ts
|
|
5413
|
+
var DBSTSQuantity = class extends DBSTSFhirDBParamTypeBase {
|
|
5414
|
+
constructor(options) {
|
|
5415
|
+
super(options);
|
|
5416
|
+
}
|
|
5238
5417
|
async InsertRecord(client, data) {
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5418
|
+
try {
|
|
5419
|
+
const text = `
|
|
5420
|
+
INSERT INTO stsresfhirquantity (
|
|
5421
|
+
PID,
|
|
5422
|
+
PARTITION_ID,
|
|
5423
|
+
PARTITION_DATE,
|
|
5424
|
+
SP_NAME,
|
|
5425
|
+
SP_PARAM_TYPE,
|
|
5426
|
+
SP_STR,
|
|
5427
|
+
RES_ID,
|
|
5428
|
+
RES_TYPE,
|
|
5429
|
+
UPDATED,
|
|
5430
|
+
SP_MISSING,
|
|
5431
|
+
HASH_IDENTITY,
|
|
5432
|
+
SP_SYSTEM,
|
|
5433
|
+
SP_VALUE,
|
|
5434
|
+
SP_UNITS,
|
|
5435
|
+
HASH_IDENTITY_AND_UNITS,
|
|
5436
|
+
HASH_IDENTITY_SYS_UNITS,
|
|
5437
|
+
PATH_FOR_COMP,
|
|
5438
|
+
COMPOSITE,
|
|
5439
|
+
COMPOSITE_HASH_EXACT
|
|
5440
|
+
) VALUES (
|
|
5441
|
+
$1, $2, $3, $4, $5, $6,
|
|
5442
|
+
$7, $8, $9, $10, $11, $12,
|
|
5443
|
+
$13, $14, $15, $16,
|
|
5444
|
+
$17, $18, $19
|
|
5445
|
+
)`;
|
|
5446
|
+
const values = [
|
|
5447
|
+
data.PID,
|
|
5448
|
+
data.PARTITION_ID,
|
|
5449
|
+
data.PARTITION_DATE,
|
|
5450
|
+
data.SP_NAME,
|
|
5451
|
+
data.SP_PARAM_TYPE,
|
|
5452
|
+
data.SP_STR,
|
|
5453
|
+
data.RES_ID,
|
|
5454
|
+
data.RES_TYPE,
|
|
5455
|
+
BigInt(data.UPDATED),
|
|
5456
|
+
data.SP_MISSING,
|
|
5457
|
+
BigInt(data.HASH_IDENTITY),
|
|
5458
|
+
data.SP_SYSTEM,
|
|
5459
|
+
data.SP_VALUE,
|
|
5460
|
+
data.SP_UNITS,
|
|
5461
|
+
data.HASH_IDENTITY_AND_UNITS,
|
|
5462
|
+
data.HASH_IDENTITY_SYS_UNITS,
|
|
5463
|
+
data.PATH_FOR_COMP,
|
|
5464
|
+
data.COMPOSITE,
|
|
5465
|
+
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5466
|
+
];
|
|
5467
|
+
await client.query(text, values);
|
|
5468
|
+
} catch (error) {
|
|
5469
|
+
const message = `DBSTSQuantity:InsertRecord(): Error: [${error}]`;
|
|
5470
|
+
this._options.logger.error(message);
|
|
5471
|
+
throw new Error(message);
|
|
5472
|
+
}
|
|
5290
5473
|
}
|
|
5291
5474
|
async DeleteRecord(client, data) {
|
|
5292
|
-
|
|
5475
|
+
try {
|
|
5476
|
+
await client.query(`DELETE FROM stsresfhirquantity WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5477
|
+
} catch (error) {
|
|
5478
|
+
const message = `DBSTSQuantity:DeleteRecord(): Error: [${error}]`;
|
|
5479
|
+
this._options.logger.error(message);
|
|
5480
|
+
throw new Error(message);
|
|
5481
|
+
}
|
|
5293
5482
|
}
|
|
5294
5483
|
async ReadByPIDRecord(client, PID) {
|
|
5295
|
-
|
|
5484
|
+
try {
|
|
5485
|
+
return (await client.query(`SELECT * FROM stsresfhirquantity WHERE PID = $1`, [PID])).rows[0];
|
|
5486
|
+
} catch (error) {
|
|
5487
|
+
const message = `DBSTSQuantity:ReadByPIDRecord(): Error: [${error}]`;
|
|
5488
|
+
this._options.logger.error(message);
|
|
5489
|
+
throw new Error(message);
|
|
5490
|
+
}
|
|
5296
5491
|
}
|
|
5297
5492
|
async ReadAllRecords(client) {
|
|
5298
|
-
|
|
5493
|
+
try {
|
|
5494
|
+
return (await client.query(`SELECT * FROM stsresfhirquantity`)).rows;
|
|
5495
|
+
} catch (error) {
|
|
5496
|
+
const message = `DBSTSQuantity:ReadAllRecords(): Error: [${error}]`;
|
|
5497
|
+
this._options.logger.error(message);
|
|
5498
|
+
throw new Error(message);
|
|
5499
|
+
}
|
|
5299
5500
|
}
|
|
5300
5501
|
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5502
|
+
try {
|
|
5503
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5504
|
+
const res = await client.query(`SELECT * FROM stsresfhirquantity WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5505
|
+
return this.#filterResults({
|
|
5506
|
+
SP_NAME: parameterName,
|
|
5507
|
+
RES_TYPE: resourceName
|
|
5508
|
+
}, res.rows);
|
|
5509
|
+
} catch (error) {
|
|
5510
|
+
const message = `DBSTSQuantity:ReadByIdentity(): Error: [${error}]`;
|
|
5511
|
+
this._options.logger.error(message);
|
|
5512
|
+
throw new Error(message);
|
|
5513
|
+
}
|
|
5307
5514
|
}
|
|
5308
|
-
async
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5515
|
+
async ReadByUnits(client, units, searchValue, parameterName, resourceName) {
|
|
5516
|
+
try {
|
|
5517
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${units}`, true);
|
|
5518
|
+
const res = await client.query(`SELECT * FROM stsresfhirquantity WHERE HASH_IDENTITY_AND_UNITS = $1 AND SP_VALUE = $2`, [hash, searchValue]);
|
|
5519
|
+
return this.#filterResults({
|
|
5520
|
+
SP_NAME: parameterName,
|
|
5521
|
+
RES_TYPE: resourceName
|
|
5522
|
+
}, res.rows);
|
|
5523
|
+
} catch (error) {
|
|
5524
|
+
const message = `DBSTSQuantity:ReadByUnits(): Error: [${error}]`;
|
|
5525
|
+
this._options.logger.error(message);
|
|
5526
|
+
throw new Error(message);
|
|
5527
|
+
}
|
|
5315
5528
|
}
|
|
5316
|
-
async
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5529
|
+
async ReadBySystemAndUnits(client, searchSystem, units, searchValue, parameterName, resourceName) {
|
|
5530
|
+
try {
|
|
5531
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${searchSystem}|${units}`, true);
|
|
5532
|
+
const res = await client.query(`SELECT * FROM stsresfhirquantity WHERE HASH_IDENTITY_SYS_UNITS = $1 AND SP_VALUE = $2`, [hash, searchValue]);
|
|
5533
|
+
return this.#filterResults({
|
|
5534
|
+
SP_NAME: parameterName,
|
|
5535
|
+
RES_TYPE: resourceName
|
|
5536
|
+
}, res.rows);
|
|
5537
|
+
} catch (error) {
|
|
5538
|
+
const message = `DBSTSQuantity:ReadBySystemAndUnits(): Error: [${error}]`;
|
|
5539
|
+
this._options.logger.error(message);
|
|
5540
|
+
throw new Error(message);
|
|
5541
|
+
}
|
|
5323
5542
|
}
|
|
5324
|
-
async
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5543
|
+
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5544
|
+
try {
|
|
5545
|
+
return (await client.query(`SELECT * FROM stsresfhirquantity WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5546
|
+
} catch (error) {
|
|
5547
|
+
const message = `DBSTSQuantity:ReadByResID(): Error: [${error}]`;
|
|
5548
|
+
this._options.logger.error(message);
|
|
5549
|
+
throw new Error(message);
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
#filterResults(data, results) {
|
|
5553
|
+
try {
|
|
5554
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5555
|
+
} catch (error) {
|
|
5556
|
+
const message = `DBSTSQuantity:#filterResults(): Error: [${error}]`;
|
|
5557
|
+
this._options.logger.error(message);
|
|
5558
|
+
throw new Error(message);
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
};
|
|
5562
|
+
//#endregion
|
|
5563
|
+
//#region src/fhir-database/pg/pgfhirnumber.ts
|
|
5564
|
+
var DBSTSNumber = class extends DBSTSFhirDBParamTypeBase {
|
|
5565
|
+
constructor(options) {
|
|
5566
|
+
super(options);
|
|
5567
|
+
}
|
|
5568
|
+
async InsertRecord(client, data) {
|
|
5569
|
+
try {
|
|
5570
|
+
const text = `
|
|
5571
|
+
INSERT INTO stsresfhirnumber (
|
|
5572
|
+
PID,
|
|
5573
|
+
PARTITION_ID,
|
|
5574
|
+
PARTITION_DATE,
|
|
5575
|
+
SP_NAME,
|
|
5576
|
+
SP_PARAM_TYPE,
|
|
5577
|
+
SP_STR,
|
|
5578
|
+
RES_ID,
|
|
5579
|
+
RES_TYPE,
|
|
5580
|
+
UPDATED,
|
|
5581
|
+
SP_MISSING,
|
|
5582
|
+
HASH_IDENTITY,
|
|
5583
|
+
SP_VALUE,
|
|
5584
|
+
PATH_FOR_COMP,
|
|
5585
|
+
COMPOSITE,
|
|
5586
|
+
COMPOSITE_HASH_EXACT
|
|
5587
|
+
) VALUES (
|
|
5588
|
+
$1, $2, $3, $4, $5, $6,
|
|
5589
|
+
$7, $8, $9, $10, $11, $12,
|
|
5590
|
+
$13, $14, $15
|
|
5591
|
+
)`;
|
|
5592
|
+
const values = [
|
|
5593
|
+
data.PID,
|
|
5594
|
+
data.PARTITION_ID ?? 0,
|
|
5595
|
+
data.PARTITION_DATE ?? 0,
|
|
5596
|
+
data.SP_NAME,
|
|
5597
|
+
data.SP_PARAM_TYPE,
|
|
5598
|
+
data.SP_STR,
|
|
5599
|
+
data.RES_ID,
|
|
5600
|
+
data.RES_TYPE,
|
|
5601
|
+
BigInt(data.UPDATED),
|
|
5602
|
+
data.SP_MISSING,
|
|
5603
|
+
BigInt(data.HASH_IDENTITY),
|
|
5604
|
+
data.SP_VALUE ?? 0,
|
|
5605
|
+
data.PATH_FOR_COMP,
|
|
5606
|
+
data.COMPOSITE,
|
|
5607
|
+
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5608
|
+
];
|
|
5609
|
+
await client.query(text, values);
|
|
5610
|
+
} catch (error) {
|
|
5611
|
+
const message = `DBSTSNumber:InsertRecord(): Error: [${error}]`;
|
|
5612
|
+
this._options.logger.error(message);
|
|
5613
|
+
throw new Error(message);
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
async DeleteRecord(client, data) {
|
|
5617
|
+
try {
|
|
5618
|
+
await client.query(`DELETE FROM stsresfhirnumber WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5619
|
+
} catch (error) {
|
|
5620
|
+
const message = `DBSTSNumber:DeleteRecord(): Error: [${error}]`;
|
|
5621
|
+
this._options.logger.error(message);
|
|
5622
|
+
throw new Error(message);
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
async ReadByPIDRecord(client, PID) {
|
|
5626
|
+
try {
|
|
5627
|
+
return (await client.query(`SELECT * FROM stsresfhirnumber WHERE PID = $1`, [PID])).rows[0];
|
|
5628
|
+
} catch (error) {
|
|
5629
|
+
const message = `DBSTSNumber:ReadByPIDRecord(): Error: [${error}]`;
|
|
5630
|
+
this._options.logger.error(message);
|
|
5631
|
+
throw new Error(message);
|
|
5632
|
+
}
|
|
5633
|
+
}
|
|
5634
|
+
async ReadAllRecords(client) {
|
|
5635
|
+
try {
|
|
5636
|
+
return (await client.query(`SELECT * FROM stsresfhirnumber`)).rows;
|
|
5637
|
+
} catch (error) {
|
|
5638
|
+
const message = `DBSTSNumber:ReadAllRecords(): Error: [${error}]`;
|
|
5639
|
+
this._options.logger.error(message);
|
|
5640
|
+
throw new Error(message);
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5644
|
+
try {
|
|
5645
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5646
|
+
const res = await client.query(`SELECT * FROM stsresfhirnumber WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5647
|
+
return this.#filterResults({
|
|
5648
|
+
SP_NAME: parameterName,
|
|
5649
|
+
RES_TYPE: resourceName
|
|
5650
|
+
}, res.rows);
|
|
5651
|
+
} catch (error) {
|
|
5652
|
+
const message = `DBSTSNumber:ReadByIdentity(): Error: [${error}]`;
|
|
5653
|
+
this._options.logger.error(message);
|
|
5654
|
+
throw new Error(message);
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
async ReadByValue(client, searchValue, parameterName, resourceName) {
|
|
5658
|
+
try {
|
|
5659
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5660
|
+
const res = await client.query(`SELECT * FROM stsresfhirnumber WHERE HASH_IDENTITY = $1 AND SP_VALUE = $2`, [hash, searchValue]);
|
|
5661
|
+
return this.#filterResults({
|
|
5662
|
+
SP_NAME: parameterName,
|
|
5663
|
+
RES_TYPE: resourceName
|
|
5664
|
+
}, res.rows);
|
|
5665
|
+
} catch (error) {
|
|
5666
|
+
const message = `DBSTSNumber:ReadByValue(): Error: [${error}]`;
|
|
5667
|
+
this._options.logger.error(message);
|
|
5668
|
+
throw new Error(message);
|
|
5669
|
+
}
|
|
5331
5670
|
}
|
|
5332
5671
|
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5333
|
-
|
|
5672
|
+
try {
|
|
5673
|
+
return (await client.query(`SELECT * FROM stsresfhirnumber WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5674
|
+
} catch (error) {
|
|
5675
|
+
const message = `DBSTSNumber:ReadByResID(): Error: [${error}]`;
|
|
5676
|
+
this._options.logger.error(message);
|
|
5677
|
+
throw new Error(message);
|
|
5678
|
+
}
|
|
5334
5679
|
}
|
|
5335
5680
|
#filterResults(data, results) {
|
|
5336
|
-
|
|
5681
|
+
try {
|
|
5682
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5683
|
+
} catch (error) {
|
|
5684
|
+
const message = `DBSTSNumber:#filterResults(): Error: [${error}]`;
|
|
5685
|
+
this._options.logger.error(message);
|
|
5686
|
+
throw new Error(message);
|
|
5687
|
+
}
|
|
5337
5688
|
}
|
|
5338
5689
|
};
|
|
5339
5690
|
//#endregion
|
|
5340
|
-
//#region src/fhir-database/pg/
|
|
5341
|
-
var
|
|
5691
|
+
//#region src/fhir-database/pg/pgfhirdate.ts
|
|
5692
|
+
var DBSTSDate = class extends DBSTSFhirDBParamTypeBase {
|
|
5693
|
+
constructor(options) {
|
|
5694
|
+
super(options);
|
|
5695
|
+
}
|
|
5342
5696
|
async InsertRecord(client, data) {
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5697
|
+
try {
|
|
5698
|
+
const text = `
|
|
5699
|
+
INSERT INTO stsresfhirdate (
|
|
5700
|
+
PID,
|
|
5701
|
+
PARTITION_ID,
|
|
5702
|
+
PARTITION_DATE,
|
|
5703
|
+
SP_NAME,
|
|
5704
|
+
SP_PARAM_TYPE,
|
|
5705
|
+
SP_STR,
|
|
5706
|
+
RES_ID,
|
|
5707
|
+
RES_TYPE,
|
|
5708
|
+
UPDATED,
|
|
5709
|
+
SP_MISSING,
|
|
5710
|
+
HASH_IDENTITY,
|
|
5711
|
+
SP_VALUE_LOW,
|
|
5712
|
+
SP_VALUE_HIGH,
|
|
5713
|
+
SP_VALUE_LOW_DATE_ORDINAL,
|
|
5714
|
+
SP_VALUE_HIGH_DATE_ORDINAL,
|
|
5715
|
+
PATH_FOR_COMP,
|
|
5716
|
+
COMPOSITE,
|
|
5717
|
+
COMPOSITE_HASH_EXACT
|
|
5718
|
+
) VALUES (
|
|
5719
|
+
$1, $2, $3, $4, $5, $6,
|
|
5720
|
+
$7, $8, $9, $10, $11, $12,
|
|
5721
|
+
$13, $14, $15,
|
|
5722
|
+
$16, $17, $18
|
|
5723
|
+
)`;
|
|
5724
|
+
const values = [
|
|
5725
|
+
data.PID,
|
|
5726
|
+
data.PARTITION_ID ?? 0,
|
|
5727
|
+
data.PARTITION_DATE ?? 0,
|
|
5728
|
+
data.SP_NAME,
|
|
5729
|
+
data.SP_PARAM_TYPE,
|
|
5730
|
+
data.SP_STR,
|
|
5731
|
+
data.RES_ID,
|
|
5732
|
+
data.RES_TYPE,
|
|
5733
|
+
BigInt(data.UPDATED),
|
|
5734
|
+
data.SP_MISSING,
|
|
5735
|
+
BigInt(data.HASH_IDENTITY),
|
|
5736
|
+
data.SP_VALUE_LOW ? data.SP_VALUE_LOW.toJSDate() : null,
|
|
5737
|
+
data.SP_VALUE_HIGH ? data.SP_VALUE_HIGH.toJSDate() : null,
|
|
5738
|
+
data.SP_VALUE_LOW_DATE_ORDINAL,
|
|
5739
|
+
data.SP_VALUE_HIGH_DATE_ORDINAL,
|
|
5740
|
+
data.PATH_FOR_COMP,
|
|
5741
|
+
data.COMPOSITE,
|
|
5742
|
+
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5743
|
+
];
|
|
5744
|
+
await client.query(text, values);
|
|
5745
|
+
} catch (error) {
|
|
5746
|
+
const message = `DBSTSDate:InsertRecord(): Error: [${error}]`;
|
|
5747
|
+
this._options.logger.error(message);
|
|
5748
|
+
throw new Error(message);
|
|
5749
|
+
}
|
|
5392
5750
|
}
|
|
5393
5751
|
async DeleteRecord(client, data) {
|
|
5394
|
-
|
|
5752
|
+
try {
|
|
5753
|
+
await client.query(`DELETE FROM stsresfhirdate WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5754
|
+
} catch (error) {
|
|
5755
|
+
const message = `DBSTSDate:DeleteRecord(): Error: [${error}]`;
|
|
5756
|
+
this._options.logger.error(message);
|
|
5757
|
+
throw new Error(message);
|
|
5758
|
+
}
|
|
5395
5759
|
}
|
|
5396
5760
|
async ReadByPIDRecord(client, PID) {
|
|
5397
|
-
|
|
5761
|
+
try {
|
|
5762
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE PID = $1`, [PID]);
|
|
5763
|
+
if (res.rows && res.rows.length === 1) {
|
|
5764
|
+
if (res.rows[0].sp_value_high !== null) res.rows[0].sp_value_high = luxon.DateTime.fromJSDate(res.rows[0].sp_value_high);
|
|
5765
|
+
if (res.rows[0].sp_value_low !== null) res.rows[0].sp_value_low = luxon.DateTime.fromJSDate(res.rows[0].sp_value_low);
|
|
5766
|
+
}
|
|
5767
|
+
return res.rows[0];
|
|
5768
|
+
} catch (error) {
|
|
5769
|
+
const message = `DBSTSDate:ReadByPIDRecord(): Error: [${error}]`;
|
|
5770
|
+
this._options.logger.error(message);
|
|
5771
|
+
throw new Error(message);
|
|
5772
|
+
}
|
|
5398
5773
|
}
|
|
5399
5774
|
async ReadAllRecords(client) {
|
|
5400
|
-
|
|
5775
|
+
try {
|
|
5776
|
+
return (await client.query(`SELECT * FROM stsresfhirdate`)).rows;
|
|
5777
|
+
} catch (error) {
|
|
5778
|
+
const message = `DBSTSDate:ReadAllRecords(): Error: [${error}]`;
|
|
5779
|
+
this._options.logger.error(message);
|
|
5780
|
+
throw new Error(message);
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5784
|
+
try {
|
|
5785
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5786
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5787
|
+
return this.#filterResults({
|
|
5788
|
+
SP_NAME: parameterName,
|
|
5789
|
+
RES_TYPE: resourceName
|
|
5790
|
+
}, res.rows);
|
|
5791
|
+
} catch (error) {
|
|
5792
|
+
const message = `DBSTSDate:ReadByIdentity(): Error: [${error}]`;
|
|
5793
|
+
this._options.logger.error(message);
|
|
5794
|
+
throw new Error(message);
|
|
5795
|
+
}
|
|
5796
|
+
}
|
|
5797
|
+
async ReadByDateTime(client, SP_VALUE_LOW, SP_VALUE_HIGH, parameterName, resourceName) {
|
|
5798
|
+
try {
|
|
5799
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5800
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW >= $2 AND SP_VALUE_HIGH <= $3`, [
|
|
5801
|
+
hash,
|
|
5802
|
+
SP_VALUE_LOW,
|
|
5803
|
+
SP_VALUE_HIGH
|
|
5804
|
+
]);
|
|
5805
|
+
return this.#filterResults({
|
|
5806
|
+
SP_NAME: parameterName,
|
|
5807
|
+
RES_TYPE: resourceName
|
|
5808
|
+
}, res.rows);
|
|
5809
|
+
} catch (error) {
|
|
5810
|
+
const message = `DBSTSDate:ReadByDateTime(): Error: [${error}]`;
|
|
5811
|
+
this._options.logger.error(message);
|
|
5812
|
+
throw new Error(message);
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
async ReadByDateTimeLow(client, SP_VALUE_LOW, parameterName, resourceName) {
|
|
5816
|
+
try {
|
|
5817
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5818
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW >= $2`, [hash, SP_VALUE_LOW]);
|
|
5819
|
+
return this.#filterResults({
|
|
5820
|
+
SP_NAME: parameterName,
|
|
5821
|
+
RES_TYPE: resourceName
|
|
5822
|
+
}, res.rows);
|
|
5823
|
+
} catch (error) {
|
|
5824
|
+
const message = `DBSTSDate:ReadByDateTimeLow(): Error: [${error}]`;
|
|
5825
|
+
this._options.logger.error(message);
|
|
5826
|
+
throw new Error(message);
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
async ReadByDateTimeHigh(client, SP_VALUE_HIGH, parameterName, resourceName) {
|
|
5830
|
+
try {
|
|
5831
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5832
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_HIGH <= $2`, [hash, SP_VALUE_HIGH]);
|
|
5833
|
+
return this.#filterResults({
|
|
5834
|
+
SP_NAME: parameterName,
|
|
5835
|
+
RES_TYPE: resourceName
|
|
5836
|
+
}, res.rows);
|
|
5837
|
+
} catch (error) {
|
|
5838
|
+
const message = `DBSTSDate:ReadByDateTimeHigh(): Error: [${error}]`;
|
|
5839
|
+
this._options.logger.error(message);
|
|
5840
|
+
throw new Error(message);
|
|
5841
|
+
}
|
|
5401
5842
|
}
|
|
5402
|
-
async
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5843
|
+
async ReadByDateOrdinal(client, SP_VALUE_LOW_DATE_ORDINAL, SP_VALUE_HIGH_DATE_ORDINAL, parameterName, resourceName) {
|
|
5844
|
+
try {
|
|
5845
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5846
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW_DATE_ORDINAL >= $2 AND SP_VALUE_HIGH_DATE_ORDINAL <= $3`, [
|
|
5847
|
+
hash,
|
|
5848
|
+
SP_VALUE_LOW_DATE_ORDINAL,
|
|
5849
|
+
SP_VALUE_HIGH_DATE_ORDINAL
|
|
5850
|
+
]);
|
|
5851
|
+
return this.#filterResults({
|
|
5852
|
+
SP_NAME: parameterName,
|
|
5853
|
+
RES_TYPE: resourceName
|
|
5854
|
+
}, res.rows);
|
|
5855
|
+
} catch (error) {
|
|
5856
|
+
const message = `DBSTSDate:ReadByDateOrdinal(): Error: [${error}]`;
|
|
5857
|
+
this._options.logger.error(message);
|
|
5858
|
+
throw new Error(message);
|
|
5859
|
+
}
|
|
5409
5860
|
}
|
|
5410
|
-
async
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5861
|
+
async ReadByDateOrdinalLow(client, SP_VALUE_LOW_DATE_ORDINAL, parameterName, resourceName) {
|
|
5862
|
+
try {
|
|
5863
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5864
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW_DATE_ORDINAL >= $2`, [hash, SP_VALUE_LOW_DATE_ORDINAL]);
|
|
5865
|
+
return this.#filterResults({
|
|
5866
|
+
SP_NAME: parameterName,
|
|
5867
|
+
RES_TYPE: resourceName
|
|
5868
|
+
}, res.rows);
|
|
5869
|
+
} catch (error) {
|
|
5870
|
+
const message = `DBSTSDate:ReadByDateOrdinalLow(): Error: [${error}]`;
|
|
5871
|
+
this._options.logger.error(message);
|
|
5872
|
+
throw new Error(message);
|
|
5873
|
+
}
|
|
5417
5874
|
}
|
|
5418
|
-
async
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5875
|
+
async ReadByDateOrdinalHigh(client, SP_VALUE_HIGH_DATE_ORDINAL, parameterName, resourceName) {
|
|
5876
|
+
try {
|
|
5877
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5878
|
+
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_HIGH_DATE_ORDINAL <= $2`, [hash, SP_VALUE_HIGH_DATE_ORDINAL]);
|
|
5879
|
+
return this.#filterResults({
|
|
5880
|
+
SP_NAME: parameterName,
|
|
5881
|
+
RES_TYPE: resourceName
|
|
5882
|
+
}, res.rows);
|
|
5883
|
+
} catch (error) {
|
|
5884
|
+
const message = `DBSTSDate:ReadByDateOrdinalHigh(): Error: [${error}]`;
|
|
5885
|
+
this._options.logger.error(message);
|
|
5886
|
+
throw new Error(message);
|
|
5887
|
+
}
|
|
5425
5888
|
}
|
|
5426
5889
|
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5427
|
-
|
|
5890
|
+
try {
|
|
5891
|
+
return (await client.query(`SELECT * FROM stsresfhirdate WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5892
|
+
} catch (error) {
|
|
5893
|
+
const message = `DBSTSDate:ReadByResID(): Error: [${error}]`;
|
|
5894
|
+
this._options.logger.error(message);
|
|
5895
|
+
throw new Error(message);
|
|
5896
|
+
}
|
|
5428
5897
|
}
|
|
5429
5898
|
#filterResults(data, results) {
|
|
5430
|
-
|
|
5899
|
+
try {
|
|
5900
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5901
|
+
} catch (error) {
|
|
5902
|
+
const message = `DBSTSDate:#filterResults(): Error: [${error}]`;
|
|
5903
|
+
this._options.logger.error(message);
|
|
5904
|
+
throw new Error(message);
|
|
5905
|
+
}
|
|
5431
5906
|
}
|
|
5432
5907
|
};
|
|
5433
5908
|
//#endregion
|
|
5434
|
-
//#region src/fhir-database/pg/
|
|
5435
|
-
var
|
|
5909
|
+
//#region src/fhir-database/pg/pgfhiruri.ts
|
|
5910
|
+
var DBSTSUri = class extends DBSTSFhirDBParamTypeBase {
|
|
5911
|
+
constructor(options) {
|
|
5912
|
+
super(options);
|
|
5913
|
+
}
|
|
5436
5914
|
async InsertRecord(client, data) {
|
|
5437
5915
|
try {
|
|
5438
5916
|
const text = `
|
|
5439
|
-
INSERT INTO
|
|
5917
|
+
INSERT INTO stsresfhiruri (
|
|
5440
5918
|
PID,
|
|
5441
5919
|
PARTITION_ID,
|
|
5442
5920
|
PARTITION_DATE,
|
|
@@ -5448,14 +5926,15 @@ var DBSTSNumber = class {
|
|
|
5448
5926
|
UPDATED,
|
|
5449
5927
|
SP_MISSING,
|
|
5450
5928
|
HASH_IDENTITY,
|
|
5451
|
-
|
|
5929
|
+
SP_URI,
|
|
5930
|
+
HASH_URI,
|
|
5452
5931
|
PATH_FOR_COMP,
|
|
5453
5932
|
COMPOSITE,
|
|
5454
5933
|
COMPOSITE_HASH_EXACT
|
|
5455
5934
|
) VALUES (
|
|
5456
5935
|
$1, $2, $3, $4, $5, $6,
|
|
5457
|
-
$7, $8, $9, $10, $11, $12,
|
|
5458
|
-
$
|
|
5936
|
+
$7, $8, $9, $10, $11, $12, $13,
|
|
5937
|
+
$14, $15, $16
|
|
5459
5938
|
)`;
|
|
5460
5939
|
const values = [
|
|
5461
5940
|
data.PID,
|
|
@@ -5469,269 +5948,99 @@ var DBSTSNumber = class {
|
|
|
5469
5948
|
BigInt(data.UPDATED),
|
|
5470
5949
|
data.SP_MISSING,
|
|
5471
5950
|
BigInt(data.HASH_IDENTITY),
|
|
5472
|
-
data.
|
|
5951
|
+
data.SP_URI,
|
|
5952
|
+
data.HASH_URI,
|
|
5473
5953
|
data.PATH_FOR_COMP,
|
|
5474
5954
|
data.COMPOSITE,
|
|
5475
5955
|
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5476
5956
|
];
|
|
5477
5957
|
await client.query(text, values);
|
|
5478
5958
|
} catch (error) {
|
|
5479
|
-
|
|
5959
|
+
const message = `DBSTSUri:InsertRecord(): Error: [${error}]`;
|
|
5960
|
+
this._options.logger.error(message);
|
|
5961
|
+
throw new Error(message);
|
|
5480
5962
|
}
|
|
5481
5963
|
}
|
|
5482
5964
|
async DeleteRecord(client, data) {
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
return (await client.query(`SELECT * FROM stsresfhirnumber`)).rows;
|
|
5490
|
-
}
|
|
5491
|
-
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5492
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5493
|
-
const res = await client.query(`SELECT * FROM stsresfhirnumber WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5494
|
-
return this.#filterResults({
|
|
5495
|
-
SP_NAME: parameterName,
|
|
5496
|
-
RES_TYPE: resourceName
|
|
5497
|
-
}, res.rows);
|
|
5498
|
-
}
|
|
5499
|
-
async ReadByValue(client, searchValue, parameterName, resourceName) {
|
|
5500
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5501
|
-
const res = await client.query(`SELECT * FROM stsresfhirnumber WHERE HASH_IDENTITY = $1 AND SP_VALUE = $2`, [hash, searchValue]);
|
|
5502
|
-
return this.#filterResults({
|
|
5503
|
-
SP_NAME: parameterName,
|
|
5504
|
-
RES_TYPE: resourceName
|
|
5505
|
-
}, res.rows);
|
|
5506
|
-
}
|
|
5507
|
-
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5508
|
-
return (await client.query(`SELECT * FROM stsresfhirnumber WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5509
|
-
}
|
|
5510
|
-
#filterResults(data, results) {
|
|
5511
|
-
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5512
|
-
}
|
|
5513
|
-
};
|
|
5514
|
-
//#endregion
|
|
5515
|
-
//#region src/fhir-database/pg/pgfhirdate.ts
|
|
5516
|
-
var DBSTSDate = class {
|
|
5517
|
-
async InsertRecord(client, data) {
|
|
5518
|
-
const text = `
|
|
5519
|
-
INSERT INTO stsresfhirdate (
|
|
5520
|
-
PID,
|
|
5521
|
-
PARTITION_ID,
|
|
5522
|
-
PARTITION_DATE,
|
|
5523
|
-
SP_NAME,
|
|
5524
|
-
SP_PARAM_TYPE,
|
|
5525
|
-
SP_STR,
|
|
5526
|
-
RES_ID,
|
|
5527
|
-
RES_TYPE,
|
|
5528
|
-
UPDATED,
|
|
5529
|
-
SP_MISSING,
|
|
5530
|
-
HASH_IDENTITY,
|
|
5531
|
-
SP_VALUE_LOW,
|
|
5532
|
-
SP_VALUE_HIGH,
|
|
5533
|
-
SP_VALUE_LOW_DATE_ORDINAL,
|
|
5534
|
-
SP_VALUE_HIGH_DATE_ORDINAL,
|
|
5535
|
-
PATH_FOR_COMP,
|
|
5536
|
-
COMPOSITE,
|
|
5537
|
-
COMPOSITE_HASH_EXACT
|
|
5538
|
-
) VALUES (
|
|
5539
|
-
$1, $2, $3, $4, $5, $6,
|
|
5540
|
-
$7, $8, $9, $10, $11, $12,
|
|
5541
|
-
$13, $14, $15,
|
|
5542
|
-
$16, $17, $18
|
|
5543
|
-
)`;
|
|
5544
|
-
const values = [
|
|
5545
|
-
data.PID,
|
|
5546
|
-
data.PARTITION_ID ?? 0,
|
|
5547
|
-
data.PARTITION_DATE ?? 0,
|
|
5548
|
-
data.SP_NAME,
|
|
5549
|
-
data.SP_PARAM_TYPE,
|
|
5550
|
-
data.SP_STR,
|
|
5551
|
-
data.RES_ID,
|
|
5552
|
-
data.RES_TYPE,
|
|
5553
|
-
BigInt(data.UPDATED),
|
|
5554
|
-
data.SP_MISSING,
|
|
5555
|
-
BigInt(data.HASH_IDENTITY),
|
|
5556
|
-
data.SP_VALUE_LOW ? data.SP_VALUE_LOW.toJSDate() : null,
|
|
5557
|
-
data.SP_VALUE_HIGH ? data.SP_VALUE_HIGH.toJSDate() : null,
|
|
5558
|
-
data.SP_VALUE_LOW_DATE_ORDINAL,
|
|
5559
|
-
data.SP_VALUE_HIGH_DATE_ORDINAL,
|
|
5560
|
-
data.PATH_FOR_COMP,
|
|
5561
|
-
data.COMPOSITE,
|
|
5562
|
-
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5563
|
-
];
|
|
5564
|
-
await client.query(text, values);
|
|
5565
|
-
}
|
|
5566
|
-
async DeleteRecord(client, data) {
|
|
5567
|
-
await client.query(`DELETE FROM stsresfhirdate WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5568
|
-
}
|
|
5569
|
-
async ReadByPIDRecord(client, PID) {
|
|
5570
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE PID = $1`, [PID]);
|
|
5571
|
-
if (res.rows && res.rows.length === 1) {
|
|
5572
|
-
if (res.rows[0].sp_value_high !== null) res.rows[0].sp_value_high = luxon.DateTime.fromJSDate(res.rows[0].sp_value_high);
|
|
5573
|
-
if (res.rows[0].sp_value_low !== null) res.rows[0].sp_value_low = luxon.DateTime.fromJSDate(res.rows[0].sp_value_low);
|
|
5965
|
+
try {
|
|
5966
|
+
await client.query(`DELETE FROM stsresfhiruri WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5967
|
+
} catch (error) {
|
|
5968
|
+
const message = `DBSTSUri:DeleteRecord(): Error: [${error}]`;
|
|
5969
|
+
this._options.logger.error(message);
|
|
5970
|
+
throw new Error(message);
|
|
5574
5971
|
}
|
|
5575
|
-
return res.rows[0];
|
|
5576
|
-
}
|
|
5577
|
-
async ReadAllRecords(client) {
|
|
5578
|
-
return (await client.query(`SELECT * FROM stsresfhirdate`)).rows;
|
|
5579
|
-
}
|
|
5580
|
-
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5581
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5582
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5583
|
-
return this.#filterResults({
|
|
5584
|
-
SP_NAME: parameterName,
|
|
5585
|
-
RES_TYPE: resourceName
|
|
5586
|
-
}, res.rows);
|
|
5587
|
-
}
|
|
5588
|
-
async ReadByDateTime(client, SP_VALUE_LOW, SP_VALUE_HIGH, parameterName, resourceName) {
|
|
5589
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5590
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW >= $2 AND SP_VALUE_HIGH <= $3`, [
|
|
5591
|
-
hash,
|
|
5592
|
-
SP_VALUE_LOW,
|
|
5593
|
-
SP_VALUE_HIGH
|
|
5594
|
-
]);
|
|
5595
|
-
return this.#filterResults({
|
|
5596
|
-
SP_NAME: parameterName,
|
|
5597
|
-
RES_TYPE: resourceName
|
|
5598
|
-
}, res.rows);
|
|
5599
|
-
}
|
|
5600
|
-
async ReadByDateTimeLow(client, SP_VALUE_LOW, parameterName, resourceName) {
|
|
5601
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5602
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW >= $2`, [hash, SP_VALUE_LOW]);
|
|
5603
|
-
return this.#filterResults({
|
|
5604
|
-
SP_NAME: parameterName,
|
|
5605
|
-
RES_TYPE: resourceName
|
|
5606
|
-
}, res.rows);
|
|
5607
|
-
}
|
|
5608
|
-
async ReadByDateTimeHigh(client, SP_VALUE_HIGH, parameterName, resourceName) {
|
|
5609
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5610
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_HIGH <= $2`, [hash, SP_VALUE_HIGH]);
|
|
5611
|
-
return this.#filterResults({
|
|
5612
|
-
SP_NAME: parameterName,
|
|
5613
|
-
RES_TYPE: resourceName
|
|
5614
|
-
}, res.rows);
|
|
5615
|
-
}
|
|
5616
|
-
async ReadByDateOrdinal(client, SP_VALUE_LOW_DATE_ORDINAL, SP_VALUE_HIGH_DATE_ORDINAL, parameterName, resourceName) {
|
|
5617
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5618
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW_DATE_ORDINAL >= $2 AND SP_VALUE_HIGH_DATE_ORDINAL <= $3`, [
|
|
5619
|
-
hash,
|
|
5620
|
-
SP_VALUE_LOW_DATE_ORDINAL,
|
|
5621
|
-
SP_VALUE_HIGH_DATE_ORDINAL
|
|
5622
|
-
]);
|
|
5623
|
-
return this.#filterResults({
|
|
5624
|
-
SP_NAME: parameterName,
|
|
5625
|
-
RES_TYPE: resourceName
|
|
5626
|
-
}, res.rows);
|
|
5627
|
-
}
|
|
5628
|
-
async ReadByDateOrdinalLow(client, SP_VALUE_LOW_DATE_ORDINAL, parameterName, resourceName) {
|
|
5629
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5630
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_LOW_DATE_ORDINAL >= $2`, [hash, SP_VALUE_LOW_DATE_ORDINAL]);
|
|
5631
|
-
return this.#filterResults({
|
|
5632
|
-
SP_NAME: parameterName,
|
|
5633
|
-
RES_TYPE: resourceName
|
|
5634
|
-
}, res.rows);
|
|
5635
|
-
}
|
|
5636
|
-
async ReadByDateOrdinalHigh(client, SP_VALUE_HIGH_DATE_ORDINAL, parameterName, resourceName) {
|
|
5637
|
-
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5638
|
-
const res = await client.query(`SELECT * FROM stsresfhirdate WHERE HASH_IDENTITY = $1 AND SP_VALUE_HIGH_DATE_ORDINAL <= $2`, [hash, SP_VALUE_HIGH_DATE_ORDINAL]);
|
|
5639
|
-
return this.#filterResults({
|
|
5640
|
-
SP_NAME: parameterName,
|
|
5641
|
-
RES_TYPE: resourceName
|
|
5642
|
-
}, res.rows);
|
|
5643
|
-
}
|
|
5644
|
-
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5645
|
-
return (await client.query(`SELECT * FROM stsresfhirdate WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
5646
|
-
}
|
|
5647
|
-
#filterResults(data, results) {
|
|
5648
|
-
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
5649
|
-
}
|
|
5650
|
-
};
|
|
5651
|
-
//#endregion
|
|
5652
|
-
//#region src/fhir-database/pg/pgfhiruri.ts
|
|
5653
|
-
var DBSTSUri = class {
|
|
5654
|
-
async InsertRecord(client, data) {
|
|
5655
|
-
const text = `
|
|
5656
|
-
INSERT INTO stsresfhiruri (
|
|
5657
|
-
PID,
|
|
5658
|
-
PARTITION_ID,
|
|
5659
|
-
PARTITION_DATE,
|
|
5660
|
-
SP_NAME,
|
|
5661
|
-
SP_PARAM_TYPE,
|
|
5662
|
-
SP_STR,
|
|
5663
|
-
RES_ID,
|
|
5664
|
-
RES_TYPE,
|
|
5665
|
-
UPDATED,
|
|
5666
|
-
SP_MISSING,
|
|
5667
|
-
HASH_IDENTITY,
|
|
5668
|
-
SP_URI,
|
|
5669
|
-
HASH_URI,
|
|
5670
|
-
PATH_FOR_COMP,
|
|
5671
|
-
COMPOSITE,
|
|
5672
|
-
COMPOSITE_HASH_EXACT
|
|
5673
|
-
) VALUES (
|
|
5674
|
-
$1, $2, $3, $4, $5, $6,
|
|
5675
|
-
$7, $8, $9, $10, $11, $12, $13,
|
|
5676
|
-
$14, $15, $16
|
|
5677
|
-
)`;
|
|
5678
|
-
const values = [
|
|
5679
|
-
data.PID,
|
|
5680
|
-
data.PARTITION_ID ?? 0,
|
|
5681
|
-
data.PARTITION_DATE ?? 0,
|
|
5682
|
-
data.SP_NAME,
|
|
5683
|
-
data.SP_PARAM_TYPE,
|
|
5684
|
-
data.SP_STR,
|
|
5685
|
-
data.RES_ID,
|
|
5686
|
-
data.RES_TYPE,
|
|
5687
|
-
BigInt(data.UPDATED),
|
|
5688
|
-
data.SP_MISSING,
|
|
5689
|
-
BigInt(data.HASH_IDENTITY),
|
|
5690
|
-
data.SP_URI,
|
|
5691
|
-
data.HASH_URI,
|
|
5692
|
-
data.PATH_FOR_COMP,
|
|
5693
|
-
data.COMPOSITE,
|
|
5694
|
-
data.COMPOSITE_HASH_EXACT ? BigInt(data.COMPOSITE_HASH_EXACT) : null
|
|
5695
|
-
];
|
|
5696
|
-
await client.query(text, values);
|
|
5697
|
-
}
|
|
5698
|
-
async DeleteRecord(client, data) {
|
|
5699
|
-
await client.query(`DELETE FROM stsresfhiruri WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
5700
5972
|
}
|
|
5701
5973
|
async ReadByPIDRecord(client, PID) {
|
|
5702
|
-
|
|
5974
|
+
try {
|
|
5975
|
+
return (await client.query(`SELECT * FROM stsresfhiruri WHERE PID = $1`, [PID])).rows[0];
|
|
5976
|
+
} catch (error) {
|
|
5977
|
+
const message = `DBSTSUri:ReadByPIDRecord(): Error: [${error}]`;
|
|
5978
|
+
this._options.logger.error(message);
|
|
5979
|
+
throw new Error(message);
|
|
5980
|
+
}
|
|
5703
5981
|
}
|
|
5704
5982
|
async ReadAllRecords(client) {
|
|
5705
|
-
|
|
5983
|
+
try {
|
|
5984
|
+
return (await client.query(`SELECT * FROM stsresfhiruri`)).rows;
|
|
5985
|
+
} catch (error) {
|
|
5986
|
+
const message = `DBSTSUri:ReadAllRecords(): Error: [${error}]`;
|
|
5987
|
+
this._options.logger.error(message);
|
|
5988
|
+
throw new Error(message);
|
|
5989
|
+
}
|
|
5706
5990
|
}
|
|
5707
5991
|
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5992
|
+
try {
|
|
5993
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
5994
|
+
const res = await client.query(`SELECT * FROM stsresfhiruri WHERE HASH_IDENTITY = $1`, [hash]);
|
|
5995
|
+
return this.#filterResults({
|
|
5996
|
+
SP_NAME: parameterName,
|
|
5997
|
+
RES_TYPE: resourceName
|
|
5998
|
+
}, res.rows);
|
|
5999
|
+
} catch (error) {
|
|
6000
|
+
const message = `DBSTSUri:ReadByIdentity(): Error: [${error}]`;
|
|
6001
|
+
this._options.logger.error(message);
|
|
6002
|
+
throw new Error(message);
|
|
6003
|
+
}
|
|
5714
6004
|
}
|
|
5715
6005
|
async ReadByURI(client, uri, parameterName, resourceName) {
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
6006
|
+
try {
|
|
6007
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}|${uri}`, true);
|
|
6008
|
+
const res = await client.query(`SELECT * FROM stsresfhiruri WHERE HASH_URI = $1`, [hash]);
|
|
6009
|
+
return this.#filterResults({
|
|
6010
|
+
SP_NAME: parameterName,
|
|
6011
|
+
RES_TYPE: resourceName
|
|
6012
|
+
}, res.rows);
|
|
6013
|
+
} catch (error) {
|
|
6014
|
+
const message = `DBSTSUri:ReadByURI(): Error: [${error}]`;
|
|
6015
|
+
this._options.logger.error(message);
|
|
6016
|
+
throw new Error(message);
|
|
6017
|
+
}
|
|
5722
6018
|
}
|
|
5723
6019
|
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5724
|
-
|
|
6020
|
+
try {
|
|
6021
|
+
return (await client.query(`SELECT * FROM stsresfhiruri WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
6022
|
+
} catch (error) {
|
|
6023
|
+
const message = `DBSTSUri:ReadByResID(): Error: [${error}]`;
|
|
6024
|
+
this._options.logger.error(message);
|
|
6025
|
+
throw new Error(message);
|
|
6026
|
+
}
|
|
5725
6027
|
}
|
|
5726
6028
|
#filterResults(data, results) {
|
|
5727
|
-
|
|
6029
|
+
try {
|
|
6030
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
6031
|
+
} catch (error) {
|
|
6032
|
+
const message = `DBSTSUri:#filterResults(): Error: [${error}]`;
|
|
6033
|
+
this._options.logger.error(message);
|
|
6034
|
+
throw new Error(message);
|
|
6035
|
+
}
|
|
5728
6036
|
}
|
|
5729
6037
|
};
|
|
5730
6038
|
//#endregion
|
|
5731
6039
|
//#region src/fhir-database/pg/pgfhircombo.ts
|
|
5732
|
-
var DBSTSCombo = class {
|
|
5733
|
-
|
|
5734
|
-
|
|
6040
|
+
var DBSTSCombo = class extends DBSTSFhirDBParamTypeBase {
|
|
6041
|
+
constructor(options) {
|
|
6042
|
+
super(options);
|
|
6043
|
+
}
|
|
5735
6044
|
async InsertRecord(client, data) {
|
|
5736
6045
|
try {
|
|
5737
6046
|
const text = `
|
|
@@ -5770,28 +6079,51 @@ var DBSTSCombo = class {
|
|
|
5770
6079
|
];
|
|
5771
6080
|
await client.query(text, values);
|
|
5772
6081
|
} catch (error) {
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
throw error;
|
|
6082
|
+
const message = `DBSTSCombo:InsertRecord(): Error: [${error}]`;
|
|
6083
|
+
this._options.logger.error(message);
|
|
6084
|
+
throw new Error(message);
|
|
5777
6085
|
}
|
|
5778
6086
|
}
|
|
5779
6087
|
async DeleteRecord(client, data) {
|
|
5780
|
-
|
|
6088
|
+
try {
|
|
6089
|
+
await client.query(`DELETE FROM stsresfhircombo WHERE RES_ID = $1 AND RES_TYPE = $2`, [data.RES_ID, data.RES_TYPE]);
|
|
6090
|
+
} catch (error) {
|
|
6091
|
+
const message = `DBSTSCombo:DeleteRecord(): Error: [${error}]`;
|
|
6092
|
+
this._options.logger.error(message);
|
|
6093
|
+
throw new Error(message);
|
|
6094
|
+
}
|
|
5781
6095
|
}
|
|
5782
6096
|
async ReadByPIDRecord(client, PID) {
|
|
5783
|
-
|
|
6097
|
+
try {
|
|
6098
|
+
return (await client.query(`SELECT * FROM stsresfhircombo WHERE PID = $1`, [PID])).rows[0];
|
|
6099
|
+
} catch (error) {
|
|
6100
|
+
const message = `DBSTSCombo:ReadByPIDRecord(): Error: [${error}]`;
|
|
6101
|
+
this._options.logger.error(message);
|
|
6102
|
+
throw new Error(message);
|
|
6103
|
+
}
|
|
5784
6104
|
}
|
|
5785
6105
|
async ReadAllRecords(client) {
|
|
5786
|
-
|
|
6106
|
+
try {
|
|
6107
|
+
return (await client.query(`SELECT * FROM stsresfhircombo`)).rows;
|
|
6108
|
+
} catch (error) {
|
|
6109
|
+
const message = `DBSTSCombo:ReadAllRecords(): Error: [${error}]`;
|
|
6110
|
+
this._options.logger.error(message);
|
|
6111
|
+
throw new Error(message);
|
|
6112
|
+
}
|
|
5787
6113
|
}
|
|
5788
6114
|
async ReadByIdentity(client, parameterName, resourceName) {
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
6115
|
+
try {
|
|
6116
|
+
const hash = hashStringParam(`${parameterName}|${resourceName}`, true);
|
|
6117
|
+
const res = await client.query(`SELECT * FROM stsresfhircombo WHERE HASH_IDENTITY = $1`, [hash]);
|
|
6118
|
+
return this.#filterResults({
|
|
6119
|
+
SP_NAME: parameterName,
|
|
6120
|
+
RES_TYPE: resourceName
|
|
6121
|
+
}, res.rows);
|
|
6122
|
+
} catch (error) {
|
|
6123
|
+
const message = `DBSTSCombo:ReadByIdentity(): Error: [${error}]`;
|
|
6124
|
+
this._options.logger.error(message);
|
|
6125
|
+
throw new Error(message);
|
|
6126
|
+
}
|
|
5795
6127
|
}
|
|
5796
6128
|
async ReadByString(client, stringVal, parameterName, resourceName) {
|
|
5797
6129
|
return [];
|
|
@@ -5815,10 +6147,22 @@ var DBSTSCombo = class {
|
|
|
5815
6147
|
return [];
|
|
5816
6148
|
}
|
|
5817
6149
|
async ReadByResID(client, RES_ID, RES_TYPE) {
|
|
5818
|
-
|
|
6150
|
+
try {
|
|
6151
|
+
return (await client.query(`SELECT * FROM stsresfhircombo WHERE RES_ID = $1 AND RES_TYPE = $2`, [RES_ID, RES_TYPE])).rows;
|
|
6152
|
+
} catch (error) {
|
|
6153
|
+
const message = `DBSTSCombo:ReadByResID(): Error: [${error}]`;
|
|
6154
|
+
this._options.logger.error(message);
|
|
6155
|
+
throw new Error(message);
|
|
6156
|
+
}
|
|
5819
6157
|
}
|
|
5820
6158
|
#filterResults(data, results) {
|
|
5821
|
-
|
|
6159
|
+
try {
|
|
6160
|
+
return results.filter((r) => r.SP_NAME === data.SP_NAME && r.RES_TYPE === data.RES_TYPE);
|
|
6161
|
+
} catch (error) {
|
|
6162
|
+
const message = `DBSTSCombo:#filterResults(): Error: [${error}]`;
|
|
6163
|
+
this._options.logger.error(message);
|
|
6164
|
+
throw new Error(message);
|
|
6165
|
+
}
|
|
5822
6166
|
}
|
|
5823
6167
|
};
|
|
5824
6168
|
//#endregion
|
|
@@ -5840,8 +6184,6 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
5840
6184
|
#dbSTSCombo;
|
|
5841
6185
|
#transactions = {};
|
|
5842
6186
|
#maxTransactionTime = 6e4;
|
|
5843
|
-
#replacer = (_, v) => typeof v === "bigint" ? { __bigint__: v.toString() } : v;
|
|
5844
|
-
#reviver = (_, v) => v && v.__bigint__ !== void 0 ? BigInt(v.__bigint__) : v;
|
|
5845
6187
|
constructor(options) {
|
|
5846
6188
|
super();
|
|
5847
6189
|
this.#options = options;
|
|
@@ -5849,18 +6191,34 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
5849
6191
|
logger: this.#options.logger,
|
|
5850
6192
|
usedefaultdb: this.#options.usedefaultdb
|
|
5851
6193
|
});
|
|
5852
|
-
this.#dbSTSResource = new DBSTSResource(
|
|
5853
|
-
|
|
6194
|
+
this.#dbSTSResource = new DBSTSResource({
|
|
6195
|
+
logger: this.#options.logger,
|
|
6196
|
+
poolManager: this.#poolManager
|
|
6197
|
+
});
|
|
6198
|
+
this.#dbSTSResourceVersion = new DBSTSResourceVersion({
|
|
6199
|
+
logger: this.#options.logger,
|
|
6200
|
+
poolManager: this.#poolManager
|
|
6201
|
+
});
|
|
5854
6202
|
this.#dbSearchIndex = DBSearchIndex.getInstance();
|
|
5855
|
-
this.#dbSTSResourceLink = new DBSTSResourceLink();
|
|
5856
|
-
this.#dbSTSString = new DBSTSString();
|
|
5857
|
-
this.#dbSTSToken = new DBSTSToken();
|
|
5858
|
-
this.#dbSTSQuantity = new DBSTSQuantity();
|
|
5859
|
-
this.#dbSTSNumber = new DBSTSNumber();
|
|
5860
|
-
this.#dbSTSDate = new DBSTSDate();
|
|
5861
|
-
this.#dbSTSUri = new DBSTSUri();
|
|
5862
|
-
this.#dbSTSCombo = new DBSTSCombo();
|
|
5863
|
-
}
|
|
6203
|
+
this.#dbSTSResourceLink = new DBSTSResourceLink({ logger: this.#options.logger });
|
|
6204
|
+
this.#dbSTSString = new DBSTSString({ logger: this.#options.logger });
|
|
6205
|
+
this.#dbSTSToken = new DBSTSToken({ logger: this.#options.logger });
|
|
6206
|
+
this.#dbSTSQuantity = new DBSTSQuantity({ logger: this.#options.logger });
|
|
6207
|
+
this.#dbSTSNumber = new DBSTSNumber({ logger: this.#options.logger });
|
|
6208
|
+
this.#dbSTSDate = new DBSTSDate({ logger: this.#options.logger });
|
|
6209
|
+
this.#dbSTSUri = new DBSTSUri({ logger: this.#options.logger });
|
|
6210
|
+
this.#dbSTSCombo = new DBSTSCombo({ logger: this.#options.logger });
|
|
6211
|
+
}
|
|
6212
|
+
GetOperationOutcome = (code, diagnostics) => {
|
|
6213
|
+
return {
|
|
6214
|
+
resourceType: "OperationOutcome",
|
|
6215
|
+
issue: [{
|
|
6216
|
+
severity: "error",
|
|
6217
|
+
code,
|
|
6218
|
+
diagnostics
|
|
6219
|
+
}]
|
|
6220
|
+
};
|
|
6221
|
+
};
|
|
5864
6222
|
async StartDatabase() {
|
|
5865
6223
|
return true;
|
|
5866
6224
|
}
|
|
@@ -6046,14 +6404,14 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6046
6404
|
return false;
|
|
6047
6405
|
};
|
|
6048
6406
|
CreateResource = async (resource, transactionHandle) => {
|
|
6049
|
-
if (this.#poolManager)
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6407
|
+
if (!this.#poolManager) {
|
|
6408
|
+
const errorMessage = `CreateResource(): poolManager not set`;
|
|
6409
|
+
this.#options.logger.error(errorMessage);
|
|
6410
|
+
throw new Error(errorMessage);
|
|
6411
|
+
}
|
|
6412
|
+
let client;
|
|
6413
|
+
let useTransaction;
|
|
6414
|
+
try {
|
|
6057
6415
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
6058
6416
|
client = this.#transactions[transactionHandle].client;
|
|
6059
6417
|
useTransaction = false;
|
|
@@ -6061,50 +6419,72 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6061
6419
|
client = await this.#poolManager.connectReadWrite();
|
|
6062
6420
|
useTransaction = true;
|
|
6063
6421
|
}
|
|
6064
|
-
try {
|
|
6065
|
-
if (useTransaction) await client.query("BEGIN");
|
|
6066
|
-
await this.#dbSTSResource.InsertResourceEx(client, {
|
|
6067
|
-
PID: PK,
|
|
6068
|
-
PARTITION_ID: 0,
|
|
6069
|
-
PARTITION_DATE: 0,
|
|
6070
|
-
RES_ID,
|
|
6071
|
-
RES_TYPE,
|
|
6072
|
-
RES_VER: 1,
|
|
6073
|
-
RES_VERSION: "r5",
|
|
6074
|
-
RES_PUBLISHED: now,
|
|
6075
|
-
RES_UPDATED: now
|
|
6076
|
-
});
|
|
6077
|
-
await this.#dbSTSResourceVersion.InsertResourceVersionEx(client, {
|
|
6078
|
-
PID: (0, node_crypto.randomUUID)(),
|
|
6079
|
-
PARTITION_ID: 0,
|
|
6080
|
-
PARTITION_DATE: 0,
|
|
6081
|
-
RES_ID,
|
|
6082
|
-
RES_TYPE,
|
|
6083
|
-
RES_VER: 1,
|
|
6084
|
-
OPERATION: "POST",
|
|
6085
|
-
RES
|
|
6086
|
-
});
|
|
6087
|
-
performance.now();
|
|
6088
|
-
await this.UpdateIndexes(client, resource);
|
|
6089
|
-
if (useTransaction) await client.query("COMMIT");
|
|
6090
|
-
return resource;
|
|
6091
|
-
} catch (error) {
|
|
6092
|
-
if (useTransaction) await client.query("ROLLBACK");
|
|
6093
|
-
} finally {
|
|
6094
|
-
if (useTransaction) client.release();
|
|
6095
|
-
}
|
|
6096
6422
|
} catch (error) {
|
|
6097
|
-
|
|
6423
|
+
const errorMessage = `CreateResource(): Could not get connection: Error: [${error}]`;
|
|
6424
|
+
this.#options.logger.error(errorMessage);
|
|
6425
|
+
throw new Error(errorMessage);
|
|
6098
6426
|
}
|
|
6099
|
-
|
|
6100
|
-
UpdateResource = async (resource, RES_VER, operation, transactionHandle) => {
|
|
6101
|
-
if (this.#poolManager) try {
|
|
6427
|
+
try {
|
|
6102
6428
|
const RES_ID = resource.id;
|
|
6103
6429
|
const RES_TYPE = resource.resourceType;
|
|
6104
|
-
const RES = JSON.stringify(resource);
|
|
6105
6430
|
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
6106
|
-
|
|
6107
|
-
|
|
6431
|
+
if (useTransaction) await client.query("BEGIN");
|
|
6432
|
+
const newVersion = await this.#dbSTSResource.InsertResourceEx(client, {
|
|
6433
|
+
PID: (0, node_crypto.randomUUID)(),
|
|
6434
|
+
PARTITION_ID: 0,
|
|
6435
|
+
PARTITION_DATE: 0,
|
|
6436
|
+
RES_ID,
|
|
6437
|
+
RES_TYPE,
|
|
6438
|
+
RES_VER: 1,
|
|
6439
|
+
RES_VERSION: "r5",
|
|
6440
|
+
RES_PUBLISHED: now,
|
|
6441
|
+
RES_UPDATED: now
|
|
6442
|
+
});
|
|
6443
|
+
if (newVersion === void 0) {
|
|
6444
|
+
const errorMessage = `CreateResource(): Version Conflict. newVersion is undefined.`;
|
|
6445
|
+
this.#options.logger.error(errorMessage);
|
|
6446
|
+
throw new Error(errorMessage);
|
|
6447
|
+
}
|
|
6448
|
+
resource.meta ??= {};
|
|
6449
|
+
resource.meta.versionId = String(newVersion);
|
|
6450
|
+
resource.meta.lastUpdated = new Date(now).toISOString();
|
|
6451
|
+
const RES = JSON.stringify(resource);
|
|
6452
|
+
if (await this.#dbSTSResourceVersion.InsertResourceVersionEx(client, {
|
|
6453
|
+
PID: (0, node_crypto.randomUUID)(),
|
|
6454
|
+
PARTITION_ID: 0,
|
|
6455
|
+
PARTITION_DATE: 0,
|
|
6456
|
+
RES_ID,
|
|
6457
|
+
RES_TYPE,
|
|
6458
|
+
RES_VER: newVersion,
|
|
6459
|
+
OPERATION: "POST",
|
|
6460
|
+
RES
|
|
6461
|
+
}) === void 0) {
|
|
6462
|
+
const errorMessage = `CreateResource(): Version Conflict. resourceVersionRunResult is undefined.`;
|
|
6463
|
+
this.#options.logger.error(errorMessage);
|
|
6464
|
+
throw new Error(errorMessage);
|
|
6465
|
+
}
|
|
6466
|
+
performance.now();
|
|
6467
|
+
await this.UpdateIndexes(client, resource);
|
|
6468
|
+
if (useTransaction) await client.query("COMMIT");
|
|
6469
|
+
return resource;
|
|
6470
|
+
} catch (error) {
|
|
6471
|
+
if (useTransaction) await client.query("ROLLBACK");
|
|
6472
|
+
const errorMessage = `CreateResource(): Error: [${error}]`;
|
|
6473
|
+
this.#options.logger.error(errorMessage);
|
|
6474
|
+
throw new Error(errorMessage);
|
|
6475
|
+
} finally {
|
|
6476
|
+
if (useTransaction) client.release();
|
|
6477
|
+
}
|
|
6478
|
+
};
|
|
6479
|
+
UpdateResource = async (resource, RES_VER, operation, transactionHandle) => {
|
|
6480
|
+
if (!this.#poolManager) {
|
|
6481
|
+
const errorMessage = `UpdateResource(): poolManager not set`;
|
|
6482
|
+
this.#options.logger.error(errorMessage);
|
|
6483
|
+
throw new Error(errorMessage);
|
|
6484
|
+
}
|
|
6485
|
+
let client;
|
|
6486
|
+
let useTransaction;
|
|
6487
|
+
try {
|
|
6108
6488
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
6109
6489
|
client = this.#transactions[transactionHandle].client;
|
|
6110
6490
|
useTransaction = false;
|
|
@@ -6112,43 +6492,66 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6112
6492
|
client = await this.#poolManager.connectReadWrite();
|
|
6113
6493
|
useTransaction = true;
|
|
6114
6494
|
}
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
}
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6495
|
+
} catch (error) {
|
|
6496
|
+
const errorMessage = `UpdateResource(): Could not get connection: Error: [${error}]`;
|
|
6497
|
+
this.#options.logger.error(errorMessage);
|
|
6498
|
+
throw new Error(errorMessage);
|
|
6499
|
+
}
|
|
6500
|
+
try {
|
|
6501
|
+
const RES_ID = resource.id;
|
|
6502
|
+
const RES_TYPE = resource.resourceType;
|
|
6503
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
6504
|
+
if (useTransaction) await client.query("BEGIN");
|
|
6505
|
+
const newVersion = await this.#dbSTSResource.UpdateResourceRecordEx(client, {
|
|
6506
|
+
RES_TYPE,
|
|
6507
|
+
RES_ID,
|
|
6508
|
+
RES_VER,
|
|
6509
|
+
RES_UPDATED: now
|
|
6510
|
+
});
|
|
6511
|
+
if (newVersion === void 0) {
|
|
6512
|
+
const errorMessage = `UpdateResource(): Version Conflict. newVersion is undefined. RES_VER: [${RES_VER}]`;
|
|
6513
|
+
this.#options.logger.error(errorMessage);
|
|
6514
|
+
throw new Error(errorMessage);
|
|
6515
|
+
}
|
|
6516
|
+
resource.meta ??= {};
|
|
6517
|
+
resource.meta.versionId = String(newVersion);
|
|
6518
|
+
resource.meta.lastUpdated = new Date(now).toISOString();
|
|
6519
|
+
const RES = JSON.stringify(resource);
|
|
6520
|
+
if (await this.#dbSTSResourceVersion.InsertResourceVersionEx(client, {
|
|
6521
|
+
PID: (0, node_crypto.randomUUID)(),
|
|
6522
|
+
PARTITION_ID: 0,
|
|
6523
|
+
PARTITION_DATE: 0,
|
|
6524
|
+
RES_ID,
|
|
6525
|
+
RES_TYPE,
|
|
6526
|
+
RES_VER: newVersion,
|
|
6527
|
+
OPERATION: operation,
|
|
6528
|
+
RES
|
|
6529
|
+
}) === void 0) {
|
|
6530
|
+
const errorMessage = `UpdateResource(): Version Conflict. resourceVersionRunResult is undefined. RES_VER: [${RES_VER}]`;
|
|
6531
|
+
this.#options.logger.error(errorMessage);
|
|
6532
|
+
throw new Error(errorMessage);
|
|
6140
6533
|
}
|
|
6534
|
+
await this.UpdateIndexes(client, resource);
|
|
6535
|
+
if (useTransaction) await client.query("COMMIT");
|
|
6536
|
+
return resource;
|
|
6141
6537
|
} catch (error) {
|
|
6142
|
-
|
|
6538
|
+
if (useTransaction) await client.query("ROLLBACK");
|
|
6539
|
+
const errorMessage = `UpdateResource(): Error: [${error}]`;
|
|
6540
|
+
this.#options.logger.error(errorMessage);
|
|
6541
|
+
throw new Error(errorMessage);
|
|
6542
|
+
} finally {
|
|
6543
|
+
if (useTransaction) client.release();
|
|
6143
6544
|
}
|
|
6144
6545
|
};
|
|
6145
6546
|
DeleteResource = async (resource, RES_VER, transactionHandle) => {
|
|
6146
|
-
if (this.#poolManager)
|
|
6147
|
-
const
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6547
|
+
if (!this.#poolManager) {
|
|
6548
|
+
const errorMessage = `DeleteResource(): poolManager not set`;
|
|
6549
|
+
this.#options.logger.error(errorMessage);
|
|
6550
|
+
throw new Error(errorMessage);
|
|
6551
|
+
}
|
|
6552
|
+
let client;
|
|
6553
|
+
let useTransaction;
|
|
6554
|
+
try {
|
|
6152
6555
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
6153
6556
|
client = this.#transactions[transactionHandle].client;
|
|
6154
6557
|
useTransaction = false;
|
|
@@ -6156,39 +6559,64 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6156
6559
|
client = await this.#poolManager.connectReadWrite();
|
|
6157
6560
|
useTransaction = true;
|
|
6158
6561
|
}
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
}
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
return resource;
|
|
6181
|
-
} catch (error) {
|
|
6182
|
-
if (useTransaction) await client.query("ROLLBACK");
|
|
6183
|
-
} finally {
|
|
6184
|
-
if (useTransaction) client.release();
|
|
6562
|
+
} catch (error) {
|
|
6563
|
+
const errorMessage = `DeleteResource(): Could not get connection: Error: [${error}]`;
|
|
6564
|
+
this.#options.logger.error(errorMessage);
|
|
6565
|
+
throw new Error(errorMessage);
|
|
6566
|
+
}
|
|
6567
|
+
try {
|
|
6568
|
+
const RES_ID = resource.id;
|
|
6569
|
+
const RES_TYPE = resource.resourceType;
|
|
6570
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
6571
|
+
if (useTransaction) await client.query("BEGIN");
|
|
6572
|
+
const newVersion = await this.#dbSTSResource.DeleteResourceRecordEx(client, {
|
|
6573
|
+
RES_ID,
|
|
6574
|
+
RES_TYPE,
|
|
6575
|
+
RES_VER,
|
|
6576
|
+
RES_DELETED_AT: now,
|
|
6577
|
+
RES_UPDATED: now
|
|
6578
|
+
});
|
|
6579
|
+
if (newVersion === void 0) {
|
|
6580
|
+
const errorMessage = `DeleteResource(): Version Conflict. newVersion is undefined. RES_VER: [${RES_VER}]`;
|
|
6581
|
+
this.#options.logger.error(errorMessage);
|
|
6582
|
+
throw new Error(errorMessage);
|
|
6185
6583
|
}
|
|
6584
|
+
resource.meta ??= {};
|
|
6585
|
+
resource.meta.versionId = String(newVersion);
|
|
6586
|
+
resource.meta.lastUpdated = new Date(now).toISOString();
|
|
6587
|
+
if (await this.#dbSTSResourceVersion.InsertResourceVersionEx(client, {
|
|
6588
|
+
PID: (0, node_crypto.randomUUID)(),
|
|
6589
|
+
PARTITION_ID: 0,
|
|
6590
|
+
PARTITION_DATE: 0,
|
|
6591
|
+
RES_ID,
|
|
6592
|
+
RES_TYPE,
|
|
6593
|
+
RES_VER: newVersion,
|
|
6594
|
+
OPERATION: "DELETE",
|
|
6595
|
+
RES: ""
|
|
6596
|
+
}) === void 0) {
|
|
6597
|
+
const errorMessage = `DeleteResource(): Version Conflict. resourceVersionRunResult is undefined. RES_VER: [${RES_VER}]`;
|
|
6598
|
+
this.#options.logger.error(errorMessage);
|
|
6599
|
+
throw new Error(errorMessage);
|
|
6600
|
+
}
|
|
6601
|
+
await this.UpdateIndexes(client, resource);
|
|
6602
|
+
if (useTransaction) await client.query("COMMIT");
|
|
6603
|
+
return resource;
|
|
6186
6604
|
} catch (error) {
|
|
6187
|
-
|
|
6605
|
+
if (useTransaction) await client.query("ROLLBACK");
|
|
6606
|
+
const errorMessage = `DeleteResource(): Error: [${error}]`;
|
|
6607
|
+
this.#options.logger.error(errorMessage);
|
|
6608
|
+
throw new Error(errorMessage);
|
|
6609
|
+
} finally {
|
|
6610
|
+
if (useTransaction) client.release();
|
|
6188
6611
|
}
|
|
6189
6612
|
};
|
|
6190
6613
|
ReadResourceRecord = async (RES_TYPE, RES_ID, transactionHandle) => {
|
|
6191
|
-
if (this.#poolManager)
|
|
6614
|
+
if (!this.#poolManager) {
|
|
6615
|
+
const errorMessage = `ReadResourceRecord(): poolManager not set`;
|
|
6616
|
+
this.#options.logger.error(errorMessage);
|
|
6617
|
+
throw new Error(errorMessage);
|
|
6618
|
+
}
|
|
6619
|
+
try {
|
|
6192
6620
|
let client;
|
|
6193
6621
|
let useTransaction;
|
|
6194
6622
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6200,19 +6628,19 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6200
6628
|
}
|
|
6201
6629
|
try {
|
|
6202
6630
|
return (await client.query(`
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6631
|
+
SELECT
|
|
6632
|
+
r.*, v.* FROM stsresfhir r
|
|
6633
|
+
JOIN
|
|
6634
|
+
stsresfhirver v
|
|
6635
|
+
ON
|
|
6636
|
+
r.RES_ID = v.RES_ID AND
|
|
6637
|
+
r.RES_TYPE = v.RES_TYPE AND
|
|
6638
|
+
r.RES_VER = v.RES_VER
|
|
6639
|
+
WHERE
|
|
6640
|
+
r.RES_ID = $1 AND
|
|
6641
|
+
r.RES_TYPE = $2 AND
|
|
6642
|
+
r.RES_DELETED_AT IS NULL
|
|
6643
|
+
`, [RES_ID, RES_TYPE])).rows[0];
|
|
6216
6644
|
} catch (error) {
|
|
6217
6645
|
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
6218
6646
|
} finally {
|
|
@@ -6223,7 +6651,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6223
6651
|
}
|
|
6224
6652
|
};
|
|
6225
6653
|
ReadResourceRecordWithVersion = async (RES_TYPE, RES_ID, RES_VER, transactionHandle) => {
|
|
6226
|
-
if (this.#poolManager)
|
|
6654
|
+
if (!this.#poolManager) {
|
|
6655
|
+
const errorMessage = `ReadResourceRecordWithVersion(): poolManager not set`;
|
|
6656
|
+
this.#options.logger.error(errorMessage);
|
|
6657
|
+
throw new Error(errorMessage);
|
|
6658
|
+
}
|
|
6659
|
+
try {
|
|
6227
6660
|
let client;
|
|
6228
6661
|
let useTransaction;
|
|
6229
6662
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6235,18 +6668,18 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6235
6668
|
}
|
|
6236
6669
|
try {
|
|
6237
6670
|
return (await client.query(`
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6671
|
+
SELECT
|
|
6672
|
+
r.*, v.*, r.res_ver as R_res_ver, v.res_ver as V_res_ver FROM stsresfhir r
|
|
6673
|
+
JOIN
|
|
6674
|
+
stsresfhirver v
|
|
6675
|
+
ON
|
|
6676
|
+
r.RES_ID = v.RES_ID AND
|
|
6677
|
+
r.RES_TYPE = v.RES_TYPE
|
|
6678
|
+
WHERE
|
|
6679
|
+
r.RES_ID = $1 AND
|
|
6680
|
+
r.RES_TYPE = $2 AND
|
|
6681
|
+
v.RES_VER = $3
|
|
6682
|
+
`, [
|
|
6250
6683
|
RES_ID,
|
|
6251
6684
|
RES_TYPE,
|
|
6252
6685
|
RES_VER
|
|
@@ -6261,7 +6694,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6261
6694
|
}
|
|
6262
6695
|
};
|
|
6263
6696
|
ReadResourceInstanceWithAllVersions = async (RES_TYPE, RES_ID, transactionHandle) => {
|
|
6264
|
-
if (this.#poolManager)
|
|
6697
|
+
if (!this.#poolManager) {
|
|
6698
|
+
const errorMessage = `ReadResourceInstanceWithAllVersions(): poolManager not set`;
|
|
6699
|
+
this.#options.logger.error(errorMessage);
|
|
6700
|
+
throw new Error(errorMessage);
|
|
6701
|
+
}
|
|
6702
|
+
try {
|
|
6265
6703
|
let client;
|
|
6266
6704
|
let useTransaction;
|
|
6267
6705
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6273,19 +6711,19 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6273
6711
|
}
|
|
6274
6712
|
try {
|
|
6275
6713
|
return (await client.query(`
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6714
|
+
SELECT
|
|
6715
|
+
r.*, v.*, r.res_ver as R_res_ver, v.res_ver as V_res_ver FROM stsresfhir r
|
|
6716
|
+
JOIN
|
|
6717
|
+
stsresfhirver v
|
|
6718
|
+
ON
|
|
6719
|
+
r.RES_ID = v.RES_ID AND
|
|
6720
|
+
r.RES_TYPE = v.RES_TYPE
|
|
6721
|
+
WHERE
|
|
6722
|
+
r.RES_ID = $1 AND
|
|
6723
|
+
r.RES_TYPE = $2
|
|
6724
|
+
ORDER BY
|
|
6725
|
+
v.RES_TYPE ASC, v.RES_ID ASC, v.RES_VER DESC
|
|
6726
|
+
`, [RES_ID, RES_TYPE])).rows;
|
|
6289
6727
|
} catch (error) {
|
|
6290
6728
|
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
6291
6729
|
} finally {
|
|
@@ -6296,7 +6734,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6296
6734
|
}
|
|
6297
6735
|
};
|
|
6298
6736
|
ReadResourcesWithAllVersions = async (RES_TYPE, transactionHandle) => {
|
|
6299
|
-
if (this.#poolManager)
|
|
6737
|
+
if (!this.#poolManager) {
|
|
6738
|
+
const errorMessage = `ReadResourcesWithAllVersions(): poolManager not set`;
|
|
6739
|
+
this.#options.logger.error(errorMessage);
|
|
6740
|
+
throw new Error(errorMessage);
|
|
6741
|
+
}
|
|
6742
|
+
try {
|
|
6300
6743
|
let client;
|
|
6301
6744
|
let useTransaction;
|
|
6302
6745
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6308,18 +6751,18 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6308
6751
|
}
|
|
6309
6752
|
try {
|
|
6310
6753
|
return (await client.query(`
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6754
|
+
SELECT
|
|
6755
|
+
r.*, v.*, r.res_ver as R_res_ver, v.res_ver as V_res_ver FROM stsresfhir r
|
|
6756
|
+
JOIN
|
|
6757
|
+
stsresfhirver v
|
|
6758
|
+
ON
|
|
6759
|
+
r.RES_ID = v.RES_ID AND
|
|
6760
|
+
r.RES_TYPE = v.RES_TYPE
|
|
6761
|
+
WHERE
|
|
6762
|
+
r.RES_TYPE = $1
|
|
6763
|
+
ORDER BY
|
|
6764
|
+
v.RES_TYPE ASC, v.RES_ID ASC, v.RES_VER DESC
|
|
6765
|
+
`, [RES_TYPE])).rows;
|
|
6323
6766
|
} catch (error) {
|
|
6324
6767
|
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
6325
6768
|
} finally {
|
|
@@ -6330,7 +6773,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6330
6773
|
}
|
|
6331
6774
|
};
|
|
6332
6775
|
ReadAllResourcesWithVersions = async (transactionHandle) => {
|
|
6333
|
-
if (this.#poolManager)
|
|
6776
|
+
if (!this.#poolManager) {
|
|
6777
|
+
const errorMessage = `ReadAllResourcesWithVersions(): poolManager not set`;
|
|
6778
|
+
this.#options.logger.error(errorMessage);
|
|
6779
|
+
throw new Error(errorMessage);
|
|
6780
|
+
}
|
|
6781
|
+
try {
|
|
6334
6782
|
let client;
|
|
6335
6783
|
let useTransaction;
|
|
6336
6784
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6342,16 +6790,16 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6342
6790
|
}
|
|
6343
6791
|
try {
|
|
6344
6792
|
return (await client.query(`
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6793
|
+
SELECT
|
|
6794
|
+
r.*, v.* FROM stsresfhir r
|
|
6795
|
+
JOIN
|
|
6796
|
+
stsresfhirver v
|
|
6797
|
+
ON
|
|
6798
|
+
r.RES_ID = v.RES_ID AND
|
|
6799
|
+
r.RES_TYPE = v.RES_TYPE AND
|
|
6800
|
+
ORDER BY
|
|
6801
|
+
v.RES_TYPE ASC, v.RES_ID ASC, v.RES_VER DESC
|
|
6802
|
+
`)).rows;
|
|
6355
6803
|
} catch (error) {
|
|
6356
6804
|
_nsshunt_stsutils.defaultLogger.error(`DBSTSResource:ReadResourceRecord(): Query Error: [${error}]`);
|
|
6357
6805
|
} finally {
|
|
@@ -6365,7 +6813,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6365
6813
|
return this.#dbSTSResourceVersion.ReadAllResourceVersionRecords();
|
|
6366
6814
|
};
|
|
6367
6815
|
ReadResourceIndexes = async (resource, transactionHandle) => {
|
|
6368
|
-
if (this.#poolManager)
|
|
6816
|
+
if (!this.#poolManager) {
|
|
6817
|
+
const errorMessage = `ReadResourceIndexes(): poolManager not set`;
|
|
6818
|
+
this.#options.logger.error(errorMessage);
|
|
6819
|
+
throw new Error(errorMessage);
|
|
6820
|
+
}
|
|
6821
|
+
try {
|
|
6369
6822
|
const resultSet = {
|
|
6370
6823
|
"stsresfhirlink": [],
|
|
6371
6824
|
"stsresfhirstring": [],
|
|
@@ -6405,7 +6858,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6405
6858
|
}
|
|
6406
6859
|
};
|
|
6407
6860
|
ExecuteReadQuery = async (queryData, transactionHandle) => {
|
|
6408
|
-
if (this.#poolManager)
|
|
6861
|
+
if (!this.#poolManager) {
|
|
6862
|
+
const errorMessage = `ExecuteReadQuery(): poolManager not set`;
|
|
6863
|
+
this.#options.logger.error(errorMessage);
|
|
6864
|
+
throw new Error(errorMessage);
|
|
6865
|
+
}
|
|
6866
|
+
try {
|
|
6409
6867
|
let client;
|
|
6410
6868
|
let useTransaction;
|
|
6411
6869
|
if (transactionHandle && this.#transactions[transactionHandle]) {
|
|
@@ -6428,7 +6886,12 @@ var PGFhirAccessLayer = class extends tiny_emitter.TinyEmitter {
|
|
|
6428
6886
|
}
|
|
6429
6887
|
};
|
|
6430
6888
|
TruncateAll = async () => {
|
|
6431
|
-
if (this.#poolManager)
|
|
6889
|
+
if (!this.#poolManager) {
|
|
6890
|
+
const errorMessage = `TruncateAll(): poolManager not set`;
|
|
6891
|
+
this.#options.logger.error(errorMessage);
|
|
6892
|
+
throw new Error(errorMessage);
|
|
6893
|
+
}
|
|
6894
|
+
try {
|
|
6432
6895
|
let client;
|
|
6433
6896
|
client = await this.#poolManager.connectReadWrite();
|
|
6434
6897
|
try {
|