@icure/api 6.3.1 → 6.4.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 (99) hide show
  1. package/icc-api/api/IccAccesslogApi.d.ts +7 -0
  2. package/icc-api/api/IccAccesslogApi.js +20 -0
  3. package/icc-api/api/IccAccesslogApi.js.map +1 -1
  4. package/icc-api/api/IccCalendarItemApi.d.ts +7 -0
  5. package/icc-api/api/IccCalendarItemApi.js +20 -0
  6. package/icc-api/api/IccCalendarItemApi.js.map +1 -1
  7. package/icc-api/api/IccContactApi.d.ts +16 -0
  8. package/icc-api/api/IccContactApi.js +44 -0
  9. package/icc-api/api/IccContactApi.js.map +1 -1
  10. package/icc-api/api/IccDataownerApi.d.ts +33 -0
  11. package/icc-api/api/IccDataownerApi.js +55 -0
  12. package/icc-api/api/IccDataownerApi.js.map +1 -0
  13. package/icc-api/api/IccFormApi.d.ts +17 -0
  14. package/icc-api/api/IccFormApi.js +46 -0
  15. package/icc-api/api/IccFormApi.js.map +1 -1
  16. package/icc-api/api/IccGroupApi.d.ts +10 -1
  17. package/icc-api/api/IccGroupApi.js +23 -2
  18. package/icc-api/api/IccGroupApi.js.map +1 -1
  19. package/icc-api/api/IccHelementApi.d.ts +14 -0
  20. package/icc-api/api/IccHelementApi.js +40 -0
  21. package/icc-api/api/IccHelementApi.js.map +1 -1
  22. package/icc-api/api/IccInvoiceApi.d.ts +14 -0
  23. package/icc-api/api/IccInvoiceApi.js +40 -0
  24. package/icc-api/api/IccInvoiceApi.js.map +1 -1
  25. package/icc-api/api/IccMessageApi.d.ts +6 -0
  26. package/icc-api/api/IccMessageApi.js +15 -0
  27. package/icc-api/api/IccMessageApi.js.map +1 -1
  28. package/icc-api/api/IccUserApi.js +1 -1
  29. package/icc-api/api/IccUserApi.js.map +1 -1
  30. package/icc-api/iccApi.d.ts +1 -0
  31. package/icc-api/iccApi.js +1 -0
  32. package/icc-api/iccApi.js.map +1 -1
  33. package/icc-api/model/AttachmentMetadata.d.ts +21 -0
  34. package/icc-api/model/AttachmentMetadata.js +24 -0
  35. package/icc-api/model/AttachmentMetadata.js.map +1 -0
  36. package/icc-api/model/BulkAttachmentUpdateOptions.d.ts +28 -0
  37. package/icc-api/model/BulkAttachmentUpdateOptions.js +13 -0
  38. package/icc-api/model/BulkAttachmentUpdateOptions.js.map +1 -0
  39. package/icc-api/model/{Body2.d.ts → DataOwnerWithType.d.ts} +4 -4
  40. package/icc-api/model/{Body1.js → DataOwnerWithType.js} +5 -6
  41. package/icc-api/model/DataOwnerWithType.js.map +1 -0
  42. package/icc-api/model/DiaryNoteExportInfo.d.ts +1 -1
  43. package/icc-api/model/DiaryNoteExportInfo.js.map +1 -1
  44. package/icc-api/model/GroupDeletionReport.d.ts +17 -0
  45. package/icc-api/model/{Body2.js → GroupDeletionReport.js} +7 -8
  46. package/icc-api/model/GroupDeletionReport.js.map +1 -0
  47. package/icc-api/model/IncapacityExportInfo.d.ts +2 -0
  48. package/icc-api/model/IncapacityExportInfo.js.map +1 -1
  49. package/icc-api/model/{Body1.d.ts → Part.d.ts} +1 -2
  50. package/icc-api/model/Part.js +21 -0
  51. package/icc-api/model/Part.js.map +1 -0
  52. package/icc-api/model/UserGroup.d.ts +2 -0
  53. package/icc-api/model/UserGroup.js +0 -11
  54. package/icc-api/model/UserGroup.js.map +1 -1
  55. package/icc-api/model/models.d.ts +8 -1
  56. package/icc-api/model/models.js +8 -1
  57. package/icc-api/model/models.js.map +1 -1
  58. package/icc-x-api/auth/JwtAuthService.js.map +1 -1
  59. package/icc-x-api/crypto/AES.d.ts +1 -0
  60. package/icc-x-api/crypto/AES.js +10 -1
  61. package/icc-x-api/crypto/AES.js.map +1 -1
  62. package/icc-x-api/filters/PatientByHcPartyAndAddressFilter.d.ts +21 -0
  63. package/icc-x-api/filters/PatientByHcPartyAndAddressFilter.js +24 -0
  64. package/icc-x-api/filters/PatientByHcPartyAndAddressFilter.js.map +1 -0
  65. package/icc-x-api/filters/filters.d.ts +2 -0
  66. package/icc-x-api/filters/filters.js +10 -0
  67. package/icc-x-api/filters/filters.js.map +1 -1
  68. package/icc-x-api/icc-accesslog-x-api.d.ts +3 -1
  69. package/icc-x-api/icc-accesslog-x-api.js +15 -6
  70. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  71. package/icc-x-api/icc-bekmehr-x-api.d.ts +1 -0
  72. package/icc-x-api/icc-bekmehr-x-api.js +100 -64
  73. package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
  74. package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -1
  75. package/icc-x-api/icc-calendar-item-x-api.js +17 -4
  76. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  77. package/icc-x-api/icc-contact-x-api.d.ts +3 -1
  78. package/icc-x-api/icc-contact-x-api.js +19 -8
  79. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  80. package/icc-x-api/icc-crypto-x-api.d.ts +6 -0
  81. package/icc-x-api/icc-crypto-x-api.js +19 -6
  82. package/icc-x-api/icc-crypto-x-api.js.map +1 -1
  83. package/icc-x-api/icc-form-x-api.d.ts +3 -2
  84. package/icc-x-api/icc-form-x-api.js +8 -4
  85. package/icc-x-api/icc-form-x-api.js.map +1 -1
  86. package/icc-x-api/icc-helement-x-api.d.ts +8 -3
  87. package/icc-x-api/icc-helement-x-api.js +33 -6
  88. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  89. package/icc-x-api/icc-invoice-x-api.d.ts +2 -1
  90. package/icc-x-api/icc-invoice-x-api.js +5 -2
  91. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  92. package/icc-x-api/icc-maintenance-task-x-api.js +8 -2
  93. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  94. package/icc-x-api/icc-patient-x-api.d.ts +2 -2
  95. package/icc-x-api/icc-patient-x-api.js +72 -61
  96. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  97. package/package.json +1 -1
  98. package/icc-api/model/Body1.js.map +0 -1
  99. package/icc-api/model/Body2.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"icc-maintenance-task-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-maintenance-task-x-api.ts"],"names":[],"mappings":";;;AAAA,gFAA4E;AAG5E,4BAA2B;AAC3B,8DAAkE;AAClE,mCAA0D;AAI1D,0EAAgG;AAEhG,MAAa,sBAAuB,SAAQ,6CAAqB;IAO/D,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,UAA0B,EAC1B,YAA8B,EAC9B,gBAA+B,EAAE,EACjC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,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,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,WAAW,CAAC,IAAiB,EAAE,CAAM,EAAE,YAAsB,EAAE;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC1D,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAC9B;YACE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YAC5B,KAAK,EAAE,2CAA2C;YAClD,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;YAC7B,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;YAC9B,WAAW,EAAE,WAAW;YACxB,MA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;oBACL,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;iBAC3B;YACH,CAAC,CAAC,CAAA;SAAA,CACH,CACF,CAAA;IACH,CAAC;CACF;AAvOD,wDAuOC","sourcesContent":["import { IccMaintenanceTaskApi } from '../icc-api/api/IccMaintenanceTaskApi'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport * as _ from 'lodash'\nimport { a2b, b2a, string2ua } from '../icc-api/model/ModelHelper'\nimport { hex2ua, ua2utf8, utf8_2ua, crypt } from './utils'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { DocIdentifier } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi {\n crypto: IccCryptoXApi\n hcPartyApi: IccHcpartyXApi\n dataOwnerApi: IccDataOwnerXApi\n\n private readonly encryptedKeys: Array<string>\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n hcPartyApi: IccHcpartyXApi,\n dataOwnerApi: IccDataOwnerXApi,\n encryptedKeys: Array<string> = [],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.hcPartyApi = hcPartyApi\n this.dataOwnerApi = dataOwnerApi\n this.encryptedKeys = encryptedKeys\n }\n\n newInstance(user: models.User, m: any, delegates: string[] = []) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n const maintenanceTask = _.assign(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.MaintenanceTask',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: dataOwnerId,\n author: user.id,\n },\n m || {}\n )\n\n return this.initDelegations(user, maintenanceTask, delegates).then((task) => this.initEncryptionKeys(user, task, delegates))\n }\n\n initDelegations(user: models.User, maintenanceTask: models.MaintenanceTask, delegates: string[] = []): Promise<models.MaintenanceTask> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n return this.crypto.initObjectDelegations(maintenanceTask, null, dataOwnerId!, null).then((initData) => {\n _.extend(maintenanceTask, { delegations: initData.delegations })\n\n let promise = Promise.resolve(maintenanceTask)\n _.uniq(delegates.concat(user.autoDelegations ? user.autoDelegations.all || [] : [])).forEach(\n (delegateId) =>\n (promise = promise\n .then((patient) => this.crypto.extendedDelegationsAndCryptedForeignKeys(patient, null, dataOwnerId!, delegateId, initData.secretId))\n .then((extraData) => _.extend(maintenanceTask, { delegations: extraData.delegations }))\n .catch((e) => {\n console.log(e)\n return maintenanceTask\n }))\n )\n return promise\n })\n }\n\n initEncryptionKeys(user: models.User, maintenanceTask: models.MaintenanceTask, delegates: string[] = []): Promise<models.MaintenanceTask> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n return this.crypto.initEncryptionKeys(maintenanceTask, dataOwnerId!).then((eks) => {\n let promise = Promise.resolve(\n _.extend(maintenanceTask, {\n encryptionKeys: eks.encryptionKeys,\n })\n )\n _.uniq(delegates.concat(user.autoDelegations ? user.autoDelegations.all || [] : [])).forEach(\n (delegateId) =>\n (promise = promise.then((patient) =>\n this.crypto\n .appendEncryptionKeys(patient, dataOwnerId!, delegateId, eks.secretId)\n .then((extraEks) => {\n return _.extend(extraEks.modifiedObject, {\n encryptionKeys: extraEks.encryptionKeys,\n })\n })\n .catch((e) => {\n console.log(e.message)\n return patient\n })\n ))\n )\n return promise\n })\n }\n\n createMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n createMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((tasks) => super.createMaintenanceTask(tasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((tasks) => tasks[0])\n : Promise.resolve(null)\n }\n\n filterMaintenanceTasksBy(startDocumentId?: string, limit?: number, body?: models.FilterChainMaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTask(_maintenanceTaskIds: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<Array<DocIdentifier>> | never {\n return super.getMaintenanceTask(maintenanceTaskId).then((mt) => {\n return this.dataOwnerApi.hasAccessTo(user, mt.delegations ?? {}).then((hasAccess) => {\n if (hasAccess) return super.deleteMaintenanceTask(maintenanceTaskId)\n else throw new Error('User does not have a delegation for this maintenanceTask')\n })\n })\n }\n\n filterMaintenanceTasksByWithUser(\n user: models.User,\n startDocumentId?: string,\n limit?: number,\n body?: models.FilterChainMaintenanceTask\n ): Promise<models.PaginatedListMaintenanceTask | any> {\n return super\n .filterMaintenanceTasksBy(startDocumentId, limit, body)\n .then((pl) => this.decrypt(user, pl.rows!).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n getMaintenanceTask(maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n getMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<models.MaintenanceTask | any> {\n return super\n .getMaintenanceTask(maintenanceTaskId)\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n }\n\n modifyMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n modifyMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((encTasks) => super.modifyMaintenanceTask(encTasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n : Promise.resolve(null)\n }\n\n encrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n\n return Promise.all(\n maintenanceTasks.map((m) =>\n (m.encryptionKeys && Object.keys(m.encryptionKeys).some((k) => !!m.encryptionKeys![k].length)\n ? Promise.resolve(m)\n : this.initEncryptionKeys(user, m)\n )\n .then((m: models.MaintenanceTask) => this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId!, m.id!, m.encryptionKeys!))\n .then((sfks: { extractedKeys: Array<string>; hcpartyId: string }) =>\n this.crypto.AES.importKey('raw', hex2ua(sfks.extractedKeys[0].replace(/-/g, '')))\n )\n .then((key: CryptoKey) =>\n crypt(\n m,\n (obj: { [key: string]: string }) =>\n this.crypto.AES.encrypt(\n key,\n utf8_2ua(\n JSON.stringify(obj, (k, v) => {\n return v instanceof ArrayBuffer || v instanceof Uint8Array\n ? b2a(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))\n : v\n })\n )\n ),\n this.encryptedKeys\n )\n )\n )\n )\n }\n\n decrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n\n return Promise.all(\n maintenanceTasks.map((mT) =>\n this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, mT.id!, mT.encryptionKeys ?? {}).then(({ extractedKeys: sfks }) => {\n if (!sfks || !sfks.length) {\n console.log('Cannot decrypt maintenanceTask', mT.id)\n return Promise.resolve(mT)\n }\n if (mT.encryptedSelf) {\n return this.crypto.AES.importKey('raw', hex2ua(sfks[0].replace(/-/g, ''))).then(\n (key) =>\n new Promise((resolve: (value: any) => any) =>\n this.crypto.AES.decrypt(key, string2ua(a2b(mT.encryptedSelf!))).then(\n (dec) => {\n let jsonContent\n try {\n jsonContent = dec && ua2utf8(dec)\n jsonContent && _.assign(mT, JSON.parse(jsonContent))\n } catch (e) {\n console.log('Cannot parse mTask', mT.id, jsonContent || '<- Invalid encoding')\n }\n resolve(mT)\n },\n () => {\n console.log('Cannot decrypt mTask', mT.id)\n resolve(mT)\n }\n )\n )\n )\n } else {\n return Promise.resolve(mT)\n }\n })\n )\n )\n }\n}\n"]}
1
+ {"version":3,"file":"icc-maintenance-task-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-maintenance-task-x-api.ts"],"names":[],"mappings":";;;AAAA,gFAA4E;AAG5E,4BAA2B;AAC3B,8DAAkE;AAClE,mCAA0D;AAI1D,0EAAgG;AAEhG,MAAa,sBAAuB,SAAQ,6CAAqB;IAO/D,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,UAA0B,EAC1B,YAA8B,EAC9B,gBAA+B,EAAE,EACjC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,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,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,WAAW,CAAC,IAAiB,EAAE,CAAM,EAAE,YAAsB,EAAE;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC1D,MA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,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;yBACrD;wBAAC,OAAO,CAAC,EAAE;4BACV,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,IAAI,qBAAqB,CAAC,CAAA;yBAC/E;wBACD,OAAO,CAAC,EAAE,CAAC,CAAA;oBACb,CAAC,EACD,GAAG,EAAE;wBACH,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;wBAC1C,OAAO,CAAC,EAAE,CAAC,CAAA;oBACb,CAAC,CACF,CACF,CACJ,CAAA;iBACF;qBAAM;oBACL,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;iBAC3B;YACH,CAAC,CAAC,CAAA;SAAA,CACH,CACF,CAAA;IACH,CAAC;CACF;AA1OD,wDA0OC","sourcesContent":["import { IccMaintenanceTaskApi } from '../icc-api/api/IccMaintenanceTaskApi'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport * as _ from 'lodash'\nimport { a2b, b2a, string2ua } from '../icc-api/model/ModelHelper'\nimport { hex2ua, ua2utf8, utf8_2ua, crypt } from './utils'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { DocIdentifier } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi {\n crypto: IccCryptoXApi\n hcPartyApi: IccHcpartyXApi\n dataOwnerApi: IccDataOwnerXApi\n\n private readonly encryptedKeys: Array<string>\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n hcPartyApi: IccHcpartyXApi,\n dataOwnerApi: IccDataOwnerXApi,\n encryptedKeys: Array<string> = [],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.hcPartyApi = hcPartyApi\n this.dataOwnerApi = dataOwnerApi\n this.encryptedKeys = encryptedKeys\n }\n\n newInstance(user: models.User, m: any, delegates: string[] = []) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n const maintenanceTask = _.assign(\n {\n id: this.crypto.randomUuid(),\n _type: 'org.taktik.icure.entities.MaintenanceTask',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: dataOwnerId,\n author: user.id,\n },\n m || {}\n )\n\n return this.initDelegations(user, maintenanceTask, delegates).then((task) => this.initEncryptionKeys(user, task, delegates))\n }\n\n initDelegations(user: models.User, maintenanceTask: models.MaintenanceTask, delegates: string[] = []): Promise<models.MaintenanceTask> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n return this.crypto.initObjectDelegations(maintenanceTask, null, dataOwnerId!, null).then((initData) => {\n _.extend(maintenanceTask, { delegations: initData.delegations })\n\n let promise = Promise.resolve(maintenanceTask)\n _.uniq(delegates.concat(user.autoDelegations ? user.autoDelegations.all || [] : [])).forEach(\n (delegateId) =>\n (promise = promise\n .then((patient) => this.crypto.extendedDelegationsAndCryptedForeignKeys(patient, null, dataOwnerId!, delegateId, initData.secretId))\n .then((extraData) => _.extend(maintenanceTask, { delegations: extraData.delegations }))\n .catch((e) => {\n console.log(e)\n return maintenanceTask\n }))\n )\n return promise\n })\n }\n\n initEncryptionKeys(user: models.User, maintenanceTask: models.MaintenanceTask, delegates: string[] = []): Promise<models.MaintenanceTask> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n return this.crypto.initEncryptionKeys(maintenanceTask, dataOwnerId!).then((eks) => {\n let promise = Promise.resolve(\n _.extend(maintenanceTask, {\n encryptionKeys: eks.encryptionKeys,\n })\n )\n _.uniq(delegates.concat(user.autoDelegations ? user.autoDelegations.all || [] : [])).forEach(\n (delegateId) =>\n (promise = promise.then((patient) =>\n this.crypto\n .appendEncryptionKeys(patient, dataOwnerId!, delegateId, eks.secretId)\n .then((extraEks) => {\n return _.extend(extraEks.modifiedObject, {\n encryptionKeys: extraEks.encryptionKeys,\n })\n })\n .catch((e) => {\n console.log(e.message)\n return patient\n })\n ))\n )\n return promise\n })\n }\n\n createMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n createMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((tasks) => super.createMaintenanceTask(tasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((tasks) => tasks[0])\n : Promise.resolve(null)\n }\n\n filterMaintenanceTasksBy(startDocumentId?: string, limit?: number, body?: models.FilterChainMaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTask(_maintenanceTaskIds: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<Array<DocIdentifier>> | never {\n return super.getMaintenanceTask(maintenanceTaskId).then((mt) => {\n return this.dataOwnerApi.hasAccessTo(user, mt.delegations ?? {}).then((hasAccess) => {\n if (hasAccess) return super.deleteMaintenanceTask(maintenanceTaskId)\n else throw new Error('User does not have a delegation for this maintenanceTask')\n })\n })\n }\n\n filterMaintenanceTasksByWithUser(\n user: models.User,\n startDocumentId?: string,\n limit?: number,\n body?: models.FilterChainMaintenanceTask\n ): Promise<models.PaginatedListMaintenanceTask | any> {\n return super\n .filterMaintenanceTasksBy(startDocumentId, limit, body)\n .then((pl) => this.decrypt(user, pl.rows!).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n getMaintenanceTask(maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n getMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<models.MaintenanceTask | any> {\n return super\n .getMaintenanceTask(maintenanceTaskId)\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n }\n\n modifyMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n modifyMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((encTasks) => super.modifyMaintenanceTask(encTasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n : Promise.resolve(null)\n }\n\n encrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n\n return Promise.all(\n maintenanceTasks.map((m) =>\n (m.encryptionKeys && Object.keys(m.encryptionKeys).some((k) => !!m.encryptionKeys![k].length)\n ? Promise.resolve(m)\n : this.initEncryptionKeys(user, m)\n )\n .then((m: models.MaintenanceTask) => this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId!, m.id!, m.encryptionKeys!))\n .then((sfks: { extractedKeys: Array<string>; hcpartyId: string }) => {\n const keys = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(sfks.extractedKeys)\n if (!keys.length) throw new Error('No valid keys found for calendar item encryption')\n return this.crypto.AES.importKey('raw', hex2ua(keys[0]))\n })\n .then((key: CryptoKey) =>\n crypt(\n m,\n (obj: { [key: string]: string }) =>\n this.crypto.AES.encrypt(\n key,\n utf8_2ua(\n JSON.stringify(obj, (k, v) => {\n return v instanceof ArrayBuffer || v instanceof Uint8Array\n ? b2a(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))\n : v\n })\n )\n ),\n this.encryptedKeys\n )\n )\n )\n )\n }\n\n decrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user)\n\n return Promise.all(\n maintenanceTasks.map((mT) =>\n this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, mT.id!, mT.encryptionKeys ?? {}).then(({ extractedKeys: sfks }) => {\n sfks = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(sfks)\n if (!sfks || !sfks.length) {\n console.log('Cannot decrypt maintenanceTask', mT.id)\n return Promise.resolve(mT)\n }\n if (mT.encryptedSelf) {\n return this.crypto.AES.importKey('raw', hex2ua(sfks[0])).then(\n (key) =>\n new Promise((resolve: (value: any) => any) =>\n this.crypto.AES.decrypt(key, string2ua(a2b(mT.encryptedSelf!))).then(\n (dec) => {\n let jsonContent\n try {\n jsonContent = dec && ua2utf8(dec)\n jsonContent && _.assign(mT, JSON.parse(jsonContent))\n } catch (e) {\n console.log('Cannot parse mTask', mT.id, jsonContent || '<- Invalid encoding')\n }\n resolve(mT)\n },\n () => {\n console.log('Cannot decrypt mTask', mT.id)\n resolve(mT)\n }\n )\n )\n )\n } else {\n return Promise.resolve(mT)\n }\n })\n )\n )\n }\n}\n"]}
@@ -81,7 +81,7 @@ export declare class IccPatientXApi extends IccPatientApi {
81
81
  initEncryptionKeys(user: models.User, pat: models.Patient, additionalDelegateIds?: string[]): Promise<models.Patient>;
82
82
  share(user: models.User, patId: string, ownerId: string, delegateIds: Array<string>, delegationTags: {
83
83
  [key: string]: Array<string>;
84
- }): Promise<{
84
+ }, usingPost?: boolean): Promise<{
85
85
  patient: models.Patient | null;
86
86
  statuses: {
87
87
  [key: string]: {
@@ -90,7 +90,7 @@ export declare class IccPatientXApi extends IccPatientApi {
90
90
  };
91
91
  };
92
92
  } | null>;
93
- export(user: models.User, patId: string, ownerId: string): Promise<{
93
+ export(user: models.User, patId: string, ownerId: string, usingPost?: boolean): Promise<{
94
94
  id: string;
95
95
  }>;
96
96
  checkInami(inami: string): boolean;
@@ -85,7 +85,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
85
85
  rev: dataOwner.rev,
86
86
  publicKey: dataOwner.publicKey,
87
87
  aesExchangeKeys: dataOwner.aesExchangeKeys,
88
- hcPartyKeys: dataOwner.hcPartyKeys
88
+ hcPartyKeys: dataOwner.hcPartyKeys,
89
89
  });
90
90
  }
91
91
  }
@@ -306,12 +306,16 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
306
306
  tryEncrypt(user, pats, requireAccessibleKey) {
307
307
  const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
308
308
  return Promise.all(pats.map((p) => __awaiter(this, void 0, void 0, function* () {
309
- const patientWithInitialisedEks = (p.encryptionKeys && Object.values(p.encryptionKeys).some((v) => !!v.length)
310
- ? p
311
- : yield this.initEncryptionKeys(user, p));
312
- const seks = yield this.crypto.extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, patientWithInitialisedEks.id, patientWithInitialisedEks.encryptionKeys).catch((e) => { console.error(e); throw e; });
313
- if (seks.extractedKeys.length) {
314
- const key = yield this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(seks.extractedKeys[0].replace(/-/g, '')));
309
+ const patientWithInitialisedEks = p.encryptionKeys && Object.values(p.encryptionKeys).some((v) => !!v.length) ? p : yield this.initEncryptionKeys(user, p);
310
+ const decryptedKeys = yield this.crypto
311
+ .extractKeysFromDelegationsForHcpHierarchy(dataOwnerId, patientWithInitialisedEks.id, patientWithInitialisedEks.encryptionKeys)
312
+ .catch((e) => {
313
+ console.error(e);
314
+ throw e;
315
+ });
316
+ const fixedKeys = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(decryptedKeys.extractedKeys);
317
+ if (fixedKeys.length) {
318
+ const key = yield this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(fixedKeys[0]));
315
319
  return (0, utils_1.crypt)(patientWithInitialisedEks, (obj) => this.crypto.AES.encrypt(key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj, (k, v) => {
316
320
  return v instanceof ArrayBuffer || v instanceof Uint8Array
317
321
  ? (0, binary_utils_1.b2a)(new Uint8Array(v).reduce((d, b) => d + String.fromCharCode(b), ''))
@@ -337,7 +341,9 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
337
341
  tryDecryptOrReturnOriginal(user, patients, fillDelegations = true) {
338
342
  return __awaiter(this, void 0, void 0, function* () {
339
343
  const dataOwnerId = this.dataOwnerApi.getDataOwnerOf(user);
340
- const ids = yield (user.healthcarePartyId ? this.hcpartyApi.getHealthcarePartyHierarchyIds(user.healthcarePartyId) : Promise.resolve([dataOwnerId]));
344
+ const ids = yield (user.healthcarePartyId
345
+ ? this.hcpartyApi.getHealthcarePartyHierarchyIds(user.healthcarePartyId)
346
+ : Promise.resolve([dataOwnerId]));
341
347
  //First check that we have no dangling delegation
342
348
  const patsWithMissingDelegations = patients.filter((p) => p.delegations &&
343
349
  ids.some((id) => p.delegations[id] && !p.delegations[id].length) &&
@@ -359,10 +365,11 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
359
365
  ? yield this.crypto
360
366
  .extractKeysFromDelegationsForHcpHierarchy(hcpId, p.id, _.size(p.encryptionKeys) ? p.encryptionKeys : p.delegations)
361
367
  .then(({ extractedKeys: sfks }) => {
368
+ sfks = this.crypto.filterAndFixValidEntityEncryptionKeyStrings(sfks);
362
369
  if (!sfks || !sfks.length) {
363
370
  return Promise.resolve(undefined);
364
371
  }
365
- 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)
372
+ return this.crypto.AES.importKey('raw', (0, binary_utils_1.hex2ua)(sfks[0])).then((key) => (0, utils_1.decrypt)(p, (ec) => this.crypto.AES.decrypt(key, ec)
366
373
  .then((dec) => {
367
374
  const jsonContent = dec && (0, binary_utils_1.ua2utf8)(dec);
368
375
  try {
@@ -412,7 +419,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
412
419
  return promise;
413
420
  });
414
421
  }
415
- share(user, patId, ownerId, delegateIds, delegationTags) {
422
+ share(user, patId, ownerId, delegateIds, delegationTags, usingPost = false) {
416
423
  const addDelegationsAndKeys = (dtos, markerPromise, delegateId, patient) => {
417
424
  return dtos.reduce((p, x) => p.then(() => Promise.all([this.crypto.extractDelegationsSFKs(x, ownerId), this.crypto.extractEncryptionsSKs(x, ownerId)]).then(([sfks, eks]) => {
418
425
  //console.log(`share ${x.id} to ${delegateId}`)
@@ -486,30 +493,30 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
486
493
  return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
487
494
  return delSfks.length
488
495
  ? Promise.all([
489
- (0, utils_1.retry)(() => this.helementApi
490
- .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
491
- .then((hes) => parentId
492
- ? this.helementApi
493
- .findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
494
- .then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
496
+ (0, utils_1.retry)(() => (usingPost
497
+ ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
498
+ : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((hes) => parentId
499
+ ? (usingPost
500
+ ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
501
+ : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
495
502
  : hes)),
496
- (0, utils_1.retry)(() => this.formApi
497
- .findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
498
- .then((frms) => parentId
499
- ? this.formApi
500
- .findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
501
- .then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
503
+ (0, utils_1.retry)(() => (usingPost
504
+ ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
505
+ : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
506
+ ? (usingPost
507
+ ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
508
+ : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
502
509
  : frms)),
503
- (0, utils_1.retry)(() => this.contactApi
504
- .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
505
- .then((ctcs) => parentId
506
- ? this.contactApi
507
- .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
508
- .then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
510
+ (0, utils_1.retry)(() => (usingPost
511
+ ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(ownerId, undefined, undefined, _.uniq(delSfks))
512
+ : this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
513
+ ? (usingPost
514
+ ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(parentId, undefined, undefined, _.uniq(delSfks))
515
+ : this.contactApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
509
516
  : ctcs)),
510
- (0, utils_1.retry)(() => this.invoiceApi
511
- .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
512
- .then((ivs) => parentId
517
+ (0, utils_1.retry)(() => (usingPost
518
+ ? this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
519
+ : this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
513
520
  ? this.invoiceApi
514
521
  .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
515
522
  .then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
@@ -521,12 +528,12 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
521
528
  .findClassificationsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
522
529
  .then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
523
530
  : cls)),
524
- (0, utils_1.retry)(() => this.calendarItemApi
525
- .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
526
- .then((cls) => parentId
527
- ? this.calendarItemApi
528
- .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
529
- .then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
531
+ (0, utils_1.retry)(() => (usingPost
532
+ ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
533
+ : this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((cls) => parentId
534
+ ? (usingPost
535
+ ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
536
+ : this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCls) => _.uniqBy(cls.concat(moreCls), 'id'))
530
537
  : cls)),
531
538
  ]).then(([hes, frms, ctcs, ivs, cls, cis]) => {
532
539
  const cloneKeysAndDelegations = function (x) {
@@ -731,7 +738,7 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
731
738
  });
732
739
  });
733
740
  }
734
- export(user, patId, ownerId) {
741
+ export(user, patId, ownerId, usingPost = false) {
735
742
  return this.hcpartyApi.getHealthcareParty(ownerId).then((hcp) => {
736
743
  const parentId = hcp.parentId;
737
744
  return (0, utils_1.retry)(() => this.getPatientWithUser(user, patId))
@@ -745,33 +752,33 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
745
752
  return this.crypto.extractDelegationsSFKsAndEncryptionSKs(patient, ownerId).then(([delSfks, ecKeys]) => {
746
753
  return delSfks.length
747
754
  ? Promise.all([
748
- (0, utils_1.retry)(() => this.helementApi
749
- .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
750
- .then((hes) => parentId
755
+ (0, utils_1.retry)(() => (usingPost
756
+ ? this.helementApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
757
+ : this.helementApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((hes) => parentId
751
758
  ? this.helementApi
752
759
  .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
753
760
  .then((moreHes) => _.uniqBy(hes.concat(moreHes), 'id'))
754
761
  : hes)),
755
- (0, utils_1.retry)(() => this.formApi
756
- .findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
757
- .then((frms) => parentId
758
- ? this.formApi
759
- .findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
760
- .then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
762
+ (0, utils_1.retry)(() => (usingPost
763
+ ? this.formApi.findFormsByHCPartyPatientForeignKeysUsingPost(ownerId, undefined, undefined, undefined, _.uniq(delSfks))
764
+ : this.formApi.findFormsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((frms) => parentId
765
+ ? (usingPost
766
+ ? this.formApi.findFormsByHCPartyPatientForeignKeysUsingPost(parentId, undefined, undefined, undefined, _.uniq(delSfks))
767
+ : this.formApi.findFormsByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreFrms) => _.uniqBy(frms.concat(moreFrms), 'id'))
761
768
  : frms)),
762
- (0, utils_1.retry)(() => this.contactApi
763
- .findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))
764
- .then((ctcs) => parentId
765
- ? this.contactApi
766
- .findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))
767
- .then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
769
+ (0, utils_1.retry)(() => (usingPost
770
+ ? this.contactApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
771
+ : this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(','))).then((ctcs) => parentId
772
+ ? (usingPost
773
+ ? this.contactApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
774
+ : this.contactApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(','))).then((moreCtcs) => _.uniqBy(ctcs.concat(moreCtcs), 'id'))
768
775
  : ctcs)),
769
- (0, utils_1.retry)(() => this.invoiceApi
770
- .findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
771
- .then((ivs) => parentId
772
- ? this.invoiceApi
773
- .findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))
774
- .then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
776
+ (0, utils_1.retry)(() => (usingPost
777
+ ? this.invoiceApi.findInvoicesByHCPartyPatientForeignKeysUsingPost(ownerId, _.uniq(delSfks))
778
+ : this.invoiceApi.findInvoicesByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))).then((ivs) => parentId
779
+ ? (usingPost
780
+ ? this.invoiceApi.findInvoicesByHCPartyPatientForeignKeysUsingPost(parentId, _.uniq(delSfks))
781
+ : this.invoiceApi.findInvoicesByHCPartyPatientForeignKeys(parentId, _.uniq(delSfks).join(','))).then((moreIvs) => _.uniqBy(ivs.concat(moreIvs), 'id'))
775
782
  : ivs)),
776
783
  (0, utils_1.retry)(() => this.classificationApi
777
784
  .findClassificationsByHCPartyPatientForeignKeys(ownerId, _.uniq(delSfks).join(','))
@@ -783,9 +790,13 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
783
790
  (0, utils_1.retry)(() => __awaiter(this, void 0, void 0, function* () {
784
791
  const delegationSFKs = _.uniq(delSfks).join(',');
785
792
  try {
786
- let calendarItems = yield this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, delegationSFKs);
793
+ let calendarItems = yield (usingPost
794
+ ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, _.uniq(delSfks))
795
+ : this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, _.uniq(delSfks).join(',')));
787
796
  if (parentId) {
788
- const moreCalendarItems = yield this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, delegationSFKs);
797
+ const moreCalendarItems = yield (usingPost
798
+ ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, _.uniq(delSfks))
799
+ : this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, _.uniq(delSfks).join(',')));
789
800
  calendarItems = _.uniqBy(calendarItems.concat(moreCalendarItems), 'id');
790
801
  }
791
802
  return calendarItems;