@icure/api 8.6.5 → 8.6.7

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.
Files changed (61) hide show
  1. package/icc-api/api/IccFormApi.d.ts +89 -0
  2. package/icc-api/api/IccFormApi.js +234 -0
  3. package/icc-api/api/IccFormApi.js.map +1 -1
  4. package/icc-x-api/icc-accesslog-x-api.d.ts +93 -0
  5. package/icc-x-api/icc-accesslog-x-api.js +93 -0
  6. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  7. package/icc-x-api/icc-calendar-item-x-api.d.ts +122 -0
  8. package/icc-x-api/icc-calendar-item-x-api.js +122 -0
  9. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  10. package/icc-x-api/icc-classification-x-api.d.ts +20 -0
  11. package/icc-x-api/icc-classification-x-api.js +20 -0
  12. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  13. package/icc-x-api/icc-code-x-api.d.ts +23 -0
  14. package/icc-x-api/icc-code-x-api.js +23 -0
  15. package/icc-x-api/icc-code-x-api.js.map +1 -1
  16. package/icc-x-api/icc-contact-x-api.d.ts +219 -1
  17. package/icc-x-api/icc-contact-x-api.js +219 -2
  18. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  19. package/icc-x-api/icc-data-owner-x-api.d.ts +14 -3
  20. package/icc-x-api/icc-data-owner-x-api.js +14 -3
  21. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  22. package/icc-x-api/icc-device-x-api.d.ts +8 -0
  23. package/icc-x-api/icc-device-x-api.js +8 -0
  24. package/icc-x-api/icc-device-x-api.js.map +1 -1
  25. package/icc-x-api/icc-doctemplate-x-api.d.ts +26 -0
  26. package/icc-x-api/icc-doctemplate-x-api.js +26 -0
  27. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  28. package/icc-x-api/icc-document-x-api.d.ts +114 -1
  29. package/icc-x-api/icc-document-x-api.js +127 -1
  30. package/icc-x-api/icc-document-x-api.js.map +1 -1
  31. package/icc-x-api/icc-form-x-api.d.ts +34 -4
  32. package/icc-x-api/icc-form-x-api.js +34 -4
  33. package/icc-x-api/icc-form-x-api.js.map +1 -1
  34. package/icc-x-api/icc-hcparty-x-api.d.ts +67 -0
  35. package/icc-x-api/icc-hcparty-x-api.js +67 -0
  36. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  37. package/icc-x-api/icc-helement-x-api.d.ts +141 -0
  38. package/icc-x-api/icc-helement-x-api.js +141 -0
  39. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  40. package/icc-x-api/icc-invoice-x-api.d.ts +54 -0
  41. package/icc-x-api/icc-invoice-x-api.js +54 -0
  42. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  43. package/icc-x-api/icc-message-x-api.d.ts +162 -0
  44. package/icc-x-api/icc-message-x-api.js +162 -0
  45. package/icc-x-api/icc-message-x-api.js.map +1 -1
  46. package/icc-x-api/icc-patient-x-api.d.ts +245 -0
  47. package/icc-x-api/icc-patient-x-api.js +245 -1
  48. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  49. package/icc-x-api/icc-receipt-x-api.d.ts +25 -0
  50. package/icc-x-api/icc-receipt-x-api.js +25 -0
  51. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  52. package/icc-x-api/icc-user-x-api.d.ts +25 -0
  53. package/icc-x-api/icc-user-x-api.js +25 -0
  54. package/icc-x-api/icc-user-x-api.js.map +1 -1
  55. package/package.json +1 -1
  56. package/test/icc-x-api/icc-form-x-api.js +316 -1
  57. package/test/icc-x-api/icc-form-x-api.js.map +1 -1
  58. package/test/utils/roles.js +5 -0
  59. package/test/utils/roles.js.map +1 -1
  60. package/test/utils/test_utils.js +1 -21
  61. package/test/utils/test_utils.js.map +1 -1
@@ -52,23 +52,98 @@ export declare class IccHelementXApi extends IccHelementApi implements Encrypted
52
52
  ignoreAutoDelegations?: boolean;
53
53
  alternateRootDelegation?: string;
54
54
  }): Promise<models.HealthElement>;
55
+ /**
56
+ * @throws always. Use {@link createHealthElementWithUser} instead.
57
+ */
55
58
  createHealthElement(body?: models.HealthElement): never;
59
+ /**
60
+ * Creates a health element after encrypting its content.
61
+ * @param user the current user, used for encryption.
62
+ * @param body the health element to create.
63
+ * @return the created and decrypted health element.
64
+ */
56
65
  createHealthElementWithUser(user: models.User, body?: models.HealthElement): Promise<models.HealthElement | any>;
66
+ /**
67
+ * @throws always. Use {@link createHealthElementsWithUser} instead.
68
+ */
57
69
  createHealthElements(body?: Array<HealthElement>): never;
70
+ /**
71
+ * Creates multiple health elements after encrypting their content.
72
+ * @param user the current user, used for encryption.
73
+ * @param bodies the health elements to create.
74
+ * @return the created and decrypted health elements.
75
+ */
58
76
  createHealthElementsWithUser(user: models.User, bodies?: models.HealthElement[]): Promise<models.HealthElement[] | any>;
77
+ /**
78
+ * @throws always. Use {@link getHealthElementWithUser} instead.
79
+ */
59
80
  getHealthElement(healthElementId: string): never;
81
+ /**
82
+ * Retrieves a health element by id and decrypts it.
83
+ * @param user the current user, used for decryption.
84
+ * @param healthElementId the id of the health element to retrieve.
85
+ * @return the decrypted health element.
86
+ */
60
87
  getHealthElementWithUser(user: models.User, healthElementId: string): Promise<models.HealthElement>;
88
+ /**
89
+ * @throws always. Use {@link getHealthElementsWithUser} instead.
90
+ */
61
91
  getHealthElements(body?: models.ListOfIds): never;
92
+ /**
93
+ * Retrieves multiple health elements by their ids and decrypts them.
94
+ * @param user the current user, used for decryption.
95
+ * @param body the list of health element ids to retrieve.
96
+ * @return the decrypted health elements.
97
+ */
62
98
  getHealthElementsWithUser(user: models.User, body?: models.ListOfIds): Promise<models.HealthElement[]>;
99
+ /**
100
+ * @throws always.
101
+ */
63
102
  newHealthElementDelegations(healthElementId: string, body?: Array<models.Delegation>): never;
103
+ /**
104
+ * @throws always. Use {@link findHealthElementsByHCPartyPatientForeignKeysWithUser} instead.
105
+ */
64
106
  findHealthElementsByHCPartyPatientForeignKeys(hcPartyId: string, secretFKeys: string): never;
107
+ /**
108
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
109
+ */
65
110
  findHealthElementsByHCPartyPatientForeignKeysWithUser(user: models.User, hcPartyId: string, secretFKeys: string): Promise<HealthElement[]>;
111
+ /**
112
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
113
+ */
66
114
  findHealthElementsByHCPartyPatientForeignKeysArrayWithUser(user: models.User, hcPartyId: string, secretFKeys: string[]): Promise<HealthElement[]>;
115
+ /**
116
+ * Finds all health elements for a given patient and healthcare party, and decrypts them.
117
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
118
+ * @param user the current user, used for decryption.
119
+ * @param hcPartyId the id of the healthcare party.
120
+ * @param patient the patient whose health elements to find.
121
+ * @param usingPost if true, uses POST instead of GET for the request.
122
+ * @return the decrypted health elements.
123
+ */
67
124
  findHealthElementsByHCPartyAndPatientWithUser(user: models.User, hcPartyId: string, patient: models.Patient, usingPost?: boolean): Promise<models.HealthElement[]>;
125
+ /**
126
+ * @throws always. Use {@link modifyHealthElementWithUser} instead.
127
+ */
68
128
  modifyHealthElement(body?: HealthElement): never;
129
+ /**
130
+ * Modifies a health element after encrypting its content.
131
+ * @param user the current user, used for encryption/decryption.
132
+ * @param body the health element with updated fields.
133
+ * @return the modified and decrypted health element, or null if body was not provided.
134
+ */
69
135
  modifyHealthElementWithUser(user: models.User, body?: HealthElement): Promise<HealthElement | any>;
70
136
  private modifyHealthElementAs;
137
+ /**
138
+ * @throws always. Use {@link modifyHealthElementsWithUser} instead.
139
+ */
71
140
  modifyHealthElements(body?: Array<HealthElement>): never;
141
+ /**
142
+ * Modifies multiple health elements after encrypting their content.
143
+ * @param user the current user, used for encryption/decryption.
144
+ * @param bodies the health elements with updated fields.
145
+ * @return the modified and decrypted health elements, or null if bodies was not provided.
146
+ */
72
147
  modifyHealthElementsWithUser(user: models.User, bodies?: HealthElement[]): Promise<HealthElement[] | any>;
73
148
  /**
74
149
  * 1. Check whether there is a delegation with 'hcpartyId' or not.
@@ -102,13 +177,55 @@ export declare class IccHelementXApi extends IccHelementApi implements Encrypted
102
177
  * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
103
178
  */
104
179
  findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<models.Contact> | any>;
180
+ /**
181
+ * Encrypts the encrypted fields of a list of health elements.
182
+ * @param user the current user, used to determine the data owner for encryption.
183
+ * @param healthElements the health elements to encrypt.
184
+ * @return the encrypted health elements.
185
+ */
105
186
  encrypt(user: models.User, healthElements: Array<models.HealthElement>): Promise<Array<models.HealthElement>>;
106
187
  private encryptAs;
188
+ /**
189
+ * Decrypts a list of health elements using the given user's data owner keys.
190
+ * @param user the current user.
191
+ * @param hes the health elements to decrypt.
192
+ * @return the decrypted health elements.
193
+ */
107
194
  decryptWithUser(user: models.User, hes: Array<models.HealthElement>): Promise<Array<models.HealthElement>>;
195
+ /**
196
+ * Decrypts a list of health elements using the current data owner's keys.
197
+ * @param dataOwnerId the id of the data owner performing the decryption.
198
+ * @param hes the health elements to decrypt.
199
+ * @return the decrypted health elements.
200
+ */
108
201
  decrypt(dataOwnerId: string, hes: Array<models.HealthElement>): Promise<Array<models.HealthElement>>;
202
+ /**
203
+ * @throws always. Use {@link filterByWithUser} instead.
204
+ */
109
205
  filterHealthElementsBy(startDocumentId?: string, limit?: number, body?: FilterChainHealthElement): never;
206
+ /**
207
+ * Filters health elements using the provided filter chain and decrypts the results.
208
+ * @param user the current user, used for decryption.
209
+ * @param startDocumentId the pagination start document id.
210
+ * @param limit the maximum number of results to return.
211
+ * @param body the filter chain to apply.
212
+ * @return a paginated list of decrypted health elements.
213
+ */
110
214
  filterByWithUser(user: models.User, startDocumentId?: string, limit?: number, body?: FilterChainHealthElement): Promise<PaginatedListHealthElement>;
215
+ /**
216
+ * Converts a service into a new health element linked to the given patient.
217
+ * @param user the current user.
218
+ * @param patient the patient to link the health element to.
219
+ * @param heSvc the service to convert.
220
+ * @param descr the description for the new health element.
221
+ * @return the created health element.
222
+ */
111
223
  serviceToHealthElement(user: models.User, patient: models.Patient, heSvc: models.Service, descr: string): Promise<never>;
224
+ /**
225
+ * Parses a pipe-delimited code string into a Code object.
226
+ * @param code the code string in format "type|code|version".
227
+ * @return a Code object with the parsed fields.
228
+ */
112
229
  stringToCode(code: string): models.Code;
113
230
  /**
114
231
  * @param healthElement a health element
@@ -187,13 +304,37 @@ export declare class IccHelementXApi extends IccHelementApi implements Encrypted
187
304
  sharePatientId?: ShareMetadataBehaviour;
188
305
  };
189
306
  }): Promise<ShareResult<models.HealthElement>>;
307
+ /**
308
+ * Retrieves the data owners that have access to the given health element, along with their access levels.
309
+ * @param entity the health element.
310
+ * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.
311
+ */
190
312
  getDataOwnersWithAccessTo(entity: models.HealthElement): Promise<{
191
313
  permissionsByDataOwnerId: {
192
314
  [p: string]: AccessLevelEnum;
193
315
  };
194
316
  hasUnknownAnonymousDataOwners: boolean;
195
317
  }>;
318
+ /**
319
+ * Retrieves the encryption keys of the given health element.
320
+ * @param entity the health element.
321
+ * @return the encryption key ids.
322
+ */
196
323
  getEncryptionKeysOf(entity: models.HealthElement): Promise<string[]>;
324
+ /**
325
+ * Subscribes to real-time health element events using a WebSocket connection. Received events are automatically decrypted.
326
+ * @param eventTypes the types of events to listen for (e.g. 'CREATE', 'UPDATE', 'DELETE').
327
+ * @param filter an optional filter to restrict which health element events trigger the callback.
328
+ * @param eventFired the callback function invoked when a matching health element event is received.
329
+ * @param options optional subscription configuration such as connection parameters and retry behaviour.
330
+ * @return a connection object that can be used to manage the WebSocket subscription lifecycle.
331
+ */
197
332
  subscribeToHealthElementEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<HealthElement> | undefined, eventFired: (healthElement: HealthElement) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
333
+ /**
334
+ * Creates or updates de-anonymization metadata for the given health element, allowing the specified delegates to
335
+ * identify the data owners that have access to it.
336
+ * @param entity the health element.
337
+ * @param delegates the data owner ids for which to create de-anonymization metadata.
338
+ */
198
339
  createDelegationDeAnonymizationMetadata(entity: HealthElement, delegates: string[]): Promise<void>;
199
340
  }
@@ -69,9 +69,18 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
69
69
  return new models.HealthElement(initialisationInfo.updatedEntity);
70
70
  });
71
71
  }
72
+ /**
73
+ * @throws always. Use {@link createHealthElementWithUser} instead.
74
+ */
72
75
  createHealthElement(body) {
73
76
  throw new Error('Cannot call a method that returns health elements without providing a user for de/encryption');
74
77
  }
78
+ /**
79
+ * Creates a health element after encrypting its content.
80
+ * @param user the current user, used for encryption.
81
+ * @param body the health element to create.
82
+ * @return the created and decrypted health element.
83
+ */
75
84
  createHealthElementWithUser(user, body) {
76
85
  return body
77
86
  ? this.encrypt(user, [_.cloneDeep(body)])
@@ -80,9 +89,18 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
80
89
  .then((hes) => hes[0])
81
90
  : Promise.resolve(null);
82
91
  }
92
+ /**
93
+ * @throws always. Use {@link createHealthElementsWithUser} instead.
94
+ */
83
95
  createHealthElements(body) {
84
96
  throw new Error('Cannot call a method that returns health elements without providing a user for de/encryption');
85
97
  }
98
+ /**
99
+ * Creates multiple health elements after encrypting their content.
100
+ * @param user the current user, used for encryption.
101
+ * @param bodies the health elements to create.
102
+ * @return the created and decrypted health elements.
103
+ */
86
104
  createHealthElementsWithUser(user, bodies) {
87
105
  return bodies
88
106
  ? this.encrypt(user, bodies.map((c) => _.cloneDeep(c)))
@@ -90,33 +108,72 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
90
108
  .then((hes) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), hes))
91
109
  : Promise.resolve(null);
92
110
  }
111
+ /**
112
+ * @throws always. Use {@link getHealthElementWithUser} instead.
113
+ */
93
114
  getHealthElement(healthElementId) {
94
115
  throw new Error('Cannot call a method that returns health element without providing a user for de/encryption');
95
116
  }
117
+ /**
118
+ * Retrieves a health element by id and decrypts it.
119
+ * @param user the current user, used for decryption.
120
+ * @param healthElementId the id of the health element to retrieve.
121
+ * @return the decrypted health element.
122
+ */
96
123
  getHealthElementWithUser(user, healthElementId) {
97
124
  return super
98
125
  .getHealthElement(healthElementId)
99
126
  .then((he) => this.decryptWithUser(user, [he]))
100
127
  .then((hes) => hes[0]);
101
128
  }
129
+ /**
130
+ * @throws always. Use {@link getHealthElementsWithUser} instead.
131
+ */
102
132
  getHealthElements(body) {
103
133
  throw new Error('Cannot call a method that returns health elements without providing a user for de/encryption');
104
134
  }
135
+ /**
136
+ * Retrieves multiple health elements by their ids and decrypts them.
137
+ * @param user the current user, used for decryption.
138
+ * @param body the list of health element ids to retrieve.
139
+ * @return the decrypted health elements.
140
+ */
105
141
  getHealthElementsWithUser(user, body) {
106
142
  return super.getHealthElements(body).then((hes) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), hes));
107
143
  }
144
+ /**
145
+ * @throws always.
146
+ */
108
147
  newHealthElementDelegations(healthElementId, body) {
109
148
  throw new Error('Cannot call a method that returns health element without providing a user for de/encryption');
110
149
  }
150
+ /**
151
+ * @throws always. Use {@link findHealthElementsByHCPartyPatientForeignKeysWithUser} instead.
152
+ */
111
153
  findHealthElementsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys) {
112
154
  throw new Error('Cannot call a method that returns health element without providing a user for de/encryption');
113
155
  }
156
+ /**
157
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
158
+ */
114
159
  findHealthElementsByHCPartyPatientForeignKeysWithUser(user, hcPartyId, secretFKeys) {
115
160
  return super.findHealthElementsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys).then((hes) => this.decryptWithUser(user, hes));
116
161
  }
162
+ /**
163
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
164
+ */
117
165
  findHealthElementsByHCPartyPatientForeignKeysArrayWithUser(user, hcPartyId, secretFKeys) {
118
166
  return super.findHealthElementsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys).then((hes) => this.decryptWithUser(user, hes));
119
167
  }
168
+ /**
169
+ * Finds all health elements for a given patient and healthcare party, and decrypts them.
170
+ * @deprecated use {@link findHealthElementIdsByDataOwnerPatientOpeningDate} instead.
171
+ * @param user the current user, used for decryption.
172
+ * @param hcPartyId the id of the healthcare party.
173
+ * @param patient the patient whose health elements to find.
174
+ * @param usingPost if true, uses POST instead of GET for the request.
175
+ * @return the decrypted health elements.
176
+ */
120
177
  findHealthElementsByHCPartyAndPatientWithUser(user_1, hcPartyId_1, patient_1) {
121
178
  return __awaiter(this, arguments, void 0, function* (user, hcPartyId, patient, usingPost = false) {
122
179
  var _a;
@@ -130,9 +187,18 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
130
187
  : this.findHealthElementsByHCPartyPatientForeignKeysWithUser(user, hcPartyId, keys.join(','));
131
188
  });
132
189
  }
190
+ /**
191
+ * @throws always. Use {@link modifyHealthElementWithUser} instead.
192
+ */
133
193
  modifyHealthElement(body) {
134
194
  throw new Error('Cannot call a method that returns health element without providing a user for de/encryption');
135
195
  }
196
+ /**
197
+ * Modifies a health element after encrypting its content.
198
+ * @param user the current user, used for encryption/decryption.
199
+ * @param body the health element with updated fields.
200
+ * @return the modified and decrypted health element, or null if body was not provided.
201
+ */
136
202
  modifyHealthElementWithUser(user, body) {
137
203
  return body ? this.modifyHealthElementAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : Promise.resolve(null);
138
204
  }
@@ -142,9 +208,18 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
142
208
  .then((he) => this.decrypt(dataOwner, [he]))
143
209
  .then((hes) => hes[0]);
144
210
  }
211
+ /**
212
+ * @throws always. Use {@link modifyHealthElementsWithUser} instead.
213
+ */
145
214
  modifyHealthElements(body) {
146
215
  throw new Error('Cannot call a method that returns health elements without providing a user for de/encryption');
147
216
  }
217
+ /**
218
+ * Modifies multiple health elements after encrypting their content.
219
+ * @param user the current user, used for encryption/decryption.
220
+ * @param bodies the health elements with updated fields.
221
+ * @return the modified and decrypted health elements, or null if bodies was not provided.
222
+ */
148
223
  modifyHealthElementsWithUser(user, bodies) {
149
224
  return bodies
150
225
  ? this.encrypt(user, bodies.map((c) => _.cloneDeep(c)))
@@ -242,28 +317,65 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
242
317
  .findHealthElementsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys)
243
318
  .then((helements) => this.decrypt(hcPartyId, helements));
244
319
  }
320
+ /**
321
+ * Encrypts the encrypted fields of a list of health elements.
322
+ * @param user the current user, used to determine the data owner for encryption.
323
+ * @param healthElements the health elements to encrypt.
324
+ * @return the encrypted health elements.
325
+ */
245
326
  encrypt(user, healthElements) {
246
327
  return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), healthElements);
247
328
  }
248
329
  encryptAs(owner, healthElements) {
249
330
  return this.crypto.xapi.tryEncryptEntities(healthElements, utils_1.EntityWithDelegationTypeName.HealthElement, this.encryptedFields, false, false, (x) => new models.HealthElement(x));
250
331
  }
332
+ /**
333
+ * Decrypts a list of health elements using the given user's data owner keys.
334
+ * @param user the current user.
335
+ * @param hes the health elements to decrypt.
336
+ * @return the decrypted health elements.
337
+ */
251
338
  decryptWithUser(user, hes) {
252
339
  return this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), hes);
253
340
  }
341
+ /**
342
+ * Decrypts a list of health elements using the current data owner's keys.
343
+ * @param dataOwnerId the id of the data owner performing the decryption.
344
+ * @param hes the health elements to decrypt.
345
+ * @return the decrypted health elements.
346
+ */
254
347
  decrypt(dataOwnerId, hes) {
255
348
  return __awaiter(this, void 0, void 0, function* () {
256
349
  return (yield this.crypto.xapi.tryDecryptEntities(hes, utils_1.EntityWithDelegationTypeName.HealthElement, (x) => new models.HealthElement(x))).map(({ entity }) => entity);
257
350
  });
258
351
  }
352
+ /**
353
+ * @throws always. Use {@link filterByWithUser} instead.
354
+ */
259
355
  filterHealthElementsBy(startDocumentId, limit, body) {
260
356
  throw new Error('Cannot call a method that returns health elements without providing a user for de/encryption');
261
357
  }
358
+ /**
359
+ * Filters health elements using the provided filter chain and decrypts the results.
360
+ * @param user the current user, used for decryption.
361
+ * @param startDocumentId the pagination start document id.
362
+ * @param limit the maximum number of results to return.
363
+ * @param body the filter chain to apply.
364
+ * @return a paginated list of decrypted health elements.
365
+ */
262
366
  filterByWithUser(user, startDocumentId, limit, body) {
263
367
  return super
264
368
  .filterHealthElementsBy(startDocumentId, limit, body)
265
369
  .then((pl) => this.decryptWithUser(user, pl.rows).then((dr) => Object.assign(pl, { rows: dr })));
266
370
  }
371
+ /**
372
+ * Converts a service into a new health element linked to the given patient.
373
+ * @param user the current user.
374
+ * @param patient the patient to link the health element to.
375
+ * @param heSvc the service to convert.
376
+ * @param descr the description for the new health element.
377
+ * @return the created health element.
378
+ */
267
379
  // noinspection JSUnusedGlobalSymbols
268
380
  serviceToHealthElement(user, patient, heSvc, descr) {
269
381
  return this.newInstance(user, patient, {
@@ -281,6 +393,11 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
281
393
  return this.createHealthElement(he);
282
394
  });
283
395
  }
396
+ /**
397
+ * Parses a pipe-delimited code string into a Code object.
398
+ * @param code the code string in format "type|code|version".
399
+ * @return a Code object with the parsed fields.
400
+ */
284
401
  // noinspection JSUnusedGlobalSymbols, JSMethodCanBeStatic
285
402
  stringToCode(code) {
286
403
  const c = code.split('|');
@@ -386,18 +503,42 @@ class IccHelementXApi extends icc_api_1.IccHelementApi {
386
503
  .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])));
387
504
  });
388
505
  }
506
+ /**
507
+ * Retrieves the data owners that have access to the given health element, along with their access levels.
508
+ * @param entity the health element.
509
+ * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.
510
+ */
389
511
  getDataOwnersWithAccessTo(entity) {
390
512
  return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.HealthElement });
391
513
  }
514
+ /**
515
+ * Retrieves the encryption keys of the given health element.
516
+ * @param entity the health element.
517
+ * @return the encryption key ids.
518
+ */
392
519
  getEncryptionKeysOf(entity) {
393
520
  return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.HealthElement }, undefined);
394
521
  }
522
+ /**
523
+ * Subscribes to real-time health element events using a WebSocket connection. Received events are automatically decrypted.
524
+ * @param eventTypes the types of events to listen for (e.g. 'CREATE', 'UPDATE', 'DELETE').
525
+ * @param filter an optional filter to restrict which health element events trigger the callback.
526
+ * @param eventFired the callback function invoked when a matching health element event is received.
527
+ * @param options optional subscription configuration such as connection parameters and retry behaviour.
528
+ * @return a connection object that can be used to manage the WebSocket subscription lifecycle.
529
+ */
395
530
  subscribeToHealthElementEvents(eventTypes_1, filter_1, eventFired_1) {
396
531
  return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
397
532
  const currentUser = yield this.userApi.getCurrentUser();
398
533
  return yield (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, utils_1.EntityWithDelegationTypeName.HealthElement, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(currentUser), [encrypted]))[0]; })).then((rs) => new Connection_1.ConnectionImpl(rs));
399
534
  });
400
535
  }
536
+ /**
537
+ * Creates or updates de-anonymization metadata for the given health element, allowing the specified delegates to
538
+ * identify the data owners that have access to it.
539
+ * @param entity the health element.
540
+ * @param delegates the data owner ids for which to create de-anonymization metadata.
541
+ */
401
542
  createDelegationDeAnonymizationMetadata(entity, delegates) {
402
543
  return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.HealthElement }, delegates);
403
544
  }