@icure/api 8.0.8 → 8.0.10

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 (270) hide show
  1. package/icc-api/model/models.d.ts +1 -0
  2. package/icc-api/model/models.js +1 -0
  3. package/icc-api/model/models.js.map +1 -1
  4. package/icc-x-api/crypto/BaseExchangeDataManager.js +1 -1
  5. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  6. package/icc-x-api/crypto/BaseExchangeKeysManager.js +7 -3
  7. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
  8. package/icc-x-api/crypto/ExchangeDataManager.js +3 -2
  9. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  10. package/icc-x-api/crypto/KeyRecovery.js +6 -5
  11. package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
  12. package/icc-x-api/crypto/RSA.d.ts +4 -1
  13. package/icc-x-api/crypto/RSA.js +6 -1
  14. package/icc-x-api/crypto/RSA.js.map +1 -1
  15. package/icc-x-api/crypto/SecureDelegationsManager.js +2 -1
  16. package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
  17. package/icc-x-api/crypto/ShamirKeysManager.js +8 -9
  18. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
  19. package/icc-x-api/crypto/TransferKeysManager.js +4 -3
  20. package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
  21. package/icc-x-api/crypto/UserEncryptionKeysManager.js +4 -4
  22. package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
  23. package/icc-x-api/crypto/UserSignatureKeysManager.js +9 -5
  24. package/icc-x-api/crypto/UserSignatureKeysManager.js.map +1 -1
  25. package/icc-x-api/crypto/utils.d.ts +13 -4
  26. package/icc-x-api/crypto/utils.js +27 -9
  27. package/icc-x-api/crypto/utils.js.map +1 -1
  28. package/icc-x-api/icc-accesslog-x-api.js +16 -14
  29. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  30. package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -2
  31. package/icc-x-api/icc-calendar-item-x-api.js +17 -17
  32. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  33. package/icc-x-api/icc-classification-x-api.js +12 -11
  34. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  35. package/icc-x-api/icc-contact-x-api.d.ts +2 -2
  36. package/icc-x-api/icc-contact-x-api.js +23 -20
  37. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  38. package/icc-x-api/icc-data-owner-x-api.js +1 -1
  39. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  40. package/icc-x-api/icc-document-x-api.js +17 -16
  41. package/icc-x-api/icc-document-x-api.js.map +1 -1
  42. package/icc-x-api/icc-form-x-api.js +13 -12
  43. package/icc-x-api/icc-form-x-api.js.map +1 -1
  44. package/icc-x-api/icc-helement-x-api.js +18 -16
  45. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  46. package/icc-x-api/icc-icure-maintenance-x-api.js +4 -3
  47. package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
  48. package/icc-x-api/icc-invoice-x-api.js +12 -11
  49. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  50. package/icc-x-api/icc-maintenance-task-x-api.js +11 -11
  51. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  52. package/icc-x-api/icc-message-x-api.js +14 -14
  53. package/icc-x-api/icc-message-x-api.js.map +1 -1
  54. package/icc-x-api/icc-patient-x-api.js +28 -27
  55. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  56. package/icc-x-api/icc-receipt-x-api.js +11 -10
  57. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  58. package/icc-x-api/icc-recovery-x-api.js +3 -2
  59. package/icc-x-api/icc-recovery-x-api.js.map +1 -1
  60. package/icc-x-api/icc-time-table-x-api.js +9 -8
  61. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  62. package/icc-x-api/icc-topic-x-api.js +13 -13
  63. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  64. package/icc-x-api/storage/IcureStorageFacade.js +4 -1
  65. package/icc-x-api/storage/IcureStorageFacade.js.map +1 -1
  66. package/icc-x-api/utils/EntityWithDelegationTypeName.d.ts +17 -1
  67. package/icc-x-api/utils/EntityWithDelegationTypeName.js +33 -15
  68. package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -1
  69. package/package.json +1 -1
  70. package/test/icc-api/api/IccAnonymousAccessApi.d.ts +1 -0
  71. package/test/icc-api/api/IccAnonymousAccessApi.js +58 -0
  72. package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -0
  73. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  74. package/test/icc-api/api/IccDocumentApi.js +208 -0
  75. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  76. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  77. package/test/icc-api/api/IccGroupApi.js +50 -0
  78. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  79. package/test/icc-api/api/IccRecoveryDataApi.d.ts +1 -0
  80. package/test/icc-api/api/IccRecoveryDataApi.js +95 -0
  81. package/test/icc-api/api/IccRecoveryDataApi.js.map +1 -0
  82. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  83. package/test/icc-api/api/IccRoleApi.js +34 -0
  84. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  85. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  86. package/test/icc-api/api/IccUserApi.js +96 -0
  87. package/test/icc-api/api/IccUserApi.js.map +1 -0
  88. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  89. package/test/icc-api/e2e/IccCalendarItemApi.js +46 -0
  90. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  91. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  92. package/test/icc-api/model/modelHelpersTest.js +45 -0
  93. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  94. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  95. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  96. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  97. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  98. package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
  99. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  100. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  101. package/test/icc-x-api/auth/smart-auth-provider-test.js +224 -0
  102. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  103. package/test/icc-x-api/autofix-anonymity-test.d.ts +1 -0
  104. package/test/icc-x-api/autofix-anonymity-test.js +108 -0
  105. package/test/icc-x-api/autofix-anonymity-test.js.map +1 -0
  106. package/test/icc-x-api/confidential-entities-test.d.ts +1 -0
  107. package/test/icc-x-api/confidential-entities-test.js +110 -0
  108. package/test/icc-x-api/confidential-entities-test.js.map +1 -0
  109. package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +1 -0
  110. package/test/icc-x-api/crud/comprehensive-crud-test.js +276 -0
  111. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -0
  112. package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +16 -0
  113. package/test/icc-x-api/crud/entities-crud-test-interface.js +422 -0
  114. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -0
  115. package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +1 -0
  116. package/test/icc-x-api/crypto/anonymous-delegations-test.js +588 -0
  117. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -0
  118. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  119. package/test/icc-x-api/crypto/concurrency.js +35 -0
  120. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  121. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  122. package/test/icc-x-api/crypto/crypto-utils.js +80 -0
  123. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  124. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  125. package/test/icc-x-api/crypto/cryptoTest.js +302 -0
  126. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  127. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  128. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +166 -0
  129. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  130. package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +1 -0
  131. package/test/icc-x-api/crypto/exchange-data-manager-test.js +690 -0
  132. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -0
  133. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  134. package/test/icc-x-api/crypto/full-crypto-test.js +457 -0
  135. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  136. package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +1 -0
  137. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +266 -0
  138. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -0
  139. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.d.ts +1 -0
  140. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js +393 -0
  141. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js.map +1 -0
  142. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.d.ts +1 -0
  143. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js +213 -0
  144. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js.map +1 -0
  145. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  146. package/test/icc-x-api/crypto/shamir.js +166 -0
  147. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  148. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  149. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +71 -0
  150. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  151. package/test/icc-x-api/crypto/signature-keys-manager-test.d.ts +1 -0
  152. package/test/icc-x-api/crypto/signature-keys-manager-test.js +44 -0
  153. package/test/icc-x-api/crypto/signature-keys-manager-test.js.map +1 -0
  154. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +1 -0
  155. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +246 -0
  156. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -0
  157. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  158. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  159. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  160. package/test/icc-x-api/filters/filters.d.ts +1 -0
  161. package/test/icc-x-api/filters/filters.js +49 -0
  162. package/test/icc-x-api/filters/filters.js.map +1 -0
  163. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  164. package/test/icc-x-api/icc-accesslog-x-api.js +106 -0
  165. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  166. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  167. package/test/icc-x-api/icc-auth-api.js +47 -0
  168. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  169. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  170. package/test/icc-x-api/icc-calendar-item-x-api.js +150 -0
  171. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  172. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  173. package/test/icc-x-api/icc-contact-x-api.js +279 -0
  174. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  175. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  176. package/test/icc-x-api/icc-form-x-api.js +98 -0
  177. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  178. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  179. package/test/icc-x-api/icc-helement-x-api-test.js +153 -0
  180. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  181. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  182. package/test/icc-x-api/icc-invoice-x-api.js +99 -0
  183. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  184. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  185. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +221 -0
  186. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  187. package/test/icc-x-api/icc-message-x-api.d.ts +1 -0
  188. package/test/icc-x-api/icc-message-x-api.js +328 -0
  189. package/test/icc-x-api/icc-message-x-api.js.map +1 -0
  190. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  191. package/test/icc-x-api/icc-patient-x-api-test.js +158 -0
  192. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  193. package/test/icc-x-api/icc-recovery-x-api.d.ts +1 -0
  194. package/test/icc-x-api/icc-recovery-x-api.js +170 -0
  195. package/test/icc-x-api/icc-recovery-x-api.js.map +1 -0
  196. package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
  197. package/test/icc-x-api/icc-time-table-x-api.js +100 -0
  198. package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
  199. package/test/icc-x-api/icc-topic-x-api.d.ts +1 -0
  200. package/test/icc-x-api/icc-topic-x-api.js +269 -0
  201. package/test/icc-x-api/icc-topic-x-api.js.map +1 -0
  202. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  203. package/test/icc-x-api/icc-user-x-api-test.js +99 -0
  204. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  205. package/test/icc-x-api/patient-user.d.ts +2 -0
  206. package/test/icc-x-api/patient-user.js +104 -0
  207. package/test/icc-x-api/patient-user.js.map +1 -0
  208. package/test/icc-x-api/storage/storage.d.ts +1 -0
  209. package/test/icc-x-api/storage/storage.js +48 -0
  210. package/test/icc-x-api/storage/storage.js.map +1 -0
  211. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  212. package/test/icc-x-api/test-api-no-parent.js +79 -0
  213. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  214. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  215. package/test/icc-x-api/test-legacy-data-support.js +376 -0
  216. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  217. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  218. package/test/icc-x-api/utils/graph-test.js +54 -0
  219. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  220. package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +1 -0
  221. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +364 -0
  222. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +1 -0
  223. package/test/support/CSM-185.d.ts +1 -0
  224. package/test/support/CSM-185.js +124 -0
  225. package/test/support/CSM-185.js.map +1 -0
  226. package/test/support/CSM-243.d.ts +1 -0
  227. package/test/support/CSM-243.js +120 -0
  228. package/test/support/CSM-243.js.map +1 -0
  229. package/test/support/CSM-87.d.ts +0 -0
  230. package/test/support/CSM-87.js +21 -0
  231. package/test/support/CSM-87.js.map +1 -0
  232. package/test/support/CSM-93.d.ts +1 -0
  233. package/test/support/CSM-93.js +112 -0
  234. package/test/support/CSM-93.js.map +1 -0
  235. package/test/utils/FakeDataOwnerApi.d.ts +32 -0
  236. package/test/utils/FakeDataOwnerApi.js +136 -0
  237. package/test/utils/FakeDataOwnerApi.js.map +1 -0
  238. package/test/utils/FakeEncryptionKeysManager.d.ts +35 -0
  239. package/test/utils/FakeEncryptionKeysManager.js +87 -0
  240. package/test/utils/FakeEncryptionKeysManager.js.map +1 -0
  241. package/test/utils/FakeExchangeDataApi.d.ts +30 -0
  242. package/test/utils/FakeExchangeDataApi.js +74 -0
  243. package/test/utils/FakeExchangeDataApi.js.map +1 -0
  244. package/test/utils/FakeExchangeDataManager.d.ts +40 -0
  245. package/test/utils/FakeExchangeDataManager.js +89 -0
  246. package/test/utils/FakeExchangeDataManager.js.map +1 -0
  247. package/test/utils/FakeExchangeDataMapManager.d.ts +12 -0
  248. package/test/utils/FakeExchangeDataMapManager.js +38 -0
  249. package/test/utils/FakeExchangeDataMapManager.js.map +1 -0
  250. package/test/utils/FakeGenericApi.d.ts +16 -0
  251. package/test/utils/FakeGenericApi.js +65 -0
  252. package/test/utils/FakeGenericApi.js.map +1 -0
  253. package/test/utils/FakeSignatureKeysManager.d.ts +16 -0
  254. package/test/utils/FakeSignatureKeysManager.js +54 -0
  255. package/test/utils/FakeSignatureKeysManager.js.map +1 -0
  256. package/test/utils/TestApi.d.ts +3 -0
  257. package/test/utils/TestApi.js +30 -0
  258. package/test/utils/TestApi.js.map +1 -0
  259. package/test/utils/TestCollectionUtils.d.ts +1 -0
  260. package/test/utils/TestCollectionUtils.js +109 -0
  261. package/test/utils/TestCollectionUtils.js.map +1 -0
  262. package/test/utils/TestCryptoStrategies.d.ts +42 -0
  263. package/test/utils/TestCryptoStrategies.js +80 -0
  264. package/test/utils/TestCryptoStrategies.js.map +1 -0
  265. package/test/utils/TestStorage.d.ts +23 -0
  266. package/test/utils/TestStorage.js +61 -0
  267. package/test/utils/TestStorage.js.map +1 -0
  268. package/test/utils/test_utils.d.ts +76 -0
  269. package/test/utils/test_utils.js +419 -0
  270. package/test/utils/test_utils.js.map +1 -0
@@ -0,0 +1,279 @@
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 icc_x_api_1 = require("../../icc-x-api");
15
+ const Patient_1 = require("../../icc-api/model/Patient");
16
+ const chai_1 = require("chai");
17
+ const crypto_1 = require("crypto");
18
+ const test_utils_1 = require("../utils/test_utils");
19
+ const Code_1 = require("../../icc-api/model/Code");
20
+ const Contact_1 = require("../../icc-api/model/Contact");
21
+ const Service_1 = require("../../icc-api/model/Service");
22
+ const Content_1 = require("../../icc-api/model/Content");
23
+ const HealthElement_1 = require("../../icc-api/model/HealthElement");
24
+ const SubContact_1 = require("../../icc-api/model/SubContact");
25
+ const ServiceLink_1 = require("../../icc-api/model/ServiceLink");
26
+ const FilterChainService_1 = require("../../icc-api/model/FilterChainService");
27
+ const ServiceByHcPartyHealthElementIdsFilter_1 = require("../../icc-x-api/filters/ServiceByHcPartyHealthElementIdsFilter");
28
+ const types_1 = require("@icure/test-setup/types");
29
+ const Measure_1 = require("../../icc-api/model/Measure");
30
+ var initApi = test_utils_1.TestUtils.initApi;
31
+ (0, test_utils_1.setLocalStorage)(fetch);
32
+ let env;
33
+ (0, mocha_1.before)(function () {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ this.timeout(600000);
36
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
37
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
38
+ });
39
+ });
40
+ function createPatient(patientApiForHcp, hcpUser) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
43
+ id: (0, crypto_1.randomUUID)(),
44
+ firstName: 'John',
45
+ lastName: 'Snow',
46
+ note: 'Winter is coming',
47
+ })));
48
+ });
49
+ }
50
+ function createHealthElement(healthElementApi, hcpUser, patient) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ return healthElementApi.createHealthElementWithUser(hcpUser, yield healthElementApi.newInstance(hcpUser, patient, new HealthElement_1.HealthElement({
53
+ id: (0, crypto_1.randomUUID)(),
54
+ note: 'My secret note',
55
+ tags: [
56
+ new Code_1.Code({
57
+ id: 'ICURE|MY-CODE|1',
58
+ code: 'MY-CODE',
59
+ type: 'ICURE',
60
+ version: '1',
61
+ }),
62
+ ],
63
+ }), { confidential: true }));
64
+ });
65
+ }
66
+ function createBasicContact(contactApiForHcp, hcpUser, patient) {
67
+ return contactApiForHcp.newInstance(hcpUser, patient, new Contact_1.Contact({
68
+ id: (0, crypto_1.randomUUID)(),
69
+ services: [
70
+ contactApiForHcp.service().newInstance(hcpUser, new Service_1.Service({
71
+ id: (0, crypto_1.randomUUID)(),
72
+ valueDate: 20220203111034,
73
+ content: { en: new Content_1.Content({ numberValue: 53.5 }) },
74
+ tags: [
75
+ new Code_1.Code({
76
+ id: 'LOINC|29463-7|2',
77
+ code: '29463-7',
78
+ type: 'LOINC',
79
+ version: '2',
80
+ }),
81
+ ],
82
+ })),
83
+ ],
84
+ descr: 'Weight value',
85
+ }), { confidential: true });
86
+ }
87
+ describe('icc-x-contact-api Tests', () => {
88
+ it('CreateContactWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
89
+ // Given
90
+ const { userApi: userApiForHcp, patientApi: patientApiForHcp, contactApi: contactApiForHcp, cryptoApi } = yield initApi(env, test_utils_1.hcp1Username);
91
+ const hcpUser = yield userApiForHcp.getCurrentUser();
92
+ const patient = yield createPatient(patientApiForHcp, hcpUser);
93
+ const contactToCreate = yield createBasicContact(contactApiForHcp, hcpUser, patient);
94
+ // When
95
+ const createdContact = (yield contactApiForHcp.createContactWithUser(hcpUser, contactToCreate));
96
+ // Then
97
+ const readContact = yield contactApiForHcp.getContactWithUser(hcpUser, createdContact.id);
98
+ (0, chai_1.expect)(readContact).to.not.be.undefined;
99
+ (0, chai_1.expect)(readContact).to.not.be.null;
100
+ (0, chai_1.expect)(readContact.openingDate).to.not.be.undefined;
101
+ (0, chai_1.expect)(readContact.openingDate).to.not.be.null;
102
+ (0, chai_1.expect)(readContact.groupId).to.not.be.undefined;
103
+ (0, chai_1.expect)(readContact.groupId).to.not.be.null;
104
+ (0, chai_1.expect)(readContact.responsible).to.be.equal(hcpUser.healthcarePartyId);
105
+ (0, chai_1.expect)(readContact.id).to.be.equal(contactToCreate.id);
106
+ (0, chai_1.expect)(readContact.descr).to.be.equal(contactToCreate.descr);
107
+ (0, chai_1.expect)(readContact.services[0].responsible).to.be.equal(hcpUser.healthcarePartyId);
108
+ (0, chai_1.expect)(readContact.services[0].id).to.be.equal(contactToCreate.services[0].id);
109
+ (0, chai_1.expect)(readContact.services[0].valueDate).to.be.equal(contactToCreate.services[0].valueDate);
110
+ (0, chai_1.expect)(readContact.services[0].tags[0].id).to.be.equal(contactToCreate.services[0].tags[0].id);
111
+ (0, chai_1.expect)(yield cryptoApi.xapi.encryptionKeysOf({ entity: readContact, type: icc_x_api_1.EntityWithDelegationTypeName.Contact }, undefined)).to.have.length(1);
112
+ const decryptedPatientIds = yield contactApiForHcp.decryptPatientIdOf(readContact);
113
+ (0, chai_1.expect)(decryptedPatientIds).to.have.length(1);
114
+ (0, chai_1.expect)(decryptedPatientIds[0]).to.equal(patient.id);
115
+ }));
116
+ it('Filter Services By HealthElementId - Success', () => __awaiter(void 0, void 0, void 0, function* () {
117
+ // Given
118
+ const { userApi: userApiForHcp, patientApi: patientApiForHcp, contactApi: contactApiForHcp, healthcareElementApi: hElementApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
119
+ const hcpUser = yield userApiForHcp.getCurrentUser();
120
+ const patient = yield createPatient(patientApiForHcp, hcpUser);
121
+ const healthElement = yield createHealthElement(hElementApiForHcp, hcpUser, patient);
122
+ const contactToCreate = yield createBasicContact(contactApiForHcp, hcpUser, patient).then((contact) => {
123
+ return Object.assign(Object.assign({}, contact), { subContacts: [
124
+ new SubContact_1.SubContact({
125
+ id: (0, crypto_1.randomUUID)(),
126
+ healthElementId: healthElement.id,
127
+ services: [new ServiceLink_1.ServiceLink({ serviceId: contact.services[0].id })],
128
+ }),
129
+ ] });
130
+ });
131
+ const createdContact = (yield contactApiForHcp.createContactWithUser(hcpUser, new Contact_1.Contact(contactToCreate)));
132
+ (0, chai_1.assert)(createdContact != null);
133
+ // When
134
+ const foundServices = yield contactApiForHcp.filterServicesBy(undefined, undefined, new FilterChainService_1.FilterChainService({
135
+ filter: new ServiceByHcPartyHealthElementIdsFilter_1.ServiceByHcPartyHealthElementIdsFilter({
136
+ healthcarePartyId: hcpUser.healthcarePartyId,
137
+ healthElementIds: [healthElement.id],
138
+ }),
139
+ }));
140
+ // Then
141
+ (0, chai_1.assert)(foundServices.rows.length == 1);
142
+ (0, chai_1.assert)(foundServices.rows[0].id == createdContact.services[0].id);
143
+ (0, chai_1.assert)(foundServices.rows[0].healthElementsIds.find((heId) => heId == healthElement.id) != undefined);
144
+ }));
145
+ it('contacts findBy for HCP GET and POSt', () => __awaiter(void 0, void 0, void 0, function* () {
146
+ // Given
147
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, contactApi: contactApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
148
+ const hcpUser = yield userApiForHcp.getCurrentUser();
149
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
150
+ const healthElement = yield createHealthElement(hElementApiForHcp, hcpUser, patient);
151
+ const contactToCreate = yield createBasicContact(contactApiForHcp, hcpUser, patient).then((contact) => {
152
+ return Object.assign(Object.assign({}, contact), { subContacts: [
153
+ new SubContact_1.SubContact({
154
+ id: (0, crypto_1.randomUUID)(),
155
+ healthElementId: healthElement.id,
156
+ services: [new ServiceLink_1.ServiceLink({ serviceId: contact.services[0].id })],
157
+ }),
158
+ ] });
159
+ });
160
+ const createdContact = (yield contactApiForHcp.createContactWithUser(hcpUser, contactToCreate));
161
+ // When
162
+ const foundContats = yield contactApiForHcp.findBy(hcpUser.healthcarePartyId, patient, false);
163
+ const foundContatsUsingPost = yield contactApiForHcp.findBy(hcpUser.healthcarePartyId, patient, true);
164
+ // Then
165
+ (0, chai_1.assert)(foundContats.length == 1, 'Found items should be 1');
166
+ (0, chai_1.assert)(foundContats[0].id == contactToCreate.id, 'Found item should be the same as the created one');
167
+ (0, chai_1.assert)(foundContatsUsingPost.length == 1, 'Found items using post should be 1');
168
+ (0, chai_1.assert)(foundContatsUsingPost[0].id == createdContact.id, 'Found item using post should be the same as the created one');
169
+ }));
170
+ it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
171
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
172
+ const user1 = yield api1.userApi.getCurrentUser();
173
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
174
+ const user2 = yield api2.userApi.getCurrentUser();
175
+ const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
176
+ const encryptedField = 'Something encrypted';
177
+ const entity = yield api1.calendarItemApi.createCalendarItemWithHcParty(user1, yield api1.calendarItemApi.newInstancePatient(user1, samplePatient, { details: encryptedField }));
178
+ (0, chai_1.expect)(entity.details).to.be.equal(encryptedField);
179
+ yield api2.calendarItemApi
180
+ .getCalendarItemWithUser(user2, entity.id)
181
+ .then(() => {
182
+ throw new Error('Should not be able to get the entity');
183
+ })
184
+ .catch(() => {
185
+ /* expected */
186
+ });
187
+ yield api1.calendarItemApi.shareWith(user2.healthcarePartyId, entity);
188
+ const retrieved = yield api2.calendarItemApi.getCalendarItemWithUser(user2, entity.id);
189
+ (0, chai_1.expect)(retrieved.details).to.be.equal(encryptedField);
190
+ (0, chai_1.expect)((yield api2.calendarItemApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
191
+ }));
192
+ it('Instanciation of old Measure should be mapped to new Measure with referenceRange', () => {
193
+ const oldMeasure = {
194
+ min: 0,
195
+ max: 10,
196
+ };
197
+ const newMeasure = new Measure_1.Measure(Object.assign({}, oldMeasure));
198
+ (0, chai_1.expect)(newMeasure.referenceRange).to.not.be.undefined;
199
+ (0, chai_1.expect)(newMeasure.referenceRange).to.not.undefined;
200
+ (0, chai_1.expect)(newMeasure.referenceRange).to.have.length(1);
201
+ (0, chai_1.expect)(newMeasure.referenceRange[0].low).to.be.equal(oldMeasure.min);
202
+ (0, chai_1.expect)(newMeasure.referenceRange[0].high).to.be.equal(oldMeasure.max);
203
+ (0, chai_1.expect)(Object.keys(newMeasure)).to.not.contain('min');
204
+ (0, chai_1.expect)(Object.keys(newMeasure)).to.not.contain('max');
205
+ });
206
+ it('Instanciation of Service with old Measure should be mapped to new Measure with referenceRange', () => {
207
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
208
+ const serviceJson = {
209
+ id: 'serviceId',
210
+ valueDate: 20220203111034,
211
+ content: {
212
+ en: {
213
+ numberValue: 53.5,
214
+ measureValue: {
215
+ min: 0,
216
+ max: 10,
217
+ },
218
+ },
219
+ },
220
+ tags: [
221
+ {
222
+ id: 'LOINC|29463-7|2',
223
+ code: '29463-7',
224
+ type: 'LOINC',
225
+ version: '2',
226
+ },
227
+ ],
228
+ };
229
+ const service = new Service_1.Service(JSON.parse(JSON.stringify(serviceJson)));
230
+ (0, chai_1.expect)((_b = (_a = service.content) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.measureValue).to.not.be.undefined;
231
+ (0, chai_1.expect)((_e = (_d = (_c = service.content) === null || _c === void 0 ? void 0 : _c.en) === null || _d === void 0 ? void 0 : _d.measureValue) === null || _e === void 0 ? void 0 : _e.referenceRange).to.not.be.undefined;
232
+ (0, chai_1.expect)((_h = (_g = (_f = service.content) === null || _f === void 0 ? void 0 : _f.en) === null || _g === void 0 ? void 0 : _g.measureValue) === null || _h === void 0 ? void 0 : _h.referenceRange).to.have.length(1);
233
+ (0, chai_1.expect)((_l = (_k = (_j = service.content) === null || _j === void 0 ? void 0 : _j.en) === null || _k === void 0 ? void 0 : _k.measureValue) === null || _l === void 0 ? void 0 : _l.referenceRange[0].low).to.be.equal(serviceJson.content.en.measureValue.min);
234
+ (0, chai_1.expect)((_p = (_o = (_m = service.content) === null || _m === void 0 ? void 0 : _m.en) === null || _o === void 0 ? void 0 : _o.measureValue) === null || _p === void 0 ? void 0 : _p.referenceRange[0].high).to.be.equal(serviceJson.content.en.measureValue.max);
235
+ (0, chai_1.expect)(Object.keys((_r = (_q = service.content) === null || _q === void 0 ? void 0 : _q.en) === null || _r === void 0 ? void 0 : _r.measureValue)).to.not.contain('min');
236
+ (0, chai_1.expect)(Object.keys((_t = (_s = service.content) === null || _s === void 0 ? void 0 : _s.en) === null || _t === void 0 ? void 0 : _t.measureValue)).to.not.contain('max');
237
+ });
238
+ it('Instanciation of Contact with old Measure should be mapped to new Measure with referenceRange', () => {
239
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
240
+ const contactJson = {
241
+ id: 'contactId',
242
+ services: [
243
+ {
244
+ id: 'serviceId',
245
+ valueDate: 20220203111034,
246
+ content: {
247
+ en: {
248
+ numberValue: 53.5,
249
+ measureValue: {
250
+ min: 0,
251
+ max: 10,
252
+ },
253
+ },
254
+ },
255
+ tags: [
256
+ {
257
+ id: 'LOINC|29463-7|2',
258
+ code: '29463-7',
259
+ type: 'LOINC',
260
+ version: '2',
261
+ },
262
+ ],
263
+ },
264
+ ],
265
+ descr: 'Weight value',
266
+ };
267
+ const contact = new Contact_1.Contact(JSON.parse(JSON.stringify(contactJson)));
268
+ (0, chai_1.expect)(contact.services).to.not.be.undefined;
269
+ (0, chai_1.expect)(contact.services).to.have.length(1);
270
+ (0, chai_1.expect)((_b = (_a = contact.services[0].content) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.measureValue).to.not.be.undefined;
271
+ (0, chai_1.expect)((_e = (_d = (_c = contact.services[0].content) === null || _c === void 0 ? void 0 : _c.en) === null || _d === void 0 ? void 0 : _d.measureValue) === null || _e === void 0 ? void 0 : _e.referenceRange).to.not.be.undefined;
272
+ (0, chai_1.expect)((_h = (_g = (_f = contact.services[0].content) === null || _f === void 0 ? void 0 : _f.en) === null || _g === void 0 ? void 0 : _g.measureValue) === null || _h === void 0 ? void 0 : _h.referenceRange).to.have.length(1);
273
+ (0, chai_1.expect)((_l = (_k = (_j = contact.services[0].content) === null || _j === void 0 ? void 0 : _j.en) === null || _k === void 0 ? void 0 : _k.measureValue) === null || _l === void 0 ? void 0 : _l.referenceRange[0].low).to.be.equal(contactJson.services[0].content.en.measureValue.min);
274
+ (0, chai_1.expect)((_p = (_o = (_m = contact.services[0].content) === null || _m === void 0 ? void 0 : _m.en) === null || _o === void 0 ? void 0 : _o.measureValue) === null || _p === void 0 ? void 0 : _p.referenceRange[0].high).to.be.equal(contactJson.services[0].content.en.measureValue.max);
275
+ (0, chai_1.expect)(Object.keys((_r = (_q = contact.services[0].content) === null || _q === void 0 ? void 0 : _q.en) === null || _r === void 0 ? void 0 : _r.measureValue)).to.not.contain('min');
276
+ (0, chai_1.expect)(Object.keys((_t = (_s = contact.services[0].content) === null || _s === void 0 ? void 0 : _s.en) === null || _t === void 0 ? void 0 : _t.measureValue)).to.not.contain('max');
277
+ });
278
+ });
279
+ //# sourceMappingURL=icc-contact-x-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icc-contact-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-contact-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAE9B,4BAAyB;AAEzB,+CAA+G;AAC/G,yDAAqD;AACrD,+BAAqC;AACrC,mCAAmC;AACnC,oDAAuH;AACvH,mDAA+C;AAC/C,yDAAqD;AACrD,yDAAqD;AACrD,yDAAqD;AAErD,qEAAiE;AACjE,+DAA2D;AAC3D,iEAA6D;AAC7D,+EAA2E;AAC3E,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,CAAC,CAAC,OAAO,0CAAE,EAAE,0CAAE,YAAY,0CAAE,cAAc,CAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QAEhJ,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,CAAC,MAAA,MAAA,OAAO,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,OAAO,0CAAE,EAAE,0CAAE,YAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1F,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,CAAC,MAAA,MAAA,OAAO,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,OAAO,0CAAE,EAAE,0CAAE,YAAa,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC5F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { before } from 'mocha'\n\nimport 'isomorphic-fetch'\n\nimport { EntityWithDelegationTypeName, IccContactXApi, 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 { Code } from '../../icc-api/model/Code'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { Service } from '../../icc-api/model/Service'\nimport { Content } from '../../icc-api/model/Content'\nimport { User } from '../../icc-api/model/User'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { SubContact } from '../../icc-api/model/SubContact'\nimport { ServiceLink } from '../../icc-api/model/ServiceLink'\nimport { FilterChainService } from '../../icc-api/model/FilterChainService'\nimport { ServiceByHcPartyHealthElementIdsFilter } from '../../icc-x-api/filters/ServiceByHcPartyHealthElementIdsFilter'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { Measure } from '../../icc-api/model/Measure'\nimport initApi = TestUtils.initApi\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nbefore(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n})\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\nasync function createHealthElement(healthElementApi: IccHelementXApi, hcpUser: User, patient: Patient) {\n return healthElementApi.createHealthElementWithUser(\n hcpUser,\n await healthElementApi.newInstance(\n hcpUser,\n patient,\n new HealthElement({\n id: randomUUID(),\n note: 'My secret note',\n tags: [\n new Code({\n id: 'ICURE|MY-CODE|1',\n code: 'MY-CODE',\n type: 'ICURE',\n version: '1',\n }),\n ],\n }),\n { confidential: true }\n )\n )\n}\n\nfunction createBasicContact(contactApiForHcp: IccContactXApi, hcpUser: User, patient: Patient) {\n return contactApiForHcp.newInstance(\n hcpUser,\n patient,\n new Contact({\n id: randomUUID(),\n services: [\n contactApiForHcp.service().newInstance(\n hcpUser,\n new Service({\n id: randomUUID(),\n valueDate: 20220203111034,\n content: { en: new Content({ numberValue: 53.5 }) },\n tags: [\n new Code({\n id: 'LOINC|29463-7|2',\n code: '29463-7',\n type: 'LOINC',\n version: '2',\n }),\n ],\n })\n ),\n ],\n descr: 'Weight value',\n }),\n { confidential: true }\n )\n}\n\ndescribe('icc-x-contact-api Tests', () => {\n it('CreateContactWithUser Success for HCP', async () => {\n // Given\n const { userApi: userApiForHcp, patientApi: patientApiForHcp, contactApi: contactApiForHcp, cryptoApi } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = await createPatient(patientApiForHcp, hcpUser)\n const contactToCreate = await createBasicContact(contactApiForHcp, hcpUser, patient)\n\n // When\n const createdContact = (await contactApiForHcp.createContactWithUser(hcpUser, contactToCreate)) as Contact\n\n // Then\n const readContact = await contactApiForHcp.getContactWithUser(hcpUser, createdContact.id!)\n expect(readContact).to.not.be.undefined\n expect(readContact).to.not.be.null\n expect(readContact.openingDate).to.not.be.undefined\n expect(readContact.openingDate).to.not.be.null\n expect(readContact.groupId).to.not.be.undefined\n expect(readContact.groupId).to.not.be.null\n expect(readContact.responsible).to.be.equal(hcpUser.healthcarePartyId)\n expect(readContact.id).to.be.equal(contactToCreate.id)\n expect(readContact.descr).to.be.equal(contactToCreate.descr)\n expect(readContact.services![0].responsible).to.be.equal(hcpUser.healthcarePartyId)\n expect(readContact.services![0].id).to.be.equal(contactToCreate.services![0].id)\n expect(readContact.services![0].valueDate).to.be.equal(contactToCreate.services![0].valueDate)\n expect(readContact.services![0].tags![0].id).to.be.equal(contactToCreate.services![0].tags![0].id!)\n expect(await cryptoApi.xapi.encryptionKeysOf({ entity: readContact, type: EntityWithDelegationTypeName.Contact }, undefined)).to.have.length(1)\n const decryptedPatientIds = await contactApiForHcp.decryptPatientIdOf(readContact)\n expect(decryptedPatientIds).to.have.length(1)\n expect(decryptedPatientIds[0]).to.equal(patient.id)\n })\n\n it('Filter Services By HealthElementId - Success', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n patientApi: patientApiForHcp,\n contactApi: contactApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = await createPatient(patientApiForHcp, hcpUser)\n const healthElement = await createHealthElement(hElementApiForHcp, hcpUser, patient)\n const contactToCreate = await createBasicContact(contactApiForHcp, hcpUser, patient).then((contact) => {\n return {\n ...contact,\n subContacts: [\n new SubContact({\n id: randomUUID(),\n healthElementId: healthElement!.id!,\n services: [new ServiceLink({ serviceId: contact.services![0].id })],\n }),\n ],\n }\n })\n\n const createdContact = (await contactApiForHcp.createContactWithUser(hcpUser, new Contact(contactToCreate))) as Contact\n assert(createdContact != null)\n\n // When\n const foundServices = await contactApiForHcp.filterServicesBy(\n undefined,\n undefined,\n new FilterChainService({\n filter: new ServiceByHcPartyHealthElementIdsFilter({\n healthcarePartyId: hcpUser.healthcarePartyId!,\n healthElementIds: [healthElement!.id!],\n }),\n })\n )\n\n // Then\n assert(foundServices.rows!.length == 1)\n assert(foundServices.rows![0].id == createdContact.services![0].id)\n assert(foundServices.rows![0].healthElementsIds!.find((heId) => heId == healthElement!.id!) != undefined)\n })\n\n it('contacts findBy for HCP GET and POSt', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n contactApi: contactApiForHcp,\n healthcareElementApi: hElementApiForHcp,\n cryptoApi: cryptoApiForHcp,\n } = await initApi(env, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n const healthElement = await createHealthElement(hElementApiForHcp, hcpUser, patient)\n const contactToCreate = await createBasicContact(contactApiForHcp, hcpUser, patient).then((contact) => {\n return {\n ...contact,\n subContacts: [\n new SubContact({\n id: randomUUID(),\n healthElementId: healthElement!.id!,\n services: [new ServiceLink({ serviceId: contact.services![0].id })],\n }),\n ],\n }\n })\n\n const createdContact = (await contactApiForHcp.createContactWithUser(hcpUser, contactToCreate)) as Contact\n\n // When\n const foundContats = await contactApiForHcp.findBy(hcpUser.healthcarePartyId!, patient, false)\n const foundContatsUsingPost = await contactApiForHcp.findBy(hcpUser.healthcarePartyId!, patient, true)\n\n // Then\n assert(foundContats.length == 1, 'Found items should be 1')\n assert(foundContats[0].id == contactToCreate.id, 'Found item should be the same as the created one')\n\n assert(foundContatsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundContatsUsingPost[0].id == createdContact.id, 'Found item using post should be the same as 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 encryptedField = 'Something encrypted'\n const entity = await api1.calendarItemApi.createCalendarItemWithHcParty(\n user1,\n await api1.calendarItemApi.newInstancePatient(user1, samplePatient, { details: encryptedField })\n )\n expect(entity.details).to.be.equal(encryptedField)\n await api2.calendarItemApi\n .getCalendarItemWithUser(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.calendarItemApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.calendarItemApi.getCalendarItemWithUser(user2, entity.id)\n expect(retrieved.details).to.be.equal(encryptedField)\n expect((await api2.calendarItemApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('Instanciation of old Measure should be mapped to new Measure with referenceRange', () => {\n const oldMeasure = {\n min: 0,\n max: 10,\n }\n\n const newMeasure = new Measure({ ...oldMeasure })\n\n expect(newMeasure.referenceRange).to.not.be.undefined\n expect(newMeasure.referenceRange).to.not.undefined\n expect(newMeasure.referenceRange).to.have.length(1)\n expect(newMeasure.referenceRange![0].low).to.be.equal(oldMeasure.min)\n expect(newMeasure.referenceRange![0].high).to.be.equal(oldMeasure.max)\n\n expect(Object.keys(newMeasure)).to.not.contain('min')\n expect(Object.keys(newMeasure)).to.not.contain('max')\n })\n\n it('Instanciation of Service with old Measure should be mapped to new Measure with referenceRange', () => {\n const serviceJson = {\n id: 'serviceId',\n valueDate: 20220203111034,\n content: {\n en: {\n numberValue: 53.5,\n measureValue: {\n min: 0,\n max: 10,\n },\n },\n },\n tags: [\n {\n id: 'LOINC|29463-7|2',\n code: '29463-7',\n type: 'LOINC',\n version: '2',\n },\n ],\n }\n\n const service = new Service(JSON.parse(JSON.stringify(serviceJson)))\n\n expect(service.content?.en?.measureValue).to.not.be.undefined\n expect(service.content?.en?.measureValue?.referenceRange).to.not.be.undefined\n expect(service.content?.en?.measureValue?.referenceRange).to.have.length(1)\n expect(service.content?.en?.measureValue?.referenceRange![0].low).to.be.equal(serviceJson.content.en.measureValue.min)\n expect(service.content?.en?.measureValue?.referenceRange![0].high).to.be.equal(serviceJson.content.en.measureValue.max)\n\n expect(Object.keys(service.content?.en?.measureValue!)).to.not.contain('min')\n expect(Object.keys(service.content?.en?.measureValue!)).to.not.contain('max')\n })\n\n it('Instanciation of Contact with old Measure should be mapped to new Measure with referenceRange', () => {\n const contactJson = {\n id: 'contactId',\n services: [\n {\n id: 'serviceId',\n valueDate: 20220203111034,\n content: {\n en: {\n numberValue: 53.5,\n measureValue: {\n min: 0,\n max: 10,\n },\n },\n },\n tags: [\n {\n id: 'LOINC|29463-7|2',\n code: '29463-7',\n type: 'LOINC',\n version: '2',\n },\n ],\n },\n ],\n descr: 'Weight value',\n }\n\n const contact = new Contact(JSON.parse(JSON.stringify(contactJson)))\n\n expect(contact.services).to.not.be.undefined\n expect(contact.services).to.have.length(1)\n expect(contact.services![0].content?.en?.measureValue).to.not.be.undefined\n expect(contact.services![0].content?.en?.measureValue?.referenceRange).to.not.be.undefined\n expect(contact.services![0].content?.en?.measureValue?.referenceRange).to.have.length(1)\n expect(contact.services![0].content?.en?.measureValue?.referenceRange![0].low).to.be.equal(contactJson.services[0].content.en.measureValue.min)\n expect(contact.services![0].content?.en?.measureValue?.referenceRange![0].high).to.be.equal(contactJson.services[0].content.en.measureValue.max)\n\n expect(Object.keys(contact.services![0].content?.en?.measureValue!)).to.not.contain('min')\n expect(Object.keys(contact.services![0].content?.en?.measureValue!)).to.not.contain('max')\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,98 @@
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 icc_api_1 = require("../../icc-api");
17
+ const Patient_1 = require("../../icc-api/model/Patient");
18
+ const crypto_1 = require("crypto");
19
+ const Form_1 = require("../../icc-api/model/Form");
20
+ const chai_1 = require("chai");
21
+ var initApi = test_utils_1.TestUtils.initApi;
22
+ const types_1 = require("@icure/test-setup/types");
23
+ const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
24
+ (0, test_utils_1.setLocalStorage)(fetch);
25
+ let env;
26
+ describe('icc-calendar-item-x-api Tests', () => {
27
+ (0, mocha_1.before)(function () {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ this.timeout(600000);
30
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
31
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
32
+ });
33
+ });
34
+ function createPatient(patientApiForHcp, hcpUser) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
37
+ id: (0, crypto_1.randomUUID)(),
38
+ firstName: 'John',
39
+ lastName: 'Snow',
40
+ note: 'Winter is coming',
41
+ })));
42
+ });
43
+ }
44
+ it('Test', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ // Given
46
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
47
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
48
+ const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
49
+ const userApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, authProvider, null, fetch);
50
+ const formApi = new icc_api_1.IccFormApi(env.iCureUrl, {}, authProvider, fetch);
51
+ const currentUser = yield userApi.getCurrentUser();
52
+ }));
53
+ it('Test findBy', () => __awaiter(void 0, void 0, void 0, function* () {
54
+ // Given
55
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, cryptoApi: cryptoApiForHcp, dataOwnerApi: dateOwnerApiForHcp, formApi: formXApi, } = yield initApi(env, test_utils_1.hcp1Username);
56
+ const hcpUser = yield userApiForHcp.getCurrentUser();
57
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
58
+ const form = new Form_1.Form({
59
+ id: (0, crypto_1.randomUUID)(),
60
+ created: new Date().getTime(),
61
+ modified: new Date().getTime(),
62
+ responsible: hcpUser.healthcarePartyId,
63
+ author: hcpUser.id,
64
+ codes: [],
65
+ tags: [],
66
+ user: hcpUser.id,
67
+ patient: patient.id,
68
+ });
69
+ const formToCreate = yield formXApi.newInstance(hcpUser, patient, form);
70
+ const createdForm = yield formXApi.createForm(formToCreate);
71
+ const foundItems = (yield formXApi.findBy(hcpUser.healthcarePartyId, patient, false));
72
+ const foundItemsUsingPost = (yield formXApi.findBy(hcpUser.healthcarePartyId, patient, true));
73
+ (0, chai_1.assert)(foundItems.length == 1, 'Found items should be 1');
74
+ (0, chai_1.assert)(foundItems[0].id == createdForm.id, 'Found item should be the created one');
75
+ (0, chai_1.assert)(foundItemsUsingPost.length == 1, 'Found items using post should be 1');
76
+ (0, chai_1.assert)(foundItemsUsingPost[0].id == createdForm.id, 'Found item using post should be the created one');
77
+ }));
78
+ it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
79
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
80
+ const user1 = yield api1.userApi.getCurrentUser();
81
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
82
+ const user2 = yield api2.userApi.getCurrentUser();
83
+ const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
84
+ const entity = yield api1.formApi.createForm(yield api1.formApi.newInstance(user1, samplePatient));
85
+ yield api2.formApi
86
+ .getForm(entity.id)
87
+ .then(() => {
88
+ throw new Error('Should not be able to get the entity');
89
+ })
90
+ .catch(() => {
91
+ /* expected */
92
+ });
93
+ yield api1.formApi.shareWith(user2.healthcarePartyId, entity);
94
+ const retrieved = yield api2.formApi.getForm(entity.id);
95
+ (0, chai_1.expect)((yield api2.formApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
96
+ }));
97
+ });
98
+ //# sourceMappingURL=icc-form-x-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icc-form-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-form-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAuH;AACvH,iCAA8B;AAC9B,+CAA6D;AAC7D,2CAA0C;AAC1C,yDAAqD;AAErD,mCAAmC;AACnC,mDAA+C;AAC/C,+BAAqC;AACrC,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AACnE,wFAAyF;AAEzF,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,IAAA,cAAM,EAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,G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C,iBAAkB,EAAE,MAAM,CAAC,CAAA;QAC9D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAG,CAAC,CAAA;QACxD,IAAA,aAAM,EAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC1F,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 { IccPatientXApi, IccUserXApi } from '../../icc-x-api'\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 { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\n\nsetLocalStorage(fetch)\nlet env: TestVars\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 formApi: formXApi,\n } = await initApi(env, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\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"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,153 @@
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 icc_x_api_1 = require("../../icc-x-api");
15
+ const Patient_1 = require("../../icc-api/model/Patient");
16
+ const chai_1 = require("chai");
17
+ const crypto_1 = require("crypto");
18
+ const test_utils_1 = require("../utils/test_utils");
19
+ const HealthElement_1 = require("../../icc-api/model/HealthElement");
20
+ const Code_1 = require("../../icc-api/model/Code");
21
+ const types_1 = require("@icure/test-setup/types");
22
+ const HealthElementByIdsFilter_1 = require("../../icc-x-api/filters/HealthElementByIdsFilter");
23
+ const FilterChainHealthElement_1 = require("../../icc-api/model/FilterChainHealthElement");
24
+ var initApi = test_utils_1.TestUtils.initApi;
25
+ (0, test_utils_1.setLocalStorage)(fetch);
26
+ let env;
27
+ function createPatient(patientApiForHcp, hcpUser) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
30
+ id: (0, crypto_1.randomUUID)(),
31
+ firstName: 'John',
32
+ lastName: 'Snow',
33
+ note: 'Winter is coming',
34
+ })));
35
+ });
36
+ }
37
+ function healthElementToCreate(hElementApiForHcp, hcpUser, patient) {
38
+ return hElementApiForHcp.newInstance(hcpUser, patient, new HealthElement_1.HealthElement({
39
+ id: (0, crypto_1.randomUUID)(),
40
+ codes: [new Code_1.Code({ system: 'LOINC', code: '95209', version: '3' })],
41
+ note: 'SARS-V2',
42
+ }), { confidential: true });
43
+ }
44
+ describe('icc-helement-x-api Tests', () => {
45
+ (0, mocha_1.before)(function () {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ this.timeout(600000);
48
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
49
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
50
+ });
51
+ });
52
+ it('CreateHealthElementWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
53
+ // Given
54
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
55
+ const hcpUser = yield userApiForHcp.getCurrentUser();
56
+ const patient = yield createPatient(patientApiForHcp, hcpUser);
57
+ const hElementToCreate = yield healthElementToCreate(hElementApiForHcp, hcpUser, patient);
58
+ // When
59
+ const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, hElementToCreate);
60
+ // Then
61
+ const readHealthElement = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
62
+ (0, chai_1.assert)(readHealthElement != null);
63
+ (0, chai_1.assert)(readHealthElement.id != null);
64
+ (0, chai_1.assert)(readHealthElement.note == hElementToCreate.note);
65
+ (0, chai_1.expect)(yield cryptoApiForHcp.xapi.encryptionKeysOf({ entity: readHealthElement, type: icc_x_api_1.EntityWithDelegationTypeName.HealthElement }, undefined)).to.have.length(1);
66
+ const decryptedPatientIds = yield hElementApiForHcp.decryptPatientIdOf(readHealthElement);
67
+ (0, chai_1.expect)(decryptedPatientIds).to.have.length(1);
68
+ (0, chai_1.expect)(decryptedPatientIds[0]).to.equal(patient.id);
69
+ }));
70
+ it('ModifyHealthElementWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
71
+ // Given
72
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
73
+ const hcpUser = yield userApiForHcp.getCurrentUser();
74
+ yield initApi(env, test_utils_1.hcp1Username);
75
+ const patient = yield createPatient(patientApiForHcp, hcpUser);
76
+ const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
77
+ // When
78
+ const newNote = 'SARS-V2 (COVID-19)';
79
+ const modifiedHealthElement = yield hElementApiForHcp.modifyHealthElementWithUser(hcpUser, Object.assign(Object.assign({}, createdHealthElement), { note: newNote }));
80
+ // Then
81
+ const readHealthElement = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
82
+ (0, chai_1.assert)(readHealthElement != null);
83
+ (0, chai_1.assert)(readHealthElement.id != null);
84
+ (0, chai_1.assert)(readHealthElement.note != createdHealthElement.note);
85
+ (0, chai_1.assert)(readHealthElement.note == modifiedHealthElement.note);
86
+ (0, chai_1.assert)(readHealthElement.note == newNote);
87
+ (0, chai_1.expect)(yield cryptoApiForHcp.xapi.encryptionKeysOf({ entity: readHealthElement, type: icc_x_api_1.EntityWithDelegationTypeName.HealthElement }, undefined)).to.have.length(1);
88
+ const decryptedPatientIds = yield hElementApiForHcp.decryptPatientIdOf(readHealthElement);
89
+ (0, chai_1.expect)(decryptedPatientIds).to.have.length(1);
90
+ (0, chai_1.expect)(decryptedPatientIds[0]).to.equal(patient.id);
91
+ }));
92
+ it('findHealthElementsByHCPartyAndPatientWithUser Success for HCP', () => __awaiter(void 0, void 0, void 0, function* () {
93
+ // Given
94
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
95
+ const hcpUser = yield userApiForHcp.getCurrentUser();
96
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
97
+ const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
98
+ // When
99
+ const foundHealthElements = yield hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(hcpUser, hcpUser.healthcarePartyId, patient);
100
+ const foundHealthElementsUsingPost = yield hElementApiForHcp.findHealthElementsByHCPartyAndPatientWithUser(hcpUser, hcpUser.healthcarePartyId, patient, true);
101
+ // Then
102
+ (0, chai_1.assert)(foundHealthElements.length == 1, 'Found health elements should be 1');
103
+ (0, chai_1.assert)(foundHealthElements[0].id == createdHealthElement.id, 'Found health element should be the same as the created one');
104
+ (0, chai_1.assert)(foundHealthElementsUsingPost.length == 1, 'Found health elements using POST should be 1');
105
+ (0, chai_1.assert)(foundHealthElementsUsingPost[0].id == createdHealthElement.id, 'Found health element using POST should be the same as the created one');
106
+ }));
107
+ it('filter healthcare element result should return same output by id', () => __awaiter(void 0, void 0, void 0, function* () {
108
+ var _a;
109
+ // Given
110
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, healthcareElementApi: hElementApiForHcp, cryptoApi: cryptoApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
111
+ const hcpUser = yield userApiForHcp.getCurrentUser();
112
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
113
+ const createdHealthElement = yield hElementApiForHcp.createHealthElementWithUser(hcpUser, yield healthElementToCreate(hElementApiForHcp, hcpUser, patient));
114
+ // When
115
+ const healthElementById = yield hElementApiForHcp.getHealthElementWithUser(hcpUser, createdHealthElement.id);
116
+ const healthElementByFilter = yield hElementApiForHcp.filterByWithUser(hcpUser, undefined, undefined, new FilterChainHealthElement_1.FilterChainHealthElement({
117
+ filter: new HealthElementByIdsFilter_1.HealthElementByIdsFilter({
118
+ ids: [createdHealthElement.id],
119
+ healthcarePartyId: hcpUser.healthcarePartyId,
120
+ }),
121
+ }));
122
+ // Then
123
+ // expect(foundHealthElements).to.have.length(1)
124
+ // expect(foundHealthElements[0].id).to.equal(createdHealthElement.id)
125
+ (0, chai_1.assert)(((_a = healthElementByFilter.rows) === null || _a === void 0 ? void 0 : _a.length) == 1, 'Found health elements should be 1');
126
+ (0, chai_1.assert)(healthElementByFilter.rows[0].id == createdHealthElement.id, 'Found health element should be the same as the created one');
127
+ (0, chai_1.assert)(!!healthElementById.note, 'Health element should have a note');
128
+ (0, chai_1.assert)(JSON.stringify(healthElementByFilter.rows[0]) === JSON.stringify(healthElementById), 'Found health elements by id should match the one found by filter');
129
+ }));
130
+ it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
131
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
132
+ const user1 = yield api1.userApi.getCurrentUser();
133
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
134
+ const user2 = yield api2.userApi.getCurrentUser();
135
+ const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
136
+ const encryptedField = 'Something encrypted';
137
+ const entity = yield api1.healthcareElementApi.createHealthElementWithUser(user1, yield api1.healthcareElementApi.newInstance(user1, samplePatient, { note: encryptedField }));
138
+ (0, chai_1.expect)(entity.note).to.be.equal(encryptedField);
139
+ yield api2.healthcareElementApi
140
+ .getHealthElementWithUser(user2, entity.id)
141
+ .then(() => {
142
+ throw new Error('Should not be able to get the entity');
143
+ })
144
+ .catch(() => {
145
+ /* expected */
146
+ });
147
+ yield api1.healthcareElementApi.shareWith(user2.healthcarePartyId, entity);
148
+ const retrieved = yield api2.healthcareElementApi.getHealthElementWithUser(user2, entity.id);
149
+ (0, chai_1.expect)(retrieved.note).to.be.equal(encryptedField);
150
+ (0, chai_1.expect)((yield api2.healthcareElementApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
151
+ }));
152
+ });
153
+ //# sourceMappingURL=icc-helement-x-api-test.js.map