@icure/api 4.0.98 → 4.1.1

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.
Files changed (55) hide show
  1. package/icc-api/api/XHR.js +2 -12
  2. package/icc-api/api/XHR.js.map +1 -1
  3. package/icc-api/model/AppointmentTypeAndPlace.d.ts +1 -0
  4. package/icc-api/model/AppointmentTypeAndPlace.js.map +1 -1
  5. package/icc-api/model/ModelHelper.d.ts +8 -0
  6. package/icc-api/model/ModelHelper.js +52 -12
  7. package/icc-api/model/ModelHelper.js.map +1 -1
  8. package/icc-api/model/Remote.d.ts +2 -2
  9. package/icc-api/model/Remote.js.map +1 -1
  10. package/icc-api/model/models.d.ts +3 -0
  11. package/icc-api/model/models.js +3 -0
  12. package/icc-api/model/models.js.map +1 -1
  13. package/icc-x-api/crypto/AES.d.ts +1 -4
  14. package/icc-x-api/crypto/AES.js +4 -9
  15. package/icc-x-api/crypto/AES.js.map +1 -1
  16. package/icc-x-api/icc-accesslog-x-api.js +1 -1
  17. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  18. package/icc-x-api/icc-calendar-item-x-api.js +1 -1
  19. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  20. package/icc-x-api/icc-classification-x-api.js +1 -1
  21. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  22. package/icc-x-api/icc-contact-x-api.js +1 -1
  23. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  24. package/icc-x-api/icc-crypto-x-api.d.ts +10 -20
  25. package/icc-x-api/icc-crypto-x-api.js +4 -4
  26. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  27. package/icc-x-api/icc-document-x-api.d.ts +2 -2
  28. package/icc-x-api/icc-document-x-api.js +3 -3
  29. package/icc-x-api/icc-document-x-api.js.map +1 -1
  30. package/icc-x-api/icc-form-x-api.js +1 -1
  31. package/icc-x-api/icc-form-x-api.js.map +1 -1
  32. package/icc-x-api/icc-helement-x-api.js +1 -1
  33. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  34. package/icc-x-api/icc-invoice-x-api.js +1 -1
  35. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  36. package/icc-x-api/icc-message-x-api.d.ts +2 -12
  37. package/icc-x-api/icc-message-x-api.js +2 -7
  38. package/icc-x-api/icc-message-x-api.js.map +1 -1
  39. package/icc-x-api/icc-patient-x-api.js +43 -43
  40. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  41. package/icc-x-api/icc-receipt-x-api.d.ts +1 -1
  42. package/icc-x-api/icc-receipt-x-api.js +1 -1
  43. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  44. package/icc-x-api/index.js +1 -1
  45. package/icc-x-api/index.js.map +1 -1
  46. package/icc-x-api/utils/binary-utils.d.ts +2 -15
  47. package/icc-x-api/utils/binary-utils.js +18 -79
  48. package/icc-x-api/utils/binary-utils.js.map +1 -1
  49. package/icc-x-api/utils/index.d.ts +2 -0
  50. package/icc-x-api/utils/index.js +2 -0
  51. package/icc-x-api/utils/index.js.map +1 -1
  52. package/index.d.ts +1 -1
  53. package/index.js +1 -1
  54. package/index.js.map +1 -1
  55. package/package.json +3 -2
@@ -1,21 +1,11 @@
1
- import { IccEntityrefApi, IccInsuranceApi, IccMessageApi } from '../icc-api';
1
+ import { IccMessageApi } from '../icc-api';
2
2
  import { IccCryptoXApi } from './icc-crypto-x-api';
3
- import { IccDocumentXApi } from './icc-document-x-api';
4
- import { IccInvoiceXApi } from './icc-invoice-x-api';
5
3
  import { Patient, User } from '../icc-api/model/models';
6
- import { IccReceiptXApi } from './icc-receipt-x-api';
7
- import { IccPatientXApi } from './icc-patient-x-api';
8
4
  export declare class IccMessageXApi extends IccMessageApi {
9
5
  private crypto;
10
- private insuranceApi;
11
- private entityReferenceApi;
12
- private receiptXApi;
13
- private invoiceXApi;
14
- private documentXApi;
15
- private patientApi;
16
6
  constructor(host: string, headers: {
17
7
  [key: string]: string;
18
- }, crypto: IccCryptoXApi, insuranceApi: IccInsuranceApi, entityReferenceApi: IccEntityrefApi, invoiceXApi: IccInvoiceXApi, documentXApi: IccDocumentXApi, receiptXApi: IccReceiptXApi, patientApi: IccPatientXApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
8
+ }, crypto: IccCryptoXApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
19
9
  newInstance(user: User, m: any): Promise<any>;
20
10
  newInstanceWithPatient(user: User, patient: Patient | null, m: any): Promise<any>;
21
11
  }
@@ -4,19 +4,14 @@ exports.IccMessageXApi = void 0;
4
4
  const icc_api_1 = require("../icc-api");
5
5
  const _ = require("lodash");
6
6
  class IccMessageXApi extends icc_api_1.IccMessageApi {
7
- constructor(host, headers, crypto, insuranceApi, entityReferenceApi, invoiceXApi, documentXApi, receiptXApi, patientApi, fetchImpl = typeof window !== 'undefined'
7
+ constructor(host, headers, crypto, fetchImpl = typeof window !== 'undefined'
8
8
  ? window.fetch
9
9
  : typeof self !== 'undefined'
10
10
  ? self.fetch
11
11
  : fetch) {
12
12
  super(host, headers, fetchImpl);
13
13
  this.crypto = crypto;
14
- this.insuranceApi = insuranceApi;
15
- this.entityReferenceApi = entityReferenceApi;
16
- this.receiptXApi = receiptXApi;
17
- this.invoiceXApi = invoiceXApi;
18
- this.documentXApi = documentXApi;
19
- this.patientApi = patientApi;
14
+ this.crypto = crypto;
20
15
  }
21
16
  // noinspection JSUnusedGlobalSymbols
22
17
  newInstance(user, m) {
@@ -1 +1 @@
1
- {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAA4E;AAK5E,4BAA2B;AAuB3B,MAAa,cAAe,SAAQ,uBAAa;IAS/C,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA6B,EAC7B,kBAAmC,EACnC,WAA2B,EAC3B,YAA6B,EAC7B,WAA2B,EAC3B,UAA0B,EAC1B,YAA2E,OAA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d,OAAO,QAAQ,CAAA;YACjB,CAAC,CAAC,CACL,CAAC,CACL,CAAA;YACD,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AAvFD,wCAuFC","sourcesContent":["import { IccEntityrefApi, IccInsuranceApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\n\nimport {\n AbstractFilterPatient,\n EntityReference,\n FilterChainPatient,\n HealthcareParty,\n Insurance,\n Invoice,\n ListOfIds,\n Message,\n PaginatedListPatient,\n Patient,\n PatientHealthCareParty,\n Receipt,\n ReferralPeriod,\n User,\n} from '../icc-api/model/models'\n\nimport { IccReceiptXApi } from './icc-receipt-x-api'\nimport { IccPatientXApi } from './icc-patient-x-api'\n\nexport class IccMessageXApi extends IccMessageApi {\n private crypto: IccCryptoXApi\n private insuranceApi: IccInsuranceApi\n private entityReferenceApi: IccEntityrefApi\n private receiptXApi: IccReceiptXApi\n private invoiceXApi: IccInvoiceXApi\n private documentXApi: IccDocumentXApi\n private patientApi: IccPatientXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n insuranceApi: IccInsuranceApi,\n entityReferenceApi: IccEntityrefApi,\n invoiceXApi: IccInvoiceXApi,\n documentXApi: IccDocumentXApi,\n receiptXApi: IccReceiptXApi,\n patientApi: IccPatientXApi,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, fetchImpl)\n this.crypto = crypto\n this.insuranceApi = insuranceApi\n this.entityReferenceApi = entityReferenceApi\n this.receiptXApi = receiptXApi\n this.invoiceXApi = invoiceXApi\n this.documentXApi = documentXApi\n this.patientApi = patientApi\n }\n\n // noinspection JSUnusedGlobalSymbols\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n newInstanceWithPatient(user: User, patient: Patient | null, m: any) {\n const message = _.extend(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.Message',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: user.healthcarePartyId,\n author: user.id,\n codes: [],\n tags: [],\n },\n m || {}\n )\n\n const hcpId = user.healthcarePartyId || user.patientId\n return this.crypto\n .extractDelegationsSFKs(patient, hcpId)\n .then((secretForeignKeys) => this.crypto.initObjectDelegations(message, patient, hcpId!, secretForeignKeys.extractedKeys[0]))\n .then((initData) => {\n _.extend(message, {\n delegations: initData.delegations,\n cryptedForeignKeys: initData.cryptedForeignKeys,\n secretForeignKeys: initData.secretForeignKeys,\n })\n\n let promise = Promise.resolve(message)\n ;(user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : []).forEach(\n (delegateId) =>\n (promise = promise.then((helement) =>\n this.crypto\n .extendedDelegationsAndCryptedForeignKeys(helement, patient, hcpId!, delegateId, initData.secretId)\n .then((extraData) =>\n _.extend(helement, {\n delegations: extraData.delegations,\n cryptedForeignKeys: extraData.cryptedForeignKeys,\n })\n )\n .catch((e) => {\n console.log(e)\n return helement\n })\n ))\n )\n return promise\n })\n }\n}\n"]}
1
+ {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAA0C;AAG1C,4BAA2B;AAI3B,MAAa,cAAe,SAAQ,uBAAa;IAC/C,YACE,IAAY,EACZ,OAAkC,EAC1B,MAAqB,EAC7B,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC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,EAAE,QAAQ,CAAC,iBAAiB;aAC9C,CAAC,CAAA;YAEF,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CACrC;YAAA,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAC3H,CAAC,UAAU,EAAE,EAAE,CACb,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnC,IAAI,CAAC,MAAM;iBACR,wCAAwC,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC;iBAClG,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAClB,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACjB,WAAW,EAAE,SAAS,CAAC,WAAW;gBAClC,kBAAkB,EAAE,SAAS,CAAC,kBAAkB;aACjD,CAAC,CACH;iBACA,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;gBACd,OAAO,QAAQ,CAAA;YACjB,CAAC,CAAC,CACL,CAAC,CACL,CAAA;YACD,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AAnED,wCAmEC","sourcesContent":["import { IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as _ from 'lodash'\n\nimport { Patient, User } from '../icc-api/model/models'\n\nexport class IccMessageXApi extends IccMessageApi {\n constructor(\n host: string,\n headers: { [key: string]: string },\n private crypto: IccCryptoXApi,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, fetchImpl)\n this.crypto = crypto\n }\n\n // noinspection JSUnusedGlobalSymbols\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n newInstanceWithPatient(user: User, patient: Patient | null, m: any) {\n const message = _.extend(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.Message',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: user.healthcarePartyId,\n author: user.id,\n codes: [],\n tags: [],\n },\n m || {}\n )\n\n const hcpId = user.healthcarePartyId || user.patientId\n return this.crypto\n .extractDelegationsSFKs(patient, hcpId)\n .then((secretForeignKeys) => this.crypto.initObjectDelegations(message, patient, hcpId!, secretForeignKeys.extractedKeys[0]))\n .then((initData) => {\n _.extend(message, {\n delegations: initData.delegations,\n cryptedForeignKeys: initData.cryptedForeignKeys,\n secretForeignKeys: initData.secretForeignKeys,\n })\n\n let promise = Promise.resolve(message)\n ;(user.autoDelegations ? (user.autoDelegations.all || []).concat(user.autoDelegations.medicalInformation || []) : []).forEach(\n (delegateId) =>\n (promise = promise.then((helement) =>\n this.crypto\n .extendedDelegationsAndCryptedForeignKeys(helement, patient, hcpId!, delegateId, initData.secretId)\n .then((extraData) =>\n _.extend(helement, {\n delegations: extraData.delegations,\n cryptedForeignKeys: extraData.cryptedForeignKeys,\n })\n )\n .catch((e) => {\n console.log(e)\n return helement\n })\n ))\n )\n return promise\n })\n }\n}\n"]}
@@ -14,11 +14,11 @@ 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("./utils");
18
- const utils_2 = require("./crypto/utils");
17
+ const utils_1 = require("./crypto/utils");
19
18
  const ModelHelper_1 = require("../icc-api/model/ModelHelper");
20
19
  const binary_utils_1 = require("./utils/binary-utils");
21
20
  const person_util_1 = require("./utils/person-util");
21
+ const net_utils_1 = require("./utils/net-utils");
22
22
  // noinspection JSUnusedGlobalSymbols
23
23
  class IccPatientXApi extends icc_api_1.IccPatientApi {
24
24
  constructor(host, headers, crypto, contactApi, formApi, helementApi, invoiceApi, documentApi, hcpartyApi, classificationApi, calendarItemaApi, encryptedKeys = ['note'], fetchImpl = typeof window !== 'undefined'
@@ -276,7 +276,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
276
276
  : this.initEncryptionKeys(user, p))
277
277
  .then((p) => this.crypto.extractKeysFromDelegationsForHcpHierarchy((user.healthcarePartyId || user.patientId), p.id, p.encryptionKeys))
278
278
  .then((sfks) => this.crypto.AES.importKey('raw', binary_utils_1.hex2ua(sfks.extractedKeys[0].replace(/-/g, ''))))
279
- .then((key) => utils_2.utils.crypt(p, (obj) => this.crypto.AES.encrypt(key, binary_utils_1.utf8_2ua(JSON.stringify(obj, (k, v) => {
279
+ .then((key) => utils_1.utils.crypt(p, (obj) => this.crypto.AES.encrypt(key, binary_utils_1.utf8_2ua(JSON.stringify(obj, (k, v) => {
280
280
  return v instanceof ArrayBuffer || v instanceof Uint8Array
281
281
  ? binary_utils_1.b2a(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))
282
282
  : v;
@@ -314,7 +314,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
314
314
  //console.log("Cannot decrypt contact", ctc.id)
315
315
  return Promise.resolve(p);
316
316
  }
317
- return this.crypto.AES.importKey('raw', binary_utils_1.hex2ua(sfks[0].replace(/-/g, ''))).then((key) => utils_2.utils
317
+ return this.crypto.AES.importKey('raw', binary_utils_1.hex2ua(sfks[0].replace(/-/g, ''))).then((key) => utils_1.utils
318
318
  .decrypt(p, (ec) => this.crypto.AES.decrypt(key, ec)
319
319
  .then((dec) => {
320
320
  const jsonContent = dec && binary_utils_1.ua2utf8(dec);
@@ -421,7 +421,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
421
421
  },
422
422
  patient: { success: false, error: null, modified: 0 },
423
423
  };
424
- return utils_1.retry(() => this.getPatientWithUser(user, patId))
424
+ return net_utils_1.retry(() => this.getPatientWithUser(user, patId))
425
425
  .then((patient) => patient.encryptionKeys && Object.keys(patient.encryptionKeys || {}).length
426
426
  ? Promise.resolve(patient)
427
427
  : this.initEncryptionKeys(user, patient).then((patient) => this.modifyPatientWithUser(user, patient)))
@@ -436,46 +436,46 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
436
436
  return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
437
437
  return delSfks.length
438
438
  ? Promise.all([
439
- utils_1.retry(() => this.helementApi
440
- .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
439
+ net_utils_1.retry(() => this.helementApi
440
+ .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
441
441
  .then((hes) => parentId
442
442
  ? this.helementApi
443
- .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
443
+ .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
444
444
  .then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
445
445
  : hes)),
446
- utils_1.retry(() => this.formApi
447
- .findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
446
+ net_utils_1.retry(() => this.formApi
447
+ .findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
448
448
  .then((frms) => parentId
449
449
  ? this.formApi
450
- .findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
450
+ .findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
451
451
  .then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
452
452
  : frms)),
453
- utils_1.retry(() => this.contactApi
454
- .findByHCPartyPatientSecretFKeys(ownerId, delSfks.join(','))
453
+ net_utils_1.retry(() => this.contactApi
454
+ .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
455
455
  .then((ctcs) => parentId
456
456
  ? this.contactApi
457
- .findByHCPartyPatientSecretFKeys(parentId, delSfks.join(','))
457
+ .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
458
458
  .then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
459
459
  : ctcs)),
460
- utils_1.retry(() => this.invoiceApi
461
- .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
460
+ net_utils_1.retry(() => this.invoiceApi
461
+ .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
462
462
  .then((ivs) => parentId
463
463
  ? this.invoiceApi
464
- .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
464
+ .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
465
465
  .then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
466
466
  : ivs)),
467
- utils_1.retry(() => this.classificationApi
468
- .findClassificationsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
467
+ net_utils_1.retry(() => this.classificationApi
468
+ .findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
469
469
  .then((cls) => parentId
470
470
  ? this.classificationApi
471
- .findClassificationsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
471
+ .findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
472
472
  .then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
473
473
  : cls)),
474
- utils_1.retry(() => this.calendarItemApi
475
- .findByHCPartyPatientSecretFKeys(ownerId, delSfks.join(','))
474
+ net_utils_1.retry(() => this.calendarItemApi
475
+ .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
476
476
  .then((cls) => parentId
477
477
  ? this.calendarItemApi
478
- .findByHCPartyPatientSecretFKeys(parentId, delSfks.join(','))
478
+ .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
479
479
  .then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
480
480
  : cls)),
481
481
  ]).then(([hes, frms, ctcs, ivs, cls, cis]) => {
@@ -496,7 +496,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
496
496
  const docIds = {};
497
497
  ctcs.forEach((c) => c.services &&
498
498
  c.services.forEach((s) => s.content && Object.values(s.content).forEach((c) => c.documentId && (docIds[c.documentId] = 1))));
499
- return utils_1.retry(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
499
+ return net_utils_1.retry(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
500
500
  const oDocs = docs.map((x) => _.assign({}, x, cloneKeysAndDelegations(x)));
501
501
  let markerPromise = Promise.resolve(null);
502
502
  delegateIds.forEach((delegateId) => {
@@ -684,7 +684,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
684
684
  export(user, patId, ownerId) {
685
685
  return this.hcpartyApi.getHealthcareParty(ownerId).then((hcp) => {
686
686
  const parentId = hcp.parentId;
687
- return utils_1.retry(() => this.getPatientWithUser(user, patId))
687
+ return net_utils_1.retry(() => this.getPatientWithUser(user, patId))
688
688
  .then((patient) => patient.encryptionKeys && Object.keys(patient.encryptionKeys || {}).length
689
689
  ? Promise.resolve(patient)
690
690
  : this.initEncryptionKeys(user, patient).then((patient) => this.modifyPatientWithUser(user, patient)))
@@ -695,43 +695,43 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
695
695
  return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
696
696
  return delSfks.length
697
697
  ? Promise.all([
698
- utils_1.retry(() => this.helementApi
699
- .findByHCPartyPatientSecretFKeys(ownerId, delSfks.join(','))
698
+ net_utils_1.retry(() => this.helementApi
699
+ .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
700
700
  .then((hes) => parentId
701
701
  ? this.helementApi
702
- .findByHCPartyPatientSecretFKeys(parentId, delSfks.join(','))
702
+ .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
703
703
  .then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
704
704
  : hes)),
705
- utils_1.retry(() => this.formApi
706
- .findFormsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
705
+ net_utils_1.retry(() => this.formApi
706
+ .findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
707
707
  .then((frms) => parentId
708
708
  ? this.formApi
709
- .findFormsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
709
+ .findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
710
710
  .then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
711
711
  : frms)),
712
- utils_1.retry(() => this.contactApi
713
- .findByHCPartyPatientSecretFKeys(ownerId, delSfks.join(','))
712
+ net_utils_1.retry(() => this.contactApi
713
+ .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
714
714
  .then((ctcs) => parentId
715
715
  ? this.contactApi
716
- .findByHCPartyPatientSecretFKeys(parentId, delSfks.join(','))
716
+ .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
717
717
  .then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
718
718
  : ctcs)),
719
- utils_1.retry(() => this.invoiceApi
720
- .findInvoicesByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
719
+ net_utils_1.retry(() => this.invoiceApi
720
+ .findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
721
721
  .then((ivs) => parentId
722
722
  ? this.invoiceApi
723
- .findInvoicesByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
723
+ .findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
724
724
  .then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
725
725
  : ivs)),
726
- utils_1.retry(() => this.classificationApi
727
- .findClassificationsByHCPartyPatientForeignKeys(ownerId, delSfks.join(','))
726
+ net_utils_1.retry(() => this.classificationApi
727
+ .findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
728
728
  .then((cls) => parentId
729
729
  ? this.classificationApi
730
- .findClassificationsByHCPartyPatientForeignKeys(parentId, delSfks.join(','))
730
+ .findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
731
731
  .then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
732
732
  : cls)),
733
- utils_1.retry(() => __awaiter(this, void 0, void 0, function* () {
734
- const delegationSFKs = delSfks.join(',');
733
+ net_utils_1.retry(() => __awaiter(this, void 0, void 0, function* () {
734
+ const delegationSFKs = _.uniq(delSfks).join(',');
735
735
  try {
736
736
  let calendarItems = yield this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, delegationSFKs);
737
737
  if (parentId) {
@@ -749,7 +749,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
749
749
  const docIds = {};
750
750
  ctcs.forEach((c) => c.services &&
751
751
  c.services.forEach((s) => s.content && Object.values(s.content).forEach((c) => c.documentId && (docIds[c.documentId] = 1))));
752
- return utils_1.retry(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
752
+ return net_utils_1.retry(() => this.documentApi.getDocuments(new models_1.ListOfIds({ ids: Object.keys(docIds) }))).then((docs) => {
753
753
  return {
754
754
  id: patId,
755
755
  patient: patient,