import * as models from '../icc-api/model/models'; import { CalendarItem, User } from '../icc-api/model/models'; import { IccCryptoXApi } from './icc-crypto-x-api'; import { IccCalendarItemApi } from '../icc-api'; import { IccDataOwnerXApi } from './icc-data-owner-x-api'; import { AuthenticationProvider } from './auth/AuthenticationProvider'; import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'; import { ShareResult } from './utils/ShareResult'; import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'; import { SecureDelegation } from '../icc-api/model/SecureDelegation'; import { XHR } from '../icc-api/api/XHR'; import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'; import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum; import AccessLevelEnum = SecureDelegation.AccessLevelEnum; import { PaginatedListCalendarItem } from '../icc-api/model/PaginatedListCalendarItem'; import { SecretIdUseOption } from './crypto/SecretIdUseOption'; export declare class IccCalendarItemXApi extends IccCalendarItemApi implements EncryptedEntityXApi { private readonly autofillAuthor; i18n: any; crypto: IccCryptoXApi; dataOwnerApi: IccDataOwnerXApi; private readonly encryptedFields; get headers(): Promise>; constructor(host: string, headers: { [key: string]: string; }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, encryptedKeys?: Array, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise); /** * Creates a new instance of calendar item with initialised encryption metadata (not in the database), without * linking it to a patient. Use {@link newInstancePatient} to create a calendar item linked to a patient. * @param user the current user. * @param ci initialised data for the calendar item. * @param options optional parameters for delegates and root delegation. * @return a new instance of calendar item. */ newInstance(user: User, ci: any | CalendarItem, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; alternateRootDelegation?: string; }): Promise; /** * Creates a new instance of calendar item with initialised encryption metadata (not in the database). * @param user the current user. * @param patient the patient this calendar item refers to. * @param ci initialised data for the calendar item. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata. * @param options optional parameters: * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the * 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 * auto-delegations, in such case the access level specified here will be used. * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classcalendar itemification. The default value will be a * secret id of patient known by the topmost parent in the current data owner hierarchy. * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible, * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation. * @return a new instance of calendar item. */ newInstancePatient(user: models.User, patient: models.Patient | null, ci: any, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; sfkOption?: SecretIdUseOption; alternateRootDelegation?: string; }): Promise; /** * @deprecated use {@link findIdsBy} instead. */ findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise; /** * Same as `findBy` but it will only return the ids of the calendar items. It can also filter the access logs where CalendarItem.date is between * startDate and endDate in ascending or descending order by that field. (default: ascending). */ findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise; /** * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead. */ findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise>; /** * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead. */ findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise | any>; /** * @throws always. Use {@link createCalendarItemWithHcParty} instead. */ createCalendarItem(body?: CalendarItem): never; /** * Creates a calendar item after encrypting its content. * @param user the current user, used for encryption. * @param body the calendar item to create. * @return the created and decrypted calendar item. */ createCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise; /** * Retrieves a calendar item by id and decrypts it. * @param user the current user, used for decryption. * @param calendarItemId the id of the calendar item to retrieve. * @return the decrypted calendar item. */ getCalendarItemWithUser(user: models.User, calendarItemId: string): Promise; /** * @throws always. Use {@link getCalendarItemWithUser} instead. */ getCalendarItem(calendarItemId: string): never; /** * @deprecated use {@link getCalendarItemsWithPaginationWithUser} instead. */ getCalendarItemsWithUser(user: models.User): Promise | any>; /** * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead. */ getCalendarItems(): never; /** * Retrieves calendar items with pagination and decrypts them. * @param user the current user, used for decryption. * @param startDocumentId the pagination start document id. * @param limit the maximum number of results to return. * @return a paginated list of decrypted calendar items. */ getCalendarItemsWithPaginationWithUser(user: models.User, startDocumentId?: string, limit?: number): Promise; /** * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead. */ getCalendarItemsWithPagination(startDocumentId?: string, limit?: number): never; /** * @deprecated use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead. */ findCalendarItemsByRecurrenceIdWithUser(user: models.User, recurrenceId: string): Promise | any>; /** * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead. */ findCalendarItemsByRecurrenceId(recurrenceId: string): never; /** * Finds calendar items by recurrence id with pagination and decrypts them. * @param user the current user, used for decryption. * @param recurrenceId the recurrence id to search for. * @param startKey the pagination start key. * @param startDocumentId the pagination start document id. * @param limit the maximum number of results to return. * @return a paginated list of decrypted calendar items matching the recurrence id. */ findCalendarItemsByRecurrenceIdWithPaginationWithUser(user: models.User, recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise; /** * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead. */ findCalendarItemsByRecurrenceIdWithPagination(recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): never; /** * Retrieves multiple calendar items by their ids and decrypts them. * @param user the current user, used for decryption. * @param body the list of calendar item ids to retrieve. * @return the decrypted calendar items. */ getCalendarItemsWithIdsWithUser(user: models.User, body?: models.ListOfIds): Promise | any>; /** * @throws always. Use {@link getCalendarItemsWithIdsWithUser} instead. */ getCalendarItemsWithIds(body?: models.ListOfIds): never; /** * Retrieves calendar items for a given healthcare party within a date range and decrypts them. * @param user the current user, used for decryption. * @param startDate the start of the date range. * @param endDate the end of the date range. * @param hcPartyId the id of the healthcare party. * @return the decrypted calendar items. */ getCalendarItemsByPeriodAndHcPartyIdWithUser(user: models.User, startDate: number, endDate: number, hcPartyId: string): Promise | any>; /** * @throws always. Use {@link getCalendarItemsByPeriodAndHcPartyIdWithUser} instead. */ getCalendarItemsByPeriodAndHcPartyId(startDate?: number, endDate?: number, hcPartyId?: string): never; /** * Retrieves calendar items for a given agenda within a date range and decrypts them. * @param user the current user, used for decryption. * @param startDate the start of the date range. * @param endDate the end of the date range. * @param agendaId the id of the agenda. * @return the decrypted calendar items. */ getCalendarsByPeriodAndAgendaIdWithUser(user: models.User, startDate: number, endDate: number, agendaId: string): Promise | any>; /** * @throws always. Use {@link getCalendarsByPeriodAndAgendaIdWithUser} instead. */ getCalendarsByPeriodAndAgendaId(startDate?: number, endDate?: number, agendaId?: string): never; /** * @throws always. Use {@link modifyCalendarItemWithHcParty} instead. */ modifyCalendarItem(body?: CalendarItem): never; /** * Remove the following delegation objects from the * CalendarItem instance: cryptedForeignKeys, secretForeignKeys. * * The delegations & encryptionKeys objects are not removed because * in the case the CalendarItem is saved in the DB & then encrypted, * if later we remove the patient from it, it'd reset the delegations * and encryptionKeys thus impossibilitating further access. * * @param calendarItem The Calendar Item object */ resetCalendarDelegationObjects(calendarItem: models.CalendarItem): models.CalendarItem; /** * Modifies a calendar item after encrypting its content. * @param user the current user, used for encryption/decryption. * @param body the calendar item with updated fields. * @return the modified and decrypted calendar item, or null if body was not provided. */ modifyCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise; private modifyAs; /** * Encrypts the encrypted fields of a list of calendar items. * @param user the current user, used to determine the data owner for encryption. * @param calendarItems the calendar items to encrypt. * @return the encrypted calendar items. */ encrypt(user: models.User, calendarItems: Array): Promise>; private encryptAs; /** * Decrypts a list of calendar items using the current data owner's keys. * @param hcpId the id of the healthcare party performing the decryption. * @param calendarItems the calendar items to decrypt. * @return the decrypted calendar items. */ decrypt(hcpId: string, calendarItems: Array): Promise>; /** * @param calendarItem a calendar item * @return the id of the patient that the calendar item refers to, retrieved from the encrypted metadata. Normally there should only be one element * in the returned array, but in case of entity merges there could be multiple values. */ decryptPatientIdOf(calendarItem: models.CalendarItem): Promise; /** * @return if the logged data owner has write access to the content of the given calendar item */ hasWriteAccess(calendarItem: models.CalendarItem): Promise; /** * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also * the encrypted content, with read-only or read-write permissions. * @param delegateId the id of the data owner which will be granted access to the calendar item. * @param calendarItem item the calendar item to share. * @param options optional parameters to customize the sharing behaviour: * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a * calendar item does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this calendar item refers to should be shared with the delegate (defaults to * {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @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 * the operation failed. */ shareWith(delegateId: string, calendarItem: models.CalendarItem, options?: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }): Promise; /** * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also * the encrypted content, with read-only or read-write permissions. * @param calendarItem item the calendar item to share. * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options: * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a * calendar item does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this calendar item refers to should be shared with the delegate (defaults to * {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ shareWithMany(calendarItem: models.CalendarItem, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise; /** * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also * the encrypted content, with read-only or read-write permissions. * @param calendarItem item the calendar item to share. * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options: * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a * calendar item does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this calendar item refers to should be shared with the delegate (defaults to * {@link ShareMetadataBehaviour.IF_AVAILABLE}). * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}. * @return the updated entity */ tryShareWithMany(calendarItem: models.CalendarItem, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise>; /** * Retrieves the data owners that have access to the given calendar item, along with their access levels. * @param entity the calendar item. * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners. */ getDataOwnersWithAccessTo(entity: CalendarItem): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum; }; hasUnknownAnonymousDataOwners: boolean; }>; /** * Retrieves the encryption keys of the given calendar item. * @param entity the calendar item. * @return the encryption key ids. */ getEncryptionKeysOf(entity: CalendarItem): Promise; /** * Adds a bidirectional link between a calendar item with a patient. * Note that this operation is not reversible: it is not possible to change the patient linked to a calendar * item. * @param calendarItem a calendar item * @param patient the patient which will be linked to the calendar item. * @param shareLinkWithDelegates data owners other than the current data owner which will also be able to decrypt the id of the newly linked * patient. If any of these data owners do not already have access to the calendar item, they will be granted read access (no write). * @param sfkOption specify how to create the link from the patient * @return the updated calendar item */ linkWithPatient(calendarItem: models.CalendarItem, patient: models.Patient, shareLinkWithDelegates: string[], sfkOption?: SecretIdUseOption): Promise; /** * Checks if a calendar item has an (encrypted) link from a patient. * Calendar item where this method returns false won't be findable when searching for them by patient. * If this method returns false there may still be a link to the patient; you can check for it by using the method * {@link decryptPatientIdOf}. * * Note: this method only checks the presence of a link, it doesn't verify that it is valid (for example, this method * doesn't check if the link from the patient matches the link to the patient). */ hasLinkFromPatient(calendarItem: CalendarItem): boolean; /** * Adds a link to a calendar item allowing it to be found from the patient. * This method only adds a partial link; if the calendar item is not already linked to the patient you should * instead use the {@link linkWithPatient} * @param calendarItem the calendar item to update. * @param patient the patient to link with the calendar item. * @param sfkOption customize how to create the link. * @return the updated calendar item */ addLinkFromPatient(calendarItem: CalendarItem, patient: models.Patient, sfkOption?: SecretIdUseOption): Promise; /** * Creates or updates de-anonymization metadata for the given calendar item, allowing the specified delegates to * identify the data owners that have access to it. * @param entity the calendar item. * @param delegates the data owner ids for which to create de-anonymization metadata. */ createDelegationDeAnonymizationMetadata(entity: CalendarItem, delegates: string[]): Promise; /** * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user. * @param user the current user, used to determine the data owner that will decrypt the entities. * @param entityId the id of the calendar item to retrieve the conflicts for. * @return the decrypted conflicting revisions of the calendar item. */ getConflictsForEntityWithUser(user: models.User, entityId: string): Promise>; /** * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved * winner returned by the backend. * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity. * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge. * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved. */ declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest): Promise>; }