import { IccEntityrefApi, IccInvoiceApi } from '../icc-api'; import { IccCryptoXApi } from './icc-crypto-x-api'; import * as models from '../icc-api/model/models'; import { Invoice } from '../icc-api/model/models'; import { IccDataOwnerXApi } from './icc-data-owner-x-api'; import { AuthenticationProvider } from './auth/AuthenticationProvider'; import { SecureDelegation } from '../icc-api/model/SecureDelegation'; import AccessLevelEnum = SecureDelegation.AccessLevelEnum; import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'; import { ShareResult } from './utils/ShareResult'; import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'; import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum; import { XHR } from '../icc-api/api/XHR'; import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'; import { SecretIdUseOption } from './crypto/SecretIdUseOption'; export declare class IccInvoiceXApi extends IccInvoiceApi implements EncryptedEntityXApi { private readonly crypto; private readonly entityrefApi; private readonly dataOwnerApi; private readonly autofillAuthor; get headers(): Promise>; constructor(host: string, headers: { [key: string]: string; }, crypto: IccCryptoXApi, entityrefApi: IccEntityrefApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise); /** * Creates a new instance of invoice with initialised encryption metadata (not in the database). * @param user the current user. * @param patient the patient this invoice refers to. * @param inv initialised data for the invoice. 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. * - sfkOption: specifies which sfk of the owning entity to use. * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates * - 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 invoice. */ newInstance(user: models.User, patient: models.Patient, inv?: any, options?: { additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum; }; sfkOption?: SecretIdUseOption; ignoreAutoDelegations?: boolean; alternateRootDelegation?: string; }): Promise; /** * Creates an invoice. If a prefix is provided, an auto-incrementing invoice reference is generated using the * entity reference API. If the invoice has an internshipNihii, the reference is adjusted accordingly. * @param invoice the invoice to create. * @param prefix optional prefix for generating an auto-incrementing invoice reference. * @return the created invoice. */ createInvoice(invoice: Invoice, prefix?: string): Promise; /** * Gets the next available invoice reference number for the given prefix. * @param prefix the prefix to look up the latest reference for. * @param entityrefApi the entity reference API to query. * @return the next sequence number (1-based). */ getNextInvoiceReference(prefix: string, entityrefApi: IccEntityrefApi): Promise; /** * Creates an entity reference for an invoice with the given reference number. If the reference already exists * (conflict), retries with the next available number. * @param nextReference the reference number to use. * @param docId the document id to link to this reference. * @param prefix the prefix for the reference id. * @param entityrefApi the entity reference API to use. * @return the created entity reference. */ createInvoiceReference(nextReference: number, docId: string, prefix: string, entityrefApi: IccEntityrefApi): Promise; /** * 1. Check whether there is a delegation with 'hcpartyId' or not. * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him. * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key * 3.1. KeyPair should be fetch from cache (in jwk) * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4) * 6. Do the REST call to get all invoices with (allSecretForeignKeysDelimitedByComa, hcpartyId) * * After these painful steps, you have the invoices for the patient. * * @deprecated use {@link findIdsBy} instead * @param hcpartyId * @param patient (Promise) * @param usingPost */ findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise>; /** * Same as {@link findBy} but it will only return the ids of the invoices. It can also filter the invoices where Invoice.invoiceDate 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; /** * Encrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields. * @param user the current user. * @param invoices the invoices to encrypt. * @return the invoices unchanged. */ encrypt(user: models.User, invoices: Array): Promise; /** * Decrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields. * @param hcpartyId the id of the healthcare party. * @param invoices the invoices to decrypt. * @return the invoices unchanged. */ decrypt(hcpartyId: string, invoices: Array): Promise>; /** * @param invoice a invoice * @return the id of the patient that the invoice 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(invoice: models.Invoice): Promise; /** * @return if the logged data owner has write access to the content of the given invoice */ hasWriteAccess(invoice: models.Invoice): Promise; /** * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice 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 invoice. * @param invoice the invoice 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 * invoice does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this invoice 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 */ shareWith(delegateId: string, invoice: models.Invoice, options?: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }): Promise; /** * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also * the encrypted content, with read-only or read-write permissions. * @param invoice the invoice 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 * invoice does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this invoice 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(invoice: models.Invoice, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise; /** * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also * the encrypted content, with read-only or read-write permissions. * @param invoice the invoice 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 * invoice does not have encrypted content. * - sharePatientId: specifies if the id of the patient that this invoice 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. */ tryShareWithMany(invoice: models.Invoice, delegates: { [delegateId: string]: { shareSecretIds?: string[]; requestedPermissions?: RequestedPermissionEnum; shareEncryptionKey?: ShareMetadataBehaviour; sharePatientId?: ShareMetadataBehaviour; }; }): Promise>; /** * Retrieves the data owners that have access to the given invoice, along with their access levels. * @param entity the invoice. * @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: models.Invoice): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum; }; hasUnknownAnonymousDataOwners: boolean; }>; /** * Retrieves the encryption keys of the given invoice. * @param entity the invoice. * @return the encryption key ids. */ getEncryptionKeysOf(entity: models.Invoice): Promise; /** * Creates or updates de-anonymization metadata for the given invoice, allowing the specified delegates to * identify the data owners that have access to it. * @param entity the invoice. * @param delegates the data owner ids for which to create de-anonymization metadata. */ createDelegationDeAnonymizationMetadata(entity: models.Invoice, 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 invoice to retrieve the conflicts for. * @return the decrypted conflicting revisions of the invoice. */ 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>; /** * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id. * @param user the current user, used to determine the data owner that will decrypt the entities. * @param groupId the id of the group the invoice belongs to. * @param entityId the id of the invoice to retrieve the conflicts for. * @return the decrypted conflicting revisions of the invoice. */ getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise>; /** * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id. * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity. * @param groupId the id of the group the invoice belongs to. * @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. */ declareConflictWinnerInGroupWithUser(user: models.User, groupId: string, request: models.ConflictResolutionRequest): Promise>; }