@icure/api 8.8.0 → 8.8.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 (97) hide show
  1. package/icc-api/api/IccAccesslogApi.d.ts +48 -0
  2. package/icc-api/api/IccAccesslogApi.js +100 -0
  3. package/icc-api/api/IccAccesslogApi.js.map +1 -1
  4. package/icc-api/api/IccAgendaApi.d.ts +25 -0
  5. package/icc-api/api/IccAgendaApi.js +49 -0
  6. package/icc-api/api/IccAgendaApi.js.map +1 -1
  7. package/icc-api/api/IccCalendarItemApi.d.ts +25 -0
  8. package/icc-api/api/IccCalendarItemApi.js +49 -0
  9. package/icc-api/api/IccCalendarItemApi.js.map +1 -1
  10. package/icc-api/api/IccCalendarItemTypeApi.d.ts +25 -0
  11. package/icc-api/api/IccCalendarItemTypeApi.js +49 -0
  12. package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
  13. package/icc-api/api/IccCodeApi.d.ts +25 -0
  14. package/icc-api/api/IccCodeApi.js +49 -0
  15. package/icc-api/api/IccCodeApi.js.map +1 -1
  16. package/icc-api/api/IccContactApi.d.ts +48 -0
  17. package/icc-api/api/IccContactApi.js +100 -0
  18. package/icc-api/api/IccContactApi.js.map +1 -1
  19. package/icc-api/api/IccDeviceApi.d.ts +48 -0
  20. package/icc-api/api/IccDeviceApi.js +100 -0
  21. package/icc-api/api/IccDeviceApi.js.map +1 -1
  22. package/icc-api/api/IccDocumentApi.d.ts +48 -0
  23. package/icc-api/api/IccDocumentApi.js +100 -0
  24. package/icc-api/api/IccDocumentApi.js.map +1 -1
  25. package/icc-api/api/IccFormApi.d.ts +48 -0
  26. package/icc-api/api/IccFormApi.js +101 -4
  27. package/icc-api/api/IccFormApi.js.map +1 -1
  28. package/icc-api/api/IccHcpartyApi.d.ts +48 -0
  29. package/icc-api/api/IccHcpartyApi.js +100 -0
  30. package/icc-api/api/IccHcpartyApi.js.map +1 -1
  31. package/icc-api/api/IccHelementApi.d.ts +48 -0
  32. package/icc-api/api/IccHelementApi.js +100 -0
  33. package/icc-api/api/IccHelementApi.js.map +1 -1
  34. package/icc-api/api/IccInsuranceApi.d.ts +50 -2
  35. package/icc-api/api/IccInsuranceApi.js +100 -0
  36. package/icc-api/api/IccInsuranceApi.js.map +1 -1
  37. package/icc-api/api/IccInvoiceApi.d.ts +48 -0
  38. package/icc-api/api/IccInvoiceApi.js +100 -0
  39. package/icc-api/api/IccInvoiceApi.js.map +1 -1
  40. package/icc-api/api/IccMessageApi.d.ts +48 -0
  41. package/icc-api/api/IccMessageApi.js +100 -0
  42. package/icc-api/api/IccMessageApi.js.map +1 -1
  43. package/icc-api/api/IccPatientApi.d.ts +48 -0
  44. package/icc-api/api/IccPatientApi.js +100 -0
  45. package/icc-api/api/IccPatientApi.js.map +1 -1
  46. package/icc-api/api/IccPlaceApi.d.ts +25 -0
  47. package/icc-api/api/IccPlaceApi.js +49 -0
  48. package/icc-api/api/IccPlaceApi.js.map +1 -1
  49. package/icc-api/api/IccReceiptApi.d.ts +25 -0
  50. package/icc-api/api/IccReceiptApi.js +49 -0
  51. package/icc-api/api/IccReceiptApi.js.map +1 -1
  52. package/icc-api/api/IccTopicApi.d.ts +48 -0
  53. package/icc-api/api/IccTopicApi.js +100 -0
  54. package/icc-api/api/IccTopicApi.js.map +1 -1
  55. package/icc-api/api/IccUserApi.d.ts +25 -0
  56. package/icc-api/api/IccUserApi.js +49 -0
  57. package/icc-api/api/IccUserApi.js.map +1 -1
  58. package/icc-api/model/ConflictResolutionRequest.d.ts +18 -0
  59. package/icc-api/model/ConflictResolutionRequest.js +17 -0
  60. package/icc-api/model/ConflictResolutionRequest.js.map +1 -0
  61. package/icc-api/model/ConflictResolutionResult.d.ts +22 -0
  62. package/icc-api/model/ConflictResolutionResult.js +24 -0
  63. package/icc-api/model/ConflictResolutionResult.js.map +1 -0
  64. package/icc-api/model/models.d.ts +2 -0
  65. package/icc-api/model/models.js +2 -0
  66. package/icc-api/model/models.js.map +1 -1
  67. package/icc-x-api/icc-accesslog-x-api.d.ts +31 -0
  68. package/icc-x-api/icc-accesslog-x-api.js +57 -0
  69. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  70. package/icc-x-api/icc-calendar-item-x-api.d.ts +15 -0
  71. package/icc-x-api/icc-calendar-item-x-api.js +28 -0
  72. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  73. package/icc-x-api/icc-contact-x-api.d.ts +31 -0
  74. package/icc-x-api/icc-contact-x-api.js +60 -1
  75. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  76. package/icc-x-api/icc-document-x-api.d.ts +31 -0
  77. package/icc-x-api/icc-document-x-api.js +64 -0
  78. package/icc-x-api/icc-document-x-api.js.map +1 -1
  79. package/icc-x-api/icc-form-x-api.d.ts +31 -0
  80. package/icc-x-api/icc-form-x-api.js +58 -0
  81. package/icc-x-api/icc-form-x-api.js.map +1 -1
  82. package/icc-x-api/icc-helement-x-api.d.ts +31 -0
  83. package/icc-x-api/icc-helement-x-api.js +57 -0
  84. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  85. package/icc-x-api/icc-invoice-x-api.d.ts +31 -0
  86. package/icc-x-api/icc-invoice-x-api.js +58 -0
  87. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  88. package/icc-x-api/icc-message-x-api.d.ts +31 -0
  89. package/icc-x-api/icc-message-x-api.js +64 -0
  90. package/icc-x-api/icc-message-x-api.js.map +1 -1
  91. package/icc-x-api/icc-patient-x-api.d.ts +31 -0
  92. package/icc-x-api/icc-patient-x-api.js +57 -0
  93. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  94. package/icc-x-api/icc-topic-x-api.d.ts +31 -0
  95. package/icc-x-api/icc-topic-x-api.js +58 -0
  96. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  97. package/package.json +1 -1
@@ -1116,6 +1116,63 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
1116
1116
  return true;
1117
1117
  });
1118
1118
  }
1119
+ /**
1120
+ * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
1121
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
1122
+ * @param entityId the id of the patient to retrieve the conflicts for.
1123
+ * @return the decrypted conflicting revisions of the patient.
1124
+ */
1125
+ getConflictsForEntityWithUser(user, entityId) {
1126
+ return super.getConflictsForEntity(entityId).then((ps) => this.decrypt(user, ps));
1127
+ }
1128
+ /**
1129
+ * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
1130
+ * winner returned by the backend.
1131
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
1132
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
1133
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
1134
+ */
1135
+ declareConflictWinnerWithUser(user, request) {
1136
+ const _super = Object.create(null, {
1137
+ declareConflictWinner: { get: () => super.declareConflictWinner }
1138
+ });
1139
+ return __awaiter(this, void 0, void 0, function* () {
1140
+ const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
1141
+ const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
1142
+ if (result.document)
1143
+ result.document = (yield this.decrypt(user, [result.document]))[0];
1144
+ return result;
1145
+ });
1146
+ }
1147
+ /**
1148
+ * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
1149
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
1150
+ * @param groupId the id of the group the patient belongs to.
1151
+ * @param entityId the id of the patient to retrieve the conflicts for.
1152
+ * @return the decrypted conflicting revisions of the patient.
1153
+ */
1154
+ getConflictsForEntityInGroupWithUser(user, groupId, entityId) {
1155
+ return super.getConflictsForEntityInGroup(groupId, entityId).then((ps) => this.decrypt(user, ps));
1156
+ }
1157
+ /**
1158
+ * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
1159
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
1160
+ * @param groupId the id of the group the patient belongs to.
1161
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
1162
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
1163
+ */
1164
+ declareConflictWinnerInGroupWithUser(user, groupId, request) {
1165
+ const _super = Object.create(null, {
1166
+ declareConflictWinnerInGroup: { get: () => super.declareConflictWinnerInGroup }
1167
+ });
1168
+ return __awaiter(this, void 0, void 0, function* () {
1169
+ const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
1170
+ const result = yield _super.declareConflictWinnerInGroup.call(this, groupId, Object.assign(Object.assign({}, request), { document: encrypted }));
1171
+ if (result.document)
1172
+ result.document = (yield this.decrypt(user, [result.document]))[0];
1173
+ return result;
1174
+ });
1175
+ }
1119
1176
  }
1120
1177
  exports.IccPatientXApi = IccPatientXApi;
1121
1178
  //# sourceMappingURL=icc-patient-x-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icc-patient-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-patient-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AAUtD,+DAA4D;AAC5D,kDAAiD;AACjD,oDAA8G;AAE9G,8DAAsD;AACtD,qDAA8E;AAC9E,mCAA4H;AAE5H,0EAAgG;AAChG,uFAAmF;AACnF,wEAAoE;AAEpE,qFAAiF;AACjF,4EAAwE;AAExE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAK3E,4DAAwE;AAGxE,qCAAqC;AACrC,MAAa,cAAe,SAAQ,uBAAa;IAG/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAA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,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,2DAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IACpJ,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,gDAAgD,CAAC,SAAiB;;;;;YACtE,MAAM,OAAO,GAAG,MAAM,OAAM,UAAU,YAAC,SAAS,CAAC,CAAA;YACjD,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI;gBAAE,OAAO,KAAK,CAAA;YACpE,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,2BAA2B,CAAC,SAAS,EAAE;gBACpE,+BAA+B,EAAE,IAAI;aACtC,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;QACb,CAAC;KAAA;CACF;AAv/CD,wCAu/CC","sourcesContent":["import { IccAuthApi, IccPatientApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\n\nimport { cloneDeep, uniqBy } from './utils/collection-utils'\nimport * as models from '../icc-api/model/models'\nimport { Document, IcureStub, ListOfIds, MaintenanceTask, Patient, TimingInfo } from '../icc-api/model/models'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { b64_2ab } from '../icc-api/model/ModelHelper'\nimport { findName, garnishPersonWithName, hasName } from './utils/person-util'\nimport { EncryptedFieldsManifest, parseEncryptedFields, retry, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { EntityWithDelegationTypeName } from './utils/EntityWithDelegationTypeName'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { MinimalEntityBulkShareResult } from '../icc-api/model/requests/MinimalEntityBulkShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { BulkShareOrUpdateMetadataParams } from '../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccPatientXApi extends IccPatientApi implements EncryptedEntityXApi<models.Patient> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Patient))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly contactApi: IccContactXApi,\n private readonly formApi: IccFormXApi,\n private readonly helementApi: IccHelementXApi,\n private readonly invoiceApi: IccInvoiceXApi,\n private readonly documentApi: IccDocumentXApi,\n private readonly hcpartyApi: IccHcpartyXApi,\n private readonly classificationApi: IccClassificationXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly calendarItemApi: IccCalendarItemXApi,\n private readonly userApi: IccUserXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = ['note'],\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\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Patient.')\n }\n\n /**\n * Creates a new instance of patient with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param p initialised data for the patient. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of patient.\n */\n async newInstance(\n user: models.User,\n p: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const patient = {\n ...(p ?? {}),\n _type: 'org.taktik.icure.entities.Patient',\n id: p?.id ?? this.crypto.primitives.randomUuid(),\n created: p?.created ?? new Date().getTime(),\n modified: p?.modified ?? new Date().getTime(),\n responsible: p?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: p?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: p?.codes ?? [],\n tags: p?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n const initialisationInfo = await this.crypto.xapi.entityWithInitialisedEncryptedMetadata(\n patient,\n EntityWithDelegationTypeName.Patient,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n return new models.Patient(initialisationInfo.updatedEntity)\n }\n\n /**\n * Ensures patient names are consistent by synchronizing names property with firstName/lastName/maidenName/alias fields.\n * @param patient the patient to process\n * @return the patient with completed names\n */\n completeNames(patient: models.Patient): models.Patient {\n let finalPatient: any = patient\n\n if (!!finalPatient.lastName && !hasName(finalPatient, models.PersonName.UseEnum.Official)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Official, finalPatient.lastName, finalPatient.firstName)\n }\n\n if (!!finalPatient.maidenName && !hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Maiden, finalPatient.maidenName, finalPatient.firstName)\n }\n\n if (!!finalPatient.alias && !hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Nickname, finalPatient.alias, finalPatient.firstName)\n }\n\n if (!finalPatient.lastName && !!hasName(finalPatient, models.PersonName.UseEnum.Official)) {\n const officialName = findName(finalPatient, models.PersonName.UseEnum.Official)\n finalPatient = {\n ...finalPatient,\n lastName: officialName!.lastName,\n firstName: officialName!.firstNames?.[0],\n }\n }\n\n if (!finalPatient.maidenName && !!hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {\n finalPatient = {\n ...finalPatient,\n maidenName: findName(finalPatient, models.PersonName.UseEnum.Maiden)!.lastName,\n }\n }\n\n if (!finalPatient.alias && !!hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {\n finalPatient = {\n ...finalPatient,\n alias: findName(finalPatient, models.PersonName.UseEnum.Nickname)!.lastName,\n }\n }\n\n return new Patient(finalPatient)\n }\n\n /**\n * @deprecated replace with {@link initConfidentialSecretId}\n */\n async initConfidentialDelegation(patient: models.Patient, user: models.User): Promise<models.Patient> {\n return this.initConfidentialSecretId(patient, user)\n }\n\n /**\n * Ensures that the current data owner has some confidential secret ids for the provided patient. If not creates them and updates the patient in the\n * database.\n * @param patient the patient for which you want to initialise the confidential secret id.\n * @param user the current user.\n * @return the updated patient or the original patient if no change was necessary.\n */\n async initConfidentialSecretId(patient: models.Patient, user: models.User): Promise<models.Patient> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (dataOwnerId !== (await this.dataOwnerApi.getCurrentDataOwnerId()))\n throw new Error('You can initialise confidential delegations only for the current data owner')\n let updatedPatient = patient\n if (!patient.rev) {\n updatedPatient = await this.createPatientWithUser(user, patient)\n if (!updatedPatient) throw new Error('Could not create patient')\n }\n const initialised = await this.crypto.xapi.initialiseConfidentialSecretId(updatedPatient, EntityWithDelegationTypeName.Patient, (x) =>\n this.bulkSharePatients(x)\n )\n if (initialised) {\n return initialised\n } else {\n return updatedPatient\n }\n }\n\n createPatient(body?: models.Patient): never {\n throw new Error('Cannot call a method that returns patients without providing a user for de/encryption')\n }\n\n /**\n * Creates a patient in the database with encryption.\n * @param user the current user\n * @param body the patient data to create\n * @return the created patient\n */\n createPatientWithUser(user: models.User, body?: models.Patient): Promise<models.Patient | any> {\n return body\n ? this.encrypt(user, [cloneDeep(this.completeNames(body))])\n .then((pats) => super.createPatient(pats[0]))\n .then(async (patient: Patient) => {\n /**\n * This code is a workaround for the fact that the backend is adding empty delegations to the patient when it is created.\n */\n\n const patientDelegations = patient.delegations\n\n if (patientDelegations != undefined && Object.keys(patientDelegations).length > 0) {\n const areDelegationsEmpty = Object.values(patientDelegations).every((delegation) => delegation.length === 0)\n\n if (areDelegationsEmpty) {\n return await this.modifyPatientRaw(\n new Patient({\n ...patient,\n delegations: {},\n })\n )\n }\n }\n return patient\n })\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n : Promise.resolve(null)\n }\n\n filterBy(\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n body?: models.FilterChainPatient\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Filters patients using a filter chain and returns decrypted results.\n * @param user the current user\n * @param filterChain the filter chain to apply\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param skip optional number of results to skip\n * @param sort optional sort field\n * @param desc optional sort direction\n * @param collectTiming add timing information to the response\n * @return paginated list of decrypted patients\n */\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming?: false\n ): Promise<models.PaginatedListPatient | any>\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming?: true\n ): Promise<(models.PaginatedListPatient & TimingInfo) | any>\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming: boolean = false\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .filterPatientsBy(startKey, startDocumentId, limit, skip, sort, desc, filterChain, collectTiming as any)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n findByAccessLogUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds patients by access log user after a specific date and returns decrypted results.\n * @param user the current user\n * @param userId the user id to search for in access logs\n * @param accessType optional type of access\n * @param startDate optional start date timestamp\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted patients\n */\n findByAccessLogUserAfterDateWithUser(\n user: models.User,\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .findByAccessLogUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n findByAccessLogUserAfterDate_1(externalId: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds a patient by external id and returns the decrypted result.\n * @param user the current user\n * @param externalId the external id to search for\n * @return the decrypted patient\n */\n findByExternalIdWithUser(user: models.User, externalId: string): Promise<models.Patient | any> {\n return super\n .findByExternalId(externalId)\n .then((pats) => this.decrypt(user, [pats]))\n .then((x) => x[0])\n }\n\n findByNameBirthSsinAuto(\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds patients by name, birth date, or SSIN with automatic search and returns decrypted results.\n * @param user the current user\n * @param healthcarePartyId optional healthcare party id\n * @param filterValue optional search value\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n findByNameBirthSsinAutoWithUser(\n user: models.User,\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .findByNameBirthSsinAuto(healthcarePartyId, filterValue, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n fuzzySearch(firstName?: string, lastName?: string, dateOfBirth?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Performs a fuzzy search for patients and returns decrypted results.\n * @param user the current user\n * @param firstName optional first name to search for\n * @param lastName optional last name to search for\n * @param dateOfBirth optional date of birth timestamp\n * @return array of decrypted patients\n */\n fuzzySearchWithUser(user: models.User, firstName?: string, lastName?: string, dateOfBirth?: number): Promise<Array<models.Patient> | any> {\n return super.fuzzySearch(firstName, lastName, dateOfBirth).then((pats) => this.decrypt(user, pats))\n }\n\n getPatient(patientId: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Gets a patient by id without decryption.\n * @param patientId the patient id\n * @return the encrypted patient\n */\n getPatientRaw(patientId: string): Promise<models.Patient | any> {\n return super.getPatient(patientId)\n }\n\n /**\n * Gets a patient by id with decryption.\n * @param user the current user\n * @param patientId the patient id\n * @return the decrypted patient\n */\n getPatientWithUser(user: models.User, patientId: string): Promise<models.Patient | any> {\n return super\n .getPatient(patientId)\n .then((p) => this.tryDecryptOrReturnOriginal([p]))\n .then((pats) => pats[0].entity)\n }\n\n /**\n * Gets a patient by id and indicates whether it was successfully decrypted.\n * @param user the current user\n * @param patientId the patient id\n * @return object containing the patient and a flag indicating if it was decrypted\n */\n getPotentiallyEncryptedPatientWithUser(user: models.User, patientId: string): Promise<{ patient: models.Patient; decrypted: boolean }> {\n return super\n .getPatient(patientId)\n .then((p) => this.tryDecryptOrReturnOriginal([p]))\n .then((pats) => ({ patient: pats[0].entity, decrypted: pats[0].decrypted }))\n }\n\n getPatients(body?: models.ListOfIds): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Gets multiple patients by their ids with decryption.\n * @param user the current user\n * @param body list of patient ids\n * @return array of decrypted patients\n */\n getPatientsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<models.Patient> | any> {\n return super.getPatients(body).then((pats) => this.decrypt(user, pats))\n }\n\n listDeletedPatients(startDate?: number, endDate?: number, desc?: boolean, startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists deleted patients with decryption.\n * @param user the current user\n * @param startDate optional start date timestamp\n * @param endDate optional end date timestamp\n * @param desc optional sort direction\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted deleted patients\n */\n listDeletedPatientsWithUser(\n user: models.User,\n startDate?: number,\n endDate?: number,\n desc?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listDeletedPatients(startDate, endDate, desc, startDocumentId, startKey, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listDeletedPatients_2(firstName?: string, lastName?: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists deleted patients by name with decryption.\n * @param user the current user\n * @param firstName optional first name to filter by\n * @param lastName optional last name to filter by\n * @return array of decrypted deleted patients\n */\n listDeletedPatientsByNameWithUser(user: models.User, firstName?: string, lastName?: string): Promise<Array<models.Patient> | any> {\n return super.listDeletedPatientsByName(firstName, lastName).then((rows) => this.decrypt(user, rows, false))\n }\n\n listOfMergesAfter(date: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists merged patients after a specific date with decryption.\n * @param user the current user\n * @param date timestamp to start from\n * @return array of decrypted merged patients\n */\n listOfMergesAfterWithUser(user: models.User, date: number): Promise<Array<models.Patient> | any> {\n return super.listOfMergesAfter(date).then((pats) => this.decrypt(user, pats, false))\n }\n\n listOfPatientsModifiedAfter(date: number, startKey?: number, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients modified after a specific date with decryption.\n * @param user the current user\n * @param date timestamp to start from\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted modified patients\n */\n listOfPatientsModifiedAfterWithUser(\n user: models.User,\n date: number,\n startKey?: number,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listOfPatientsModifiedAfter(date, startKey, startDocumentId, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatients(hcPartyId?: string, sortField?: string, startKey?: string, startDocumentId?: string, limit?: number, sortDirection?: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients with decryption.\n * @param user the current user\n * @param hcPartyId optional healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsWithUser(\n user: models.User,\n hcPartyId?: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatients(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatientsByHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients by healthcare party with decryption.\n * @param user the current user\n * @param hcPartyId the healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsByHcPartyWithUser(\n user: models.User,\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatientsByHcParty(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatientsOfHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients of a healthcare party with decryption.\n * @param user the current user\n * @param hcPartyId the healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsOfHcPartyWithUser(\n user: models.User,\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatientsOfHcParty(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n mergeInto(toId: string, fromIds: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Merges patients and returns the decrypted result.\n * @param user the current user\n * @param toId the target patient id\n * @param fromIds the source patient ids to merge from\n * @return the decrypted merged patient\n */\n mergeIntoWithUser(user: models.User, toId: string, fromIds: string): Promise<models.Patient | any> {\n return super\n .mergeInto(toId, fromIds)\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n }\n\n modifyPatient(body?: models.Patient): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice.\n */\n modifyPatientRaw(body?: models.Patient): Promise<models.Patient | any> {\n return super.modifyPatient(body)\n }\n\n /**\n * Updates a patient with encryption.\n * @param user the current user\n * @param body the patient data to update\n * @return the updated decrypted patient\n */\n modifyPatientWithUser(user: models.User, body?: models.Patient): Promise<models.Patient | null> {\n return body ? this.modifyPatientAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : Promise.resolve(null)\n }\n\n private modifyPatientAs(dataOwner: string, body: models.Patient): Promise<models.Patient> {\n return this.encryptAs(dataOwner, [cloneDeep(this.completeNames(body))])\n .then((pats) => super.modifyPatient(pats[0]))\n .then((p) => this.decryptAs(dataOwner, [p]))\n .then((pats) => pats[0])\n }\n\n modifyPatientReferral(patientId: string, referralId: string, start?: number, end?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Updates a patient referral and returns the decrypted result.\n * @param user the current user\n * @param patientId the patient id\n * @param referralId the referral id\n * @param start optional start timestamp\n * @param end optional end timestamp\n * @return the updated decrypted patient\n */\n modifyPatientReferralWithUser(\n user: models.User,\n patientId: string,\n referralId: string,\n start?: number,\n end?: number\n ): Promise<models.Patient | any> {\n return super\n .modifyPatientReferral(patientId, referralId, start, end)\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n }\n\n /**\n * Encrypts patients using the current user's encryption keys.\n * @param user the current user\n * @param pats the patients to encrypt\n * @return the encrypted patients\n */\n encrypt(user: models.User, pats: Array<models.Patient>): Promise<Array<models.Patient>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(dataOwnerId, pats)\n }\n\n private encryptAs(dataOwner: string, pats: Array<models.Patient>): Promise<Array<models.Patient>> {\n return this.crypto.xapi.tryEncryptEntities(\n pats,\n EntityWithDelegationTypeName.Patient,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Patient(x)\n )\n }\n\n /**\n * Decrypts patients using the current user's encryption keys. If a patient can't be decrypted, returns it with encrypted data.\n * @param user the current user\n * @param patients the patients to decrypt\n * @param fillDelegations optional flag to fill delegations (defaults to true)\n * @return the decrypted patients\n */\n decrypt(user: models.User, patients: Array<models.Patient>, fillDelegations = true): Promise<Array<models.Patient>> {\n return this.decryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), patients, fillDelegations)\n }\n\n private decryptAs(dataOwner: string, patients: Array<models.Patient>, fillDelegations = true): Promise<Array<models.Patient>> {\n return this.tryDecryptOrReturnOriginal(patients).then((ps) => ps.map((p) => p.entity))\n }\n\n /**\n * Attempts to decrypt patients. If decryption fails, returns the original encrypted patients.\n * @param patients the patients to decrypt\n * @return array of objects containing the patient entity and a flag indicating if it was decrypted\n */\n async tryDecryptOrReturnOriginal(patients: Array<models.Patient>): Promise<{ entity: models.Patient; decrypted: boolean }[]> {\n return (await this.crypto.xapi.tryDecryptEntities(patients, EntityWithDelegationTypeName.Patient, (x) => new models.Patient(x))).map((p) => {\n if (p.entity.picture && !(p.entity.picture instanceof ArrayBuffer)) {\n return {\n entity: new models.Patient({\n ...p.entity,\n picture: b64_2ab(p.entity.picture),\n }),\n decrypted: p.decrypted,\n }\n } else return p\n })\n }\n\n /**\n * @deprecated replace with {@link shareAllDataOfPatient}\n */\n async share(\n user: models.User,\n patId: string,\n ownerId: string,\n delegateIds: Array<string>,\n delegationTags: { [key: string]: Array<string> },\n usingPost: boolean = false\n ): Promise<{\n patient: models.Patient | null\n statuses: { [key: string]: { success: boolean | null; error: Error | null } }\n } | null> {\n return this.shareAllDataOfPatient(user, patId, ownerId, delegateIds, delegationTags, usingPost)\n }\n\n /**\n * Shares a patient and all related data with specified delegates.\n * @param user the current user\n * @param patId the patient id\n * @param ownerId the owner healthcare party id\n * @param delegateIds the delegate ids to share with\n * @param delegationTags tags specifying what data to share (e.g., medicalInformation, financialInformation, all)\n * @param usingPost optional flag to use POST method instead of GET (defaults to false)\n * @return object containing the updated patient and sharing statuses for each entity type\n */\n async shareAllDataOfPatient(\n user: models.User,\n patId: string,\n ownerId: string,\n delegateIds: Array<string>,\n delegationTags: { [key: string]: Array<string> },\n usingPost: boolean = false\n ): Promise<{\n patient: models.Patient | null\n statuses: { [key: string]: { success: boolean | null; error: Error | null } }\n } | null> {\n const allTags: string[] = [...new Set(Object.values(delegationTags).flat())]\n const status = {\n contacts: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n forms: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n healthElements: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n invoices: {\n success: allTags.includes('financialInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n documents: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n classifications: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n calendarItems: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n patient: { success: false, error: null, modified: 0 } as {\n success: boolean\n error: Error | null\n },\n }\n const hcp = await this.hcpartyApi.getHealthcareParty(ownerId)\n const parentId = hcp.parentId\n let patient = await retry(() => this.getPatientWithUser(user, patId))\n const patientWithInitialisedEncryption = await this.crypto.xapi.ensureEncryptionKeysInitialised(patient, EntityWithDelegationTypeName.Patient)\n if (patientWithInitialisedEncryption) {\n patient = await this.modifyPatientWithUser(user, patientWithInitialisedEncryption)\n }\n\n if (!patient) {\n status.patient = {\n success: false,\n error: new Error('Patient does not exist or cannot initialise encryption keys'),\n }\n return { patient: patient, statuses: status }\n }\n\n const delSfks = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId)\n const ecKeys = await this.crypto.xapi.encryptionKeysOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId)\n\n if (delSfks.length) {\n const retrievedHealthElements = await retry(() =>\n (usingPost\n ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((hes) =>\n parentId\n ? (usingPost\n ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, [...new Set(delSfks)])\n : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreHes) => uniqBy(hes.concat(moreHes), 'id'))\n : hes\n )\n )\n const retrievedForms = await retry(() =>\n (usingPost\n ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((frms) =>\n parentId\n ? (usingPost\n ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, [...new Set(delSfks)])\n : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreFrms) => uniqBy(frms.concat(moreFrms), 'id'))\n : frms\n )\n )\n const retrievedContacts = await retry(() =>\n (usingPost\n ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(ownerId, undefined, undefined, [...new Set(delSfks)])\n : this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((ctcs) =>\n parentId\n ? (usingPost\n ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(parentId, undefined, undefined, [...new Set(delSfks)])\n : this.contactApi.findByHCPartyPatientSecretFKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreCtcs) => uniqBy(ctcs.concat(moreCtcs), 'id'))\n : ctcs\n )\n )\n const retrievedInvoices = await retry(() =>\n (usingPost\n ? this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((ivs) =>\n parentId\n ? this.invoiceApi\n .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n .then((moreIvs) => uniqBy(ivs.concat(moreIvs), 'id'))\n : ivs\n )\n )\n const retrievedClassifications = await retry(() =>\n this.classificationApi\n .findClassificationsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n .then((cls) =>\n parentId\n ? this.classificationApi\n .findClassificationsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n .then((moreCls) => uniqBy(cls.concat(moreCls), 'id'))\n : cls\n )\n )\n const retrievedCalendarItems = await retry(() =>\n (usingPost\n ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, [...new Set(delSfks)])\n : this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((cls) =>\n parentId\n ? (usingPost\n ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, [...new Set(delSfks)])\n : this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreCls) => uniqBy(cls.concat(moreCls), 'id'))\n : cls\n )\n )\n const isMedicalInfoTags = (tags: string[]) => tags.includes('medicalInformation') || tags.includes('all')\n const isFinancialInfoTags = (tags: string[]) => tags.includes('financialInformation') || tags.includes('all')\n const doShareEntitiesAndUpdateStatus = async (\n entities: models.IcureStub[],\n entitiesType: EntityWithDelegationTypeName,\n status: {\n success: boolean | null\n error: null | Error\n modified: number\n },\n tagsCondition: (tags: string[]) => boolean,\n doShareMinimal: (request: BulkShareOrUpdateMetadataParams) => Promise<MinimalEntityBulkShareResult[]>\n ): Promise<void> => {\n const delegatesToApply = delegateIds.filter((delegateId) => tagsCondition(delegationTags[delegateId]))\n if (entities.length && delegatesToApply.length) {\n const requests: {\n entity: IcureStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[] = []\n for (const entity of entities) {\n const currentEntityRequests: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n } = {}\n const secretIds = await this.crypto.xapi.secretIdsOf({ entity, type: entitiesType }, undefined)\n const encryptionKeys = await this.crypto.xapi.encryptionKeysOf({ entity, type: entitiesType }, undefined)\n const request = {\n shareSecretIds: secretIds,\n shareEncryptionKeys: encryptionKeys,\n shareOwningEntityIds: [patient.id!],\n requestedPermissions: RequestedPermissionEnum.MAX_WRITE,\n }\n for (const delegateId of delegatesToApply) {\n currentEntityRequests[delegateId] = request\n }\n requests.push({ dataForDelegates: currentEntityRequests, entity })\n }\n await this.crypto.xapi\n .bulkShareOrUpdateEncryptedEntityMetadataNoEntities(entitiesType, requests, (x) => doShareMinimal(x))\n .then((shareResult) => {\n status.modified = new Set(shareResult.successfulUpdates.map((x) => x.entityId)).size\n status.success = shareResult.updateErrors.length === 0\n if (!status.success) {\n const errorMsg = `Error while sharing (some) entities of type ${entitiesType} for patient ${patient.id} : ${JSON.stringify(\n shareResult.updateErrors\n )}`\n console.error(errorMsg)\n status.error = new Error(errorMsg)\n }\n })\n .catch((e) => {\n status.success = false\n status.error = e\n })\n } else {\n status.success = true\n }\n }\n await doShareEntitiesAndUpdateStatus(\n retrievedHealthElements,\n EntityWithDelegationTypeName.HealthElement,\n status.healthElements,\n isMedicalInfoTags,\n (x) => this.helementApi.bulkShareHealthElementsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedContacts, EntityWithDelegationTypeName.Contact, status.contacts, isMedicalInfoTags, (x) =>\n this.contactApi.bulkShareContactsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedInvoices, EntityWithDelegationTypeName.Invoice, status.invoices, isFinancialInfoTags, (x) =>\n this.invoiceApi.bulkShareInvoicesMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(\n retrievedClassifications,\n EntityWithDelegationTypeName.Classification,\n status.classifications,\n isMedicalInfoTags,\n (x) => this.classificationApi.bulkShareClassificationsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(\n retrievedCalendarItems,\n EntityWithDelegationTypeName.CalendarItem,\n status.calendarItems,\n isMedicalInfoTags,\n (x) => this.calendarItemApi.bulkShareCalendarItemsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedForms, EntityWithDelegationTypeName.Form, status.forms, isMedicalInfoTags, (x) =>\n this.formApi.bulkShareFormsMinimal(x)\n )\n }\n const sharePatientDataRequest = {\n shareSecretIds: delSfks,\n shareEncryptionKeys: ecKeys,\n shareOwningEntityIds: [],\n requestedPermissions: RequestedPermissionEnum.MAX_WRITE,\n }\n const sharePatientRequest = {\n entity: patient,\n dataForDelegates: Object.fromEntries(delegateIds.map((delegateId) => [delegateId, sharePatientDataRequest])),\n }\n return await this.crypto.xapi\n .bulkShareOrUpdateEncryptedEntityMetadata(EntityWithDelegationTypeName.Patient, [sharePatientRequest], (x) => this.bulkSharePatients(x))\n .then((shareResult) => {\n if (shareResult.updatedEntities.length && !shareResult.updateErrors.length) {\n status.patient.success = true\n return { patient: shareResult.updatedEntities[0], statuses: status }\n } else {\n const errorMsg = `Error while sharing patient with id ${patient.id} : ${JSON.stringify(shareResult.updateErrors)}`\n console.error(errorMsg)\n status.patient.error = new Error(errorMsg)\n status.patient.success = false\n return { patient: shareResult.updatedEntities[0] ?? patient, statuses: status }\n }\n })\n .catch((e) => {\n status.patient.error = e\n status.patient.success = false\n return { patient, statuses: status }\n })\n }\n\n /**\n * Exports a patient and all related medical data.\n * @param user the current user\n * @param patId the patient id\n * @param ownerId the owner healthcare party id\n * @return object containing the patient and all related entities (contacts, forms, health elements, invoices, classifications, calendar items, documents)\n */\n async export(\n user: models.User,\n patId: string,\n ownerId: string\n ): Promise<{\n id: string\n patient: Patient | null\n contacts: models.Contact[]\n forms: models.Form[]\n healthElements: models.HealthElement[]\n invoices: models.Invoice[]\n classifications: models.Classification[]\n calItems: models.CalendarItem[]\n documents: models.Document[]\n }> {\n const parentId = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds().then((h) => (h.length - 2 >= 0 ? h[h.length - 2] : h[0]))\n const patient = await retry(async () => {\n const retrieved: Patient | undefined = await this.getPatientWithUser(user, patId)\n if (retrieved != undefined) {\n const initialised = await this.crypto.xapi.ensureEncryptionKeysInitialised(retrieved, EntityWithDelegationTypeName.Patient)\n if (!initialised) {\n return retrieved\n } else {\n return await this.modifyPatientWithUser(user, initialised)\n }\n } else {\n return null\n }\n })\n const delSfks =\n patient != null ? await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId) : []\n if (delSfks.length <= 0) {\n return {\n id: patId,\n patient,\n contacts: [],\n forms: [],\n healthElements: [],\n invoices: [],\n classifications: [],\n calItems: [],\n documents: [],\n }\n }\n const contactIds = new Set([\n ...(await retry(() => this.contactApi.findContactIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.contactApi.findContactIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const formIds = new Set([\n ...(await retry(() => this.formApi.findFormIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.formApi.findFormIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const healthElementIds = new Set([\n ...(await retry(() => this.helementApi.findHealthElementIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.helementApi.findHealthElementIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const invoiceIds = new Set([\n ...(await retry(() => this.invoiceApi.findInvoiceIdsByDataOwnerPatientInvoiceDate(ownerId, delSfks))),\n ...(await retry(() => this.invoiceApi.findInvoiceIdsByDataOwnerPatientInvoiceDate(parentId, delSfks))),\n ])\n const classificationIds = new Set([\n ...(await retry(() => this.classificationApi.findClassificationIdsByDataOwnerPatientCreated(ownerId, delSfks))),\n ...(await retry(() => this.classificationApi.findClassificationIdsByDataOwnerPatientCreated(parentId, delSfks))),\n ])\n const calendarItemIds = new Set([\n ...(await retry(() => this.calendarItemApi.findCalendarItemIdsByDataOwnerPatientStartTime(ownerId, delSfks))),\n ...(await retry(() => this.calendarItemApi.findCalendarItemIdsByDataOwnerPatientStartTime(parentId, delSfks))),\n ])\n async function batchGet<T>(items: string[], get: (batch: string[]) => Promise<T[]>, batchSize: number = 1000): Promise<T[]> {\n const results: T[] = []\n for (let i = 0; i < items.length; i += batchSize) {\n const batch = items.slice(i, i + batchSize)\n const res = await retry(() => get(batch))\n results.push(...res)\n }\n return results\n }\n const contacts = await batchGet([...contactIds], (x): Promise<models.Contact[]> => this.contactApi.getContactsWithUser(user, { ids: x }))\n const forms = await batchGet([...formIds], (x): Promise<models.Form[]> => this.formApi.getForms({ ids: x }))\n const healthElements = await batchGet(\n [...healthElementIds],\n (x): Promise<models.HealthElement[]> => this.helementApi.getHealthElementsWithUser(user, { ids: x })\n )\n const invoices = await batchGet([...invoiceIds], (x): Promise<models.Invoice[]> => this.invoiceApi.getInvoices({ ids: x }))\n const classifications = await batchGet(\n [...classificationIds],\n (x): Promise<models.Classification[]> => this.classificationApi.getClassifications({ ids: x })\n )\n const calItems = await batchGet(\n [...calendarItemIds],\n (x): Promise<models.CalendarItem[]> => this.calendarItemApi.getCalendarItemsWithIdsWithUser(user, { ids: x })\n )\n const documentIds = new Set<string>()\n contacts.forEach((contact) => {\n contact.services?.forEach((service) => {\n Object.values(service.content ?? {}).forEach((content) => {\n if (!!content.documentId) documentIds.add(content.documentId)\n })\n })\n })\n const documents = await batchGet([...documentIds], (x): Promise<models.Document[]> => this.documentApi.getDocumentsWithUser(user, { ids: x }))\n return {\n id: patId,\n patient,\n calItems,\n classifications,\n contacts,\n documents,\n forms,\n healthElements,\n invoices,\n }\n }\n\n /**\n * Validates a Belgian INAMI number using modulo 97 check.\n * @param inami the INAMI number to validate\n * @return true if the INAMI number is valid, false otherwise\n */\n checkInami(inami: string): boolean {\n const num_inami = inami.replace(new RegExp('[^(0-9)]', 'g'), '')\n\n const checkDigit = num_inami.substring(6, 8)\n const numSansCheck = num_inami.substring(0, 6)\n let retour = false\n\n //modulo du niss\n const modINAMI = parseInt(numSansCheck) % 97\n\n //obtention du num de check 97 - le resultat du mod\n const checkDigit_2 = 97 - modINAMI\n\n if (parseInt(checkDigit) == checkDigit_2) {\n retour = true\n }\n return retour\n }\n\n /**\n * Validates a Belgian social security identification number (SSIN/NISS) including support for bis and ter numbers.\n * @param ssin the SSIN to validate\n * @return true if the SSIN is valid, false otherwise\n */\n isValidSsin(ssin: string) {\n ssin = ssin.replace(new RegExp('[^(0-9)]', 'g'), '')\n let isValidNiss = false\n\n const normalNumber =\n /^[0-9][0-9](([0][0-9])|([1][0-2]))(([0-2][0-9])|([3][0-1]))(([0-9]{2}[1-9])|([0-9][1-9][0-9])|([1-9][0-9]{2}))(([0-8][0-9])|([9][0-7]))$/.test(\n ssin\n )\n const bisNumber = /^[0-9][0-9](([2][0-9])|([3][0-2]))(([0-2][0-9])|([3][0-1]))[0-9]{3}(([0-8][0-9])|([9][0-7]))$/.test(ssin)\n const terNumber = /^[0-9][0-9](([4][0-9])|([5][0-2]))(([0-2][0-9])|([3][0-1]))[0-9]{3}(([0-8][0-9])|([9][0-7]))$/.test(ssin)\n\n if (normalNumber || bisNumber || terNumber) {\n isValidNiss =\n 97 - (Number(ssin.substring(0, 9)) % 97) === Number(ssin.substring(9, 11))\n ? true\n : 97 - (Number('2' + ssin.substring(0, 9)) % 97) === Number(ssin.substring(9, 11))\n }\n\n return isValidNiss\n }\n\n /**\n * Extracts the patient id from a child document, following merge chains if necessary.\n * @param childDocument the child document (invoice, calendar item, contact, or access log)\n * @param hcpId the healthcare party id\n * @param childDocumentType the type of the child document\n * @return the patient id after following any merge chains\n */\n async getPatientIdOfChildDocumentForHcpAndHcpParents(\n childDocument: models.Invoice | models.CalendarItem | models.Contact | models.AccessLog,\n hcpId: string,\n childDocumentType: EntityWithDelegationTypeName\n ): Promise<string> {\n const parentIdsArray = await this.crypto.xapi.owningEntityIdsOf({ entity: childDocument, type: childDocumentType }, hcpId)\n\n const multipleParentIds = [...new Set(parentIdsArray)].length > 1\n\n if (multipleParentIds) {\n throw 'Child document with id ' + childDocument.id + ' contains multiple parent ids in its CFKs for hcpId: ' + hcpId\n }\n\n const parentId = parentIdsArray[0]\n\n if (!parentId) {\n throw 'Parent id is empty in CFK of child document with id ' + childDocument.id + ' for hcpId: ' + hcpId\n }\n\n let patient: models.Patient = await super.getPatient(parentId!)\n\n let mergeLevel = 0\n const maxMergeLevel = 10\n while (patient.mergeToPatientId) {\n mergeLevel++\n if (mergeLevel === maxMergeLevel) {\n throw 'Too many merged levels for parent (Patient) of child document ' + childDocument.id + ' ; hcpId: ' + hcpId\n }\n\n patient = await super.getPatient(patient.mergeToPatientId!)\n }\n\n return patient.id!\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given patient\n */\n async hasWriteAccess(patient: models.Patient): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: patient, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the patient.\n * @param patient the patient to share.\n * @param shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n patient: models.Patient,\n shareSecretIds: string[],\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Patient> {\n return this.shareWithMany(patient, { [delegateId]: { ...options, shareSecretIds: shareSecretIds } })\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param patient the patient to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n patient: models.Patient,\n delegates: {\n [delegateIds: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Patient> {\n return (await this.tryShareWithMany(patient, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param patient the patient to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n patient: models.Patient,\n delegates: {\n [delegateIds: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Patient>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(patient, EntityWithDelegationTypeName.Patient)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyPatientAs(self, entityWithEncryptionKey) : patient\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Patient,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkSharePatients(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decryptAs(self, [e]).then((es) => es[0])))\n }\n\n /**\n * @param patient a patient\n * @return all the decryptable secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * @param patient a patient\n * @return the confidential secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptConfidentialSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.getConfidentialSecretIds({ entity: patient, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * @param patient a patient\n * @return the non-confidential secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptNonConfidentialSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.getSecretIdsSharedWithParents({ entity: patient, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Gets all data owners with access to the patient and their permission levels.\n * @param entity the patient\n * @return object containing permissions by data owner id and a flag indicating if there are unknown anonymous data owners\n */\n getDataOwnersWithAccessTo(\n entity: models.Patient\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Gets all encryption keys of the patient that the current user can decrypt.\n * @param entity the patient\n * @return array of encryption keys\n */\n getEncryptionKeysOf(entity: models.Patient): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * Merge two patients into one. This method performs the following operations:\n * - The `from` patient will be soft-deleted, and it will point to the `into` patient. Only the `deletionDate` and `mergeToPatientId` fields of the\n * patient will be changed (automatically by this method). Note that the value of {@link from} is only used to verify that the client is aware of\n * the last version of the `from` patient: any changes to its content and/or metadata compared to what is actually stored in the database will be\n * ignored.\n * - The metadata of the `into` patient will be automatically updated to contain also the metadata of the `from` patient and to keep track of the\n * merge:\n * - the `mergedIds` will be updated to contain the `from` patient id\n * - all secret ids of the `from` patient will be added to the `into` patient\n * - all data owners (including anonymous data owners) with access to the `from` patient will have the same access to the merged `into` patient\n * (unless they already had greater access to the `into` patient, in which case they keep the greater access)\n * - The content of the `into` patient will be updated to match the content (name, address, note, ...) of the provided {@link mergedInto} parameter.\n * Note that since the metadata is automatically updated by this method you must not change the metadata of the `mergedInto` patient\n * (`delegations`, mergedInto`, ...): if there is any change between the metadata of the provided `mergedInto` patient and the stored patient this\n * method will fail with an error.\n *\n * In case the revisions of {@link from} and/or {@link mergedInto} does not match the latest revisions for these patients in the database this\n * method will fail without soft-deleting the `from` patient and without updating the `into` patient with the merged content and metadata. You will\n * have to retrieve the updated versions of both patients before retrying the merge.\n *\n * Finally, note that this method only merges existing data, and does not perform any automatic sharing of the data. The secret ids and encryption\n * keys will not be shared with users that had access only to one of the entity, you will have to use the {@link shareWith} method after the merge\n * if you want to do so.\n * For example consider hcps A, B with access to P' and hcps A, C with access to P'', and we merge P'' into P'. After the merge:\n * - A has access to all secret ids of the merged patient and to the encryption key of the merged patient\n * - B has access to the encryption key of the merged patient (since it is the same as in P'), but only to the secret id which was originally from\n * the unmerged P'\n * - C has no access to the encryption key of the merged patient, and has access only to the secret id which was originally from the unmerged P''\n *\n * @param from the original, unmodified `from` patient. Its content will be unchanged and its metadata will be automatically updated by this method\n * to reflect the merge.\n * @param mergedInto the `into` patient with updated content result of the merge with the `from` patient, as specified by your application logic.\n * The metadata of the `mergedInto` patient must not differ from the metadata of the stored version of the patient, since it will be automatically\n * updated by the method.\n * @return the updated `into` patient.\n */\n async mergePatients(from: Patient, mergedInto: Patient): Promise<Patient> {\n const encryptedMerged = (await this.encryptAs(await this.dataOwnerApi.getCurrentDataOwnerId(), [mergedInto]))[0]\n const merged = await super.baseMergePatients(from.id!, from.rev!, encryptedMerged)\n return (await this.tryDecryptOrReturnOriginal([merged]))[0].entity\n }\n\n /**\n * Subscribes to patient events (create, update, delete) and automatically decrypts them.\n * @param eventTypes the types of events to subscribe to\n * @param filter optional filter to apply to events\n * @param eventFired callback function to handle each event\n * @param options optional subscription options\n * @return connection object to manage the subscription\n */\n async subscribeToPatientEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Patient> | undefined,\n eventFired: (patient: Patient) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n const currentUser = await this.userApi.getCurrentUser()\n return subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Patient,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt(currentUser, [encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n /**\n * Creates or updates de-anonymization metadata for patient delegations.\n * @param entity the patient\n * @param delegates array of delegate ids to create metadata for\n */\n createDelegationDeAnonymizationMetadata(entity: Patient, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Patient }, delegates)\n }\n\n /**\n * Initializes the exchange data towards a newly invited patient. This allows the doctor to share data with the\n * patient even if the patient has not yet initialized a keypair for himself.\n *\n * This method should be used only if the patient has not yet initialized a keypair for himself. If the patient has\n * already initialized a keypair this method does nothing and returns false. In this case the exchange data will be\n * automatically created the first time you share data with the patient, and your implementation of the crypto\n * strategies will be used to validate the public keys of the patient.\n *\n * Once exchange data is initialized you can use the {@link IccRecoveryXApi.createExchangeDataRecoveryInfo} to\n * generate a key that the patient will be able to use on his first login to immediately gain access to the exchange\n * data (through the {@link IccRecoveryXApi.recoverExchangeData} method).\n *\n * @param patientId the id of the newly invited patient.\n * @return true if exchange data was initialized, false if the patient already has a key pair and the exchange data\n * will be initialized in the standard way (automatically on the first time data is shared with the user).\n */\n async forceInitialiseExchangeDataToNewlyInvitedPatient(patientId: string): Promise<boolean> {\n const patient = await super.getPatient(patientId)\n if (this.dataOwnerApi.getHexPublicKeysOf(patient).size) return false\n await this.crypto.exchangeData.getOrCreateEncryptionDataTo(patientId, {\n allowCreationWithoutDelegateKey: true,\n })\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"icc-patient-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-patient-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AAUtD,+DAA4D;AAC5D,kDAAiD;AACjD,oDAA8G;AAE9G,8DAAsD;AACtD,qDAA8E;AAC9E,mCAA4H;AAE5H,0EAAgG;AAChG,uFAAmF;AACnF,wEAAoE;AAEpE,qFAAiF;AACjF,4EAAwE;AAExE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAK3E,4DAAwE;AAGxE,qCAAqC;AACrC,MAAa,cAAe,SAAQ,uBAAa;IAG/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,2DAA4B,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7I,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,UAA0B,EAC1B,OAAoB,EACpB,WAA4B,EAC5B,UAA0B,EAC1B,WAA4B,EAC5B,UAA0B,EAC1B,iBAAwC,EACxC,YAA8B,EAC9B,eAAoC,EACpC,OAAoB,EACpB,OAAmB,EACnB,cAAuB,EACxC,gBAA+B,CAAC,MAAM,CAAC,EACvC,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,sBA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A4B,YAAC,OAAO,kCAAO,OAAO,KAAE,QAAQ,EAAE,SAAS,IAAG,CAAA;YACrG,IAAI,MAAM,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACvF,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AA/iDD,wCA+iDC","sourcesContent":["import { IccAuthApi, IccPatientApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccContactXApi } from './icc-contact-x-api'\nimport { IccFormXApi } from './icc-form-x-api'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { IccInvoiceXApi } from './icc-invoice-x-api'\nimport { IccDocumentXApi } from './icc-document-x-api'\nimport { IccHelementXApi } from './icc-helement-x-api'\nimport { IccClassificationXApi } from './icc-classification-x-api'\n\nimport { cloneDeep, uniqBy } from './utils/collection-utils'\nimport * as models from '../icc-api/model/models'\nimport { Document, IcureStub, ListOfIds, MaintenanceTask, Patient, TimingInfo } from '../icc-api/model/models'\nimport { IccCalendarItemXApi } from './icc-calendar-item-x-api'\nimport { b64_2ab } from '../icc-api/model/ModelHelper'\nimport { findName, garnishPersonWithName, hasName } from './utils/person-util'\nimport { EncryptedFieldsManifest, parseEncryptedFields, retry, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { EntityWithDelegationTypeName } from './utils/EntityWithDelegationTypeName'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { MinimalEntityBulkShareResult } from '../icc-api/model/requests/MinimalEntityBulkShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { IccUserXApi } from './icc-user-x-api'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { BulkShareOrUpdateMetadataParams } from '../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccPatientXApi extends IccPatientApi implements EncryptedEntityXApi<models.Patient> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Patient))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly contactApi: IccContactXApi,\n private readonly formApi: IccFormXApi,\n private readonly helementApi: IccHelementXApi,\n private readonly invoiceApi: IccInvoiceXApi,\n private readonly documentApi: IccDocumentXApi,\n private readonly hcpartyApi: IccHcpartyXApi,\n private readonly classificationApi: IccClassificationXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly calendarItemApi: IccCalendarItemXApi,\n private readonly userApi: IccUserXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = ['note'],\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\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Patient.')\n }\n\n /**\n * Creates a new instance of patient with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param p initialised data for the patient. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of patient.\n */\n async newInstance(\n user: models.User,\n p: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const patient = {\n ...(p ?? {}),\n _type: 'org.taktik.icure.entities.Patient',\n id: p?.id ?? this.crypto.primitives.randomUuid(),\n created: p?.created ?? new Date().getTime(),\n modified: p?.modified ?? new Date().getTime(),\n responsible: p?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: p?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: p?.codes ?? [],\n tags: p?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n const initialisationInfo = await this.crypto.xapi.entityWithInitialisedEncryptedMetadata(\n patient,\n EntityWithDelegationTypeName.Patient,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n return new models.Patient(initialisationInfo.updatedEntity)\n }\n\n /**\n * Ensures patient names are consistent by synchronizing names property with firstName/lastName/maidenName/alias fields.\n * @param patient the patient to process\n * @return the patient with completed names\n */\n completeNames(patient: models.Patient): models.Patient {\n let finalPatient: any = patient\n\n if (!!finalPatient.lastName && !hasName(finalPatient, models.PersonName.UseEnum.Official)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Official, finalPatient.lastName, finalPatient.firstName)\n }\n\n if (!!finalPatient.maidenName && !hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Maiden, finalPatient.maidenName, finalPatient.firstName)\n }\n\n if (!!finalPatient.alias && !hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {\n finalPatient = garnishPersonWithName(finalPatient, models.PersonName.UseEnum.Nickname, finalPatient.alias, finalPatient.firstName)\n }\n\n if (!finalPatient.lastName && !!hasName(finalPatient, models.PersonName.UseEnum.Official)) {\n const officialName = findName(finalPatient, models.PersonName.UseEnum.Official)\n finalPatient = {\n ...finalPatient,\n lastName: officialName!.lastName,\n firstName: officialName!.firstNames?.[0],\n }\n }\n\n if (!finalPatient.maidenName && !!hasName(finalPatient, models.PersonName.UseEnum.Maiden)) {\n finalPatient = {\n ...finalPatient,\n maidenName: findName(finalPatient, models.PersonName.UseEnum.Maiden)!.lastName,\n }\n }\n\n if (!finalPatient.alias && !!hasName(finalPatient, models.PersonName.UseEnum.Nickname)) {\n finalPatient = {\n ...finalPatient,\n alias: findName(finalPatient, models.PersonName.UseEnum.Nickname)!.lastName,\n }\n }\n\n return new Patient(finalPatient)\n }\n\n /**\n * @deprecated replace with {@link initConfidentialSecretId}\n */\n async initConfidentialDelegation(patient: models.Patient, user: models.User): Promise<models.Patient> {\n return this.initConfidentialSecretId(patient, user)\n }\n\n /**\n * Ensures that the current data owner has some confidential secret ids for the provided patient. If not creates them and updates the patient in the\n * database.\n * @param patient the patient for which you want to initialise the confidential secret id.\n * @param user the current user.\n * @return the updated patient or the original patient if no change was necessary.\n */\n async initConfidentialSecretId(patient: models.Patient, user: models.User): Promise<models.Patient> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (dataOwnerId !== (await this.dataOwnerApi.getCurrentDataOwnerId()))\n throw new Error('You can initialise confidential delegations only for the current data owner')\n let updatedPatient = patient\n if (!patient.rev) {\n updatedPatient = await this.createPatientWithUser(user, patient)\n if (!updatedPatient) throw new Error('Could not create patient')\n }\n const initialised = await this.crypto.xapi.initialiseConfidentialSecretId(updatedPatient, EntityWithDelegationTypeName.Patient, (x) =>\n this.bulkSharePatients(x)\n )\n if (initialised) {\n return initialised\n } else {\n return updatedPatient\n }\n }\n\n createPatient(body?: models.Patient): never {\n throw new Error('Cannot call a method that returns patients without providing a user for de/encryption')\n }\n\n /**\n * Creates a patient in the database with encryption.\n * @param user the current user\n * @param body the patient data to create\n * @return the created patient\n */\n createPatientWithUser(user: models.User, body?: models.Patient): Promise<models.Patient | any> {\n return body\n ? this.encrypt(user, [cloneDeep(this.completeNames(body))])\n .then((pats) => super.createPatient(pats[0]))\n .then(async (patient: Patient) => {\n /**\n * This code is a workaround for the fact that the backend is adding empty delegations to the patient when it is created.\n */\n\n const patientDelegations = patient.delegations\n\n if (patientDelegations != undefined && Object.keys(patientDelegations).length > 0) {\n const areDelegationsEmpty = Object.values(patientDelegations).every((delegation) => delegation.length === 0)\n\n if (areDelegationsEmpty) {\n return await this.modifyPatientRaw(\n new Patient({\n ...patient,\n delegations: {},\n })\n )\n }\n }\n return patient\n })\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n : Promise.resolve(null)\n }\n\n filterBy(\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n body?: models.FilterChainPatient\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Filters patients using a filter chain and returns decrypted results.\n * @param user the current user\n * @param filterChain the filter chain to apply\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param skip optional number of results to skip\n * @param sort optional sort field\n * @param desc optional sort direction\n * @param collectTiming add timing information to the response\n * @return paginated list of decrypted patients\n */\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming?: false\n ): Promise<models.PaginatedListPatient | any>\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming?: true\n ): Promise<(models.PaginatedListPatient & TimingInfo) | any>\n filterByWithUser(\n user: models.User,\n filterChain: models.FilterChainPatient,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n skip?: number,\n sort?: string,\n desc?: boolean,\n collectTiming: boolean = false\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .filterPatientsBy(startKey, startDocumentId, limit, skip, sort, desc, filterChain, collectTiming as any)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n findByAccessLogUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds patients by access log user after a specific date and returns decrypted results.\n * @param user the current user\n * @param userId the user id to search for in access logs\n * @param accessType optional type of access\n * @param startDate optional start date timestamp\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted patients\n */\n findByAccessLogUserAfterDateWithUser(\n user: models.User,\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .findByAccessLogUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n findByAccessLogUserAfterDate_1(externalId: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds a patient by external id and returns the decrypted result.\n * @param user the current user\n * @param externalId the external id to search for\n * @return the decrypted patient\n */\n findByExternalIdWithUser(user: models.User, externalId: string): Promise<models.Patient | any> {\n return super\n .findByExternalId(externalId)\n .then((pats) => this.decrypt(user, [pats]))\n .then((x) => x[0])\n }\n\n findByNameBirthSsinAuto(\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Finds patients by name, birth date, or SSIN with automatic search and returns decrypted results.\n * @param user the current user\n * @param healthcarePartyId optional healthcare party id\n * @param filterValue optional search value\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n findByNameBirthSsinAutoWithUser(\n user: models.User,\n healthcarePartyId?: string,\n filterValue?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .findByNameBirthSsinAuto(healthcarePartyId, filterValue, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n fuzzySearch(firstName?: string, lastName?: string, dateOfBirth?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Performs a fuzzy search for patients and returns decrypted results.\n * @param user the current user\n * @param firstName optional first name to search for\n * @param lastName optional last name to search for\n * @param dateOfBirth optional date of birth timestamp\n * @return array of decrypted patients\n */\n fuzzySearchWithUser(user: models.User, firstName?: string, lastName?: string, dateOfBirth?: number): Promise<Array<models.Patient> | any> {\n return super.fuzzySearch(firstName, lastName, dateOfBirth).then((pats) => this.decrypt(user, pats))\n }\n\n getPatient(patientId: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Gets a patient by id without decryption.\n * @param patientId the patient id\n * @return the encrypted patient\n */\n getPatientRaw(patientId: string): Promise<models.Patient | any> {\n return super.getPatient(patientId)\n }\n\n /**\n * Gets a patient by id with decryption.\n * @param user the current user\n * @param patientId the patient id\n * @return the decrypted patient\n */\n getPatientWithUser(user: models.User, patientId: string): Promise<models.Patient | any> {\n return super\n .getPatient(patientId)\n .then((p) => this.tryDecryptOrReturnOriginal([p]))\n .then((pats) => pats[0].entity)\n }\n\n /**\n * Gets a patient by id and indicates whether it was successfully decrypted.\n * @param user the current user\n * @param patientId the patient id\n * @return object containing the patient and a flag indicating if it was decrypted\n */\n getPotentiallyEncryptedPatientWithUser(user: models.User, patientId: string): Promise<{ patient: models.Patient; decrypted: boolean }> {\n return super\n .getPatient(patientId)\n .then((p) => this.tryDecryptOrReturnOriginal([p]))\n .then((pats) => ({ patient: pats[0].entity, decrypted: pats[0].decrypted }))\n }\n\n getPatients(body?: models.ListOfIds): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Gets multiple patients by their ids with decryption.\n * @param user the current user\n * @param body list of patient ids\n * @return array of decrypted patients\n */\n getPatientsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<models.Patient> | any> {\n return super.getPatients(body).then((pats) => this.decrypt(user, pats))\n }\n\n listDeletedPatients(startDate?: number, endDate?: number, desc?: boolean, startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists deleted patients with decryption.\n * @param user the current user\n * @param startDate optional start date timestamp\n * @param endDate optional end date timestamp\n * @param desc optional sort direction\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted deleted patients\n */\n listDeletedPatientsWithUser(\n user: models.User,\n startDate?: number,\n endDate?: number,\n desc?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listDeletedPatients(startDate, endDate, desc, startDocumentId, startKey, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listDeletedPatients_2(firstName?: string, lastName?: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists deleted patients by name with decryption.\n * @param user the current user\n * @param firstName optional first name to filter by\n * @param lastName optional last name to filter by\n * @return array of decrypted deleted patients\n */\n listDeletedPatientsByNameWithUser(user: models.User, firstName?: string, lastName?: string): Promise<Array<models.Patient> | any> {\n return super.listDeletedPatientsByName(firstName, lastName).then((rows) => this.decrypt(user, rows, false))\n }\n\n listOfMergesAfter(date: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists merged patients after a specific date with decryption.\n * @param user the current user\n * @param date timestamp to start from\n * @return array of decrypted merged patients\n */\n listOfMergesAfterWithUser(user: models.User, date: number): Promise<Array<models.Patient> | any> {\n return super.listOfMergesAfter(date).then((pats) => this.decrypt(user, pats, false))\n }\n\n listOfPatientsModifiedAfter(date: number, startKey?: number, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients modified after a specific date with decryption.\n * @param user the current user\n * @param date timestamp to start from\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @return paginated list of decrypted modified patients\n */\n listOfPatientsModifiedAfterWithUser(\n user: models.User,\n date: number,\n startKey?: number,\n startDocumentId?: string,\n limit?: number\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listOfPatientsModifiedAfter(date, startKey, startDocumentId, limit)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatients(hcPartyId?: string, sortField?: string, startKey?: string, startDocumentId?: string, limit?: number, sortDirection?: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients with decryption.\n * @param user the current user\n * @param hcPartyId optional healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsWithUser(\n user: models.User,\n hcPartyId?: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatients(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatientsByHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients by healthcare party with decryption.\n * @param user the current user\n * @param hcPartyId the healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsByHcPartyWithUser(\n user: models.User,\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatientsByHcParty(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n listPatientsOfHcParty(\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Lists patients of a healthcare party with decryption.\n * @param user the current user\n * @param hcPartyId the healthcare party id\n * @param sortField optional sort field\n * @param startKey optional start key for pagination\n * @param startDocumentId optional start document id for pagination\n * @param limit optional maximum number of results\n * @param sortDirection optional sort direction\n * @return paginated list of decrypted patients\n */\n listPatientsOfHcPartyWithUser(\n user: models.User,\n hcPartyId: string,\n sortField?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n sortDirection?: string\n ): Promise<models.PaginatedListPatient | any> {\n return super\n .listPatientsOfHcParty(hcPartyId, sortField, startKey, startDocumentId, limit, sortDirection)\n .then((pl) => this.decrypt(user, pl.rows!, false).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n mergeInto(toId: string, fromIds: string): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Merges patients and returns the decrypted result.\n * @param user the current user\n * @param toId the target patient id\n * @param fromIds the source patient ids to merge from\n * @return the decrypted merged patient\n */\n mergeIntoWithUser(user: models.User, toId: string, fromIds: string): Promise<models.Patient | any> {\n return super\n .mergeInto(toId, fromIds)\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n }\n\n modifyPatient(body?: models.Patient): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice.\n */\n modifyPatientRaw(body?: models.Patient): Promise<models.Patient | any> {\n return super.modifyPatient(body)\n }\n\n /**\n * Updates a patient with encryption.\n * @param user the current user\n * @param body the patient data to update\n * @return the updated decrypted patient\n */\n modifyPatientWithUser(user: models.User, body?: models.Patient): Promise<models.Patient | null> {\n return body ? this.modifyPatientAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : Promise.resolve(null)\n }\n\n private modifyPatientAs(dataOwner: string, body: models.Patient): Promise<models.Patient> {\n return this.encryptAs(dataOwner, [cloneDeep(this.completeNames(body))])\n .then((pats) => super.modifyPatient(pats[0]))\n .then((p) => this.decryptAs(dataOwner, [p]))\n .then((pats) => pats[0])\n }\n\n modifyPatientReferral(patientId: string, referralId: string, start?: number, end?: number): never {\n throw new Error('Cannot call a method that returns contacts without providing a user for de/encryption')\n }\n\n /**\n * Updates a patient referral and returns the decrypted result.\n * @param user the current user\n * @param patientId the patient id\n * @param referralId the referral id\n * @param start optional start timestamp\n * @param end optional end timestamp\n * @return the updated decrypted patient\n */\n modifyPatientReferralWithUser(\n user: models.User,\n patientId: string,\n referralId: string,\n start?: number,\n end?: number\n ): Promise<models.Patient | any> {\n return super\n .modifyPatientReferral(patientId, referralId, start, end)\n .then((p) => this.decrypt(user, [p]))\n .then((pats) => pats[0])\n }\n\n /**\n * Encrypts patients using the current user's encryption keys.\n * @param user the current user\n * @param pats the patients to encrypt\n * @return the encrypted patients\n */\n encrypt(user: models.User, pats: Array<models.Patient>): Promise<Array<models.Patient>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(dataOwnerId, pats)\n }\n\n private encryptAs(dataOwner: string, pats: Array<models.Patient>): Promise<Array<models.Patient>> {\n return this.crypto.xapi.tryEncryptEntities(\n pats,\n EntityWithDelegationTypeName.Patient,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Patient(x)\n )\n }\n\n /**\n * Decrypts patients using the current user's encryption keys. If a patient can't be decrypted, returns it with encrypted data.\n * @param user the current user\n * @param patients the patients to decrypt\n * @param fillDelegations optional flag to fill delegations (defaults to true)\n * @return the decrypted patients\n */\n decrypt(user: models.User, patients: Array<models.Patient>, fillDelegations = true): Promise<Array<models.Patient>> {\n return this.decryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), patients, fillDelegations)\n }\n\n private decryptAs(dataOwner: string, patients: Array<models.Patient>, fillDelegations = true): Promise<Array<models.Patient>> {\n return this.tryDecryptOrReturnOriginal(patients).then((ps) => ps.map((p) => p.entity))\n }\n\n /**\n * Attempts to decrypt patients. If decryption fails, returns the original encrypted patients.\n * @param patients the patients to decrypt\n * @return array of objects containing the patient entity and a flag indicating if it was decrypted\n */\n async tryDecryptOrReturnOriginal(patients: Array<models.Patient>): Promise<{ entity: models.Patient; decrypted: boolean }[]> {\n return (await this.crypto.xapi.tryDecryptEntities(patients, EntityWithDelegationTypeName.Patient, (x) => new models.Patient(x))).map((p) => {\n if (p.entity.picture && !(p.entity.picture instanceof ArrayBuffer)) {\n return {\n entity: new models.Patient({\n ...p.entity,\n picture: b64_2ab(p.entity.picture),\n }),\n decrypted: p.decrypted,\n }\n } else return p\n })\n }\n\n /**\n * @deprecated replace with {@link shareAllDataOfPatient}\n */\n async share(\n user: models.User,\n patId: string,\n ownerId: string,\n delegateIds: Array<string>,\n delegationTags: { [key: string]: Array<string> },\n usingPost: boolean = false\n ): Promise<{\n patient: models.Patient | null\n statuses: { [key: string]: { success: boolean | null; error: Error | null } }\n } | null> {\n return this.shareAllDataOfPatient(user, patId, ownerId, delegateIds, delegationTags, usingPost)\n }\n\n /**\n * Shares a patient and all related data with specified delegates.\n * @param user the current user\n * @param patId the patient id\n * @param ownerId the owner healthcare party id\n * @param delegateIds the delegate ids to share with\n * @param delegationTags tags specifying what data to share (e.g., medicalInformation, financialInformation, all)\n * @param usingPost optional flag to use POST method instead of GET (defaults to false)\n * @return object containing the updated patient and sharing statuses for each entity type\n */\n async shareAllDataOfPatient(\n user: models.User,\n patId: string,\n ownerId: string,\n delegateIds: Array<string>,\n delegationTags: { [key: string]: Array<string> },\n usingPost: boolean = false\n ): Promise<{\n patient: models.Patient | null\n statuses: { [key: string]: { success: boolean | null; error: Error | null } }\n } | null> {\n const allTags: string[] = [...new Set(Object.values(delegationTags).flat())]\n const status = {\n contacts: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n forms: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n healthElements: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n invoices: {\n success: allTags.includes('financialInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n documents: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n classifications: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n calendarItems: {\n success: allTags.includes('medicalInformation') || allTags.includes('all') ? false : null,\n error: null,\n modified: 0,\n },\n patient: { success: false, error: null, modified: 0 } as {\n success: boolean\n error: Error | null\n },\n }\n const hcp = await this.hcpartyApi.getHealthcareParty(ownerId)\n const parentId = hcp.parentId\n let patient = await retry(() => this.getPatientWithUser(user, patId))\n const patientWithInitialisedEncryption = await this.crypto.xapi.ensureEncryptionKeysInitialised(patient, EntityWithDelegationTypeName.Patient)\n if (patientWithInitialisedEncryption) {\n patient = await this.modifyPatientWithUser(user, patientWithInitialisedEncryption)\n }\n\n if (!patient) {\n status.patient = {\n success: false,\n error: new Error('Patient does not exist or cannot initialise encryption keys'),\n }\n return { patient: patient, statuses: status }\n }\n\n const delSfks = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId)\n const ecKeys = await this.crypto.xapi.encryptionKeysOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId)\n\n if (delSfks.length) {\n const retrievedHealthElements = await retry(() =>\n (usingPost\n ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((hes) =>\n parentId\n ? (usingPost\n ? this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, [...new Set(delSfks)])\n : this.helementApi.findHealthElementsDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreHes) => uniqBy(hes.concat(moreHes), 'id'))\n : hes\n )\n )\n const retrievedForms = await retry(() =>\n (usingPost\n ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((frms) =>\n parentId\n ? (usingPost\n ? this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeysUsingPost(parentId, [...new Set(delSfks)])\n : this.formApi.findFormsDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreFrms) => uniqBy(frms.concat(moreFrms), 'id'))\n : frms\n )\n )\n const retrievedContacts = await retry(() =>\n (usingPost\n ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(ownerId, undefined, undefined, [...new Set(delSfks)])\n : this.contactApi.findByHCPartyPatientSecretFKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((ctcs) =>\n parentId\n ? (usingPost\n ? this.contactApi.findByHCPartyPatientSecretFKeysUsingPost(parentId, undefined, undefined, [...new Set(delSfks)])\n : this.contactApi.findByHCPartyPatientSecretFKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreCtcs) => uniqBy(ctcs.concat(moreCtcs), 'id'))\n : ctcs\n )\n )\n const retrievedInvoices = await retry(() =>\n (usingPost\n ? this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(ownerId, [...new Set(delSfks)])\n : this.invoiceApi.findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((ivs) =>\n parentId\n ? this.invoiceApi\n .findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n .then((moreIvs) => uniqBy(ivs.concat(moreIvs), 'id'))\n : ivs\n )\n )\n const retrievedClassifications = await retry(() =>\n this.classificationApi\n .findClassificationsByHCPartyPatientForeignKeys(ownerId, [...new Set(delSfks)].join(','))\n .then((cls) =>\n parentId\n ? this.classificationApi\n .findClassificationsByHCPartyPatientForeignKeys(parentId, [...new Set(delSfks)].join(','))\n .then((moreCls) => uniqBy(cls.concat(moreCls), 'id'))\n : cls\n )\n )\n const retrievedCalendarItems = await retry(() =>\n (usingPost\n ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(ownerId, [...new Set(delSfks)])\n : this.calendarItemApi.findByHCPartyPatientSecretFKeys(ownerId, [...new Set(delSfks)].join(','))\n ).then((cls) =>\n parentId\n ? (usingPost\n ? this.calendarItemApi.findByHCPartyPatientSecretFKeysArray(parentId, [...new Set(delSfks)])\n : this.calendarItemApi.findByHCPartyPatientSecretFKeys(parentId, [...new Set(delSfks)].join(','))\n ).then((moreCls) => uniqBy(cls.concat(moreCls), 'id'))\n : cls\n )\n )\n const isMedicalInfoTags = (tags: string[]) => tags.includes('medicalInformation') || tags.includes('all')\n const isFinancialInfoTags = (tags: string[]) => tags.includes('financialInformation') || tags.includes('all')\n const doShareEntitiesAndUpdateStatus = async (\n entities: models.IcureStub[],\n entitiesType: EntityWithDelegationTypeName,\n status: {\n success: boolean | null\n error: null | Error\n modified: number\n },\n tagsCondition: (tags: string[]) => boolean,\n doShareMinimal: (request: BulkShareOrUpdateMetadataParams) => Promise<MinimalEntityBulkShareResult[]>\n ): Promise<void> => {\n const delegatesToApply = delegateIds.filter((delegateId) => tagsCondition(delegationTags[delegateId]))\n if (entities.length && delegatesToApply.length) {\n const requests: {\n entity: IcureStub\n dataForDelegates: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n }\n }[] = []\n for (const entity of entities) {\n const currentEntityRequests: {\n [delegateId: string]: {\n shareSecretIds: string[]\n shareEncryptionKeys: string[]\n shareOwningEntityIds: string[]\n requestedPermissions: RequestedPermissionEnum\n }\n } = {}\n const secretIds = await this.crypto.xapi.secretIdsOf({ entity, type: entitiesType }, undefined)\n const encryptionKeys = await this.crypto.xapi.encryptionKeysOf({ entity, type: entitiesType }, undefined)\n const request = {\n shareSecretIds: secretIds,\n shareEncryptionKeys: encryptionKeys,\n shareOwningEntityIds: [patient.id!],\n requestedPermissions: RequestedPermissionEnum.MAX_WRITE,\n }\n for (const delegateId of delegatesToApply) {\n currentEntityRequests[delegateId] = request\n }\n requests.push({ dataForDelegates: currentEntityRequests, entity })\n }\n await this.crypto.xapi\n .bulkShareOrUpdateEncryptedEntityMetadataNoEntities(entitiesType, requests, (x) => doShareMinimal(x))\n .then((shareResult) => {\n status.modified = new Set(shareResult.successfulUpdates.map((x) => x.entityId)).size\n status.success = shareResult.updateErrors.length === 0\n if (!status.success) {\n const errorMsg = `Error while sharing (some) entities of type ${entitiesType} for patient ${patient.id} : ${JSON.stringify(\n shareResult.updateErrors\n )}`\n console.error(errorMsg)\n status.error = new Error(errorMsg)\n }\n })\n .catch((e) => {\n status.success = false\n status.error = e\n })\n } else {\n status.success = true\n }\n }\n await doShareEntitiesAndUpdateStatus(\n retrievedHealthElements,\n EntityWithDelegationTypeName.HealthElement,\n status.healthElements,\n isMedicalInfoTags,\n (x) => this.helementApi.bulkShareHealthElementsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedContacts, EntityWithDelegationTypeName.Contact, status.contacts, isMedicalInfoTags, (x) =>\n this.contactApi.bulkShareContactsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedInvoices, EntityWithDelegationTypeName.Invoice, status.invoices, isFinancialInfoTags, (x) =>\n this.invoiceApi.bulkShareInvoicesMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(\n retrievedClassifications,\n EntityWithDelegationTypeName.Classification,\n status.classifications,\n isMedicalInfoTags,\n (x) => this.classificationApi.bulkShareClassificationsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(\n retrievedCalendarItems,\n EntityWithDelegationTypeName.CalendarItem,\n status.calendarItems,\n isMedicalInfoTags,\n (x) => this.calendarItemApi.bulkShareCalendarItemsMinimal(x)\n )\n await doShareEntitiesAndUpdateStatus(retrievedForms, EntityWithDelegationTypeName.Form, status.forms, isMedicalInfoTags, (x) =>\n this.formApi.bulkShareFormsMinimal(x)\n )\n }\n const sharePatientDataRequest = {\n shareSecretIds: delSfks,\n shareEncryptionKeys: ecKeys,\n shareOwningEntityIds: [],\n requestedPermissions: RequestedPermissionEnum.MAX_WRITE,\n }\n const sharePatientRequest = {\n entity: patient,\n dataForDelegates: Object.fromEntries(delegateIds.map((delegateId) => [delegateId, sharePatientDataRequest])),\n }\n return await this.crypto.xapi\n .bulkShareOrUpdateEncryptedEntityMetadata(EntityWithDelegationTypeName.Patient, [sharePatientRequest], (x) => this.bulkSharePatients(x))\n .then((shareResult) => {\n if (shareResult.updatedEntities.length && !shareResult.updateErrors.length) {\n status.patient.success = true\n return { patient: shareResult.updatedEntities[0], statuses: status }\n } else {\n const errorMsg = `Error while sharing patient with id ${patient.id} : ${JSON.stringify(shareResult.updateErrors)}`\n console.error(errorMsg)\n status.patient.error = new Error(errorMsg)\n status.patient.success = false\n return { patient: shareResult.updatedEntities[0] ?? patient, statuses: status }\n }\n })\n .catch((e) => {\n status.patient.error = e\n status.patient.success = false\n return { patient, statuses: status }\n })\n }\n\n /**\n * Exports a patient and all related medical data.\n * @param user the current user\n * @param patId the patient id\n * @param ownerId the owner healthcare party id\n * @return object containing the patient and all related entities (contacts, forms, health elements, invoices, classifications, calendar items, documents)\n */\n async export(\n user: models.User,\n patId: string,\n ownerId: string\n ): Promise<{\n id: string\n patient: Patient | null\n contacts: models.Contact[]\n forms: models.Form[]\n healthElements: models.HealthElement[]\n invoices: models.Invoice[]\n classifications: models.Classification[]\n calItems: models.CalendarItem[]\n documents: models.Document[]\n }> {\n const parentId = await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds().then((h) => (h.length - 2 >= 0 ? h[h.length - 2] : h[0]))\n const patient = await retry(async () => {\n const retrieved: Patient | undefined = await this.getPatientWithUser(user, patId)\n if (retrieved != undefined) {\n const initialised = await this.crypto.xapi.ensureEncryptionKeysInitialised(retrieved, EntityWithDelegationTypeName.Patient)\n if (!initialised) {\n return retrieved\n } else {\n return await this.modifyPatientWithUser(user, initialised)\n }\n } else {\n return null\n }\n })\n const delSfks =\n patient != null ? await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, ownerId) : []\n if (delSfks.length <= 0) {\n return {\n id: patId,\n patient,\n contacts: [],\n forms: [],\n healthElements: [],\n invoices: [],\n classifications: [],\n calItems: [],\n documents: [],\n }\n }\n const contactIds = new Set([\n ...(await retry(() => this.contactApi.findContactIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.contactApi.findContactIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const formIds = new Set([\n ...(await retry(() => this.formApi.findFormIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.formApi.findFormIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const healthElementIds = new Set([\n ...(await retry(() => this.helementApi.findHealthElementIdsByDataOwnerPatientOpeningDate(ownerId, delSfks))),\n ...(await retry(() => this.helementApi.findHealthElementIdsByDataOwnerPatientOpeningDate(parentId, delSfks))),\n ])\n const invoiceIds = new Set([\n ...(await retry(() => this.invoiceApi.findInvoiceIdsByDataOwnerPatientInvoiceDate(ownerId, delSfks))),\n ...(await retry(() => this.invoiceApi.findInvoiceIdsByDataOwnerPatientInvoiceDate(parentId, delSfks))),\n ])\n const classificationIds = new Set([\n ...(await retry(() => this.classificationApi.findClassificationIdsByDataOwnerPatientCreated(ownerId, delSfks))),\n ...(await retry(() => this.classificationApi.findClassificationIdsByDataOwnerPatientCreated(parentId, delSfks))),\n ])\n const calendarItemIds = new Set([\n ...(await retry(() => this.calendarItemApi.findCalendarItemIdsByDataOwnerPatientStartTime(ownerId, delSfks))),\n ...(await retry(() => this.calendarItemApi.findCalendarItemIdsByDataOwnerPatientStartTime(parentId, delSfks))),\n ])\n async function batchGet<T>(items: string[], get: (batch: string[]) => Promise<T[]>, batchSize: number = 1000): Promise<T[]> {\n const results: T[] = []\n for (let i = 0; i < items.length; i += batchSize) {\n const batch = items.slice(i, i + batchSize)\n const res = await retry(() => get(batch))\n results.push(...res)\n }\n return results\n }\n const contacts = await batchGet([...contactIds], (x): Promise<models.Contact[]> => this.contactApi.getContactsWithUser(user, { ids: x }))\n const forms = await batchGet([...formIds], (x): Promise<models.Form[]> => this.formApi.getForms({ ids: x }))\n const healthElements = await batchGet(\n [...healthElementIds],\n (x): Promise<models.HealthElement[]> => this.helementApi.getHealthElementsWithUser(user, { ids: x })\n )\n const invoices = await batchGet([...invoiceIds], (x): Promise<models.Invoice[]> => this.invoiceApi.getInvoices({ ids: x }))\n const classifications = await batchGet(\n [...classificationIds],\n (x): Promise<models.Classification[]> => this.classificationApi.getClassifications({ ids: x })\n )\n const calItems = await batchGet(\n [...calendarItemIds],\n (x): Promise<models.CalendarItem[]> => this.calendarItemApi.getCalendarItemsWithIdsWithUser(user, { ids: x })\n )\n const documentIds = new Set<string>()\n contacts.forEach((contact) => {\n contact.services?.forEach((service) => {\n Object.values(service.content ?? {}).forEach((content) => {\n if (!!content.documentId) documentIds.add(content.documentId)\n })\n })\n })\n const documents = await batchGet([...documentIds], (x): Promise<models.Document[]> => this.documentApi.getDocumentsWithUser(user, { ids: x }))\n return {\n id: patId,\n patient,\n calItems,\n classifications,\n contacts,\n documents,\n forms,\n healthElements,\n invoices,\n }\n }\n\n /**\n * Validates a Belgian INAMI number using modulo 97 check.\n * @param inami the INAMI number to validate\n * @return true if the INAMI number is valid, false otherwise\n */\n checkInami(inami: string): boolean {\n const num_inami = inami.replace(new RegExp('[^(0-9)]', 'g'), '')\n\n const checkDigit = num_inami.substring(6, 8)\n const numSansCheck = num_inami.substring(0, 6)\n let retour = false\n\n //modulo du niss\n const modINAMI = parseInt(numSansCheck) % 97\n\n //obtention du num de check 97 - le resultat du mod\n const checkDigit_2 = 97 - modINAMI\n\n if (parseInt(checkDigit) == checkDigit_2) {\n retour = true\n }\n return retour\n }\n\n /**\n * Validates a Belgian social security identification number (SSIN/NISS) including support for bis and ter numbers.\n * @param ssin the SSIN to validate\n * @return true if the SSIN is valid, false otherwise\n */\n isValidSsin(ssin: string) {\n ssin = ssin.replace(new RegExp('[^(0-9)]', 'g'), '')\n let isValidNiss = false\n\n const normalNumber =\n /^[0-9][0-9](([0][0-9])|([1][0-2]))(([0-2][0-9])|([3][0-1]))(([0-9]{2}[1-9])|([0-9][1-9][0-9])|([1-9][0-9]{2}))(([0-8][0-9])|([9][0-7]))$/.test(\n ssin\n )\n const bisNumber = /^[0-9][0-9](([2][0-9])|([3][0-2]))(([0-2][0-9])|([3][0-1]))[0-9]{3}(([0-8][0-9])|([9][0-7]))$/.test(ssin)\n const terNumber = /^[0-9][0-9](([4][0-9])|([5][0-2]))(([0-2][0-9])|([3][0-1]))[0-9]{3}(([0-8][0-9])|([9][0-7]))$/.test(ssin)\n\n if (normalNumber || bisNumber || terNumber) {\n isValidNiss =\n 97 - (Number(ssin.substring(0, 9)) % 97) === Number(ssin.substring(9, 11))\n ? true\n : 97 - (Number('2' + ssin.substring(0, 9)) % 97) === Number(ssin.substring(9, 11))\n }\n\n return isValidNiss\n }\n\n /**\n * Extracts the patient id from a child document, following merge chains if necessary.\n * @param childDocument the child document (invoice, calendar item, contact, or access log)\n * @param hcpId the healthcare party id\n * @param childDocumentType the type of the child document\n * @return the patient id after following any merge chains\n */\n async getPatientIdOfChildDocumentForHcpAndHcpParents(\n childDocument: models.Invoice | models.CalendarItem | models.Contact | models.AccessLog,\n hcpId: string,\n childDocumentType: EntityWithDelegationTypeName\n ): Promise<string> {\n const parentIdsArray = await this.crypto.xapi.owningEntityIdsOf({ entity: childDocument, type: childDocumentType }, hcpId)\n\n const multipleParentIds = [...new Set(parentIdsArray)].length > 1\n\n if (multipleParentIds) {\n throw 'Child document with id ' + childDocument.id + ' contains multiple parent ids in its CFKs for hcpId: ' + hcpId\n }\n\n const parentId = parentIdsArray[0]\n\n if (!parentId) {\n throw 'Parent id is empty in CFK of child document with id ' + childDocument.id + ' for hcpId: ' + hcpId\n }\n\n let patient: models.Patient = await super.getPatient(parentId!)\n\n let mergeLevel = 0\n const maxMergeLevel = 10\n while (patient.mergeToPatientId) {\n mergeLevel++\n if (mergeLevel === maxMergeLevel) {\n throw 'Too many merged levels for parent (Patient) of child document ' + childDocument.id + ' ; hcpId: ' + hcpId\n }\n\n patient = await super.getPatient(patient.mergeToPatientId!)\n }\n\n return patient.id!\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given patient\n */\n async hasWriteAccess(patient: models.Patient): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: patient, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the patient.\n * @param patient the patient to share.\n * @param shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n patient: models.Patient,\n shareSecretIds: string[],\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Patient> {\n return this.shareWithMany(patient, { [delegateId]: { ...options, shareSecretIds: shareSecretIds } })\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param patient the patient to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n patient: models.Patient,\n delegates: {\n [delegateIds: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Patient> {\n return (await this.tryShareWithMany(patient, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing patient with other data owners, allowing them to access the non-encrypted data of the patient and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param patient the patient to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds the secret ids of the Patient that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Patient is the owning entity id.\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * patient does not have encrypted content.\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n patient: models.Patient,\n delegates: {\n [delegateIds: string]: {\n shareSecretIds: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Patient>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(patient, EntityWithDelegationTypeName.Patient)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyPatientAs(self, entityWithEncryptionKey) : patient\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Patient,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkSharePatients(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decryptAs(self, [e]).then((es) => es[0])))\n }\n\n /**\n * @param patient a patient\n * @return all the decryptable secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * @param patient a patient\n * @return the confidential secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptConfidentialSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.getConfidentialSecretIds({ entity: patient, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * @param patient a patient\n * @return the non-confidential secret ids of the patient, retrieved from the encrypted metadata. The result may be used to find entities where the\n * patient is the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptNonConfidentialSecretIdsOf(patient: models.Patient): Promise<string[]> {\n return this.crypto.xapi.getSecretIdsSharedWithParents({ entity: patient, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Gets all data owners with access to the patient and their permission levels.\n * @param entity the patient\n * @return object containing permissions by data owner id and a flag indicating if there are unknown anonymous data owners\n */\n getDataOwnersWithAccessTo(\n entity: models.Patient\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Patient })\n }\n\n /**\n * Gets all encryption keys of the patient that the current user can decrypt.\n * @param entity the patient\n * @return array of encryption keys\n */\n getEncryptionKeysOf(entity: models.Patient): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Patient }, undefined)\n }\n\n /**\n * Merge two patients into one. This method performs the following operations:\n * - The `from` patient will be soft-deleted, and it will point to the `into` patient. Only the `deletionDate` and `mergeToPatientId` fields of the\n * patient will be changed (automatically by this method). Note that the value of {@link from} is only used to verify that the client is aware of\n * the last version of the `from` patient: any changes to its content and/or metadata compared to what is actually stored in the database will be\n * ignored.\n * - The metadata of the `into` patient will be automatically updated to contain also the metadata of the `from` patient and to keep track of the\n * merge:\n * - the `mergedIds` will be updated to contain the `from` patient id\n * - all secret ids of the `from` patient will be added to the `into` patient\n * - all data owners (including anonymous data owners) with access to the `from` patient will have the same access to the merged `into` patient\n * (unless they already had greater access to the `into` patient, in which case they keep the greater access)\n * - The content of the `into` patient will be updated to match the content (name, address, note, ...) of the provided {@link mergedInto} parameter.\n * Note that since the metadata is automatically updated by this method you must not change the metadata of the `mergedInto` patient\n * (`delegations`, mergedInto`, ...): if there is any change between the metadata of the provided `mergedInto` patient and the stored patient this\n * method will fail with an error.\n *\n * In case the revisions of {@link from} and/or {@link mergedInto} does not match the latest revisions for these patients in the database this\n * method will fail without soft-deleting the `from` patient and without updating the `into` patient with the merged content and metadata. You will\n * have to retrieve the updated versions of both patients before retrying the merge.\n *\n * Finally, note that this method only merges existing data, and does not perform any automatic sharing of the data. The secret ids and encryption\n * keys will not be shared with users that had access only to one of the entity, you will have to use the {@link shareWith} method after the merge\n * if you want to do so.\n * For example consider hcps A, B with access to P' and hcps A, C with access to P'', and we merge P'' into P'. After the merge:\n * - A has access to all secret ids of the merged patient and to the encryption key of the merged patient\n * - B has access to the encryption key of the merged patient (since it is the same as in P'), but only to the secret id which was originally from\n * the unmerged P'\n * - C has no access to the encryption key of the merged patient, and has access only to the secret id which was originally from the unmerged P''\n *\n * @param from the original, unmodified `from` patient. Its content will be unchanged and its metadata will be automatically updated by this method\n * to reflect the merge.\n * @param mergedInto the `into` patient with updated content result of the merge with the `from` patient, as specified by your application logic.\n * The metadata of the `mergedInto` patient must not differ from the metadata of the stored version of the patient, since it will be automatically\n * updated by the method.\n * @return the updated `into` patient.\n */\n async mergePatients(from: Patient, mergedInto: Patient): Promise<Patient> {\n const encryptedMerged = (await this.encryptAs(await this.dataOwnerApi.getCurrentDataOwnerId(), [mergedInto]))[0]\n const merged = await super.baseMergePatients(from.id!, from.rev!, encryptedMerged)\n return (await this.tryDecryptOrReturnOriginal([merged]))[0].entity\n }\n\n /**\n * Subscribes to patient events (create, update, delete) and automatically decrypts them.\n * @param eventTypes the types of events to subscribe to\n * @param filter optional filter to apply to events\n * @param eventFired callback function to handle each event\n * @param options optional subscription options\n * @return connection object to manage the subscription\n */\n async subscribeToPatientEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Patient> | undefined,\n eventFired: (patient: Patient) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n const currentUser = await this.userApi.getCurrentUser()\n return subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Patient,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt(currentUser, [encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n /**\n * Creates or updates de-anonymization metadata for patient delegations.\n * @param entity the patient\n * @param delegates array of delegate ids to create metadata for\n */\n createDelegationDeAnonymizationMetadata(entity: Patient, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Patient }, delegates)\n }\n\n /**\n * Initializes the exchange data towards a newly invited patient. This allows the doctor to share data with the\n * patient even if the patient has not yet initialized a keypair for himself.\n *\n * This method should be used only if the patient has not yet initialized a keypair for himself. If the patient has\n * already initialized a keypair this method does nothing and returns false. In this case the exchange data will be\n * automatically created the first time you share data with the patient, and your implementation of the crypto\n * strategies will be used to validate the public keys of the patient.\n *\n * Once exchange data is initialized you can use the {@link IccRecoveryXApi.createExchangeDataRecoveryInfo} to\n * generate a key that the patient will be able to use on his first login to immediately gain access to the exchange\n * data (through the {@link IccRecoveryXApi.recoverExchangeData} method).\n *\n * @param patientId the id of the newly invited patient.\n * @return true if exchange data was initialized, false if the patient already has a key pair and the exchange data\n * will be initialized in the standard way (automatically on the first time data is shared with the user).\n */\n async forceInitialiseExchangeDataToNewlyInvitedPatient(patientId: string): Promise<boolean> {\n const patient = await super.getPatient(patientId)\n if (this.dataOwnerApi.getHexPublicKeysOf(patient).size) return false\n await this.crypto.exchangeData.getOrCreateEncryptionDataTo(patientId, {\n allowCreationWithoutDelegateKey: true,\n })\n return true\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param entityId the id of the patient to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the patient.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Patient>> {\n return super.getConflictsForEntity(entityId).then((ps) => this.decrypt(user, ps))\n }\n\n /**\n * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved\n * winner returned by the backend.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerWithUser(\n user: models.User,\n request: models.ConflictResolutionRequest<models.Patient>\n ): Promise<models.ConflictResolutionResult<models.Patient>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(user, [result.document]))[0]\n return result\n }\n\n /**\n * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param groupId the id of the group the patient belongs to.\n * @param entityId the id of the patient to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the patient.\n */\n getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Patient>> {\n return super.getConflictsForEntityInGroup(groupId, entityId).then((ps) => this.decrypt(user, ps))\n }\n\n /**\n * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param groupId the id of the group the patient belongs to.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerInGroupWithUser(\n user: models.User,\n groupId: string,\n request: models.ConflictResolutionRequest<models.Patient>\n ): Promise<models.ConflictResolutionResult<models.Patient>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinnerInGroup(groupId, { ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(user, [result.document]))[0]\n return result\n }\n}\n"]}