@icure/api 7.1.34 → 7.1.35
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/IccAuthApi.d.ts +1 -0
- package/icc-api/api/IccAuthApi.js +1 -0
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-x-api/index.d.ts +22 -29
- package/icc-x-api/index.js +60 -38
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
- package/test/icc-api/api/IccDocumentApi.js +200 -0
- package/test/icc-api/api/IccDocumentApi.js.map +1 -0
- package/test/icc-api/api/IccGroupApi.d.ts +1 -0
- package/test/icc-api/api/IccGroupApi.js +50 -0
- package/test/icc-api/api/IccGroupApi.js.map +1 -0
- package/test/icc-api/api/IccRoleApi.d.ts +1 -0
- package/test/icc-api/api/IccRoleApi.js +34 -0
- package/test/icc-api/api/IccRoleApi.js.map +1 -0
- package/test/icc-api/api/IccUserApi.d.ts +1 -0
- package/test/icc-api/api/IccUserApi.js +80 -0
- package/test/icc-api/api/IccUserApi.js.map +1 -0
- package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
- package/test/icc-api/e2e/IccCalendarItemApi.js +45 -0
- package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
- package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
- package/test/icc-api/model/modelHelpersTest.js +45 -0
- package/test/icc-api/model/modelHelpersTest.js.map +1 -0
- package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
- package/test/icc-x-api/auth/group-switch-test.js +81 -0
- package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
- package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.js +222 -0
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
- package/test/icc-x-api/crypto/KeyManager-test.d.ts +1 -0
- package/test/icc-x-api/crypto/KeyManager-test.js +225 -0
- package/test/icc-x-api/crypto/KeyManager-test.js.map +1 -0
- package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
- package/test/icc-x-api/crypto/concurrency.js +35 -0
- package/test/icc-x-api/crypto/concurrency.js.map +1 -0
- package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
- package/test/icc-x-api/crypto/crypto-utils.js +80 -0
- package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
- package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
- package/test/icc-x-api/crypto/cryptoTest.js +275 -0
- package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +132 -0
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
- package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
- package/test/icc-x-api/crypto/full-crypto-test.js +458 -0
- package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
- package/test/icc-x-api/crypto/shamir.d.ts +2 -0
- package/test/icc-x-api/crypto/shamir.js +156 -0
- package/test/icc-x-api/crypto/shamir.js.map +1 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +75 -0
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
- package/test/icc-x-api/data-compatibility-test-7to6.d.ts +1 -0
- package/test/icc-x-api/data-compatibility-test-7to6.js +343 -0
- package/test/icc-x-api/data-compatibility-test-7to6.js.map +1 -0
- package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
- package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
- package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
- package/test/icc-x-api/filters/filters.d.ts +1 -0
- package/test/icc-x-api/filters/filters.js +49 -0
- package/test/icc-x-api/filters/filters.js.map +1 -0
- package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-accesslog-x-api.js +121 -0
- package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
- package/test/icc-x-api/icc-auth-api.d.ts +1 -0
- package/test/icc-x-api/icc-auth-api.js +46 -0
- package/test/icc-x-api/icc-auth-api.js.map +1 -0
- package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-calendar-item-x-api.js +146 -0
- package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
- package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-contact-x-api.js +311 -0
- package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
- package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-form-x-api.js +331 -0
- package/test/icc-x-api/icc-form-x-api.js.map +1 -0
- package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-helement-x-api-test.js +158 -0
- package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-invoice-x-api.js +115 -0
- package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js +230 -0
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-patient-x-api-test.js +169 -0
- package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
- package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
- package/test/icc-x-api/icc-time-table-x-api.js +110 -0
- package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
- package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
- package/test/icc-x-api/icc-user-x-api-test.js +108 -0
- package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
- package/test/icc-x-api/icureapi-group-test.d.ts +1 -0
- package/test/icc-x-api/icureapi-group-test.js +130 -0
- package/test/icc-x-api/icureapi-group-test.js.map +1 -0
- package/test/icc-x-api/patient-user.d.ts +2 -0
- package/test/icc-x-api/patient-user.js +117 -0
- package/test/icc-x-api/patient-user.js.map +1 -0
- package/test/icc-x-api/storage/storage.d.ts +1 -0
- package/test/icc-x-api/storage/storage.js +50 -0
- package/test/icc-x-api/storage/storage.js.map +1 -0
- package/test/icc-x-api/subscription-apis.d.ts +2 -0
- package/test/icc-x-api/subscription-apis.js +498 -0
- package/test/icc-x-api/subscription-apis.js.map +1 -0
- package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
- package/test/icc-x-api/test-api-no-parent.js +79 -0
- package/test/icc-x-api/test-api-no-parent.js.map +1 -0
- package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
- package/test/icc-x-api/test-legacy-data-support.js +231 -0
- package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
- package/test/icc-x-api/utils/crypto-utils-test.d.ts +1 -0
- package/test/icc-x-api/utils/crypto-utils-test.js +586 -0
- package/test/icc-x-api/utils/crypto-utils-test.js.map +1 -0
- package/test/icc-x-api/utils/graph-test.d.ts +1 -0
- package/test/icc-x-api/utils/graph-test.js +54 -0
- package/test/icc-x-api/utils/graph-test.js.map +1 -0
- package/test/support/CSM-185.d.ts +1 -0
- package/test/support/CSM-185.js +120 -0
- package/test/support/CSM-185.js.map +1 -0
- package/test/support/CSM-87.d.ts +0 -0
- package/test/support/CSM-87.js +21 -0
- package/test/support/CSM-87.js.map +1 -0
- package/test/support/CSM-93.d.ts +1 -0
- package/test/support/CSM-93.js +111 -0
- package/test/support/CSM-93.js.map +1 -0
- package/test/utils/TestApi.d.ts +3 -0
- package/test/utils/TestApi.js +27 -0
- package/test/utils/TestApi.js.map +1 -0
- package/test/utils/TestCollectionUtils.d.ts +1 -0
- package/test/utils/TestCollectionUtils.js +109 -0
- package/test/utils/TestCollectionUtils.js.map +1 -0
- package/test/utils/TestCryptoStrategies.d.ts +37 -0
- package/test/utils/TestCryptoStrategies.js +72 -0
- package/test/utils/TestCryptoStrategies.js.map +1 -0
- package/test/utils/TestStorage.d.ts +31 -0
- package/test/utils/TestStorage.js +88 -0
- package/test/utils/TestStorage.js.map +1 -0
- package/test/utils/test_utils.d.ts +60 -0
- package/test/utils/test_utils.js +313 -0
- package/test/utils/test_utils.js.map +1 -0
|
@@ -0,0 +1,331 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
require("isomorphic-fetch");
|
|
13
|
+
const test_utils_1 = require("../utils/test_utils");
|
|
14
|
+
const mocha_1 = require("mocha");
|
|
15
|
+
const icc_x_api_1 = require("../../icc-x-api");
|
|
16
|
+
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
|
|
17
|
+
const icc_api_1 = require("../../icc-api");
|
|
18
|
+
const Patient_1 = require("../../icc-api/model/Patient");
|
|
19
|
+
const crypto_1 = require("crypto");
|
|
20
|
+
const Form_1 = require("../../icc-api/model/Form");
|
|
21
|
+
const chai_1 = require("chai");
|
|
22
|
+
var initApi = test_utils_1.TestUtils.initApi;
|
|
23
|
+
const types_1 = require("@icure/test-setup/types");
|
|
24
|
+
const Code_1 = require("../../icc-api/model/Code");
|
|
25
|
+
const FormTemplate_1 = require("../../icc-api/model/FormTemplate");
|
|
26
|
+
(0, test_utils_1.setLocalStorage)(fetch);
|
|
27
|
+
let env;
|
|
28
|
+
function createPatient(patientApiForHcp, hcpUser) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
|
|
31
|
+
id: (0, crypto_1.randomUUID)(),
|
|
32
|
+
firstName: 'John',
|
|
33
|
+
lastName: 'Snow',
|
|
34
|
+
note: 'Winter is coming',
|
|
35
|
+
})));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createForm(hFormApiForHcp, hcpUser, patient) {
|
|
39
|
+
return hFormApiForHcp.newInstance(hcpUser, patient, new Form_1.Form({
|
|
40
|
+
id: (0, crypto_1.randomUUID)(),
|
|
41
|
+
codes: [new Code_1.Code({ system: 'LOINC', code: '95209', version: '3' })],
|
|
42
|
+
descr: 'SARS-V2',
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
function createFormTemplate() {
|
|
46
|
+
return new FormTemplate_1.FormTemplate({
|
|
47
|
+
id: (0, crypto_1.randomUUID)(),
|
|
48
|
+
codes: [new Code_1.Code({ system: 'LOINC', code: '95209', version: '3' })],
|
|
49
|
+
descr: 'SARS-V2',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
describe('icc-calendar-item-x-api Tests', () => {
|
|
53
|
+
(0, mocha_1.before)(function () {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
this.timeout(600000);
|
|
56
|
+
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
57
|
+
env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
function createPatient(patientApiForHcp, hcpUser) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
|
|
63
|
+
id: (0, crypto_1.randomUUID)(),
|
|
64
|
+
firstName: 'John',
|
|
65
|
+
lastName: 'Snow',
|
|
66
|
+
note: 'Winter is coming',
|
|
67
|
+
})));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
it('Test', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
// Given
|
|
72
|
+
const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
|
|
73
|
+
const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
|
|
74
|
+
const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
|
|
75
|
+
const userApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, authProvider, null, fetch);
|
|
76
|
+
const formApi = new icc_api_1.IccFormApi(env.iCureUrl, {}, authProvider, fetch);
|
|
77
|
+
const currentUser = yield userApi.getCurrentUser();
|
|
78
|
+
}));
|
|
79
|
+
it('Test findBy', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
// Given
|
|
81
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, cryptoApi: cryptoApiForHcp, dataOwnerApi: dateOwnerApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
82
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
83
|
+
const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
|
|
84
|
+
const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
|
|
85
|
+
const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
|
|
86
|
+
const formXApi = new icc_x_api_1.IccFormXApi(env.iCureUrl, {}, cryptoApiForHcp, dateOwnerApiForHcp, authProvider, fetch);
|
|
87
|
+
const patient = (yield createPatient(patientApiForHcp, hcpUser));
|
|
88
|
+
const form = new Form_1.Form({
|
|
89
|
+
id: (0, crypto_1.randomUUID)(),
|
|
90
|
+
created: new Date().getTime(),
|
|
91
|
+
modified: new Date().getTime(),
|
|
92
|
+
responsible: hcpUser.healthcarePartyId,
|
|
93
|
+
author: hcpUser.id,
|
|
94
|
+
codes: [],
|
|
95
|
+
tags: [],
|
|
96
|
+
user: hcpUser.id,
|
|
97
|
+
patient: patient.id,
|
|
98
|
+
});
|
|
99
|
+
const formToCreate = yield formXApi.newInstance(hcpUser, patient, form);
|
|
100
|
+
const createdForm = yield formXApi.createForm(formToCreate);
|
|
101
|
+
const foundItems = (yield formXApi.findBy(hcpUser.healthcarePartyId, patient, false));
|
|
102
|
+
const foundItemsUsingPost = (yield formXApi.findBy(hcpUser.healthcarePartyId, patient, true));
|
|
103
|
+
(0, chai_1.assert)(foundItems.length == 1, 'Found items should be 1');
|
|
104
|
+
(0, chai_1.assert)(foundItems[0].id == createdForm.id, 'Found item should be the created one');
|
|
105
|
+
(0, chai_1.assert)(foundItemsUsingPost.length == 1, 'Found items using post should be 1');
|
|
106
|
+
(0, chai_1.assert)(foundItemsUsingPost[0].id == createdForm.id, 'Found item using post should be the created one');
|
|
107
|
+
}));
|
|
108
|
+
it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
+
const api1 = yield initApi(env, test_utils_1.hcp1Username);
|
|
110
|
+
const user1 = yield api1.userApi.getCurrentUser();
|
|
111
|
+
const api2 = yield initApi(env, test_utils_1.hcp2Username);
|
|
112
|
+
const user2 = yield api2.userApi.getCurrentUser();
|
|
113
|
+
const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
|
|
114
|
+
const entity = yield api1.formApi.createForm(yield api1.formApi.newInstance(user1, samplePatient));
|
|
115
|
+
yield api2.formApi
|
|
116
|
+
.getForm(entity.id)
|
|
117
|
+
.then(() => {
|
|
118
|
+
throw new Error('Should not be able to get the entity');
|
|
119
|
+
})
|
|
120
|
+
.catch(() => {
|
|
121
|
+
/* expected */
|
|
122
|
+
});
|
|
123
|
+
yield api1.formApi.shareWith(user2.healthcarePartyId, entity);
|
|
124
|
+
const retrieved = yield api2.formApi.getForm(entity.id);
|
|
125
|
+
(0, chai_1.expect)((yield api2.formApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
|
|
126
|
+
}));
|
|
127
|
+
it('CreateForm Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
// Given
|
|
129
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, formApi: hFormApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
130
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
131
|
+
const patient = yield createPatient(patientApiForHcp, hcpUser);
|
|
132
|
+
const formToCreate = yield createForm(hFormApiForHcp, hcpUser, patient);
|
|
133
|
+
// When
|
|
134
|
+
const createdForm = yield hFormApiForHcp.createForm(formToCreate);
|
|
135
|
+
// Then
|
|
136
|
+
const readForm = yield hFormApiForHcp.getForm(createdForm.id);
|
|
137
|
+
(0, chai_1.assert)(readForm != null);
|
|
138
|
+
(0, chai_1.assert)(readForm.id != null);
|
|
139
|
+
(0, chai_1.assert)(readForm.descr == formToCreate.descr);
|
|
140
|
+
(0, chai_1.assert)(readForm.delegations[hcpUser.healthcarePartyId].length > 0);
|
|
141
|
+
(0, chai_1.assert)(readForm.encryptionKeys[hcpUser.healthcarePartyId].length > 0);
|
|
142
|
+
(0, chai_1.assert)(readForm.cryptedForeignKeys[hcpUser.healthcarePartyId].length > 0);
|
|
143
|
+
}));
|
|
144
|
+
it('CreateFormTemplate Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
// Given
|
|
146
|
+
const { formApi: hFormApiForHcp } = yield initApi(env, test_utils_1.hcp1Username);
|
|
147
|
+
// When
|
|
148
|
+
const createdFormTemplate = yield hFormApiForHcp.createFormTemplate(createFormTemplate());
|
|
149
|
+
const YamlFile = 'form: Entretien préliminaire Psycho Social\n' +
|
|
150
|
+
'description: Entretien préliminaire Psycho Social\n' +
|
|
151
|
+
'sections:\n' +
|
|
152
|
+
' - section:\n' +
|
|
153
|
+
' fields:\n' +
|
|
154
|
+
' - field: Type de consultation\n' +
|
|
155
|
+
' type: dropdown\n' +
|
|
156
|
+
' labels:\n' +
|
|
157
|
+
' above : Type de consultation\n' +
|
|
158
|
+
' shortLabel: contactType\n' +
|
|
159
|
+
' options:\n' +
|
|
160
|
+
' home: Sur place\n' +
|
|
161
|
+
' visio: Visioconférence\n' +
|
|
162
|
+
' call: Téléphone\n' +
|
|
163
|
+
' rows: 1\n' +
|
|
164
|
+
' columns: 1\n' +
|
|
165
|
+
' required: true\n' +
|
|
166
|
+
' codifications :\n' +
|
|
167
|
+
' - MS-IVG-CONTACT-TYPE\n' +
|
|
168
|
+
' tags:\n' +
|
|
169
|
+
' - MS-IVG|CONTACT-TYPE|1\n' +
|
|
170
|
+
' - field : waitingRoomFollowersNumber\n' +
|
|
171
|
+
' type: number-field\n' +
|
|
172
|
+
' shortLabel: waitingRoomFollowersNumber\n' +
|
|
173
|
+
' value: 0\n' +
|
|
174
|
+
' labels:\n' +
|
|
175
|
+
' above: Accompagné de\n' +
|
|
176
|
+
" right: personne(s) (salle d'attente)\n" +
|
|
177
|
+
' rows: 2\n' +
|
|
178
|
+
' columns: 1\n' +
|
|
179
|
+
' required: true\n' +
|
|
180
|
+
' tags :\n' +
|
|
181
|
+
' - CD-CUSTOM-IVG|WAITING-ROOM-FOLLOWERS-NUMBER|1\n' +
|
|
182
|
+
' - field : consultationFollowersNumber\n' +
|
|
183
|
+
' type: number-field\n' +
|
|
184
|
+
' shortLabel: consultationFollowersNumber\n' +
|
|
185
|
+
' value: 0\n' +
|
|
186
|
+
' labels:\n' +
|
|
187
|
+
' above: Accompagné de\n' +
|
|
188
|
+
' right: personne(s) (entretien préliminaire)\n' +
|
|
189
|
+
' rows: 2\n' +
|
|
190
|
+
' columns: 1\n' +
|
|
191
|
+
' required: true\n' +
|
|
192
|
+
' tags :\n' +
|
|
193
|
+
' - CD-CUSTOM-IVG|CONSULTATION-FOLLOWERS-NUMBER|1\n' +
|
|
194
|
+
' - field : Personnes Accompagnants\n' +
|
|
195
|
+
' type: checkbox\n' +
|
|
196
|
+
' shortLabel: PersonFollowerType\n' +
|
|
197
|
+
' options:\n' +
|
|
198
|
+
' option1: Partenaire\n' +
|
|
199
|
+
' option2: Mère\n' +
|
|
200
|
+
' option3: Amie\n' +
|
|
201
|
+
' option4: Éducateur\n' +
|
|
202
|
+
' option5: Père\n' +
|
|
203
|
+
' rows: 3\n' +
|
|
204
|
+
' columns: 1\n' +
|
|
205
|
+
' required: false\n' +
|
|
206
|
+
' tags:\n' +
|
|
207
|
+
' - CD-CUSTOM-IVG|PERSON-FOLLOWER-TYPE|1\n' +
|
|
208
|
+
' - field : Profession de la patiente\n' +
|
|
209
|
+
' type: radio-button\n' +
|
|
210
|
+
' shortLabel: PatientProfession\n' +
|
|
211
|
+
' options:\n' +
|
|
212
|
+
' option1: Employé\n' +
|
|
213
|
+
' option2: Ouvrier\n' +
|
|
214
|
+
' option3: Indépendant\n' +
|
|
215
|
+
' option4: Sans travail\n' +
|
|
216
|
+
' option5: Ne veut pas dire\n' +
|
|
217
|
+
' rows: 4\n' +
|
|
218
|
+
' columns: 1\n' +
|
|
219
|
+
' required: false\n' +
|
|
220
|
+
' tags:\n' +
|
|
221
|
+
' - CD-CUSTOM-IVG|PATIENT-PROFESSION|1\n' +
|
|
222
|
+
' - field : Nombre d’enfants\n' +
|
|
223
|
+
' type: number-field\n' +
|
|
224
|
+
' shortLabel: ChildNumber\n' +
|
|
225
|
+
' value: 0\n' +
|
|
226
|
+
' rows: 5\n' +
|
|
227
|
+
' columns: 1\n' +
|
|
228
|
+
' required: true\n' +
|
|
229
|
+
' tags:\n' +
|
|
230
|
+
' - CD-CUSTOM-IVG|CHILD-NUMBER|1\n' +
|
|
231
|
+
' - field : Nombre d’enfants à charge\n' +
|
|
232
|
+
' type: number-field\n' +
|
|
233
|
+
' shortLabel: ChildInChargeNumber\n' +
|
|
234
|
+
' value: 0\n' +
|
|
235
|
+
' rows: 5\n' +
|
|
236
|
+
' columns: 1\n' +
|
|
237
|
+
' required: true\n' +
|
|
238
|
+
' tags:\n' +
|
|
239
|
+
' - CD-CUSTOM-IVG|CHILD-IN-CHARGE-NUMBER|1\n' +
|
|
240
|
+
' - field : Nombre de minutes de suivi\n' +
|
|
241
|
+
' type: measure-field\n' +
|
|
242
|
+
' shortLabel: minutesTrackingNumber\n' +
|
|
243
|
+
' rows: 6\n' +
|
|
244
|
+
' columns: 1\n' +
|
|
245
|
+
' value: 50\n' +
|
|
246
|
+
' unit: min\n' +
|
|
247
|
+
' required: true\n' +
|
|
248
|
+
' tags:\n' +
|
|
249
|
+
' - CD-CUSTOM-IVG|MINUTES-TRACKING-NUMBER|1\n' +
|
|
250
|
+
' - field : Nombre de minutes de contraception\n' +
|
|
251
|
+
' type: measure-field\n' +
|
|
252
|
+
' shortLabel: minutesContraceptionNumber\n' +
|
|
253
|
+
' rows: 6\n' +
|
|
254
|
+
' columns: 1\n' +
|
|
255
|
+
' required: true\n' +
|
|
256
|
+
' value: 10\n' +
|
|
257
|
+
' unit: min\n' +
|
|
258
|
+
' tags:\n' +
|
|
259
|
+
' - CD-CUSTOM-IVG|MINUTES-CONTRACEPTION-NUMBER|1\n' +
|
|
260
|
+
' - field : Historique/Situation\n' +
|
|
261
|
+
' type: textfield\n' +
|
|
262
|
+
' shortLabel: History\n' +
|
|
263
|
+
' rows: 7\n' +
|
|
264
|
+
' columns: 1\n' +
|
|
265
|
+
' required: false\n' +
|
|
266
|
+
' tags:\n' +
|
|
267
|
+
' - CD-CUSTOM-IVG|HISTORY|1\n' +
|
|
268
|
+
' - field : Position du partenaire pendant la grossesse\n' +
|
|
269
|
+
' type: textfield\n' +
|
|
270
|
+
' shortLabel: SexualPosition\n' +
|
|
271
|
+
' rows: 8\n' +
|
|
272
|
+
' columns: 1\n' +
|
|
273
|
+
' required: false\n' +
|
|
274
|
+
' tags:\n' +
|
|
275
|
+
' - CD-CUSTOM-IVG|SEXUAL-POSITION|1\n' +
|
|
276
|
+
" - field : Processus de prise de décision / choix / attitude par rapport à l'avortement (le cas échéant)\n" +
|
|
277
|
+
' type: textfield\n' +
|
|
278
|
+
' shortLabel: decisionProcessus\n' +
|
|
279
|
+
' rows: 9\n' +
|
|
280
|
+
' columns: 1\n' +
|
|
281
|
+
' required: false\n' +
|
|
282
|
+
' tags :\n' +
|
|
283
|
+
' - CD-CUSTOM-IVG|DECISION-PROCESSUS|1\n' +
|
|
284
|
+
' - field : Première décision de la patiente\n' +
|
|
285
|
+
' type: radio-button\n' +
|
|
286
|
+
' shortLabel: firstChoice\n' +
|
|
287
|
+
' rows: 9\n' +
|
|
288
|
+
' columns: 1\n' +
|
|
289
|
+
' required: true\n' +
|
|
290
|
+
' options:\n' +
|
|
291
|
+
' option1: Oui par curretage\n' +
|
|
292
|
+
' option2: Ne sait pas\n' +
|
|
293
|
+
' option3: Oui par médication\n' +
|
|
294
|
+
' option4: Non\n' +
|
|
295
|
+
' tags:\n' +
|
|
296
|
+
' - CD-CUSTOM-IVG|FIRST-CHOICE|1\n' +
|
|
297
|
+
' - field : Notes\n' +
|
|
298
|
+
' type: textfield\n' +
|
|
299
|
+
' shortLabel: notes\n' +
|
|
300
|
+
' rows: 10\n' +
|
|
301
|
+
' columns: 1\n' +
|
|
302
|
+
' required: false\n' +
|
|
303
|
+
' multiline: true\n' +
|
|
304
|
+
' tags:\n' +
|
|
305
|
+
' - CD-CUSTOM-IVG|NOTES|1';
|
|
306
|
+
const ua = (0, icc_x_api_1.utf8_2ua)(YamlFile);
|
|
307
|
+
const ab = (0, icc_x_api_1.ua2ab)(ua);
|
|
308
|
+
const hex = (0, icc_x_api_1.ua2hex)(ua);
|
|
309
|
+
// Note: requires node 18+
|
|
310
|
+
yield hFormApiForHcp.setTemplateAttachmentMulti(ab, createdFormTemplate.id);
|
|
311
|
+
// Then
|
|
312
|
+
const readFormTemplate = yield hFormApiForHcp.getFormTemplate(createdFormTemplate.id);
|
|
313
|
+
(0, chai_1.expect)(readFormTemplate).to.not.be.undefined;
|
|
314
|
+
(0, chai_1.expect)(readFormTemplate.id).to.not.be.undefined;
|
|
315
|
+
(0, chai_1.expect)(readFormTemplate.descr).to.equal(createdFormTemplate.descr);
|
|
316
|
+
(0, chai_1.expect)(readFormTemplate.templateLayout).to.not.be.undefined;
|
|
317
|
+
}));
|
|
318
|
+
it('newInstance should honor non-default values unless they are undefined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
319
|
+
const api = yield initApi(env, test_utils_1.hcp1Username);
|
|
320
|
+
const user = yield api.userApi.getCurrentUser();
|
|
321
|
+
const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' }));
|
|
322
|
+
const formUndefinedId = yield api.formApi.newInstance(user, patient, { id: undefined });
|
|
323
|
+
const customId = 'customId';
|
|
324
|
+
const formCustomId = yield api.formApi.newInstance(user, patient, { id: customId });
|
|
325
|
+
const formWithUndefinedInit = yield api.formApi.newInstance(user, patient, undefined);
|
|
326
|
+
(0, chai_1.expect)(formUndefinedId.id).to.not.be.undefined;
|
|
327
|
+
(0, chai_1.expect)(formWithUndefinedInit.id).to.not.be.undefined;
|
|
328
|
+
(0, chai_1.expect)(formCustomId.id).to.equal(customId);
|
|
329
|
+
}));
|
|
330
|
+
});
|
|
331
|
+
//# sourceMappingURL=icc-form-x-api.js.map
|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AM,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;QACvF,MAAM,QAAQ,GAAG,UAAU,CAAA;QAC3B,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QACnF,MAAM,qBAAqB,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;QACrF,IAAA,aAAM,EAAC,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAA;QAC9C,IAAA,aAAM,EAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAA;QACpD,IAAA,aAAM,EAAC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC5C,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { getEnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { IccFormXApi, IccPatientXApi, IccUserXApi, IcureApi, ua2ab, ua2hex, utf8_2ua } from '../../icc-x-api'\nimport { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IccFormApi } from '../../icc-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { Form } from '../../icc-api/model/Form'\nimport { assert, expect } from 'chai'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { crypto } from '../../node-compat'\nimport { Code } from '../../icc-api/model/Code'\nimport { FormTemplate } from '../../icc-api/model/FormTemplate'\nimport { read } from 'fs'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nasync function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n}\n\nfunction createForm(hFormApiForHcp: IccFormXApi, hcpUser: User, patient: Patient) {\n return hFormApiForHcp.newInstance(\n hcpUser,\n patient,\n new Form({\n id: randomUUID(),\n codes: [new Code({ system: 'LOINC', code: '95209', version: '3' })],\n descr: 'SARS-V2',\n })\n )\n}\n\nfunction createFormTemplate() {\n return new FormTemplate({\n id: randomUUID(),\n codes: [new Code({ system: 'LOINC', code: '95209', version: '3' })],\n descr: 'SARS-V2',\n })\n}\n\ndescribe('icc-calendar-item-x-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n }\n\n it('Test', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const userApi = new IccUserXApi(env.iCureUrl, {}, authProvider, null as any, fetch)\n const formApi = new IccFormApi(env.iCureUrl, {}, authProvider, fetch)\n\n const currentUser = await userApi.getCurrentUser()\n })\n\n it('Test findBy', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n cryptoApi: cryptoApiForHcp,\n dataOwnerApi: dateOwnerApiForHcp,\n } = await initApi(env!, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n const formXApi = new IccFormXApi(env.iCureUrl, {}, cryptoApiForHcp, dateOwnerApiForHcp, authProvider, fetch)\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n\n const form = new Form({\n id: randomUUID(),\n created: new Date().getTime(),\n modified: new Date().getTime(),\n responsible: hcpUser.healthcarePartyId!,\n author: hcpUser.id,\n codes: [],\n tags: [],\n user: hcpUser.id,\n patient: patient.id,\n })\n const formToCreate = await formXApi.newInstance(hcpUser, patient, form)\n const createdForm = await formXApi.createForm(formToCreate)\n\n const foundItems: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, false)) as Form[]\n const foundItemsUsingPost: Form[] = (await formXApi.findBy(hcpUser.healthcarePartyId!, patient, true)) as Form[]\n\n assert(foundItems.length == 1, 'Found items should be 1')\n assert(foundItems[0].id == createdForm.id, 'Found item should be the created one')\n\n assert(foundItemsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundItemsUsingPost[0].id == createdForm.id, 'Found item using post should be the created one')\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const entity = await api1.formApi.createForm(await api1.formApi.newInstance(user1, samplePatient))\n await api2.formApi\n .getForm(entity.id!)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.formApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.formApi.getForm(entity.id!)\n expect((await api2.formApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('CreateForm Success for HCP', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n formApi: hFormApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = await createPatient(patientApiForHcp, hcpUser)\n const formToCreate = await createForm(hFormApiForHcp, hcpUser, patient)\n\n // When\n const createdForm = await hFormApiForHcp.createForm(formToCreate)\n\n // Then\n const readForm = await hFormApiForHcp.getForm(createdForm.id!)\n assert(readForm != null)\n assert(readForm.id != null)\n assert(readForm.descr == formToCreate.descr)\n assert(readForm.delegations![hcpUser.healthcarePartyId!].length > 0)\n assert(readForm.encryptionKeys![hcpUser.healthcarePartyId!].length > 0)\n assert(readForm.cryptedForeignKeys![hcpUser.healthcarePartyId!].length > 0)\n })\n\n it('CreateFormTemplate Success for HCP', async () => {\n // Given\n const { formApi: hFormApiForHcp } = await initApi(env!, hcp1Username)\n\n // When\n const createdFormTemplate = await hFormApiForHcp.createFormTemplate(createFormTemplate())\n\n const YamlFile: string =\n 'form: Entretien préliminaire Psycho Social\\n' +\n 'description: Entretien préliminaire Psycho Social\\n' +\n 'sections:\\n' +\n ' - section:\\n' +\n ' fields:\\n' +\n ' - field: Type de consultation\\n' +\n ' type: dropdown\\n' +\n ' labels:\\n' +\n ' above : Type de consultation\\n' +\n ' shortLabel: contactType\\n' +\n ' options:\\n' +\n ' home: Sur place\\n' +\n ' visio: Visioconférence\\n' +\n ' call: Téléphone\\n' +\n ' rows: 1\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' codifications :\\n' +\n ' - MS-IVG-CONTACT-TYPE\\n' +\n ' tags:\\n' +\n ' - MS-IVG|CONTACT-TYPE|1\\n' +\n ' - field : waitingRoomFollowersNumber\\n' +\n ' type: number-field\\n' +\n ' shortLabel: waitingRoomFollowersNumber\\n' +\n ' value: 0\\n' +\n ' labels:\\n' +\n ' above: Accompagné de\\n' +\n \" right: personne(s) (salle d'attente)\\n\" +\n ' rows: 2\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' tags :\\n' +\n ' - CD-CUSTOM-IVG|WAITING-ROOM-FOLLOWERS-NUMBER|1\\n' +\n ' - field : consultationFollowersNumber\\n' +\n ' type: number-field\\n' +\n ' shortLabel: consultationFollowersNumber\\n' +\n ' value: 0\\n' +\n ' labels:\\n' +\n ' above: Accompagné de\\n' +\n ' right: personne(s) (entretien préliminaire)\\n' +\n ' rows: 2\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' tags :\\n' +\n ' - CD-CUSTOM-IVG|CONSULTATION-FOLLOWERS-NUMBER|1\\n' +\n ' - field : Personnes Accompagnants\\n' +\n ' type: checkbox\\n' +\n ' shortLabel: PersonFollowerType\\n' +\n ' options:\\n' +\n ' option1: Partenaire\\n' +\n ' option2: Mère\\n' +\n ' option3: Amie\\n' +\n ' option4: Éducateur\\n' +\n ' option5: Père\\n' +\n ' rows: 3\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|PERSON-FOLLOWER-TYPE|1\\n' +\n ' - field : Profession de la patiente\\n' +\n ' type: radio-button\\n' +\n ' shortLabel: PatientProfession\\n' +\n ' options:\\n' +\n ' option1: Employé\\n' +\n ' option2: Ouvrier\\n' +\n ' option3: Indépendant\\n' +\n ' option4: Sans travail\\n' +\n ' option5: Ne veut pas dire\\n' +\n ' rows: 4\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|PATIENT-PROFESSION|1\\n' +\n ' - field : Nombre d’enfants\\n' +\n ' type: number-field\\n' +\n ' shortLabel: ChildNumber\\n' +\n ' value: 0\\n' +\n ' rows: 5\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|CHILD-NUMBER|1\\n' +\n ' - field : Nombre d’enfants à charge\\n' +\n ' type: number-field\\n' +\n ' shortLabel: ChildInChargeNumber\\n' +\n ' value: 0\\n' +\n ' rows: 5\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|CHILD-IN-CHARGE-NUMBER|1\\n' +\n ' - field : Nombre de minutes de suivi\\n' +\n ' type: measure-field\\n' +\n ' shortLabel: minutesTrackingNumber\\n' +\n ' rows: 6\\n' +\n ' columns: 1\\n' +\n ' value: 50\\n' +\n ' unit: min\\n' +\n ' required: true\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|MINUTES-TRACKING-NUMBER|1\\n' +\n ' - field : Nombre de minutes de contraception\\n' +\n ' type: measure-field\\n' +\n ' shortLabel: minutesContraceptionNumber\\n' +\n ' rows: 6\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' value: 10\\n' +\n ' unit: min\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|MINUTES-CONTRACEPTION-NUMBER|1\\n' +\n ' - field : Historique/Situation\\n' +\n ' type: textfield\\n' +\n ' shortLabel: History\\n' +\n ' rows: 7\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|HISTORY|1\\n' +\n ' - field : Position du partenaire pendant la grossesse\\n' +\n ' type: textfield\\n' +\n ' shortLabel: SexualPosition\\n' +\n ' rows: 8\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|SEXUAL-POSITION|1\\n' +\n \" - field : Processus de prise de décision / choix / attitude par rapport à l'avortement (le cas échéant)\\n\" +\n ' type: textfield\\n' +\n ' shortLabel: decisionProcessus\\n' +\n ' rows: 9\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' tags :\\n' +\n ' - CD-CUSTOM-IVG|DECISION-PROCESSUS|1\\n' +\n ' - field : Première décision de la patiente\\n' +\n ' type: radio-button\\n' +\n ' shortLabel: firstChoice\\n' +\n ' rows: 9\\n' +\n ' columns: 1\\n' +\n ' required: true\\n' +\n ' options:\\n' +\n ' option1: Oui par curretage\\n' +\n ' option2: Ne sait pas\\n' +\n ' option3: Oui par médication\\n' +\n ' option4: Non\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|FIRST-CHOICE|1\\n' +\n ' - field : Notes\\n' +\n ' type: textfield\\n' +\n ' shortLabel: notes\\n' +\n ' rows: 10\\n' +\n ' columns: 1\\n' +\n ' required: false\\n' +\n ' multiline: true\\n' +\n ' tags:\\n' +\n ' - CD-CUSTOM-IVG|NOTES|1'\n const ua = utf8_2ua(YamlFile)\n const ab = ua2ab(ua)\n const hex = ua2hex(ua)\n // Note: requires node 18+\n await hFormApiForHcp.setTemplateAttachmentMulti(ab, createdFormTemplate.id!)\n // Then\n const readFormTemplate = await hFormApiForHcp.getFormTemplate(createdFormTemplate.id!)\n expect(readFormTemplate).to.not.be.undefined\n expect(readFormTemplate.id).to.not.be.undefined\n expect(readFormTemplate.descr).to.equal(createdFormTemplate.descr)\n expect(readFormTemplate.templateLayout).to.not.be.undefined\n })\n\n it('newInstance should honor non-default values unless they are undefined', async () => {\n const api = await initApi(env!, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const formUndefinedId = await api.formApi.newInstance(user, patient, { id: undefined })\n const customId = 'customId'\n const formCustomId = await api.formApi.newInstance(user, patient, { id: customId })\n const formWithUndefinedInit = await api.formApi.newInstance(user, patient, undefined)\n expect(formUndefinedId.id).to.not.be.undefined\n expect(formWithUndefinedInit.id).to.not.be.undefined\n expect(formCustomId.id).to.equal(customId)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'isomorphic-fetch';
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const mocha_1 = require("mocha");
|
|
13
|
+
require("isomorphic-fetch");
|
|
14
|
+
const Patient_1 = require("../../icc-api/model/Patient");
|
|
15
|
+
const chai_1 = require("chai");
|
|
16
|
+
const crypto_1 = require("crypto");
|
|
17
|
+
const test_utils_1 = require("../utils/test_utils");
|
|
18
|
+
const HealthElement_1 = require("../../icc-api/model/HealthElement");
|
|
19
|
+
const Code_1 = require("../../icc-api/model/Code");
|
|
20
|
+
const FilterChainHealthElement_1 = require("../../icc-api/model/FilterChainHealthElement");
|
|
21
|
+
const HealthElementByIdsFilter_1 = require("../../icc-x-api/filters/HealthElementByIdsFilter");
|
|
22
|
+
var initApi = test_utils_1.TestUtils.initApi;
|
|
23
|
+
const types_1 = require("@icure/test-setup/types");
|
|
24
|
+
(0, test_utils_1.setLocalStorage)(fetch);
|
|
25
|
+
let env;
|
|
26
|
+
function createPatient(patientApiForHcp, hcpUser) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
|
|
29
|
+
id: (0, crypto_1.randomUUID)(),
|
|
30
|
+
firstName: 'John',
|
|
31
|
+
lastName: 'Snow',
|
|
32
|
+
note: 'Winter is coming',
|
|
33
|
+
})));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function healthElementToCreate(hElementApiForHcp, hcpUser, patient) {
|
|
37
|
+
return hElementApiForHcp.newInstance(hcpUser, patient, new HealthElement_1.HealthElement({
|
|
38
|
+
id: (0, crypto_1.randomUUID)(),
|
|
39
|
+
codes: [new Code_1.Code({ system: 'LOINC', code: '95209', version: '3' })],
|
|
40
|
+
note: 'SARS-V2',
|
|
41
|
+
}), { confidential: true });
|
|
42
|
+
}
|
|
43
|
+
describe('icc-helement-x-api Tests', () => {
|
|
44
|
+
(0, mocha_1.before)(function () {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
this.timeout(600000);
|
|
47
|
+
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
48
|
+
env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it('CreateHealthElementWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
// Given
|
|
53
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
54
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
55
|
+
const patient = yield createPatient(patientApiForHcp, hcpUser);
|
|
56
|
+
const hElementToCreate = yield healthElementToCreate(hElementApiForHcp, hcpUser, patient);
|
|
57
|
+
// When
|
|
58
|
+
const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, hElementToCreate);
|
|
59
|
+
// Then
|
|
60
|
+
const readHealthElement = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
|
|
61
|
+
(0, chai_1.assert)(readHealthElement != null);
|
|
62
|
+
(0, chai_1.assert)(readHealthElement.id != null);
|
|
63
|
+
(0, chai_1.assert)(readHealthElement.note == hElementToCreate.note);
|
|
64
|
+
(0, chai_1.assert)(readHealthElement.delegations[hcpUser.healthcarePartyId].length > 0);
|
|
65
|
+
(0, chai_1.assert)(readHealthElement.encryptionKeys[hcpUser.healthcarePartyId].length > 0);
|
|
66
|
+
(0, chai_1.assert)(readHealthElement.cryptedForeignKeys[hcpUser.healthcarePartyId].length > 0);
|
|
67
|
+
}));
|
|
68
|
+
it('ModifyHealthElementWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
// Given
|
|
70
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
71
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
72
|
+
yield initApi(env, test_utils_1.hcp1Username);
|
|
73
|
+
const patient = yield createPatient(patientApiForHcp, hcpUser);
|
|
74
|
+
const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
|
|
75
|
+
// When
|
|
76
|
+
const modifiedHealthElement = yield hElementApiForHcp.modifyHealthElementWithUser(hcpUser, Object.assign(Object.assign({}, createdHealthElement), { note: 'SARS-V2 (COVID-19)' }));
|
|
77
|
+
// Then
|
|
78
|
+
const readHealthElement = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
|
|
79
|
+
(0, chai_1.assert)(readHealthElement != null);
|
|
80
|
+
(0, chai_1.assert)(readHealthElement.id != null);
|
|
81
|
+
(0, chai_1.assert)(readHealthElement.note != createdHealthElement.note);
|
|
82
|
+
(0, chai_1.assert)(readHealthElement.note == modifiedHealthElement.note);
|
|
83
|
+
(0, chai_1.assert)(readHealthElement.delegations[hcpUser.healthcarePartyId].length > 0);
|
|
84
|
+
(0, chai_1.assert)(readHealthElement.encryptionKeys[hcpUser.healthcarePartyId].length > 0);
|
|
85
|
+
(0, chai_1.assert)(readHealthElement.cryptedForeignKeys[hcpUser.healthcarePartyId].length > 0);
|
|
86
|
+
}));
|
|
87
|
+
it('findHealthElementsByHCPartyAndPatientWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
// Given
|
|
89
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
90
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
91
|
+
const patient = (yield createPatient(patientApiForHcp, hcpUser));
|
|
92
|
+
const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
|
|
93
|
+
// When
|
|
94
|
+
const foundHealthElements = yield hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(hcpUser, hcpUser.healthcarePartyId, patient);
|
|
95
|
+
const foundHealthElementsUsingPost = yield hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(hcpUser, hcpUser.healthcarePartyId, patient, true);
|
|
96
|
+
// Then
|
|
97
|
+
(0, chai_1.assert)(foundHealthElements.length == 1, 'Found health elements should be 1');
|
|
98
|
+
(0, chai_1.assert)(foundHealthElements[0].id == createdHealthElement.id, 'Found health element should be the same as the created one');
|
|
99
|
+
(0, chai_1.assert)(foundHealthElementsUsingPost.length == 1, 'Found health elements using POST should be 1');
|
|
100
|
+
(0, chai_1.assert)(foundHealthElementsUsingPost[0].id == createdHealthElement.id, 'Found health element using POST should be the same as the created one');
|
|
101
|
+
}));
|
|
102
|
+
it('filter healthcare element result should return same output by id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
var _a;
|
|
104
|
+
// Given
|
|
105
|
+
const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
|
|
106
|
+
const hcpUser = yield userApiForHcp.getCurrentUser();
|
|
107
|
+
const patient = (yield createPatient(patientApiForHcp, hcpUser));
|
|
108
|
+
const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
|
|
109
|
+
// When
|
|
110
|
+
const healthElementById = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
|
|
111
|
+
const healthElementByFilter = yield hElementApiForHcp.filterByWithUser(hcpUser, undefined, undefined, new FilterChainHealthElement_1.FilterChainHealthElement({
|
|
112
|
+
filter: new HealthElementByIdsFilter_1.HealthElementByIdsFilter({
|
|
113
|
+
ids: [createdHealthElement.id],
|
|
114
|
+
healthcarePartyId: hcpUser.healthcarePartyId,
|
|
115
|
+
}),
|
|
116
|
+
}));
|
|
117
|
+
// Then
|
|
118
|
+
(0, chai_1.assert)(((_a = healthElementByFilter.rows) === null || _a === void 0 ? void 0 : _a.length) == 1, 'Found health elements should be 1');
|
|
119
|
+
(0, chai_1.assert)(healthElementByFilter.rows[0].id == createdHealthElement.id, 'Found health element should be the same as the created one');
|
|
120
|
+
(0, chai_1.assert)(!!healthElementById.note, 'Health element should have a note');
|
|
121
|
+
(0, chai_1.assert)(JSON.stringify(healthElementByFilter.rows[0]) === JSON.stringify(healthElementById), 'Found health elements by id should match the one found by filter');
|
|
122
|
+
}));
|
|
123
|
+
it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
const api1 = yield initApi(env, test_utils_1.hcp1Username);
|
|
125
|
+
const user1 = yield api1.userApi.getCurrentUser();
|
|
126
|
+
const api2 = yield initApi(env, test_utils_1.hcp2Username);
|
|
127
|
+
const user2 = yield api2.userApi.getCurrentUser();
|
|
128
|
+
const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
|
|
129
|
+
const encryptedField = 'Something encrypted';
|
|
130
|
+
const entity = yield api1.healthcareElementApi.createHealthElementWithUser(user1, yield api1.healthcareElementApi.newInstance(user1, samplePatient, { note: encryptedField }));
|
|
131
|
+
(0, chai_1.expect)(entity.note).to.be.equal(encryptedField);
|
|
132
|
+
yield api2.healthcareElementApi
|
|
133
|
+
.getHealthElementWithUser(user2, entity.id)
|
|
134
|
+
.then(() => {
|
|
135
|
+
throw new Error('Should not be able to get the entity');
|
|
136
|
+
})
|
|
137
|
+
.catch(() => {
|
|
138
|
+
/* expected */
|
|
139
|
+
});
|
|
140
|
+
yield api1.healthcareElementApi.shareWith(user2.healthcarePartyId, entity);
|
|
141
|
+
const retrieved = yield api2.healthcareElementApi.getHealthElementWithUser(user2, entity.id);
|
|
142
|
+
(0, chai_1.expect)(retrieved.note).to.be.equal(encryptedField);
|
|
143
|
+
(0, chai_1.expect)((yield api2.healthcareElementApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
|
|
144
|
+
}));
|
|
145
|
+
it('newInstance should honor non-default values unless they are undefined', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
const api = yield initApi(env, test_utils_1.hcp1Username);
|
|
147
|
+
const user = yield api.userApi.getCurrentUser();
|
|
148
|
+
const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' }));
|
|
149
|
+
const helementUndefinedId = yield api.healthcareElementApi.newInstance(user, patient, { id: undefined });
|
|
150
|
+
const customId = 'customId';
|
|
151
|
+
const helementCustomId = yield api.healthcareElementApi.newInstance(user, patient, { id: customId });
|
|
152
|
+
const helementWithUndefinedInit = yield api.healthcareElementApi.newInstance(user, patient, undefined);
|
|
153
|
+
(0, chai_1.expect)(helementUndefinedId.id).to.not.be.undefined;
|
|
154
|
+
(0, chai_1.expect)(helementWithUndefinedInit.id).to.not.be.undefined;
|
|
155
|
+
(0, chai_1.expect)(helementCustomId.id).to.equal(customId);
|
|
156
|
+
}));
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=icc-helement-x-api-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icc-helement-x-api-test.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-helement-x-api-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAE9B,4BAAyB;AAGzB,yDAAqD;AACrD,+BAAqC;AACrC,mCAAmC;AACnC,oDAAuH;AACvH,qEAAiE;AACjE,mDAA+C;AAE/C,2FAAuF;AACvF,+FAA2F;AAC3F,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AAEnE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAyB,CAAA;AAE7B,SAAe,aAAa,CAAC,gBAAgC,EAAE,OAAa;;QAC1E,OAAO,gBAAgB,CAAC,qBAAqB,CAC3C,OAAO,EACP,MAAM,gBAAgB,CAAC,WAAW,CAChC,OAAO,EACP,IAAI,iBAAO,CAAC;YACV,EAAE,EAAE,IAAA,mBAAU,GAAE;YAChB,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,kBAAkB;SACzB,CAAC,CACH,CACF,CAAA;IACH,CAAC;CAAA;AAED,SAAS,qBAAqB,CAAC,iBAAkC,EAAE,OAAa,EAAE,OAAgB;IAChG,OAAO,iBAAiB,CAAC,WAAW,CAClC,OAAO,EACP,OAAO,EACP,IAAI,6BAAa,CAAC;QAChB,EAAE,EAAE,IAAA,mBAAU,GAAE;QAChB,KAAK,EAAE,CAAC,IAAI,WAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QACnE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CAAA;QACxD,IAAA,aAAM,EAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAChD,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { before } from 'mocha'\n\nimport 'isomorphic-fetch'\n\nimport { IccHelementXApi, IccPatientXApi } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { assert, expect } from 'chai'\nimport { randomUUID } from 'crypto'\nimport { getEnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { Code } from '../../icc-api/model/Code'\nimport { User } from '../../icc-api/model/User'\nimport { FilterChainHealthElement } from '../../icc-api/model/FilterChainHealthElement'\nimport { HealthElementByIdsFilter } from '../../icc-x-api/filters/HealthElementByIdsFilter'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars | undefined\n\nasync function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n}\n\nfunction healthElementToCreate(hElementApiForHcp: IccHelementXApi, hcpUser: User, patient: Patient) {\n return hElementApiForHcp.newInstance(\n hcpUser,\n patient,\n new HealthElement({\n id: randomUUID(),\n codes: [new Code({ system: 'LOINC', code: '95209', version: '3' })],\n note: 'SARS-V2',\n }),\n { confidential: true }\n )\n}\n\ndescribe('icc-helement-x-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('CreateHealthElementWithUser Success for HCP', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = await createPatient(patientApiForHcp, hcpUser)\n const hElementToCreate = await healthElementToCreate(hElementApiForHcp, hcpUser, patient)\n\n // When\n const createdHealthElement = await hElementApiForHcp.createHealthElementWithUser(hcpUser, hElementToCreate)\n\n // Then\n const readHealthElement = await hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id!)\n assert(readHealthElement != null)\n assert(readHealthElement.id != null)\n assert(readHealthElement.note == hElementToCreate.note)\n assert(readHealthElement.delegations![hcpUser.healthcarePartyId!].length > 0)\n assert(readHealthElement.encryptionKeys![hcpUser.healthcarePartyId!].length > 0)\n assert(readHealthElement.cryptedForeignKeys![hcpUser.healthcarePartyId!].length > 0)\n })\n\n it('ModifyHealthElementWithUser Success for HCP', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n await initApi(env!, hcp1Username)\n\n const patient = await createPatient(patientApiForHcp, hcpUser)\n const createdHealthElement = await hElementApiForHcp.createHealthElementWithUser(\n hcpUser,\n await healthElementToCreate(hElementApiForHcp, hcpUser, patient)\n )\n\n // When\n const modifiedHealthElement = await hElementApiForHcp.modifyHealthElementWithUser(hcpUser, {\n ...createdHealthElement,\n note: 'SARS-V2 (COVID-19)',\n })\n\n // Then\n const readHealthElement = await hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id!)\n assert(readHealthElement != null)\n assert(readHealthElement.id != null)\n assert(readHealthElement.note != createdHealthElement.note)\n assert(readHealthElement.note == modifiedHealthElement.note)\n assert(readHealthElement.delegations![hcpUser.healthcarePartyId!].length > 0)\n assert(readHealthElement.encryptionKeys![hcpUser.healthcarePartyId!].length > 0)\n assert(readHealthElement.cryptedForeignKeys![hcpUser.healthcarePartyId!].length > 0)\n })\n\n it('findHealthElementsByHCPartyAndPatientWithUser Success for HCP', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n const createdHealthElement = await hElementApiForHcp.createHealthElementWithUser(\n hcpUser,\n await healthElementToCreate(hElementApiForHcp, hcpUser, patient)\n )\n\n // When\n const foundHealthElements = await hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(hcpUser, hcpUser.healthcarePartyId!, patient)\n const foundHealthElementsUsingPost = await hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(\n hcpUser,\n hcpUser.healthcarePartyId!,\n patient,\n true\n )\n\n // Then\n assert(foundHealthElements.length == 1, 'Found health elements should be 1')\n assert(foundHealthElements[0].id == createdHealthElement.id, 'Found health element should be the same as the created one')\n\n assert(foundHealthElementsUsingPost.length == 1, 'Found health elements using POST should be 1')\n assert(foundHealthElementsUsingPost[0].id == createdHealthElement.id, 'Found health element using POST should be the same as the created one')\n })\n\n it('filter healthcare element result should return same output by id', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n const createdHealthElement = await hElementApiForHcp.createHealthElementWithUser(\n hcpUser,\n await healthElementToCreate(hElementApiForHcp, hcpUser, patient)\n )\n\n // When\n const healthElementById = await hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id)\n const healthElementByFilter = await hElementApiForHcp.filterByWithUser(\n hcpUser,\n undefined,\n undefined,\n new FilterChainHealthElement({\n filter: new HealthElementByIdsFilter({\n ids: [createdHealthElement.id!],\n healthcarePartyId: hcpUser.healthcarePartyId!,\n }),\n })\n )\n\n // Then\n assert(healthElementByFilter.rows?.length == 1, 'Found health elements should be 1')\n assert(healthElementByFilter.rows[0].id == createdHealthElement.id, 'Found health element should be the same as the created one')\n\n assert(!!healthElementById.note, 'Health element should have a note')\n\n assert(\n JSON.stringify(healthElementByFilter.rows[0]) === JSON.stringify(healthElementById),\n 'Found health elements by id should match the one found by filter'\n )\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const encryptedField = 'Something encrypted'\n const entity = await api1.healthcareElementApi.createHealthElementWithUser(\n user1,\n await api1.healthcareElementApi.newInstance(user1, samplePatient, { note: encryptedField })\n )\n expect(entity.note).to.be.equal(encryptedField)\n await api2.healthcareElementApi\n .getHealthElementWithUser(user2, entity.id)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.healthcareElementApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.healthcareElementApi.getHealthElementWithUser(user2, entity.id)\n expect(retrieved.note).to.be.equal(encryptedField)\n expect((await api2.healthcareElementApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('newInstance should honor non-default values unless they are undefined', async () => {\n const api = await initApi(env!, hcp1Username)\n const user = await api.userApi.getCurrentUser()\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const helementUndefinedId = await api.healthcareElementApi.newInstance(user, patient, { id: undefined })\n const customId = 'customId'\n const helementCustomId = await api.healthcareElementApi.newInstance(user, patient, { id: customId })\n const helementWithUndefinedInit = await api.healthcareElementApi.newInstance(user, patient, undefined)\n expect(helementUndefinedId.id).to.not.be.undefined\n expect(helementWithUndefinedInit.id).to.not.be.undefined\n expect(helementCustomId.id).to.equal(customId)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'isomorphic-fetch';
|