@icure/api 4.2.31 → 5.0.3
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/icc-api/api/IccDeviceApi.d.ts +3 -3
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +3 -3
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +3 -3
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccUserApi.js +1 -1
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/api/XHR.js +2 -1
- package/icc-api/api/XHR.js.map +1 -1
- package/icc-api/iccApi.js +5 -1
- package/icc-api/iccApi.js.map +1 -1
- package/icc-api/index.js +5 -1
- package/icc-api/index.js.map +1 -1
- package/icc-api/model/Body.js +1 -1
- package/icc-api/model/Body.js.map +1 -1
- package/icc-api/model/Body1.js +1 -1
- package/icc-api/model/Body1.js.map +1 -1
- package/icc-api/model/Body2.js +1 -1
- package/icc-api/model/Body2.js.map +1 -1
- package/icc-api/model/Body3.js +1 -1
- package/icc-api/model/Body3.js.map +1 -1
- package/icc-api/model/ByteArray.js +1 -1
- package/icc-api/model/ByteArray.js.map +1 -1
- package/icc-api/model/Content.js +1 -1
- package/icc-api/model/Content.js.map +1 -1
- package/icc-api/model/Device.js +1 -1
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/Document.js +1 -1
- package/icc-api/model/Document.js.map +1 -1
- package/icc-api/model/DocumentTemplate.js +1 -1
- package/icc-api/model/DocumentTemplate.js.map +1 -1
- package/icc-api/model/HealthcareParty.js +1 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/MimeAttachment.js +1 -1
- package/icc-api/model/MimeAttachment.js.map +1 -1
- package/icc-api/model/Patient.js +1 -1
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-api/model/models.d.ts +15 -0
- package/icc-api/model/models.js +5 -1
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/crypto/AES.d.ts +2 -1
- package/icc-x-api/crypto/AES.js +37 -10
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/RSA.d.ts +0 -31
- package/icc-x-api/crypto/RSA.js +0 -64
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/shamir.js.map +1 -1
- package/icc-x-api/filters/filters.js +7 -3
- package/icc-x-api/filters/filters.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +25 -22
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js +2 -2
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -2
- package/icc-x-api/icc-calendar-item-x-api.js +43 -30
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.js +59 -45
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +127 -54
- package/icc-x-api/icc-crypto-x-api.js +830 -393
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js +2 -2
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.js +3 -3
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +3 -3
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.js +4 -4
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +1 -1
- package/icc-x-api/icc-helement-x-api.js +34 -29
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +5 -6
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +1 -1
- package/icc-x-api/icc-patient-x-api.js +65 -53
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +1 -2
- package/icc-x-api/index.js +9 -8
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/binary-utils.js +5 -5
- package/icc-x-api/utils/binary-utils.js.map +1 -1
- package/icc-x-api/utils/crypto-utils.d.ts +61 -0
- package/icc-x-api/utils/crypto-utils.js +245 -0
- package/icc-x-api/utils/crypto-utils.js.map +1 -0
- package/icc-x-api/utils/formatting-util.js +3 -3
- package/icc-x-api/utils/formatting-util.js.map +1 -1
- package/icc-x-api/utils/functional-util.d.ts +1 -0
- package/icc-x-api/utils/functional-util.js +8 -1
- package/icc-x-api/utils/functional-util.js.map +1 -1
- package/icc-x-api/utils/index.d.ts +1 -0
- package/icc-x-api/utils/index.js +6 -1
- package/icc-x-api/utils/index.js.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/node-compat.d.ts +1 -1
- package/node-compat.js +3 -3
- package/node-compat.js.map +1 -1
- package/package.json +2 -2
- package/icc-x-api/crypto/utils.d.ts +0 -68
- package/icc-x-api/crypto/utils.js +0 -239
- package/icc-x-api/crypto/utils.js.map +0 -1
|
@@ -14,11 +14,10 @@ const icc_api_1 = require("../icc-api");
|
|
|
14
14
|
const _ = require("lodash");
|
|
15
15
|
const models = require("../icc-api/model/models");
|
|
16
16
|
const models_1 = require("../icc-api/model/models");
|
|
17
|
-
const utils_1 = require("./crypto/utils");
|
|
18
17
|
const ModelHelper_1 = require("../icc-api/model/ModelHelper");
|
|
19
18
|
const binary_utils_1 = require("./utils/binary-utils");
|
|
20
19
|
const person_util_1 = require("./utils/person-util");
|
|
21
|
-
const
|
|
20
|
+
const utils_1 = require("./utils");
|
|
22
21
|
// noinspection JSUnusedGlobalSymbols
|
|
23
22
|
class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
24
23
|
constructor(host, headers, crypto, contactApi, formApi, helementApi, invoiceApi, documentApi, hcpartyApi, classificationApi, userApi, calendarItemaApi, encryptedKeys = ['note'], fetchImpl = typeof window !== 'undefined'
|
|
@@ -51,44 +50,50 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
51
50
|
codes: [],
|
|
52
51
|
tags: [],
|
|
53
52
|
}, p || {});
|
|
54
|
-
return this.
|
|
53
|
+
return this.initDelegationsAndEncryptionKeys(patient, user, undefined, delegates);
|
|
55
54
|
}
|
|
56
55
|
completeNames(patient) {
|
|
57
56
|
var _a;
|
|
58
57
|
let finalPatient = patient;
|
|
59
|
-
if (!!finalPatient.lastName && !person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Official)) {
|
|
60
|
-
finalPatient = person_util_1.garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Official, finalPatient.lastName, finalPatient.firstName);
|
|
58
|
+
if (!!finalPatient.lastName && !(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Official)) {
|
|
59
|
+
finalPatient = (0, person_util_1.garnishPersonWithName)(finalPatient, models.PersonName.UseEnum.Official, finalPatient.lastName, finalPatient.firstName);
|
|
61
60
|
}
|
|
62
|
-
if (!!finalPatient.maidenName && !person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {
|
|
63
|
-
finalPatient = person_util_1.garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Maiden, finalPatient.maidenName, finalPatient.firstName);
|
|
61
|
+
if (!!finalPatient.maidenName && !(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Maiden)) {
|
|
62
|
+
finalPatient = (0, person_util_1.garnishPersonWithName)(finalPatient, models.PersonName.UseEnum.Maiden, finalPatient.maidenName, finalPatient.firstName);
|
|
64
63
|
}
|
|
65
|
-
if (!!finalPatient.alias && !person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {
|
|
66
|
-
finalPatient = person_util_1.garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Nickname, finalPatient.alias, finalPatient.firstName);
|
|
64
|
+
if (!!finalPatient.alias && !(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Nickname)) {
|
|
65
|
+
finalPatient = (0, person_util_1.garnishPersonWithName)(finalPatient, models.PersonName.UseEnum.Nickname, finalPatient.alias, finalPatient.firstName);
|
|
67
66
|
}
|
|
68
|
-
if (!finalPatient.lastName && !!person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Official)) {
|
|
69
|
-
let officialName = person_util_1.findName(finalPatient, models.PersonName.UseEnum.Official);
|
|
67
|
+
if (!finalPatient.lastName && !!(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Official)) {
|
|
68
|
+
let officialName = (0, person_util_1.findName)(finalPatient, models.PersonName.UseEnum.Official);
|
|
70
69
|
finalPatient = Object.assign(Object.assign({}, finalPatient), { lastName: officialName.lastName, firstName: (_a = officialName.firstNames) === null || _a === void 0 ? void 0 : _a[0] });
|
|
71
70
|
}
|
|
72
|
-
if (!finalPatient.maidenName && !!person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {
|
|
73
|
-
finalPatient = Object.assign(Object.assign({}, finalPatient), { maidenName: person_util_1.findName(finalPatient, models.PersonName.UseEnum.Maiden).lastName });
|
|
71
|
+
if (!finalPatient.maidenName && !!(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Maiden)) {
|
|
72
|
+
finalPatient = Object.assign(Object.assign({}, finalPatient), { maidenName: (0, person_util_1.findName)(finalPatient, models.PersonName.UseEnum.Maiden).lastName });
|
|
74
73
|
}
|
|
75
|
-
if (!finalPatient.alias && !!person_util_1.hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {
|
|
76
|
-
finalPatient = Object.assign(Object.assign({}, finalPatient), { alias: person_util_1.findName(finalPatient, models.PersonName.UseEnum.Nickname).lastName });
|
|
74
|
+
if (!finalPatient.alias && !!(0, person_util_1.hasName)(finalPatient, models.PersonName.UseEnum.Nickname)) {
|
|
75
|
+
finalPatient = Object.assign(Object.assign({}, finalPatient), { alias: (0, person_util_1.findName)(finalPatient, models.PersonName.UseEnum.Nickname).lastName });
|
|
77
76
|
}
|
|
78
77
|
return finalPatient;
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
initDelegationsAndEncryptionKeys(patient, user, secretForeignKey = undefined, delegates = []) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const dataOwnerId = this.userApi.getDataOwnerOf(user);
|
|
82
|
+
const dels = yield this.crypto.initObjectDelegations(patient, null, dataOwnerId, null);
|
|
83
|
+
const eks = yield this.crypto.initEncryptionKeys(patient, dataOwnerId);
|
|
84
|
+
_.extend(patient, {
|
|
85
|
+
delegations: dels.delegations,
|
|
86
|
+
encryptionKeys: eks.encryptionKeys,
|
|
87
|
+
});
|
|
84
88
|
let promise = Promise.resolve(patient);
|
|
85
|
-
_.uniq(delegates.concat(user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : [])).forEach((delegateId) => (promise = promise
|
|
86
|
-
.then((patient) => this.crypto.extendedDelegationsAndCryptedForeignKeys(patient, null, dataOwnerId, delegateId, initData.secretId))
|
|
87
|
-
.then((extraData) => _.extend(patient, { delegations: extraData.delegations }))
|
|
88
|
-
.catch((e) => {
|
|
89
|
+
_.uniq(delegates.concat(user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : [])).forEach((delegateId) => (promise = promise.then((patient) => this.crypto.addDelegationsAndEncryptionKeys(null, patient, dataOwnerId, delegateId, dels.secretId, eks.secretId).catch((e) => {
|
|
89
90
|
console.log(e);
|
|
90
91
|
return patient;
|
|
91
|
-
})));
|
|
92
|
+
}))));
|
|
93
|
+
(user.autoDelegations && user.autoDelegations.anonymousMedicalInformation ? user.autoDelegations.anonymousMedicalInformation : []).forEach((delegateId) => (promise = promise.then((patient) => this.crypto.addDelegationsAndEncryptionKeys(null, patient, dataOwnerId, delegateId, null, eks.secretId).catch((e) => {
|
|
94
|
+
console.log(e);
|
|
95
|
+
return patient;
|
|
96
|
+
}))));
|
|
92
97
|
return promise;
|
|
93
98
|
});
|
|
94
99
|
}
|
|
@@ -100,7 +105,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
100
105
|
return this.crypto
|
|
101
106
|
.decryptAndImportAesHcPartyKeysForDelegators([dataOwnerId], dataOwnerId)
|
|
102
107
|
.then((hcPartyKeys) => {
|
|
103
|
-
return this.crypto.AES.encrypt(hcPartyKeys[0].key, binary_utils_1.string2ua(patient.id + ':' + secretId).buffer);
|
|
108
|
+
return this.crypto.AES.encrypt(hcPartyKeys[0].key, (0, binary_utils_1.string2ua)(patient.id + ':' + secretId).buffer);
|
|
104
109
|
})
|
|
105
110
|
.then((newDelegation) => {
|
|
106
111
|
;
|
|
@@ -108,7 +113,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
108
113
|
owner: dataOwnerId,
|
|
109
114
|
delegatedTo: dataOwnerId,
|
|
110
115
|
tag: 'confidential',
|
|
111
|
-
key: binary_utils_1.ua2hex(newDelegation),
|
|
116
|
+
key: (0, binary_utils_1.ua2hex)(newDelegation),
|
|
112
117
|
}));
|
|
113
118
|
return patient.rev ? this.modifyPatientWithUser(user, patient) : this.createPatientWithUser(user, patient);
|
|
114
119
|
});
|
|
@@ -275,11 +280,20 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
275
280
|
return Promise.all(pats.map((p) => (p.encryptionKeys && Object.keys(p.encryptionKeys).some((k) => !!p.encryptionKeys[k].length)
|
|
276
281
|
? Promise.resolve(p)
|
|
277
282
|
: this.initEncryptionKeys(user, p))
|
|
278
|
-
.then((p) => this
|
|
279
|
-
|
|
280
|
-
|
|
283
|
+
.then((p) => __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
try {
|
|
285
|
+
const seks = yield this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, p.id, p.encryptionKeys);
|
|
286
|
+
return seks;
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
console.error(e);
|
|
290
|
+
throw e;
|
|
291
|
+
}
|
|
292
|
+
}))
|
|
293
|
+
.then((seks) => this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(seks.extractedKeys[0].replace(/-/g, ''))))
|
|
294
|
+
.then((key) => (0, utils_1.crypt)(p, (obj) => this.crypto.AES.encrypt(key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj, (k, v) => {
|
|
281
295
|
return v instanceof ArrayBuffer || v instanceof Uint8Array
|
|
282
|
-
? binary_utils_1.b2a(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))
|
|
296
|
+
? (0, binary_utils_1.b2a)(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))
|
|
283
297
|
: v;
|
|
284
298
|
}))), this.encryptedKeys))));
|
|
285
299
|
}
|
|
@@ -294,7 +308,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
294
308
|
let prom = Promise.resolve({});
|
|
295
309
|
fillDelegations &&
|
|
296
310
|
patsWithMissingDelegations.forEach((p) => {
|
|
297
|
-
prom = prom.then((acc) => this.
|
|
311
|
+
prom = prom.then((acc) => this.initDelegationsAndEncryptionKeys(p, user).then((p) => this.modifyPatientWithUser(user, p).then((mp) => {
|
|
298
312
|
acc[p.id] = mp || p;
|
|
299
313
|
return acc;
|
|
300
314
|
})));
|
|
@@ -314,10 +328,9 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
314
328
|
//console.log("Cannot decrypt contact", ctc.id)
|
|
315
329
|
return Promise.resolve(p);
|
|
316
330
|
}
|
|
317
|
-
return this.crypto.AES.importKey('raw', binary_utils_1.hex2ua(sfks[0].replace(/-/g, ''))).then((key) => utils_1.
|
|
318
|
-
.decrypt(p, (ec) => this.crypto.AES.decrypt(key, ec)
|
|
331
|
+
return this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks[0].replace(/-/g, ''))).then((key) => (0, utils_1.decrypt)(p, (ec) => this.crypto.AES.decrypt(key, ec)
|
|
319
332
|
.then((dec) => {
|
|
320
|
-
const jsonContent = dec && binary_utils_1.ua2utf8(dec);
|
|
333
|
+
const jsonContent = dec && (0, binary_utils_1.ua2utf8)(dec);
|
|
321
334
|
try {
|
|
322
335
|
return JSON.parse(jsonContent);
|
|
323
336
|
}
|
|
@@ -329,10 +342,9 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
329
342
|
.catch((err) => {
|
|
330
343
|
console.log('Cannot decrypt patient', p.id, err);
|
|
331
344
|
return p;
|
|
332
|
-
}))
|
|
333
|
-
.then((p) => {
|
|
345
|
+
})).then((p) => {
|
|
334
346
|
if (p.picture && !(p.picture instanceof ArrayBuffer)) {
|
|
335
|
-
p.picture = ModelHelper_1.b64_2ab(p.picture);
|
|
347
|
+
p.picture = (0, ModelHelper_1.b64_2ab)(p.picture);
|
|
336
348
|
}
|
|
337
349
|
return p;
|
|
338
350
|
}));
|
|
@@ -421,7 +433,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
421
433
|
},
|
|
422
434
|
patient: { success: false, error: null, modified: 0 },
|
|
423
435
|
};
|
|
424
|
-
return
|
|
436
|
+
return (0, utils_1.retry)(() => this.getPatientWithUser(user, patId))
|
|
425
437
|
.then((patient) => patient.encryptionKeys && Object.keys(patient.encryptionKeys || {}).length
|
|
426
438
|
? Promise.resolve(patient)
|
|
427
439
|
: this.initEncryptionKeys(user, patient).then((patient) => this.modifyPatientWithUser(user, patient)))
|
|
@@ -436,42 +448,42 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
436
448
|
return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
|
|
437
449
|
return delSfks.length
|
|
438
450
|
? Promise.all([
|
|
439
|
-
|
|
451
|
+
(0, utils_1.retry)(() => this.helementApi
|
|
440
452
|
.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
441
453
|
.then((hes) => parentId
|
|
442
454
|
? this.helementApi
|
|
443
455
|
.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
444
456
|
.then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
|
|
445
457
|
: hes)),
|
|
446
|
-
|
|
458
|
+
(0, utils_1.retry)(() => this.formApi
|
|
447
459
|
.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
448
460
|
.then((frms) => parentId
|
|
449
461
|
? this.formApi
|
|
450
462
|
.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
451
463
|
.then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
452
464
|
: frms)),
|
|
453
|
-
|
|
465
|
+
(0, utils_1.retry)(() => this.contactApi
|
|
454
466
|
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
|
|
455
467
|
.then((ctcs) => parentId
|
|
456
468
|
? this.contactApi
|
|
457
469
|
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
|
|
458
470
|
.then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
459
471
|
: ctcs)),
|
|
460
|
-
|
|
472
|
+
(0, utils_1.retry)(() => this.invoiceApi
|
|
461
473
|
.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
462
474
|
.then((ivs) => parentId
|
|
463
475
|
? this.invoiceApi
|
|
464
476
|
.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
465
477
|
.then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
|
|
466
478
|
: ivs)),
|
|
467
|
-
|
|
479
|
+
(0, utils_1.retry)(() => this.classificationApi
|
|
468
480
|
.findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
469
481
|
.then((cls) => parentId
|
|
470
482
|
? this.classificationApi
|
|
471
483
|
.findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
472
484
|
.then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
|
|
473
485
|
: cls)),
|
|
474
|
-
|
|
486
|
+
(0, utils_1.retry)(() => this.calendarItemApi
|
|
475
487
|
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
|
|
476
488
|
.then((cls) => parentId
|
|
477
489
|
? this.calendarItemApi
|
|
@@ -496,7 +508,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
496
508
|
const docIds = {};
|
|
497
509
|
ctcs.forEach((c) => c.services &&
|
|
498
510
|
c.services.forEach((s) => s.content && Object.values(s.content).forEach((c) => c.documentId && (docIds[c.documentId] = 1))));
|
|
499
|
-
return
|
|
511
|
+
return (0, utils_1.retry)(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
|
|
500
512
|
const oDocs = docs.map((x) => _.assign({}, x, cloneKeysAndDelegations(x)));
|
|
501
513
|
let markerPromise = Promise.resolve(null);
|
|
502
514
|
delegateIds.forEach((delegateId) => {
|
|
@@ -684,7 +696,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
684
696
|
export(user, patId, ownerId) {
|
|
685
697
|
return this.hcpartyApi.getHealthcareParty(ownerId).then((hcp) => {
|
|
686
698
|
const parentId = hcp.parentId;
|
|
687
|
-
return
|
|
699
|
+
return (0, utils_1.retry)(() => this.getPatientWithUser(user, patId))
|
|
688
700
|
.then((patient) => patient.encryptionKeys && Object.keys(patient.encryptionKeys || {}).length
|
|
689
701
|
? Promise.resolve(patient)
|
|
690
702
|
: this.initEncryptionKeys(user, patient).then((patient) => this.modifyPatientWithUser(user, patient)))
|
|
@@ -695,42 +707,42 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
695
707
|
return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
|
|
696
708
|
return delSfks.length
|
|
697
709
|
? Promise.all([
|
|
698
|
-
|
|
710
|
+
(0, utils_1.retry)(() => this.helementApi
|
|
699
711
|
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
|
|
700
712
|
.then((hes) => parentId
|
|
701
713
|
? this.helementApi
|
|
702
714
|
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
|
|
703
715
|
.then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
|
|
704
716
|
: hes)),
|
|
705
|
-
|
|
717
|
+
(0, utils_1.retry)(() => this.formApi
|
|
706
718
|
.findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
707
719
|
.then((frms) => parentId
|
|
708
720
|
? this.formApi
|
|
709
721
|
.findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
710
722
|
.then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
|
|
711
723
|
: frms)),
|
|
712
|
-
|
|
724
|
+
(0, utils_1.retry)(() => this.contactApi
|
|
713
725
|
.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
|
|
714
726
|
.then((ctcs) => parentId
|
|
715
727
|
? this.contactApi
|
|
716
728
|
.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
|
|
717
729
|
.then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
|
|
718
730
|
: ctcs)),
|
|
719
|
-
|
|
731
|
+
(0, utils_1.retry)(() => this.invoiceApi
|
|
720
732
|
.findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
721
733
|
.then((ivs) => parentId
|
|
722
734
|
? this.invoiceApi
|
|
723
735
|
.findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
724
736
|
.then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
|
|
725
737
|
: ivs)),
|
|
726
|
-
|
|
738
|
+
(0, utils_1.retry)(() => this.classificationApi
|
|
727
739
|
.findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
|
|
728
740
|
.then((cls) => parentId
|
|
729
741
|
? this.classificationApi
|
|
730
742
|
.findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
|
|
731
743
|
.then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
|
|
732
744
|
: cls)),
|
|
733
|
-
|
|
745
|
+
(0, utils_1.retry)(() => __awaiter(this, void 0, void 0, function* () {
|
|
734
746
|
const delegationSFKs = _.uniq(delSfks).join(',');
|
|
735
747
|
try {
|
|
736
748
|
let calendarItems = yield this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, delegationSFKs);
|
|
@@ -749,7 +761,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
|
|
|
749
761
|
const docIds = {};
|
|
750
762
|
ctcs.forEach((c) => c.services &&
|
|
751
763
|
c.services.forEach((s) => s.content && Object.values(s.content).forEach((c) => c.documentId && (docIds[c.documentId] = 1))));
|
|
752
|
-
return
|
|
764
|
+
return (0, utils_1.retry)(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
|
|
753
765
|
return {
|
|
754
766
|
id: patId,
|
|
755
767
|
patient: patient,
|