@icure/api 8.6.18 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccDocumentApi.d.ts +10 -2
- package/icc-api/api/IccDocumentApi.js +22 -4
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +17 -0
- package/icc-api/api/IccReceiptApi.js +52 -0
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/model/DataAttachment.d.ts +22 -0
- package/icc-api/model/DataAttachment.js.map +1 -1
- package/icc-api/model/Document.d.ts +6 -0
- package/icc-api/model/Document.js.map +1 -1
- package/icc-api/model/Receipt.d.ts +6 -0
- package/icc-api/model/Receipt.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeDataManager.js +2 -2
- package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/ExchangeDataManager.js +3 -3
- package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.d.ts +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +8 -2
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +7 -7
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.js +7 -7
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +4 -5
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-code-x-api.d.ts +2 -2
- package/icc-x-api/icc-code-x-api.js +3 -33
- package/icc-x-api/icc-code-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.js +20 -33
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +8 -7
- package/icc-x-api/icc-document-x-api.js +64 -22
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +3 -4
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.js +11 -11
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +3 -4
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +3 -3
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +29 -29
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +40 -0
- package/icc-x-api/icc-receipt-x-api.js +79 -1
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/index.js +1 -1
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/code-util.d.ts +23 -0
- package/icc-x-api/utils/code-util.js +39 -2
- package/icc-x-api/utils/code-util.js.map +1 -1
- package/icc-x-api/utils/collection-utils.d.ts +13 -0
- package/icc-x-api/utils/collection-utils.js +69 -0
- package/icc-x-api/utils/collection-utils.js.map +1 -1
- package/icc-x-api/utils/compression-utils.d.ts +28 -0
- package/icc-x-api/utils/compression-utils.js +106 -0
- package/icc-x-api/utils/compression-utils.js.map +1 -0
- package/icc-x-api/utils/crypto-utils.js +7 -7
- package/icc-x-api/utils/crypto-utils.js.map +1 -1
- package/icc-x-api/utils/formatting-util.d.ts +1 -3
- package/icc-x-api/utils/formatting-util.js +15 -17
- package/icc-x-api/utils/formatting-util.js.map +1 -1
- package/icc-x-api/utils/hcp-util.js +2 -3
- package/icc-x-api/utils/hcp-util.js.map +1 -1
- package/icc-x-api/utils/insurability-util.js +10 -8
- package/icc-x-api/utils/insurability-util.js.map +1 -1
- package/icc-x-api/utils/lzma-wasm.d.ts +6 -0
- package/icc-x-api/utils/lzma-wasm.js +81 -0
- package/icc-x-api/utils/lzma-wasm.js.map +1 -0
- package/icc-x-api/utils/mutex.d.ts +12 -0
- package/icc-x-api/utils/mutex.js +26 -0
- package/icc-x-api/utils/mutex.js.map +1 -0
- package/icc-x-api/utils/websocket.js +7 -7
- package/icc-x-api/utils/websocket.js.map +1 -1
- package/icc-x-api/wasm/lzma/lzma.js +2 -0
- package/icc-x-api/wasm/lzma/lzma.wasm +0 -0
- package/package.json +2 -11
- package/icc-x-api/utils/uuid-encoder.d.ts +0 -44
- package/icc-x-api/utils/uuid-encoder.js +0 -114
- package/icc-x-api/utils/uuid-encoder.js.map +0 -1
- package/test/icc-api/api/IccAgendaApi.d.ts +0 -1
- package/test/icc-api/api/IccAgendaApi.js +0 -64
- package/test/icc-api/api/IccAgendaApi.js.map +0 -1
- package/test/icc-api/api/IccAnonymousAccessApi.d.ts +0 -1
- package/test/icc-api/api/IccAnonymousAccessApi.js +0 -58
- package/test/icc-api/api/IccAnonymousAccessApi.js.map +0 -1
- package/test/icc-api/api/IccCalendarItemApi.d.ts +0 -1
- package/test/icc-api/api/IccCalendarItemApi.js +0 -67
- package/test/icc-api/api/IccCalendarItemApi.js.map +0 -1
- package/test/icc-api/api/IccCalendarItemTypeApi.d.ts +0 -1
- package/test/icc-api/api/IccCalendarItemTypeApi.js +0 -96
- package/test/icc-api/api/IccCalendarItemTypeApi.js.map +0 -1
- package/test/icc-api/api/IccCodeApi.d.ts +0 -1
- package/test/icc-api/api/IccCodeApi.js +0 -38
- package/test/icc-api/api/IccCodeApi.js.map +0 -1
- package/test/icc-api/api/IccDocumentApi.d.ts +0 -1
- package/test/icc-api/api/IccDocumentApi.js +0 -199
- package/test/icc-api/api/IccDocumentApi.js.map +0 -1
- package/test/icc-api/api/IccGroupApi.d.ts +0 -1
- package/test/icc-api/api/IccGroupApi.js +0 -50
- package/test/icc-api/api/IccGroupApi.js.map +0 -1
- package/test/icc-api/api/IccKeywordApi.d.ts +0 -1
- package/test/icc-api/api/IccKeywordApi.js +0 -64
- package/test/icc-api/api/IccKeywordApi.js.map +0 -1
- package/test/icc-api/api/IccMedicalLocationApi.d.ts +0 -1
- package/test/icc-api/api/IccMedicalLocationApi.js +0 -64
- package/test/icc-api/api/IccMedicalLocationApi.js.map +0 -1
- package/test/icc-api/api/IccPlaceApi.d.ts +0 -1
- package/test/icc-api/api/IccPlaceApi.js +0 -64
- package/test/icc-api/api/IccPlaceApi.js.map +0 -1
- package/test/icc-api/api/IccRecoveryDataApi.d.ts +0 -1
- package/test/icc-api/api/IccRecoveryDataApi.js +0 -95
- package/test/icc-api/api/IccRecoveryDataApi.js.map +0 -1
- package/test/icc-api/api/IccRoleApi.d.ts +0 -1
- package/test/icc-api/api/IccRoleApi.js +0 -34
- package/test/icc-api/api/IccRoleApi.js.map +0 -1
- package/test/icc-api/api/IccUserApi.d.ts +0 -1
- package/test/icc-api/api/IccUserApi.js +0 -96
- package/test/icc-api/api/IccUserApi.js.map +0 -1
- package/test/icc-api/e2e/IccCalendarItemApi.d.ts +0 -1
- package/test/icc-api/e2e/IccCalendarItemApi.js +0 -46
- package/test/icc-api/e2e/IccCalendarItemApi.js.map +0 -1
- package/test/icc-api/model/modelHelpersTest.d.ts +0 -1
- package/test/icc-api/model/modelHelpersTest.js +0 -45
- package/test/icc-api/model/modelHelpersTest.js.map +0 -1
- package/test/icc-x-api/auth/group-switch-test.d.ts +0 -1
- package/test/icc-x-api/auth/group-switch-test.js +0 -81
- package/test/icc-x-api/auth/group-switch-test.js.map +0 -1
- package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +0 -2
- package/test/icc-x-api/auth/jwt-concurrency-test.js +0 -112
- package/test/icc-x-api/auth/jwt-concurrency-test.js.map +0 -1
- package/test/icc-x-api/auth/jwt-provider-test.d.ts +0 -1
- package/test/icc-x-api/auth/jwt-provider-test.js +0 -197
- package/test/icc-x-api/auth/jwt-provider-test.js.map +0 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +0 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.js +0 -224
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +0 -1
- package/test/icc-x-api/autofix-anonymity-test.d.ts +0 -1
- package/test/icc-x-api/autofix-anonymity-test.js +0 -122
- package/test/icc-x-api/autofix-anonymity-test.js.map +0 -1
- package/test/icc-x-api/confidential-entities-test.d.ts +0 -1
- package/test/icc-x-api/confidential-entities-test.js +0 -168
- package/test/icc-x-api/confidential-entities-test.js.map +0 -1
- package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +0 -1
- package/test/icc-x-api/crud/comprehensive-crud-test.js +0 -276
- package/test/icc-x-api/crud/comprehensive-crud-test.js.map +0 -1
- package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +0 -16
- package/test/icc-x-api/crud/entities-crud-test-interface.js +0 -408
- package/test/icc-x-api/crud/entities-crud-test-interface.js.map +0 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +0 -1
- package/test/icc-x-api/crypto/anonymous-delegations-test.js +0 -587
- package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +0 -1
- package/test/icc-x-api/crypto/concurrency.d.ts +0 -1
- package/test/icc-x-api/crypto/concurrency.js +0 -35
- package/test/icc-x-api/crypto/concurrency.js.map +0 -1
- package/test/icc-x-api/crypto/crypto-utils.d.ts +0 -1
- package/test/icc-x-api/crypto/crypto-utils.js +0 -79
- package/test/icc-x-api/crypto/crypto-utils.js.map +0 -1
- package/test/icc-x-api/crypto/cryptoTest.d.ts +0 -2
- package/test/icc-x-api/crypto/cryptoTest.js +0 -402
- package/test/icc-x-api/crypto/cryptoTest.js.map +0 -1
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +0 -1
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +0 -166
- package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +0 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.js +0 -674
- package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +0 -1
- package/test/icc-x-api/crypto/full-crypto-test.d.ts +0 -1
- package/test/icc-x-api/crypto/full-crypto-test.js +0 -454
- package/test/icc-x-api/crypto/full-crypto-test.js.map +0 -1
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.d.ts +0 -1
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +0 -379
- package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +0 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js +0 -278
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +0 -1
- package/test/icc-x-api/crypto/shamir.d.ts +0 -2
- package/test/icc-x-api/crypto/shamir.js +0 -167
- package/test/icc-x-api/crypto/shamir.js.map +0 -1
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +0 -1
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +0 -71
- package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +0 -1
- package/test/icc-x-api/crypto/soft-deleted-data-owners.d.ts +0 -2
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js +0 -113
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +0 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +0 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +0 -246
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +0 -1
- package/test/icc-x-api/entity-with-attachments-api-test.d.ts +0 -1
- package/test/icc-x-api/entity-with-attachments-api-test.js +0 -142
- package/test/icc-x-api/entity-with-attachments-api-test.js.map +0 -1
- package/test/icc-x-api/filters/filters.d.ts +0 -1
- package/test/icc-x-api/filters/filters.js +0 -49
- package/test/icc-x-api/filters/filters.js.map +0 -1
- package/test/icc-x-api/filters/healthelement.d.ts +0 -1
- package/test/icc-x-api/filters/healthelement.js +0 -333
- package/test/icc-x-api/filters/healthelement.js.map +0 -1
- package/test/icc-x-api/icc-accesslog-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-accesslog-x-api.js +0 -106
- package/test/icc-x-api/icc-accesslog-x-api.js.map +0 -1
- package/test/icc-x-api/icc-application-settings-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-application-settings-x-api.js +0 -91
- package/test/icc-x-api/icc-application-settings-x-api.js.map +0 -1
- package/test/icc-x-api/icc-auth-api.d.ts +0 -1
- package/test/icc-x-api/icc-auth-api.js +0 -47
- package/test/icc-x-api/icc-auth-api.js.map +0 -1
- package/test/icc-x-api/icc-calendar-item-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-calendar-item-x-api.js +0 -150
- package/test/icc-x-api/icc-calendar-item-x-api.js.map +0 -1
- package/test/icc-x-api/icc-contact-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-contact-x-api.js +0 -355
- package/test/icc-x-api/icc-contact-x-api.js.map +0 -1
- package/test/icc-x-api/icc-document-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-document-x-api.js +0 -76
- package/test/icc-x-api/icc-document-x-api.js.map +0 -1
- package/test/icc-x-api/icc-form-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-form-x-api.js +0 -413
- package/test/icc-x-api/icc-form-x-api.js.map +0 -1
- package/test/icc-x-api/icc-hcparty-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-hcparty-x-api-test.js +0 -43
- package/test/icc-x-api/icc-hcparty-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-helement-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-helement-x-api-test.js +0 -155
- package/test/icc-x-api/icc-helement-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-invoice-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-invoice-x-api.js +0 -99
- package/test/icc-x-api/icc-invoice-x-api.js.map +0 -1
- package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js +0 -222
- package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-message-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-message-x-api.js +0 -54
- package/test/icc-x-api/icc-message-x-api.js.map +0 -1
- package/test/icc-x-api/icc-patient-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-patient-x-api-test.js +0 -165
- package/test/icc-x-api/icc-patient-x-api-test.js.map +0 -1
- package/test/icc-x-api/icc-recovery-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-recovery-x-api.js +0 -175
- package/test/icc-x-api/icc-recovery-x-api.js.map +0 -1
- package/test/icc-x-api/icc-topic-x-api.d.ts +0 -1
- package/test/icc-x-api/icc-topic-x-api.js +0 -269
- package/test/icc-x-api/icc-topic-x-api.js.map +0 -1
- package/test/icc-x-api/icc-user-x-api-test.d.ts +0 -1
- package/test/icc-x-api/icc-user-x-api-test.js +0 -99
- package/test/icc-x-api/icc-user-x-api-test.js.map +0 -1
- package/test/icc-x-api/keyless-api.d.ts +0 -1
- package/test/icc-x-api/keyless-api.js +0 -125
- package/test/icc-x-api/keyless-api.js.map +0 -1
- package/test/icc-x-api/patient-user.d.ts +0 -2
- package/test/icc-x-api/patient-user.js +0 -103
- package/test/icc-x-api/patient-user.js.map +0 -1
- package/test/icc-x-api/storage/storage.d.ts +0 -1
- package/test/icc-x-api/storage/storage.js +0 -48
- package/test/icc-x-api/storage/storage.js.map +0 -1
- package/test/icc-x-api/test-api-no-parent.d.ts +0 -1
- package/test/icc-x-api/test-api-no-parent.js +0 -79
- package/test/icc-x-api/test-api-no-parent.js.map +0 -1
- package/test/icc-x-api/test-legacy-data-support.d.ts +0 -1
- package/test/icc-x-api/test-legacy-data-support.js +0 -375
- package/test/icc-x-api/test-legacy-data-support.js.map +0 -1
- package/test/icc-x-api/utils/graph-test.d.ts +0 -1
- package/test/icc-x-api/utils/graph-test.js +0 -54
- package/test/icc-x-api/utils/graph-test.js.map +0 -1
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +0 -1
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +0 -364
- package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +0 -1
- package/test/support/CSM-185.d.ts +0 -1
- package/test/support/CSM-185.js +0 -124
- package/test/support/CSM-185.js.map +0 -1
- package/test/support/CSM-243.d.ts +0 -1
- package/test/support/CSM-243.js +0 -120
- package/test/support/CSM-243.js.map +0 -1
- package/test/support/CSM-543.d.ts +0 -1
- package/test/support/CSM-543.js +0 -164
- package/test/support/CSM-543.js.map +0 -1
- package/test/support/CSM-729.d.ts +0 -1
- package/test/support/CSM-729.js +0 -225
- package/test/support/CSM-729.js.map +0 -1
- package/test/support/CSM-87.d.ts +0 -0
- package/test/support/CSM-87.js +0 -21
- package/test/support/CSM-87.js.map +0 -1
- package/test/support/CSM-93.d.ts +0 -1
- package/test/support/CSM-93.js +0 -112
- package/test/support/CSM-93.js.map +0 -1
- package/test/utils/FakeDataOwnerApi.d.ts +0 -32
- package/test/utils/FakeDataOwnerApi.js +0 -136
- package/test/utils/FakeDataOwnerApi.js.map +0 -1
- package/test/utils/FakeEncryptionKeysManager.d.ts +0 -36
- package/test/utils/FakeEncryptionKeysManager.js +0 -98
- package/test/utils/FakeEncryptionKeysManager.js.map +0 -1
- package/test/utils/FakeExchangeDataApi.d.ts +0 -32
- package/test/utils/FakeExchangeDataApi.js +0 -92
- package/test/utils/FakeExchangeDataApi.js.map +0 -1
- package/test/utils/FakeExchangeDataManager.d.ts +0 -48
- package/test/utils/FakeExchangeDataManager.js +0 -82
- package/test/utils/FakeExchangeDataManager.js.map +0 -1
- package/test/utils/FakeExchangeDataMapManager.d.ts +0 -12
- package/test/utils/FakeExchangeDataMapManager.js +0 -38
- package/test/utils/FakeExchangeDataMapManager.js.map +0 -1
- package/test/utils/FakeGenericApi.d.ts +0 -16
- package/test/utils/FakeGenericApi.js +0 -65
- package/test/utils/FakeGenericApi.js.map +0 -1
- package/test/utils/KeylessCryptoStrategies.d.ts +0 -23
- package/test/utils/KeylessCryptoStrategies.js +0 -26
- package/test/utils/KeylessCryptoStrategies.js.map +0 -1
- package/test/utils/TestApi.d.ts +0 -3
- package/test/utils/TestApi.js +0 -30
- package/test/utils/TestApi.js.map +0 -1
- package/test/utils/TestCollectionUtils.d.ts +0 -1
- package/test/utils/TestCollectionUtils.js +0 -109
- package/test/utils/TestCollectionUtils.js.map +0 -1
- package/test/utils/TestCryptoStrategies.d.ts +0 -42
- package/test/utils/TestCryptoStrategies.js +0 -80
- package/test/utils/TestCryptoStrategies.js.map +0 -1
- package/test/utils/TestStorage.d.ts +0 -23
- package/test/utils/TestStorage.js +0 -61
- package/test/utils/TestStorage.js.map +0 -1
- package/test/utils/roles.d.ts +0 -14
- package/test/utils/roles.js +0 -345
- package/test/utils/roles.js.map +0 -1
- package/test/utils/test_utils.d.ts +0 -87
- package/test/utils/test_utils.js +0 -452
- package/test/utils/test_utils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;AACtD,kEAA8D;AAE9D,MAAa,qBAAsB,SAAQ,8BAAoB;IAI7D,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,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AC,CAAC,CACxC,CAAA;QACH,CAAC;KAAA;IAED;;;;OAIG;IACH,yBAAyB,CACvB,MAA6B;QAE7B,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,CAAC,CAAA;IACxI,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,MAA6B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAA;IACpH,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAA6B,EAAE,SAAmB;QACxF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAC7D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAnRD,sDAmRC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { EntityWithDelegationTypeName } from './utils'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Classification))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(moment().format('YYYYMMDDHHmmss')),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n classification,\n EntityWithDelegationTypeName.Classification,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @deprecated use {@link findIdsBy} instead.\n */\n async findBy(hcpartyId: string, patient: models.Patient) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as {@link findBy} but it will only return the ids of the classifications. It can also filter the classifications where\n * Classification.created is between startDate and endDate in ascending or descending order by that field (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationIdsByDataOwnerPatientCreated(topmostParentId, _.uniq(extractedKeys), startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the classification.\n * @param classification the classification to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n classification,\n EntityWithDelegationTypeName.Classification\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Classification,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareClassifications(x)\n )\n }\n\n /**\n * Retrieves the data owners that have access to the given classification, along with their access levels.\n * @param entity the classification.\n * @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.\n */\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Retrieves the encryption keys of the given classification.\n * @param entity the classification.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given classification, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the classification.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.Classification },\n delegates\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,uCAA+C;AAE/C,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;AACtD,kEAA8D;AAE9D,MAAa,qBAAsB,SAAQ,8BAAoB;IAI7D,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,cAAc,CAAC,CAAC,CAAA;IACpJ,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EACb,cAA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,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,CAAC,CAAA;IACxI,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,MAA6B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAA;IACpH,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAA6B,EAAE,SAAmB;QACxF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAC7D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAnRD,sDAmRC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport { format as formatDate } from 'date-fns'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { EntityWithDelegationTypeName } from './utils'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Classification))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(formatDate(new Date(), 'yyyyMMddHHmmss')),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n classification,\n EntityWithDelegationTypeName.Classification,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @deprecated use {@link findIdsBy} instead.\n */\n async findBy(hcpartyId: string, patient: models.Patient) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, [...new Set(extractedKeys)].join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as {@link findBy} but it will only return the ids of the classifications. It can also filter the classifications where\n * Classification.created is between startDate and endDate in ascending or descending order by that field (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationIdsByDataOwnerPatientCreated(topmostParentId, [...new Set(extractedKeys)], startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the classification.\n * @param classification the classification to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n classification,\n EntityWithDelegationTypeName.Classification\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Classification,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareClassifications(x)\n )\n }\n\n /**\n * Retrieves the data owners that have access to the given classification, along with their access levels.\n * @param entity the classification.\n * @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.\n */\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Retrieves the encryption keys of the given classification.\n * @param entity the classification.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given classification, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the classification.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.Classification },\n delegates\n )\n }\n}\n"]}
|
|
@@ -13,13 +13,13 @@ export declare class IccCodeXApi extends IccCodeApi {
|
|
|
13
13
|
* @param listOfCodes an array of ICD-10 code strings to classify into chapters.
|
|
14
14
|
* @return a sorted array of chapter objects, each containing a code, description, and list of matching sub-codes.
|
|
15
15
|
*/
|
|
16
|
-
icdChapters(listOfCodes: Array<string>): Promise<
|
|
16
|
+
icdChapters(listOfCodes: Array<string>): Promise<import("./utils").CodeChapter[]>;
|
|
17
17
|
/**
|
|
18
18
|
* Groups a list of ICPC-2 codes by their corresponding ICPC-2 chapter.
|
|
19
19
|
* @param listOfCodes an array of ICPC-2 code strings to classify into chapters.
|
|
20
20
|
* @return a sorted array of chapter objects, each containing a code, description, and list of matching sub-codes.
|
|
21
21
|
*/
|
|
22
|
-
icpcChapters(listOfCodes: Array<string>): Promise<
|
|
22
|
+
icpcChapters(listOfCodes: Array<string>): Promise<import("./utils").CodeChapter[]>;
|
|
23
23
|
/**
|
|
24
24
|
* Returns the appropriate language code for a given code type. Falls back to French ('fr') if the
|
|
25
25
|
* requested language is not available for the specified type.
|
|
@@ -5,7 +5,7 @@ const icc_api_1 = require("../icc-api");
|
|
|
5
5
|
const codelng_1 = require("./rsrc/codelng");
|
|
6
6
|
const icd10_1 = require("./rsrc/icd10");
|
|
7
7
|
const icpc2_1 = require("./rsrc/icpc2");
|
|
8
|
-
const
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
9
|
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
10
10
|
class IccCodeXApi extends icc_api_1.IccCodeApi {
|
|
11
11
|
constructor(host, headers, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
@@ -25,25 +25,7 @@ class IccCodeXApi extends icc_api_1.IccCodeApi {
|
|
|
25
25
|
*/
|
|
26
26
|
// noinspection JSUnusedGlobalSymbols
|
|
27
27
|
icdChapters(listOfCodes) {
|
|
28
|
-
return Promise.resolve(
|
|
29
|
-
code,
|
|
30
|
-
_.toPairs(this.icd10).find(([k]) => {
|
|
31
|
-
const parts = k.split(/-/);
|
|
32
|
-
return code.substr(0, 3) >= parts[0] && code.substr(0, 3) <= parts[1];
|
|
33
|
-
}),
|
|
34
|
-
])), (acc, pairOfRangeAndIcdInfo, code) => {
|
|
35
|
-
if (!pairOfRangeAndIcdInfo) {
|
|
36
|
-
return acc;
|
|
37
|
-
}
|
|
38
|
-
const shortKey = pairOfRangeAndIcdInfo[0].substr(0, 2);
|
|
39
|
-
(acc[shortKey] ||
|
|
40
|
-
(acc[shortKey] = {
|
|
41
|
-
code: shortKey,
|
|
42
|
-
descr: pairOfRangeAndIcdInfo[1],
|
|
43
|
-
subCodes: [],
|
|
44
|
-
})).subCodes.push(code);
|
|
45
|
-
return acc;
|
|
46
|
-
}, {})), (c) => c.shortKey));
|
|
28
|
+
return Promise.resolve((0, utils_1.icdChapters)(listOfCodes, this.icd10));
|
|
47
29
|
}
|
|
48
30
|
/**
|
|
49
31
|
* Groups a list of ICPC-2 codes by their corresponding ICPC-2 chapter.
|
|
@@ -52,19 +34,7 @@ class IccCodeXApi extends icc_api_1.IccCodeApi {
|
|
|
52
34
|
*/
|
|
53
35
|
// noinspection JSUnusedGlobalSymbols
|
|
54
36
|
icpcChapters(listOfCodes) {
|
|
55
|
-
return Promise.resolve(
|
|
56
|
-
if (!pairOfRangeAndIcdInfo) {
|
|
57
|
-
return acc;
|
|
58
|
-
}
|
|
59
|
-
const shortKey = pairOfRangeAndIcdInfo[0];
|
|
60
|
-
(acc[shortKey] ||
|
|
61
|
-
(acc[shortKey] = {
|
|
62
|
-
code: shortKey,
|
|
63
|
-
descr: pairOfRangeAndIcdInfo[1],
|
|
64
|
-
subCodes: [],
|
|
65
|
-
})).subCodes.push(code);
|
|
66
|
-
return acc;
|
|
67
|
-
}, {})), (c) => c.shortKey));
|
|
37
|
+
return Promise.resolve((0, utils_1.icpcChapters)(listOfCodes, this.icpc2));
|
|
68
38
|
}
|
|
69
39
|
/**
|
|
70
40
|
* Returns the appropriate language code for a given code type. Falls back to French ('fr') if the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-code-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-code-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAAuC;AAEvC,4CAA0C;AAC1C,wCAAgC;AAChC,wCAAgC;AAEhC,
|
|
1
|
+
{"version":3,"file":"icc-code-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-code-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAAuC;AAEvC,4CAA0C;AAC1C,wCAAgC;AAChC,wCAAgC;AAEhC,mCAAmD;AAEnD,0EAAgG;AAEhG,MAAa,WAAY,SAAQ,oBAAU;IAKzC,YACE,IAAY,EACZ,OAAkC,EAClC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,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,EAAG,CAAU,CAAC,IAAI,GAAG,GAAG,GAAI,CAAU,CAAC,IAAI,GAAG,GAAG,GAAG,CAAE,CAAU,CAAC,OAAO,IAAI,GAAG,CAAC;oBAClF,IAAI,EAAG,CAAU,CAAC,IAAI;oBACtB,IAAI,EAAG,CAAU,CAAC,IAAI;oBACtB,OAAO,EAAG,CAAU,CAAC,OAAO,IAAI,GAAG;iBACpC;gBACH,CAAC,CAAE,CAAU,CAAC,EAAE,IAAI,CAAC,CAAE,CAAU,CAAC,IAAI,IAAI,CAAE,CAAU,CAAC,IAAI,IAAI,CAAE,CAAU,CAAC,OAAO,CAAC;oBACpF,CAAC,CAAC;wBACE,EAAE,EAAG,CAAU,CAAC,EAAE;wBAClB,IAAI,EAAG,CAAU,CAAC,EAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBACpC,IAAI,EAAG,CAAU,CAAC,EAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBACpC,OAAO,EAAG,CAAU,CAAC,EAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;qBACxC;oBACH,CAAC,CAAC;wBACE,EAAE,EAAG,CAAU,CAAC,EAAG;wBACnB,IAAI,EAAG,CAAU,CAAC,IAAI;wBACtB,IAAI,EAAG,CAAU,CAAC,IAAI;wBACtB,OAAO,EAAG,CAAU,CAAC,OAAO,IAAI,GAAG;qBACpC,CAAA;IACP,CAAC;CACF;AAvFD,kCAuFC","sourcesContent":["import { IccCodeApi } from '../icc-api'\n\nimport codeLanguages from './rsrc/codelng'\nimport icd10 from './rsrc/icd10'\nimport icpc2 from './rsrc/icpc2'\n\nimport { icdChapters, icpcChapters } from './utils'\nimport { Code } from '../icc-api/model/Code'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\nexport class IccCodeXApi extends IccCodeApi {\n icd10: any = icd10\n icpc2: any = icpc2\n codeLanguages: any = codeLanguages\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n }\n\n /**\n * Groups a list of ICD-10 codes by their corresponding ICD-10 chapter.\n * @param listOfCodes an array of ICD-10 code strings to classify into chapters.\n * @return a sorted array of chapter objects, each containing a code, description, and list of matching sub-codes.\n */\n // noinspection JSUnusedGlobalSymbols\n icdChapters(listOfCodes: Array<string>) {\n return Promise.resolve(icdChapters(listOfCodes, this.icd10))\n }\n\n /**\n * Groups a list of ICPC-2 codes by their corresponding ICPC-2 chapter.\n * @param listOfCodes an array of ICPC-2 code strings to classify into chapters.\n * @return a sorted array of chapter objects, each containing a code, description, and list of matching sub-codes.\n */\n // noinspection JSUnusedGlobalSymbols\n icpcChapters(listOfCodes: Array<string>) {\n return Promise.resolve(icpcChapters(listOfCodes, this.icpc2))\n }\n\n /**\n * Returns the appropriate language code for a given code type. Falls back to French ('fr') if the\n * requested language is not available for the specified type.\n * @param type the code type to look up available languages for.\n * @param lng the desired language code.\n * @return the requested language code if available, or 'fr' as a fallback.\n */\n // noinspection JSUnusedGlobalSymbols\n languageForType(type: string, lng: string) {\n const availableLanguages = this.codeLanguages[type]\n return availableLanguages && availableLanguages.indexOf(lng) >= 0 ? lng : 'fr'\n }\n\n /**\n * Normalizes a code, ensuring it has a consistent structure with id, type, code, and version fields.\n * Accepts either a pipe-delimited string (e.g. \"type|code|version\") or a Code object.\n * @param c a code represented as a pipe-delimited string or a Code object.\n * @return an object with id, type, code, and version fields fully populated.\n */\n // noinspection JSMethodCanBeStatic, JSUnusedGlobalSymbols\n normalize(c: Code | string) {\n return typeof c === 'string'\n ? {\n id: c,\n type: c.split(/\\|/)[0],\n code: c.split(/\\|/)[1],\n version: c.split(/\\|/)[2],\n }\n : (c as Code).type && (c as Code).code && !(c as Code).id\n ? {\n id: (c as Code).type + '|' + (c as Code).code + '|' + ((c as Code).version || '1'),\n type: (c as Code).type,\n code: (c as Code).code,\n version: (c as Code).version || '1',\n }\n : (c as Code).id && (!(c as Code).code || !(c as Code).type || !(c as Code).version)\n ? {\n id: (c as Code).id,\n type: (c as Code).id!.split(/\\|/)[0],\n code: (c as Code).id!.split(/\\|/)[1],\n version: (c as Code).id!.split(/\\|/)[2],\n }\n : {\n id: (c as Code).id!,\n type: (c as Code).type,\n code: (c as Code).code,\n version: (c as Code).version || '1',\n }\n }\n}\n"]}
|
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.IccContactXApi = void 0;
|
|
13
13
|
const icc_api_1 = require("../icc-api");
|
|
14
14
|
const contact_i18n_1 = require("./rsrc/contact.i18n");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const date_fns_1 = require("date-fns");
|
|
16
|
+
const collection_utils_1 = require("./utils/collection-utils");
|
|
17
17
|
const models = require("../icc-api/model/models");
|
|
18
18
|
const models_1 = require("../icc-api/model/models");
|
|
19
19
|
const binary_utils_1 = require("./utils/binary-utils");
|
|
@@ -76,7 +76,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
76
76
|
newInstance(user_1, patient_1, c_1) {
|
|
77
77
|
return __awaiter(this, arguments, void 0, function* (user, patient, c, options = {}) {
|
|
78
78
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
79
|
-
const contact = new models.Contact(Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.Contact', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = c === null || c === void 0 ? void 0 : c.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = c === null || c === void 0 ? void 0 : c.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = c === null || c === void 0 ? void 0 : c.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = c === null || c === void 0 ? void 0 : c.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = c === null || c === void 0 ? void 0 : c.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = c === null || c === void 0 ? void 0 : c.tags) !== null && _g !== void 0 ? _g : [], groupId: (_h = c === null || c === void 0 ? void 0 : c.groupId) !== null && _h !== void 0 ? _h : this.crypto.primitives.randomUuid(), subContacts: (_j = c === null || c === void 0 ? void 0 : c.subContacts) !== null && _j !== void 0 ? _j : [], services: (_k = c === null || c === void 0 ? void 0 : c.services) !== null && _k !== void 0 ? _k : [], openingDate: (_l = c === null || c === void 0 ? void 0 : c.openingDate) !== null && _l !== void 0 ? _l : parseInt(
|
|
79
|
+
const contact = new models.Contact(Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.Contact', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = c === null || c === void 0 ? void 0 : c.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = c === null || c === void 0 ? void 0 : c.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = c === null || c === void 0 ? void 0 : c.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = c === null || c === void 0 ? void 0 : c.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = c === null || c === void 0 ? void 0 : c.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = c === null || c === void 0 ? void 0 : c.tags) !== null && _g !== void 0 ? _g : [], groupId: (_h = c === null || c === void 0 ? void 0 : c.groupId) !== null && _h !== void 0 ? _h : this.crypto.primitives.randomUuid(), subContacts: (_j = c === null || c === void 0 ? void 0 : c.subContacts) !== null && _j !== void 0 ? _j : [], services: (_k = c === null || c === void 0 ? void 0 : c.services) !== null && _k !== void 0 ? _k : [], openingDate: (_l = c === null || c === void 0 ? void 0 : c.openingDate) !== null && _l !== void 0 ? _l : parseInt((0, date_fns_1.format)(new Date(), 'yyyyMMddHHmmss')) }));
|
|
80
80
|
const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
|
|
81
81
|
if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
|
|
82
82
|
throw new Error('Can only initialise entities as current data owner.');
|
|
@@ -119,8 +119,8 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
119
119
|
}, [])
|
|
120
120
|
.filter((l) => l.extractedKeys.length > 0)
|
|
121
121
|
.map(({ hcpartyId, extractedKeys }) => usingPost
|
|
122
|
-
? this.findByHCPartyPatientSecretFKeysArray(hcpartyId,
|
|
123
|
-
: this.findByHCPartyPatientSecretFKeys(hcpartyId,
|
|
122
|
+
? this.findByHCPartyPatientSecretFKeysArray(hcpartyId, [...new Set(extractedKeys)])
|
|
123
|
+
: this.findByHCPartyPatientSecretFKeys(hcpartyId, [...new Set(extractedKeys)].join(',')))).then((results) => (0, collection_utils_1.uniqBy)(results.flat(), (x) => x.id))
|
|
124
124
|
: Promise.resolve([]));
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -141,7 +141,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
141
141
|
]);
|
|
142
142
|
}, [])
|
|
143
143
|
.filter((l) => l.extractedKeys.length > 0)
|
|
144
|
-
.map(({ hcpartyId, extractedKeys }) => this.findContactIdsByDataOwnerPatientOpeningDate(hcpartyId, extractedKeys, startDate, endDate, descending))).then((results) =>
|
|
144
|
+
.map(({ hcpartyId, extractedKeys }) => this.findContactIdsByDataOwnerPatientOpeningDate(hcpartyId, extractedKeys, startDate, endDate, descending))).then((results) => [...new Set(results.flat())])
|
|
145
145
|
: Promise.resolve([]));
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -169,9 +169,9 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
169
169
|
(perHcpId[hcpartyId] || (perHcpId[hcpartyId] = [])).push(...extractedKeys);
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
return
|
|
172
|
+
return (0, collection_utils_1.uniqBy)((yield Promise.all(Object.keys(perHcpId).map((hcpId) => this.findContactsByHCPartyPatientForeignKeys(hcpartyId, new models.ListOfIds({
|
|
173
173
|
ids: perHcpId[hcpId],
|
|
174
|
-
}))))), (x) => x.id);
|
|
174
|
+
}))))).flat(), (x) => x.id);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
filterBy(startKey, startDocumentId, limit, body) {
|
|
@@ -323,7 +323,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
325
|
modifyContactAs(dataOwner, body) {
|
|
326
|
-
return this.encryptAs(dataOwner, [
|
|
326
|
+
return this.encryptAs(dataOwner, [(0, collection_utils_1.cloneDeep)(body)])
|
|
327
327
|
.then((ctcs) => super.modifyContact(ctcs[0]))
|
|
328
328
|
.then((ctc) => this.decrypt(dataOwner, [ctc]))
|
|
329
329
|
.then((ctcs) => ctcs[0]);
|
|
@@ -340,7 +340,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
340
340
|
});
|
|
341
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
342
342
|
return bodies
|
|
343
|
-
? this.encrypt(user, bodies.map((c) =>
|
|
343
|
+
? this.encrypt(user, bodies.map((c) => (0, collection_utils_1.cloneDeep)(c)))
|
|
344
344
|
.then((ctcs) => _super.modifyContacts.call(this, ctcs))
|
|
345
345
|
.then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs))
|
|
346
346
|
: null;
|
|
@@ -358,7 +358,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
358
358
|
});
|
|
359
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
360
360
|
return body
|
|
361
|
-
? this.encrypt(user, [
|
|
361
|
+
? this.encrypt(user, [(0, collection_utils_1.cloneDeep)(body)])
|
|
362
362
|
.then((ctcs) => _super.createContact.call(this, ctcs[0]))
|
|
363
363
|
.then((ctc) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [ctc]))
|
|
364
364
|
.then((ctcs) => ctcs[0])
|
|
@@ -377,7 +377,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
377
377
|
});
|
|
378
378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
379
379
|
return bodies
|
|
380
|
-
? this.encrypt(user, bodies.map((c) =>
|
|
380
|
+
? this.encrypt(user, bodies.map((c) => (0, collection_utils_1.cloneDeep)(c)))
|
|
381
381
|
.then((ctcs) => _super.createContacts.call(this, ctcs))
|
|
382
382
|
.then((ctcs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), ctcs))
|
|
383
383
|
: null;
|
|
@@ -501,7 +501,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
501
501
|
let latestService;
|
|
502
502
|
ctcs.forEach((c) => {
|
|
503
503
|
const s = c.services.find((it) => svcId === it.id);
|
|
504
|
-
if (s && (!latestService ||
|
|
504
|
+
if (s && (!latestService || (0, date_fns_1.isAfter)((0, date_fns_1.parse)('' + s.valueDate, 'yyyyMMddHHmmss', new Date()), (0, date_fns_1.parse)('' + latestService.valueDate, 'yyyyMMddHHmmss', new Date())))) {
|
|
505
505
|
latestContact = c;
|
|
506
506
|
latestService = s;
|
|
507
507
|
}
|
|
@@ -525,7 +525,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
525
525
|
s.contactId = c.id;
|
|
526
526
|
}
|
|
527
527
|
}));
|
|
528
|
-
return
|
|
528
|
+
return Object.values(byIds).filter((s) => !s.deleted && !s.endOfLife);
|
|
529
529
|
}
|
|
530
530
|
/**
|
|
531
531
|
* Extracts and filters services from contacts, returning a promise. Same as filteredServices but wrapped in a promise.
|
|
@@ -652,7 +652,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
652
652
|
return null;
|
|
653
653
|
}
|
|
654
654
|
const existing = ctc.services.find((s) => s.id === svc.id);
|
|
655
|
-
const promoted =
|
|
655
|
+
const promoted = Object.assign(existing || {}, svc, {
|
|
656
656
|
author: user.id,
|
|
657
657
|
responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
|
|
658
658
|
modified: new Date().getTime(),
|
|
@@ -668,7 +668,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
668
668
|
Object.keys(poaIds || {}).forEach((k) => {
|
|
669
669
|
const poas = hierarchyOfHeAndPoaIds[k];
|
|
670
670
|
if (poas) {
|
|
671
|
-
hierarchyOfHeAndPoaIds[k] =
|
|
671
|
+
hierarchyOfHeAndPoaIds[k] = [...poas, ...(poaIds || {})[k]];
|
|
672
672
|
}
|
|
673
673
|
else {
|
|
674
674
|
hierarchyOfHeAndPoaIds[k] = (poaIds || {})[k];
|
|
@@ -693,9 +693,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
693
693
|
}
|
|
694
694
|
}
|
|
695
695
|
else {
|
|
696
|
-
const newSubContact =
|
|
697
|
-
services: [{ serviceId: svc.id }],
|
|
698
|
-
});
|
|
696
|
+
const newSubContact = Object.assign(Object.assign({}, psc), { services: [{ serviceId: svc.id }] });
|
|
699
697
|
ctc.subContacts.push(newSubContact);
|
|
700
698
|
allSubcontactsInCurrentContactContainingService.push(newSubContact);
|
|
701
699
|
}
|
|
@@ -753,18 +751,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
753
751
|
return {
|
|
754
752
|
newInstance: (user, s) => {
|
|
755
753
|
var _a, _b;
|
|
756
|
-
return
|
|
757
|
-
id: this.crypto.primitives.randomUuid(),
|
|
758
|
-
_type: 'org.taktik.icure.entities.embed.Service',
|
|
759
|
-
created: new Date().getTime(),
|
|
760
|
-
modified: new Date().getTime(),
|
|
761
|
-
responsible: (_a = s === null || s === void 0 ? void 0 : s.responsible) !== null && _a !== void 0 ? _a : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),
|
|
762
|
-
author: (_b = s === null || s === void 0 ? void 0 : s.author) !== null && _b !== void 0 ? _b : (this.autofillAuthor ? user.id : undefined),
|
|
763
|
-
codes: [],
|
|
764
|
-
tags: [],
|
|
765
|
-
content: {},
|
|
766
|
-
valueDate: parseInt(moment().format('YYYYMMDDHHmmss')),
|
|
767
|
-
}, s);
|
|
754
|
+
return (Object.assign({ id: this.crypto.primitives.randomUuid(), _type: 'org.taktik.icure.entities.embed.Service', created: new Date().getTime(), modified: new Date().getTime(), responsible: (_a = s === null || s === void 0 ? void 0 : s.responsible) !== null && _a !== void 0 ? _a : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_b = s === null || s === void 0 ? void 0 : s.author) !== null && _b !== void 0 ? _b : (this.autofillAuthor ? user.id : undefined), codes: [], tags: [], content: {}, valueDate: parseInt((0, date_fns_1.format)(new Date(), 'yyyyMMddHHmmss')) }, s));
|
|
768
755
|
},
|
|
769
756
|
};
|
|
770
757
|
}
|
|
@@ -858,7 +845,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
858
845
|
: m.regimen.find((r) => r.date)
|
|
859
846
|
? this.i18n[lang].monthly
|
|
860
847
|
: this.i18n[lang].daily;
|
|
861
|
-
return `${quantityUnit}, ${m.regimen.length} x ${dayPeriod}, ${
|
|
848
|
+
return `${quantityUnit}, ${m.regimen.length} x ${dayPeriod}, ${(0, collection_utils_1.sortBy)(m.regimen, (r) => (r.date ? r.date * 1000000 : 29990000000000) +
|
|
862
849
|
(r.dayNumber || 0) * 1000000 +
|
|
863
850
|
((r.weekday && r.weekday.weekNumber) || 0) * 7 * 1000000 +
|
|
864
851
|
(r.timeOfDay ? r.timeOfDay : r.dayPeriod && r.dayPeriod.code ? regimenScores[r.dayPeriod.code] : 0))
|
|
@@ -892,7 +879,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
892
879
|
},
|
|
893
880
|
regimenToString: (r, lang) => {
|
|
894
881
|
let res = r.date
|
|
895
|
-
? `${this.i18n[lang].the} ${
|
|
882
|
+
? `${this.i18n[lang].the} ${(0, date_fns_1.format)(r.date, 'dd/MM/yyyy')}`
|
|
896
883
|
: r.dayNumber
|
|
897
884
|
? `${this.i18n[lang].onDay} ${r.dayNumber}`
|
|
898
885
|
: r.weekday && r.weekday.weekday
|