@icure/api 8.6.5 → 8.6.6
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/IccFormApi.d.ts +81 -0
- package/icc-api/api/IccFormApi.js +213 -0
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +0 -2
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Device.d.ts +0 -1
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +0 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/Patient.d.ts +0 -1
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +1 -2
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -2
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +93 -0
- package/icc-x-api/icc-accesslog-x-api.js +93 -0
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +122 -0
- package/icc-x-api/icc-calendar-item-x-api.js +122 -0
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +20 -0
- package/icc-x-api/icc-classification-x-api.js +20 -0
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-code-x-api.d.ts +23 -0
- package/icc-x-api/icc-code-x-api.js +23 -0
- package/icc-x-api/icc-code-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +219 -1
- package/icc-x-api/icc-contact-x-api.js +219 -2
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +14 -3
- package/icc-x-api/icc-data-owner-x-api.js +14 -3
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-device-x-api.d.ts +8 -0
- package/icc-x-api/icc-device-x-api.js +8 -0
- package/icc-x-api/icc-device-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.d.ts +26 -0
- package/icc-x-api/icc-doctemplate-x-api.js +26 -0
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +114 -1
- package/icc-x-api/icc-document-x-api.js +127 -1
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +34 -4
- package/icc-x-api/icc-form-x-api.js +34 -4
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +67 -0
- package/icc-x-api/icc-hcparty-x-api.js +67 -0
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +141 -0
- package/icc-x-api/icc-helement-x-api.js +141 -0
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +54 -0
- package/icc-x-api/icc-invoice-x-api.js +54 -0
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +162 -0
- package/icc-x-api/icc-message-x-api.js +162 -0
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +245 -0
- package/icc-x-api/icc-patient-x-api.js +245 -1
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +25 -0
- package/icc-x-api/icc-receipt-x-api.js +25 -0
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-user-x-api.d.ts +25 -0
- package/icc-x-api/icc-user-x-api.js +25 -0
- package/icc-x-api/icc-user-x-api.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/icc-form-x-api.js +265 -1
- package/test/icc-x-api/icc-form-x-api.js.map +1 -1
- package/test/utils/roles.js +5 -0
- package/test/utils/roles.js.map +1 -1
- package/test/utils/test_utils.js +1 -21
- package/test/utils/test_utils.js.map +1 -1
- package/test/support/CSM-729.d.ts +0 -1
- package/test/support/CSM-729.js +0 -225
- package/test/support/CSM-729.js.map +0 -1
|
@@ -125,7 +125,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
* Same as {@link
|
|
128
|
+
* Same as {@link findBy} but it will only return the ids of the contacts. It can also filter the contacts where Contact.openingDate is between
|
|
129
129
|
* startDate and endDate in ascending or descending order by that field. (default: ascending).
|
|
130
130
|
*/
|
|
131
131
|
findIdsBy(hcpartyId, patient, startDate, endDate, descending) {
|
|
@@ -220,43 +220,106 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
220
220
|
.findByHCPartyPatientSecretFKeysUsingPost(hcPartyId, planOfActionIds, skipClosedContacts, secretFKeys)
|
|
221
221
|
.then((contacts) => this.decrypt(hcPartyId, contacts));
|
|
222
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Filters contacts using a filter chain and decrypts the results for the given user.
|
|
225
|
+
* @param user the user for decryption
|
|
226
|
+
* @param startDocumentId optional document id to start pagination from
|
|
227
|
+
* @param limit maximum number of results to return
|
|
228
|
+
* @param body the filter chain to apply
|
|
229
|
+
* @return a paginated list of decrypted contacts
|
|
230
|
+
*/
|
|
223
231
|
filterByWithUser(user, startDocumentId, limit, body) {
|
|
224
232
|
return super
|
|
225
233
|
.filterContactsBy(startDocumentId, limit, body)
|
|
226
234
|
.then((ctcs) => this.decrypt(user.healthcarePartyId || user.patientId, ctcs.rows).then((decryptedRows) => Object.assign(ctcs, { rows: decryptedRows })));
|
|
227
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Lists contacts by opening date within a date range and decrypts the results for the given user.
|
|
238
|
+
* @param user the user for decryption
|
|
239
|
+
* @param startDate start of the date range (format: YYYYMMDDHHmmss)
|
|
240
|
+
* @param endDate end of the date range (format: YYYYMMDDHHmmss)
|
|
241
|
+
* @param hcpartyid the healthcare party id
|
|
242
|
+
* @param startKey optional start key for pagination
|
|
243
|
+
* @param startDocumentId optional document id to start pagination from
|
|
244
|
+
* @param limit maximum number of results to return
|
|
245
|
+
* @return a paginated list of decrypted contacts
|
|
246
|
+
*/
|
|
228
247
|
listContactsByOpeningDateWithUser(user, startDate, endDate, hcpartyid, startKey, startDocumentId, limit) {
|
|
229
248
|
return super
|
|
230
249
|
.listContactsByOpeningDate(startDate, endDate, hcpartyid, startKey, startDocumentId, limit)
|
|
231
250
|
.then((ctcs) => this.decrypt(user.healthcarePartyId || user.patientId, ctcs.rows).then((decryptedRows) => Object.assign(ctcs, { rows: decryptedRows })));
|
|
232
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Gets a service by id and decrypts it for the given user.
|
|
254
|
+
* @param user the user for decryption
|
|
255
|
+
* @param serviceId the service id
|
|
256
|
+
* @return the decrypted service
|
|
257
|
+
*/
|
|
233
258
|
getServiceWithUser(user, serviceId) {
|
|
234
259
|
return super
|
|
235
260
|
.getService(serviceId)
|
|
236
261
|
.then((service) => { var _a, _b; return this.decryptServices((_b = (_a = user.healthcarePartyId) !== null && _a !== void 0 ? _a : user.patientId) !== null && _b !== void 0 ? _b : user.deviceId, [service]); })
|
|
237
262
|
.then((decrypted) => decrypted[0]);
|
|
238
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Lists services by their ids and decrypts them for the given user.
|
|
266
|
+
* @param user the user for decryption
|
|
267
|
+
* @param serviceIds the list of service ids to retrieve
|
|
268
|
+
* @return an array of decrypted services
|
|
269
|
+
*/
|
|
239
270
|
listServicesWithUser(user, serviceIds) {
|
|
240
271
|
var _a;
|
|
241
272
|
return super
|
|
242
273
|
.filterServicesBy(undefined, (_a = serviceIds.ids) === null || _a === void 0 ? void 0 : _a.length, new models_1.FilterChainService({ filter: new ServiceByIdsFilter_1.ServiceByIdsFilter({ ids: serviceIds.ids }) }))
|
|
243
274
|
.then((paginatedList) => { var _a, _b, _c; return this.decryptServices((_b = (_a = user.healthcarePartyId) !== null && _a !== void 0 ? _a : user.patientId) !== null && _b !== void 0 ? _b : user.deviceId, (_c = paginatedList.rows) !== null && _c !== void 0 ? _c : []); });
|
|
244
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Finds contacts by healthcare party and form id and decrypts them for the given user.
|
|
278
|
+
* @param user the user for decryption
|
|
279
|
+
* @param hcPartyId the healthcare party id
|
|
280
|
+
* @param formId the form id
|
|
281
|
+
* @return an array of decrypted contacts
|
|
282
|
+
*/
|
|
245
283
|
findByHCPartyFormIdWithUser(user, hcPartyId, formId) {
|
|
246
284
|
return super.findByHCPartyFormId(hcPartyId, formId).then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs));
|
|
247
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Finds contacts by healthcare party and multiple form ids and decrypts them for the given user.
|
|
288
|
+
* @param user the user for decryption
|
|
289
|
+
* @param hcPartyId the healthcare party id
|
|
290
|
+
* @param body the list of form ids
|
|
291
|
+
* @return an array of decrypted contacts
|
|
292
|
+
*/
|
|
248
293
|
findByHCPartyFormIdsWithUser(user, hcPartyId, body) {
|
|
249
294
|
return super.findByHCPartyFormIds(hcPartyId, body).then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs));
|
|
250
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Gets a contact by id and decrypts it for the given user.
|
|
298
|
+
* @param user the user for decryption
|
|
299
|
+
* @param contactId the contact id
|
|
300
|
+
* @return the decrypted contact
|
|
301
|
+
*/
|
|
251
302
|
getContactWithUser(user, contactId) {
|
|
252
303
|
return super
|
|
253
304
|
.getContact(contactId)
|
|
254
305
|
.then((ctc) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [ctc]))
|
|
255
306
|
.then((ctcs) => ctcs[0]);
|
|
256
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Gets multiple contacts by their ids and decrypts them for the given user.
|
|
310
|
+
* @param user the user for decryption
|
|
311
|
+
* @param body the list of contact ids
|
|
312
|
+
* @return an array of decrypted contacts
|
|
313
|
+
*/
|
|
257
314
|
getContactsWithUser(user, body) {
|
|
258
315
|
return super.getContacts(body).then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs));
|
|
259
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Modifies an existing contact by encrypting it and saving it to the database.
|
|
319
|
+
* @param user the user for encryption
|
|
320
|
+
* @param body the contact to modify
|
|
321
|
+
* @return the modified and decrypted contact
|
|
322
|
+
*/
|
|
260
323
|
modifyContactWithUser(user, body) {
|
|
261
324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
262
325
|
return body ? this.modifyContactAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : null;
|
|
@@ -268,6 +331,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
268
331
|
.then((ctc) => this.decrypt(dataOwner, [ctc]))
|
|
269
332
|
.then((ctcs) => ctcs[0]);
|
|
270
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Modifies multiple existing contacts by encrypting them and saving them to the database.
|
|
336
|
+
* @param user the user for encryption
|
|
337
|
+
* @param bodies the array of contacts to modify
|
|
338
|
+
* @return an array of modified and decrypted contacts
|
|
339
|
+
*/
|
|
271
340
|
modifyContactsWithUser(user, bodies) {
|
|
272
341
|
const _super = Object.create(null, {
|
|
273
342
|
modifyContacts: { get: () => super.modifyContacts }
|
|
@@ -280,6 +349,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
280
349
|
: null;
|
|
281
350
|
});
|
|
282
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Creates a new contact by encrypting it and saving it to the database.
|
|
354
|
+
* @param user the user for encryption
|
|
355
|
+
* @param body the contact to create
|
|
356
|
+
* @return the created and decrypted contact
|
|
357
|
+
*/
|
|
283
358
|
createContactWithUser(user, body) {
|
|
284
359
|
const _super = Object.create(null, {
|
|
285
360
|
createContact: { get: () => super.createContact }
|
|
@@ -293,6 +368,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
293
368
|
: null;
|
|
294
369
|
});
|
|
295
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* Creates multiple new contacts by encrypting them and saving them to the database.
|
|
373
|
+
* @param user the user for encryption
|
|
374
|
+
* @param bodies the array of contacts to create
|
|
375
|
+
* @return an array of created and decrypted contacts
|
|
376
|
+
*/
|
|
296
377
|
createContactsWithUser(user, bodies) {
|
|
297
378
|
const _super = Object.create(null, {
|
|
298
379
|
createContacts: { get: () => super.createContacts }
|
|
@@ -305,6 +386,14 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
305
386
|
: null;
|
|
306
387
|
});
|
|
307
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Encrypts the content and custom encrypted fields of services.
|
|
391
|
+
* Services with compound values are recursively encrypted.
|
|
392
|
+
* @param key the encryption key
|
|
393
|
+
* @param rawKey the raw encryption key as a string
|
|
394
|
+
* @param services the array of services to encrypt
|
|
395
|
+
* @return a promise containing the encrypted services
|
|
396
|
+
*/
|
|
308
397
|
encryptServices(key, rawKey, services) {
|
|
309
398
|
return Promise.all(services.map((svc) => __awaiter(this, void 0, void 0, function* () {
|
|
310
399
|
if (svc.content &&
|
|
@@ -340,6 +429,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
340
429
|
}
|
|
341
430
|
})));
|
|
342
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Encrypts contacts for the given user including all services within the contacts.
|
|
434
|
+
* @param user the user for encryption
|
|
435
|
+
* @param ctcs the array of contacts to encrypt
|
|
436
|
+
* @return a promise containing the encrypted contacts
|
|
437
|
+
*/
|
|
343
438
|
encrypt(user, ctcs) {
|
|
344
439
|
return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs);
|
|
345
440
|
}
|
|
@@ -370,11 +465,23 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
370
465
|
return ctcs.map((e) => allEncrypted.get(e.id));
|
|
371
466
|
});
|
|
372
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Decrypts contacts and all their encrypted content.
|
|
470
|
+
* @param hcpartyId the healthcare party id (deprecated parameter, kept for compatibility)
|
|
471
|
+
* @param ctcs the array of encrypted contacts
|
|
472
|
+
* @return a promise containing the decrypted contacts
|
|
473
|
+
*/
|
|
373
474
|
decrypt(hcpartyId, ctcs) {
|
|
374
475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
375
476
|
return (yield this.crypto.xapi.tryDecryptEntities(ctcs, utils_1.EntityWithDelegationTypeName.Contact, (x) => new models_1.Contact(x))).map(({ entity }) => entity);
|
|
376
477
|
});
|
|
377
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Decrypts services and all their encrypted content.
|
|
481
|
+
* @param hcpartyId the healthcare party id (deprecated parameter, kept for compatibility)
|
|
482
|
+
* @param svcs the array of encrypted services
|
|
483
|
+
* @return a promise containing the decrypted services
|
|
484
|
+
*/
|
|
378
485
|
decryptServices(hcpartyId, svcs) {
|
|
379
486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
380
487
|
/*TODO
|
|
@@ -386,6 +493,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
386
493
|
return (yield this.crypto.xapi.tryDecryptEntities(svcs, utils_1.EntityWithDelegationTypeName.Contact, (x) => new models_1.Service(x))).map(({ entity }) => entity);
|
|
387
494
|
});
|
|
388
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Finds the contact containing the given service id, prioritizing the latest version by valueDate.
|
|
498
|
+
* @param ctcs the array of contacts to search
|
|
499
|
+
* @param svcId the service id to find
|
|
500
|
+
* @return the contact containing the service or undefined if not found
|
|
501
|
+
*/
|
|
389
502
|
contactOfService(ctcs, svcId) {
|
|
390
503
|
let latestContact = undefined;
|
|
391
504
|
let latestService;
|
|
@@ -398,6 +511,12 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
398
511
|
});
|
|
399
512
|
return latestContact;
|
|
400
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Extracts and filters services from contacts, keeping only the latest version of each service and excluding deleted services.
|
|
516
|
+
* @param ctcs the array of contacts containing services
|
|
517
|
+
* @param filter a predicate function to filter services: (service, contact) => boolean
|
|
518
|
+
* @return an array of filtered services with contactId set
|
|
519
|
+
*/
|
|
401
520
|
filteredServices(ctcs, filter) {
|
|
402
521
|
const byIds = {};
|
|
403
522
|
ctcs.forEach((c) => (c.services || [])
|
|
@@ -411,16 +530,38 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
411
530
|
}));
|
|
412
531
|
return _.values(byIds).filter((s) => !s.deleted && !s.endOfLife);
|
|
413
532
|
}
|
|
414
|
-
|
|
533
|
+
/**
|
|
534
|
+
* Extracts and filters services from contacts, returning a promise. Same as filteredServices but wrapped in a promise.
|
|
535
|
+
* @param ctcs the array of contacts containing services
|
|
536
|
+
* @param filter a predicate function to filter services: (service, contact) => boolean
|
|
537
|
+
* @return a promise containing an array of filtered services
|
|
538
|
+
*/
|
|
415
539
|
filterServices(ctcs, filter) {
|
|
416
540
|
return Promise.resolve(this.filteredServices(ctcs, filter));
|
|
417
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Gets all services from a contact that have the specified label.
|
|
544
|
+
* @param ctc the contact
|
|
545
|
+
* @param label the service label to filter by
|
|
546
|
+
* @return an array of services with the given label
|
|
547
|
+
*/
|
|
418
548
|
services(ctc, label) {
|
|
419
549
|
return ctc.services.filter((s) => s.label === label);
|
|
420
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Gets the preferred content for a service based on language preference, falling back to French then first available language.
|
|
553
|
+
* @param svc the service
|
|
554
|
+
* @param lng the preferred language code
|
|
555
|
+
* @return the content in the preferred language or null if no content exists
|
|
556
|
+
*/
|
|
421
557
|
preferredContent(svc, lng) {
|
|
422
558
|
return (svc && svc.content && (svc.content[lng] || svc.content['fr'] || (Object.keys(svc.content)[0] ? svc.content[Object.keys(svc.content)[0]] : null)));
|
|
423
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Extracts the value from content, prioritizing string, number, measure, medication, and boolean values in that order.
|
|
562
|
+
* @param c the content
|
|
563
|
+
* @return the extracted value or undefined if no value is present
|
|
564
|
+
*/
|
|
424
565
|
contentValue(c) {
|
|
425
566
|
return (c.stringValue ||
|
|
426
567
|
((c.numberValue || c.numberValue === 0) && c.numberValue) ||
|
|
@@ -428,10 +569,23 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
428
569
|
c.medicationValue ||
|
|
429
570
|
c.booleanValue);
|
|
430
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Gets a short human-readable description of a service in the preferred language.
|
|
574
|
+
* @param svc the service
|
|
575
|
+
* @param lng the preferred language code
|
|
576
|
+
* @return a short description of the service content or empty string
|
|
577
|
+
*/
|
|
431
578
|
shortServiceDescription(svc, lng) {
|
|
432
579
|
const c = this.preferredContent(svc, lng);
|
|
433
580
|
return !c ? '' : this.shortContentDescription(c, lng, svc.label);
|
|
434
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Gets a short human-readable description of content, formatted appropriately for the content type.
|
|
584
|
+
* @param c the content
|
|
585
|
+
* @param lng the language code for medication formatting
|
|
586
|
+
* @param label optional label used for boolean content display
|
|
587
|
+
* @return a short description of the content
|
|
588
|
+
*/
|
|
435
589
|
shortContentDescription(c, lng, label) {
|
|
436
590
|
return (c.stringValue ||
|
|
437
591
|
((c.numberValue || c.numberValue === 0) && c.numberValue) ||
|
|
@@ -443,13 +597,30 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
443
597
|
(c.booleanValue && label) ||
|
|
444
598
|
'OK');
|
|
445
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Extracts the medication value from a service's content in the preferred language.
|
|
602
|
+
* @param svc the service
|
|
603
|
+
* @param lng the preferred language code
|
|
604
|
+
* @return the medication value or undefined if not present
|
|
605
|
+
*/
|
|
446
606
|
medicationValue(svc, lng) {
|
|
447
607
|
const c = svc && svc.content && (svc.content[lng] || svc.content['fr'] || (Object.keys(svc.content)[0] ? svc.content[Object.keys(svc.content)[0]] : null));
|
|
448
608
|
return c && c.medicationValue;
|
|
449
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Checks if content has any data value set (string, number, measure, boolean, medication, or document).
|
|
612
|
+
* @param c the content to check
|
|
613
|
+
* @return true if content has data, false otherwise
|
|
614
|
+
*/
|
|
450
615
|
contentHasData(c) {
|
|
451
616
|
return c.stringValue || c.numberValue || c.measureValue || c.booleanValue || c.booleanValue === false || c.medicationValue || c.documentId;
|
|
452
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* Localizes a value by selecting the appropriate language from an object, falling back through FR, EN, and NL.
|
|
620
|
+
* @param e the object with language-keyed values or a simple value
|
|
621
|
+
* @param lng the preferred language code
|
|
622
|
+
* @return the localized value or null if e is null/undefined
|
|
623
|
+
*/
|
|
453
624
|
localize(e, lng) {
|
|
454
625
|
if (!e) {
|
|
455
626
|
return null;
|
|
@@ -567,10 +738,20 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
567
738
|
});
|
|
568
739
|
return (init && init(promoted)) || promoted;
|
|
569
740
|
}
|
|
741
|
+
/**
|
|
742
|
+
* Checks if a service has numeric content (measure or number value) in the preferred language.
|
|
743
|
+
* @param svc the service
|
|
744
|
+
* @param lng the preferred language code
|
|
745
|
+
* @return true if the service has numeric content, false otherwise
|
|
746
|
+
*/
|
|
570
747
|
isNumeric(svc, lng) {
|
|
571
748
|
const c = this.preferredContent(svc, lng);
|
|
572
749
|
return c && (c.measureValue || c.numberValue || c.numberValue == 0);
|
|
573
750
|
}
|
|
751
|
+
/**
|
|
752
|
+
* Returns utility functions for working with services.
|
|
753
|
+
* @return an object with helper methods for creating and manipulating services
|
|
754
|
+
*/
|
|
574
755
|
service() {
|
|
575
756
|
return {
|
|
576
757
|
newInstance: (user, s) => {
|
|
@@ -590,6 +771,10 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
590
771
|
},
|
|
591
772
|
};
|
|
592
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Returns utility functions for working with medication content.
|
|
776
|
+
* @return an object with helper methods for formatting and displaying medication information
|
|
777
|
+
*/
|
|
593
778
|
medication() {
|
|
594
779
|
const regimenScores = {
|
|
595
780
|
afterwakingup: 63000,
|
|
@@ -838,24 +1023,56 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
838
1023
|
.then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])));
|
|
839
1024
|
});
|
|
840
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Gets the data owners that have access to the contact and their permission levels.
|
|
1028
|
+
* @param entity the contact
|
|
1029
|
+
* @return a promise containing the permissions by data owner id and whether there are unknown anonymous data owners
|
|
1030
|
+
*/
|
|
841
1031
|
getDataOwnersWithAccessTo(entity) {
|
|
842
1032
|
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.Contact });
|
|
843
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Gets all encryption keys available for the contact.
|
|
1036
|
+
* @param entity the contact
|
|
1037
|
+
* @return a promise containing an array of encryption key hex strings
|
|
1038
|
+
*/
|
|
844
1039
|
getEncryptionKeysOf(entity) {
|
|
845
1040
|
return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.Contact }, undefined);
|
|
846
1041
|
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Subscribes to service events (create, update, delete) and receives decrypted services.
|
|
1044
|
+
* @param eventTypes the types of events to subscribe to
|
|
1045
|
+
* @param filter optional filter to apply to services
|
|
1046
|
+
* @param eventFired callback function invoked when an event occurs, receives the decrypted service
|
|
1047
|
+
* @param options optional subscription options
|
|
1048
|
+
* @return a connection that can be closed to unsubscribe
|
|
1049
|
+
*/
|
|
847
1050
|
subscribeToServiceEvents(eventTypes_1, filter_1, eventFired_1) {
|
|
848
1051
|
return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
|
|
849
1052
|
const currentUser = yield this.userApi.getCurrentUser();
|
|
850
1053
|
return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, 'Service', eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decryptServices(currentUser.healthcarePartyId, [encrypted]))[0]; })).then((ws) => new Connection_1.ConnectionImpl(ws));
|
|
851
1054
|
});
|
|
852
1055
|
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Subscribes to contact events (create, update, delete) and receives decrypted contacts.
|
|
1058
|
+
* @param eventTypes the types of events to subscribe to
|
|
1059
|
+
* @param filter optional filter to apply to contacts
|
|
1060
|
+
* @param eventFired callback function invoked when an event occurs, receives the decrypted contact
|
|
1061
|
+
* @param options optional subscription options
|
|
1062
|
+
* @return a connection that can be closed to unsubscribe
|
|
1063
|
+
*/
|
|
853
1064
|
subscribeToContactEvents(eventTypes_1, filter_1, eventFired_1) {
|
|
854
1065
|
return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
|
|
855
1066
|
const currentUser = yield this.userApi.getCurrentUser();
|
|
856
1067
|
return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, utils_1.EntityWithDelegationTypeName.Contact, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(currentUser.healthcarePartyId, [encrypted]))[0]; })).then((ws) => new Connection_1.ConnectionImpl(ws));
|
|
857
1068
|
});
|
|
858
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Creates or updates de-anonymization metadata for delegations in a contact.
|
|
1072
|
+
* @param entity the contact
|
|
1073
|
+
* @param delegates the array of delegate ids to create de-anonymization metadata for
|
|
1074
|
+
* @return a promise that completes when the metadata is created/updated
|
|
1075
|
+
*/
|
|
859
1076
|
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
860
1077
|
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.Contact }, delegates);
|
|
861
1078
|
}
|