@icure/api 6.4.0 → 7.0.0-beta.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.
- package/icc-api/api/IccDeviceApi.d.ts +1 -1
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDoctemplateApi.js.map +1 -1
- package/icc-api/api/IccDocumentTemplateApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +1 -1
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +1 -1
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/model/MaintenanceTask.d.ts +6 -5
- package/icc-api/model/MaintenanceTask.js +5 -0
- package/icc-api/model/MaintenanceTask.js.map +1 -1
- package/icc-api/model/User.d.ts +23 -1
- package/icc-api/model/User.js +21 -0
- package/icc-api/model/User.js.map +1 -1
- package/icc-api/model/models.d.ts +14 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/crypto/AES.d.ts +2 -0
- package/icc-x-api/crypto/AES.js +12 -0
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeKeysManager.d.ts +122 -0
- package/icc-x-api/crypto/BaseExchangeKeysManager.js +356 -0
- package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -0
- package/icc-x-api/crypto/ConfidentialEntities.d.ts +58 -0
- package/icc-x-api/crypto/ConfidentialEntities.js +99 -0
- package/icc-x-api/crypto/ConfidentialEntities.js.map +1 -0
- package/icc-x-api/crypto/CryptoPrimitives.d.ts +31 -0
- package/icc-x-api/crypto/CryptoPrimitives.js +55 -0
- package/icc-x-api/crypto/CryptoPrimitives.js.map +1 -0
- package/icc-x-api/crypto/CryptoStrategies.d.ts +82 -0
- package/icc-x-api/crypto/CryptoStrategies.js +3 -0
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -0
- package/icc-x-api/crypto/EntitiesEncryption.d.ts +254 -0
- package/icc-x-api/crypto/EntitiesEncryption.js +700 -0
- package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -0
- package/icc-x-api/crypto/ExchangeKeysManager.d.ts +56 -0
- package/icc-x-api/crypto/ExchangeKeysManager.js +147 -0
- package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -0
- package/icc-x-api/crypto/KeyManager.d.ts +103 -0
- package/icc-x-api/crypto/KeyManager.js +288 -0
- package/icc-x-api/crypto/KeyManager.js.map +1 -0
- package/icc-x-api/crypto/KeyRecovery.d.ts +34 -0
- package/icc-x-api/crypto/KeyRecovery.js +253 -0
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.d.ts +28 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.js +22 -0
- package/icc-x-api/crypto/LegacyCryptoStrategies.js.map +1 -0
- package/icc-x-api/crypto/RSA.d.ts +19 -20
- package/icc-x-api/crypto/RSA.js +30 -1
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.d.ts +43 -0
- package/icc-x-api/crypto/ShamirKeysManager.js +150 -0
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.d.ts +19 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.js +24 -0
- package/icc-x-api/crypto/ShareMetadataBehaviour.js.map +1 -0
- package/icc-x-api/crypto/TransferKeysManager.d.ts +29 -0
- package/icc-x-api/crypto/TransferKeysManager.js +121 -0
- package/icc-x-api/crypto/TransferKeysManager.js.map +1 -0
- package/icc-x-api/crypto/utils.d.ts +46 -0
- package/icc-x-api/crypto/utils.js +128 -0
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.d.ts +11 -0
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js +11 -0
- package/icc-x-api/filters/ContactByHcPartyTagCodeDateFilter.js.map +1 -1
- package/icc-x-api/filters/DeviceByHcPartyFilter.d.ts +11 -0
- package/icc-x-api/filters/DeviceByHcPartyFilter.js +11 -0
- package/icc-x-api/filters/DeviceByHcPartyFilter.js.map +1 -1
- package/icc-x-api/filters/DeviceByIdsFilter.d.ts +11 -0
- package/icc-x-api/filters/DeviceByIdsFilter.js +11 -0
- package/icc-x-api/filters/DeviceByIdsFilter.js.map +1 -1
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.d.ts +11 -0
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js +11 -0
- package/icc-x-api/filters/HealthElementByHcPartySecretForeignKeysFilter.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +49 -4
- package/icc-x-api/icc-accesslog-x-api.js +112 -102
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +53 -5
- package/icc-x-api/icc-calendar-item-x-api.js +112 -100
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +45 -2
- package/icc-x-api/icc-classification-x-api.js +89 -41
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +57 -19
- package/icc-x-api/icc-contact-x-api.js +149 -154
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +266 -366
- package/icc-x-api/icc-crypto-x-api.js +416 -1327
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +110 -11
- package/icc-x-api/icc-data-owner-x-api.js +188 -14
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js +3 -3
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +76 -5
- package/icc-x-api/icc-document-x-api.js +137 -59
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +47 -7
- package/icc-x-api/icc-form-x-api.js +85 -86
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +1 -1
- package/icc-x-api/icc-hcparty-x-api.js +1 -1
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +50 -3
- package/icc-x-api/icc-helement-x-api.js +101 -118
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-icure-maintenance-x-api.d.ts +31 -0
- package/icc-x-api/icc-icure-maintenance-x-api.js +124 -0
- package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -0
- package/icc-x-api/icc-invoice-x-api.d.ts +45 -5
- package/icc-x-api/icc-invoice-x-api.js +89 -64
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +38 -6
- package/icc-x-api/icc-maintenance-task-x-api.js +73 -102
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +55 -2
- package/icc-x-api/icc-message-x-api.js +92 -33
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +67 -7
- package/icc-x-api/icc-patient-x-api.js +409 -473
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +49 -5
- package/icc-x-api/icc-receipt-x-api.js +85 -47
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +34 -10
- package/icc-x-api/icc-time-table-x-api.js +61 -18
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +30 -1
- package/icc-x-api/index.js +112 -49
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/maintenance/KeyPairUpdateRequest.d.ts +35 -0
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js +54 -0
- package/icc-x-api/maintenance/KeyPairUpdateRequest.js.map +1 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.d.ts +9 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js +23 -0
- package/icc-x-api/storage/DefaultStorageEntryKeysFactory.js.map +1 -0
- package/icc-x-api/storage/IcureStorageFacade.d.ts +55 -0
- package/icc-x-api/storage/IcureStorageFacade.js +95 -0
- package/icc-x-api/storage/IcureStorageFacade.js.map +1 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.d.ts +31 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.js +3 -0
- package/icc-x-api/storage/StorageEntryKeysFactory.js.map +1 -0
- package/icc-x-api/utils/collection-utils.d.ts +8 -0
- package/icc-x-api/utils/collection-utils.js +26 -0
- package/icc-x-api/utils/collection-utils.js.map +1 -0
- package/icc-x-api/utils/crypto-utils.d.ts +8 -1
- package/icc-x-api/utils/crypto-utils.js +19 -3
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/graph-utils.d.ts +45 -0
- package/icc-x-api/utils/graph-utils.js +203 -0
- package/icc-x-api/utils/graph-utils.js.map +1 -0
- package/icc-x-api/utils/lru-temporised-async-cache.d.ts +27 -0
- package/icc-x-api/utils/lru-temporised-async-cache.js +120 -0
- package/icc-x-api/utils/lru-temporised-async-cache.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,13 +3,56 @@ import { IccCryptoXApi } from './icc-crypto-x-api';
|
|
|
3
3
|
import * as models from '../icc-api/model/models';
|
|
4
4
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
5
5
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
6
|
+
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
6
7
|
export declare class IccClassificationXApi extends IccClassificationApi {
|
|
7
8
|
crypto: IccCryptoXApi;
|
|
8
9
|
dataOwnerApi: IccDataOwnerXApi;
|
|
9
10
|
constructor(host: string, headers: {
|
|
10
11
|
[key: string]: string;
|
|
11
12
|
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of classification with initialised encryption metadata (not in the database).
|
|
15
|
+
* @param user the current user.
|
|
16
|
+
* @param patient the patient this classification refers to.
|
|
17
|
+
* @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
18
|
+
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
19
|
+
* @param options optional parameters:
|
|
20
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
21
|
+
* 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
|
|
22
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
23
|
+
* access will be possible.
|
|
24
|
+
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
25
|
+
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
26
|
+
* @return a new instance of classification.
|
|
27
|
+
*/
|
|
28
|
+
newInstance(user: models.User, patient: models.Patient, c?: any, options?: {
|
|
29
|
+
additionalDelegates?: {
|
|
30
|
+
[dataOwnerId: string]: 'WRITE';
|
|
31
|
+
};
|
|
32
|
+
preferredSfk?: string;
|
|
33
|
+
}): Promise<models.Classification>;
|
|
14
34
|
findBy(hcpartyId: string, patient: models.Patient): Promise<models.Classification[]>;
|
|
35
|
+
/**
|
|
36
|
+
* @param classification a classification
|
|
37
|
+
* @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element
|
|
38
|
+
* in the returned array, but in case of entity merges there could be multiple values.
|
|
39
|
+
*/
|
|
40
|
+
decryptPatientIdOf(classification: models.Classification): Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also
|
|
43
|
+
* the encrypted content.
|
|
44
|
+
* @param delegateId the id of the data owner which will be granted access to the classification.
|
|
45
|
+
* @param classification the classification to share.
|
|
46
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
47
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
48
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
49
|
+
* classification does not have encrypted content.
|
|
50
|
+
* - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to
|
|
51
|
+
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
52
|
+
* @return a promise which will contain the updated classification.
|
|
53
|
+
*/
|
|
54
|
+
shareWith(delegateId: string, classification: models.Classification, options?: {
|
|
55
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
56
|
+
sharePatientId?: ShareMetadataBehaviour;
|
|
57
|
+
}): Promise<models.Classification>;
|
|
15
58
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.IccClassificationXApi = void 0;
|
|
4
13
|
const icc_api_1 = require("../icc-api");
|
|
14
|
+
const models = require("../icc-api/model/models");
|
|
5
15
|
const _ = require("lodash");
|
|
6
16
|
const moment = require("moment");
|
|
7
17
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
@@ -15,50 +25,88 @@ class IccClassificationXApi extends icc_api_1.IccClassificationApi {
|
|
|
15
25
|
this.crypto = crypto;
|
|
16
26
|
this.dataOwnerApi = dataOwnerApi;
|
|
17
27
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return this
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of classification with initialised encryption metadata (not in the database).
|
|
30
|
+
* @param user the current user.
|
|
31
|
+
* @param patient the patient this classification refers to.
|
|
32
|
+
* @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
33
|
+
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
34
|
+
* @param options optional parameters:
|
|
35
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
36
|
+
* 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
|
|
37
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
38
|
+
* access will be possible.
|
|
39
|
+
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
40
|
+
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
41
|
+
* @return a new instance of classification.
|
|
42
|
+
*/
|
|
43
|
+
newInstance(user, patient, c = {}, options = {}) {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const classification = _.assign({
|
|
47
|
+
id: this.crypto.primitives.randomUuid(),
|
|
48
|
+
_type: 'org.taktik.icure.entities.Classification',
|
|
49
|
+
created: new Date().getTime(),
|
|
50
|
+
modified: new Date().getTime(),
|
|
51
|
+
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
52
|
+
author: user.id,
|
|
53
|
+
codes: [],
|
|
54
|
+
tags: [],
|
|
55
|
+
healthElementId: this.crypto.primitives.randomUuid(),
|
|
56
|
+
openingDate: parseInt(moment().format('YYYYMMDDHHmmss')),
|
|
57
|
+
}, c || {});
|
|
58
|
+
const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
|
|
59
|
+
if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
|
|
60
|
+
throw new Error('Can only initialise entities as current data owner.');
|
|
61
|
+
const sfk = (_a = options.preferredSfk) !== null && _a !== void 0 ? _a : (yield this.crypto.confidential.getAnySecretIdSharedWithParents(patient));
|
|
62
|
+
if (!sfk)
|
|
63
|
+
throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`);
|
|
64
|
+
const extraDelegations = [
|
|
65
|
+
...Object.keys((_b = options.additionalDelegates) !== null && _b !== void 0 ? _b : {}),
|
|
66
|
+
...((_d = (_c = user.autoDelegations) === null || _c === void 0 ? void 0 : _c.all) !== null && _d !== void 0 ? _d : []),
|
|
67
|
+
...((_f = (_e = user.autoDelegations) === null || _e === void 0 ? void 0 : _e.medicalInformation) !== null && _f !== void 0 ? _f : []),
|
|
68
|
+
];
|
|
69
|
+
return new models.Classification(yield this.crypto.entities
|
|
70
|
+
.entityWithInitialisedEncryptedMetadata(classification, patient === null || patient === void 0 ? void 0 : patient.id, sfk, true, extraDelegations)
|
|
71
|
+
.then((x) => x.updatedEntity));
|
|
56
72
|
});
|
|
57
73
|
}
|
|
58
74
|
findBy(hcpartyId, patient) {
|
|
59
|
-
return this
|
|
60
|
-
.
|
|
61
|
-
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const extractedKeys = yield this.crypto.entities.secretIdsOf(patient, hcpartyId);
|
|
77
|
+
const topmostParentId = (yield this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0];
|
|
78
|
+
return extractedKeys && extractedKeys.length > 0
|
|
79
|
+
? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))
|
|
80
|
+
: Promise.resolve([]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @param classification a classification
|
|
85
|
+
* @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element
|
|
86
|
+
* in the returned array, but in case of entity merges there could be multiple values.
|
|
87
|
+
*/
|
|
88
|
+
decryptPatientIdOf(classification) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
return this.crypto.entities.owningEntityIdsOf(classification, undefined);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also
|
|
95
|
+
* the encrypted content.
|
|
96
|
+
* @param delegateId the id of the data owner which will be granted access to the classification.
|
|
97
|
+
* @param classification the classification to share.
|
|
98
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
99
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
100
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
101
|
+
* classification does not have encrypted content.
|
|
102
|
+
* - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to
|
|
103
|
+
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
104
|
+
* @return a promise which will contain the updated classification.
|
|
105
|
+
*/
|
|
106
|
+
shareWith(delegateId, classification, options = {}) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
return yield this.modifyClassification(yield this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(classification, delegateId, undefined, options.shareEncryptionKey, options.sharePatientId));
|
|
109
|
+
});
|
|
62
110
|
}
|
|
63
111
|
}
|
|
64
112
|
exports.IccClassificationXApi = IccClassificationXApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAGhG,MAAa,qBAAsB,SAAQ,8BAAoB;IAI7D,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EAC9B,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;;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EAAE;;YAEN,OAAO,MAAM,IAAI,CAAC,oBAAoB,CACpC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAChE,cAAc,EACd,UAAU,EACV,SAAS,EACT,OAAO,CAAC,kBAAkB,EAC1B,OAAO,CAAC,cAAc,CACvB,CACF,CAAA;QACH,CAAC;KAAA;CACF;AA5HD,sDA4HC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\n\nexport class IccClassificationXApi extends IccClassificationApi {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. 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. Currently only WRITE access is supported, but in future also read\n * access will be possible.\n * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: 'WRITE' }\n preferredSfk?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = _.assign(\n {\n id: this.crypto.primitives.randomUuid(),\n _type: 'org.taktik.icure.entities.Classification',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: this.dataOwnerApi.getDataOwnerIdOf(user),\n author: user.id,\n codes: [],\n tags: [],\n healthElementId: this.crypto.primitives.randomUuid(),\n openingDate: parseInt(moment().format('YYYYMMDDHHmmss')),\n },\n c || {}\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 sfk = options.preferredSfk ?? (await this.crypto.confidential.getAnySecretIdSharedWithParents(patient))\n if (!sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\n const extraDelegations = [\n ...Object.keys(options.additionalDelegates ?? {}),\n ...(user.autoDelegations?.all ?? []),\n ...(user.autoDelegations?.medicalInformation ?? []),\n ]\n return new models.Classification(\n await this.crypto.entities\n .entityWithInitialisedEncryptedMetadata(classification, patient?.id, sfk, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n async findBy(hcpartyId: string, patient: models.Patient) {\n const extractedKeys = await this.crypto.entities.secretIdsOf(patient, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n /**\n * @param classification a classification\n * @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(classification: models.Classification): Promise<string[]> {\n return this.crypto.entities.owningEntityIdsOf(classification, undefined)\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content.\n * @param delegateId the id of the data owner which will be granted access to the classification.\n * @param classification the classification to share.\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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * @return a promise which will contain the updated classification.\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\n options: {\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Classification> {\n return await this.modifyClassification(\n await this.crypto.entities.entityWithAutoExtendedEncryptedMetadata(\n classification,\n delegateId,\n undefined,\n options.shareEncryptionKey,\n options.sharePatientId\n )\n )\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { Contact, ListOfIds, Service } from '../icc-api/model/models';
|
|
|
5
5
|
import { PaginatedListContact } from '../icc-api/model/PaginatedListContact';
|
|
6
6
|
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
|
|
7
7
|
import { AuthenticationProvider } from './auth/AuthenticationProvider';
|
|
8
|
+
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
|
|
8
9
|
export declare class IccContactXApi extends IccContactApi {
|
|
9
10
|
i18n: any;
|
|
10
11
|
crypto: IccCryptoXApi;
|
|
@@ -12,19 +13,30 @@ export declare class IccContactXApi extends IccContactApi {
|
|
|
12
13
|
constructor(host: string, headers: {
|
|
13
14
|
[key: string]: string;
|
|
14
15
|
}, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
15
|
-
newInstance(user: models.User, patient: models.Patient, c: any, confidential?: boolean, delegates?: string[]): Promise<models.Contact>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* Creates a new instance of contact with initialised encryption metadata (not in the database).
|
|
18
|
+
* @param user the current user.
|
|
19
|
+
* @param patient the patient this contact refers to.
|
|
20
|
+
* @param c initialised data for the contact. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify other
|
|
21
|
+
* kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
22
|
+
* @param options optional parameters:
|
|
23
|
+
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
24
|
+
* 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
|
|
25
|
+
* auto-delegations, in such case the access level specified here will be used. Currently only WRITE access is supported, but in future also read
|
|
26
|
+
* access will be possible.
|
|
27
|
+
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
28
|
+
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
29
|
+
* - confidential: if true, the entity will be created as confidential. Confidential entities are not shared with auto-delegations, and the default
|
|
30
|
+
* foreign key used is any key that is not shared with any of the data owner parents. By default entities are created as non-confidential.
|
|
31
|
+
* @return a new instance of contact.
|
|
23
32
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
newInstance(user: models.User, patient: models.Patient, c: any, options?: {
|
|
34
|
+
additionalDelegates?: {
|
|
35
|
+
[dataOwnerId: string]: 'WRITE';
|
|
36
|
+
};
|
|
37
|
+
preferredSfk?: string;
|
|
38
|
+
confidential?: boolean;
|
|
39
|
+
}): Promise<models.Contact>;
|
|
28
40
|
/**
|
|
29
41
|
* 1. Check whether there is a delegation with 'hcpartyId' or not.
|
|
30
42
|
* 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.
|
|
@@ -53,25 +65,28 @@ export declare class IccContactXApi extends IccContactApi {
|
|
|
53
65
|
modifyContact(body?: Contact): never;
|
|
54
66
|
modifyContacts(body?: Array<Contact>): never;
|
|
55
67
|
createContact(body?: Contact): never;
|
|
56
|
-
findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string, planOfActionIds?: string, skipClosedContacts?: boolean): Promise<Array<models.Contact
|
|
68
|
+
findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string, planOfActionIds?: string, skipClosedContacts?: boolean): Promise<Array<models.Contact>>;
|
|
57
69
|
findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[], planOfActionIds?: string, skipClosedContacts?: boolean): Promise<Array<models.Contact> | any>;
|
|
58
70
|
filterByWithUser(user: models.User, startDocumentId?: string, limit?: number, body?: models.FilterChainContact): Promise<PaginatedListContact | any>;
|
|
59
71
|
listContactsByOpeningDateWithUser(user: models.User, startKey: number, endKey: number, hcpartyid: string, startDocumentId?: string, limit?: number): Promise<PaginatedListContact | any>;
|
|
60
72
|
listServicesWithUser(user: models.User, serviceIds: ListOfIds): Promise<Array<Service> | any>;
|
|
61
73
|
findByHCPartyFormIdWithUser(user: models.User, hcPartyId: string, formId: string): Promise<Array<models.Contact> | any>;
|
|
62
74
|
findByHCPartyFormIdsWithUser(user: models.User, hcPartyId: string, body: models.ListOfIds): Promise<Array<models.Contact> | any>;
|
|
63
|
-
getContactWithUser(user: models.User, contactId: string): Promise<models.Contact
|
|
75
|
+
getContactWithUser(user: models.User, contactId: string): Promise<models.Contact>;
|
|
64
76
|
getContactsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<models.Contact> | any>;
|
|
65
77
|
modifyContactWithUser(user: models.User, body?: models.Contact): Promise<models.Contact | any>;
|
|
78
|
+
private modifyAs;
|
|
66
79
|
modifyContactsWithUser(user: models.User, bodies?: Array<models.Contact>): Promise<models.Contact[] | any>;
|
|
67
|
-
createContactWithUser(user: models.User, body?: models.Contact): Promise<models.Contact |
|
|
68
|
-
createContactsWithUser(user: models.User, bodies?: Array<models.Contact>): Promise<models.Contact[] |
|
|
80
|
+
createContactWithUser(user: models.User, body?: models.Contact): Promise<models.Contact | null>;
|
|
81
|
+
createContactsWithUser(user: models.User, bodies?: Array<models.Contact>): Promise<models.Contact[] | null>;
|
|
69
82
|
encryptServices(key: CryptoKey, rawKey: string, services: Service[]): PromiseLike<Service[]>;
|
|
70
|
-
encrypt(user: models.User, ctcs: Array<models.Contact>): Promise<
|
|
71
|
-
|
|
72
|
-
}))[]>;
|
|
83
|
+
encrypt(user: models.User, ctcs: Array<models.Contact>): Promise<models.Contact[]>;
|
|
84
|
+
private encryptAs;
|
|
73
85
|
decrypt(hcpartyId: string, ctcs: Array<models.Contact>): Promise<Array<models.Contact>>;
|
|
74
|
-
decryptServices(hcpartyId: string, svcs: Array<models.Service>,
|
|
86
|
+
decryptServices(hcpartyId: string, svcs: Array<models.Service>, keys?: {
|
|
87
|
+
key: CryptoKey;
|
|
88
|
+
raw: string;
|
|
89
|
+
}[]): Promise<Array<models.Service>>;
|
|
75
90
|
contactOfService(ctcs: Array<models.Contact>, svcId: string): models.Contact | undefined;
|
|
76
91
|
filteredServices(ctcs: Array<models.Contact>, filter: any): Array<models.Service>;
|
|
77
92
|
filterServices(ctcs: Array<models.Contact>, filter: any): Promise<Array<models.Service>>;
|
|
@@ -126,4 +141,27 @@ export declare class IccContactXApi extends IccContactApi {
|
|
|
126
141
|
regimenToString: (r: models.RegimenItem, lang: string) => string | null;
|
|
127
142
|
localize: (s: any, lang: string) => any;
|
|
128
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* @param contact a contact
|
|
146
|
+
* @return the id of the patient that the contact refers to, retrieved from the encrypted metadata. Normally there should only be one element
|
|
147
|
+
* in the returned array, but in case of entity merges there could be multiple values.
|
|
148
|
+
*/
|
|
149
|
+
decryptPatientIdOf(contact: models.Contact): Promise<string[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Share an existing contact with other data owners, allowing them to access the non-encrypted data of the contact and optionally also
|
|
152
|
+
* the encrypted content.
|
|
153
|
+
* @param delegateId the id of the data owner which will be granted access to the contact.
|
|
154
|
+
* @param contact the contact to share.
|
|
155
|
+
* @param options optional parameters to customize the sharing behaviour:
|
|
156
|
+
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
157
|
+
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
158
|
+
* contact does not have encrypted content.
|
|
159
|
+
* - sharePatientId: specifies if the id of the patient that this contact refers to should be shared with the delegate (defaults to
|
|
160
|
+
* {@link ShareMetadataBehaviour.IF_AVAILABLE}).
|
|
161
|
+
* @return a promise which will contain the updated contact.
|
|
162
|
+
*/
|
|
163
|
+
shareWith(delegateId: string, contact: models.Contact, options?: {
|
|
164
|
+
shareEncryptionKey?: ShareMetadataBehaviour;
|
|
165
|
+
sharePatientId?: ShareMetadataBehaviour;
|
|
166
|
+
}): Promise<models.Contact>;
|
|
129
167
|
}
|