@icure/api 8.6.2 → 8.6.4
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/model/ModelHelper.d.ts +1 -1
- package/icc-api/model/ModelHelper.js +15 -2
- package/icc-api/model/ModelHelper.js.map +1 -1
- package/icc-api/model/User.d.ts +1 -0
- package/icc-api/model/User.js.map +1 -1
- package/icc-x-api/crypto/AES.js +1 -1
- package/icc-x-api/crypto/AES.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeDataManager.js +14 -14
- package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeKeysManager.js +1 -1
- package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
- package/icc-x-api/crypto/CryptoPrimitives.js +3 -2
- package/icc-x-api/crypto/CryptoPrimitives.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/ExtendedApisUtilsImpl.js +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/KeyRecovery.js +3 -3
- package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
- package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js +13 -13
- package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js.map +1 -1
- package/icc-x-api/crypto/RSA.js +2 -2
- package/icc-x-api/crypto/RSA.js.map +1 -1
- package/icc-x-api/crypto/RecoveryDataEncryption.js +5 -5
- package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
- package/icc-x-api/crypto/SecureDelegationsManager.js +1 -1
- package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.js +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
- package/icc-x-api/crypto/utils.js +1 -1
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.d.ts +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.js +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyCodeFilter.js.map +1 -0
- package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.d.ts +22 -0
- package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.js +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter.js.map +1 -0
- package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.d.ts +21 -0
- package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.js +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter.js.map +1 -0
- package/icc-x-api/filters/HealthElementByHcPartyTagFilter.d.ts +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyTagFilter.js +24 -0
- package/icc-x-api/filters/HealthElementByHcPartyTagFilter.js.map +1 -0
- package/icc-x-api/filters/VersionFiltering.d.ts +14 -0
- package/icc-x-api/filters/VersionFiltering.js +19 -0
- package/icc-x-api/filters/VersionFiltering.js.map +1 -0
- package/icc-x-api/filters/filters.d.ts +8 -4
- package/icc-x-api/filters/filters.js +4 -0
- package/icc-x-api/filters/filters.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +1 -1
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +9 -6
- package/icc-x-api/index.js +4 -0
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/binary-utils.js +1 -1
- package/icc-x-api/utils/binary-utils.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-api/api/IccAnonymousAccessApi.js +1 -1
- package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -1
- package/test/icc-api/api/IccDocumentApi.js +13 -12
- package/test/icc-api/api/IccDocumentApi.js.map +1 -1
- package/test/icc-x-api/crud/comprehensive-crud-test.js +2 -2
- package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -1
- package/test/icc-x-api/crypto/crypto-utils.js +1 -1
- package/test/icc-x-api/crypto/crypto-utils.js.map +1 -1
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js +1 -1
- package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +1 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +1 -1
- package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -1
- package/test/icc-x-api/filters/healthelement.d.ts +1 -0
- package/test/icc-x-api/filters/healthelement.js +333 -0
- package/test/icc-x-api/filters/healthelement.js.map +1 -0
- package/test/icc-x-api/test-legacy-data-support.js +4 -4
- package/test/icc-x-api/test-legacy-data-support.js.map +1 -1
- package/test/utils/TestCryptoStrategies.js +1 -1
- package/test/utils/TestCryptoStrategies.js.map +1 -1
- package/test/utils/roles.d.ts +1 -0
- package/test/utils/roles.js +1 -0
- package/test/utils/roles.js.map +1 -1
- package/test/utils/test_utils.js +2 -2
- package/test/utils/test_utils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-encryption-keys-manager-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/user-encryption-keys-manager-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,iCAA4C;AAE5C,mCAAkC;AAClC,4BAAyB;AACzB,+BAA6B;AAC7B,uDAAmJ;AACnJ,yDAA0F;AAC1F,2EAAuE;AACvE,mDAAgF;AAChF,kDAA8G;AAC9G,wCAAqC;AAIrC,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,IAAA,gBAAQ,EAAC,aAAa,EAAE;;QACtB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEpB,IAAA,cAAM,EAAC;;gBACL,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;gBACrD,GAAG,GAAG,MAAM,WAAW,CAA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AE,QAAQ,EAAE,QAAQ,CAAC,aAAa,EAAE,EAClE,YAAY,EACZ,kBAAgB,EAChB,KAAK,EACL;wBACE,OAAO,EAAE,QAAQ,CAAC,OAAO;wBACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;wBAC/B,gBAAgB,EAAE,QAAQ,CAAC,UAAU;qBACtC,CACF,CAAA;oBACD,IAAA,aAAM,EAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA;oBACpD,MAAM,cAAc,GAAG,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAC,SAAS,CAAA;oBACpF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAA;oBACjF,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;oBAC9B,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAA,cAAM,EAAC,MAAM,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,gBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;gBACvI,CAAC;aAAA;YACD,MAAM,MAAM,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;QACpB,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { v4 as uuid } from 'uuid'\nimport { User } from '../../../icc-api/model/User'\nimport { before, describe, it } from 'mocha'\n\nimport { webcrypto } from 'crypto'\nimport 'isomorphic-fetch'\nimport { expect } from 'chai'\nimport { createHcpHierarchyApis, createNewHcpWithoutKeyAndParentWithKey, getEnvironmentInitializer, setLocalStorage } from '../../utils/test_utils'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { getEnvVariables, TestVars, UserDetails } from '@icure/test-setup/types'\nimport { CryptoPrimitives, CryptoStrategies, hex2ua, IcureApi, KeyPair, ShaVersion } from '../../../icc-x-api'\nimport { ua2hex } from '@icure/apiV6'\nimport { DataOwnerWithType } from '../../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStubWithType } from '../../../icc-api/model/CryptoActorStub'\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Key manager', async function () {\n this.timeout(600000)\n\n before(async function () {\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(`Should not ask crypto strategies to recover available keys`, async () => {\n const apis = await createHcpHierarchyApis(env)\n const storageWithoutParentKey = await testStorageWithKeys([\n {\n dataOwnerId: apis.grandCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.grandCredentials.privateKey, publicKey: apis.grandCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.childCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.childCredentials.privateKey, publicKey: apis.childCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n ])\n const cryptoStrats = new TestCryptoStrategies(undefined, {}, undefined, {\n [apis.parentCredentials.dataOwnerId]: {\n pair: { privateKey: apis.parentCredentials.privateKey, publicKey: apis.parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n })\n await IcureApi.initialise(\n env.iCureUrl,\n { username: apis.childCredentials.user, password: apis.childCredentials.password },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storageWithoutParentKey.storage,\n keyStorage: storageWithoutParentKey.keyStorage,\n entryKeysFactory: storageWithoutParentKey.keyFactory,\n }\n )\n expect(cryptoStrats.recoverAndVerifyCallsParams).to.have.length(1)\n const params = cryptoStrats.recoverAndVerifyCallsParams[0]\n expect(params).to.have.length(3)\n expect(params[0].dataOwner.dataOwner.id).to.equal(apis.grandCredentials.dataOwnerId)\n expect(params[0].unavailableKeys).to.be.empty\n expect(params[0].unknownKeys).to.be.empty\n expect(params[1].dataOwner.dataOwner.id).to.equal(apis.parentCredentials.dataOwnerId)\n expect(params[1].unavailableKeys).to.have.members([apis.parentCredentials.publicKey])\n expect(params[1].unknownKeys).to.have.members([apis.parentCredentials.publicKey])\n expect(params[2].dataOwner.dataOwner.id).to.equal(apis.childCredentials.dataOwnerId)\n expect(params[2].unavailableKeys).to.be.empty\n expect(params[2].unknownKeys).to.be.empty\n })\n\n it('Should not ask crypto strategies to recover keys if all keys are available', async () => {\n const apis = await createHcpHierarchyApis(env)\n const storageWithoutParentKey = await testStorageWithKeys([\n {\n dataOwnerId: apis.grandCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.grandCredentials.privateKey, publicKey: apis.grandCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.parentCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.parentCredentials.privateKey, publicKey: apis.parentCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.childCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.childCredentials.privateKey, publicKey: apis.childCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n ])\n const cryptoStrats = new TestCryptoStrategies()\n await IcureApi.initialise(\n env.iCureUrl,\n { username: apis.childCredentials.user, password: apis.childCredentials.password },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storageWithoutParentKey.storage,\n keyStorage: storageWithoutParentKey.keyStorage,\n entryKeysFactory: storageWithoutParentKey.keyFactory,\n }\n )\n expect(cryptoStrats.recoverAndVerifyCallsParams).to.have.length(0)\n })\n\n it('Should allow to retrieve all keys for a data owner and his parents', async () => {\n const apis = await createHcpHierarchyApis(env)\n const keysData = await apis.childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n async function checkKey(userDetails: UserDetails, key: KeyPair<CryptoKey>) {\n const exportedPrivateKey = ua2hex(await apis.childApi.cryptoApi.primitives.RSA.exportKey(key.privateKey, 'pkcs8'))\n const exportedPublicKey = ua2hex(await apis.childApi.cryptoApi.primitives.RSA.exportKey(key.publicKey, 'spki'))\n expect(exportedPublicKey).to.equal(userDetails.publicKey)\n expect(exportedPrivateKey).to.equal(userDetails.privateKey)\n }\n expect(keysData.self.dataOwnerId).to.equal(apis.childCredentials.dataOwnerId)\n expect(keysData.self.keys).to.have.length(1)\n expect(keysData.self.keys[0].verified).to.be.true\n await checkKey(apis.childCredentials, keysData.self.keys[0].pair)\n expect(keysData.parents).to.have.length(2)\n expect(keysData.parents[0].dataOwnerId).to.equal(apis.grandCredentials.dataOwnerId)\n expect(keysData.parents[0].keys).to.have.length(1)\n await checkKey(apis.grandCredentials, keysData.parents[0].keys[0].pair)\n expect(keysData.parents[1].dataOwnerId).to.equal(apis.parentCredentials.dataOwnerId)\n expect(keysData.parents[1].keys).to.have.length(1)\n await checkKey(apis.parentCredentials, keysData.parents[1].keys[0].pair)\n })\n\n it('If a HCP has no key yet, but the parent does the crypto strategies should first ask to recover the keys for the parent then ask for the generation of a new key to the data owner', async () => {\n const hcpsInfo = await createNewHcpWithoutKeyAndParentWithKey(env)\n const cryptoStrats = new (class implements CryptoStrategies {\n generateNewKeyCalled: boolean = false\n recoverCalled: boolean = false\n generatedKeyPair: KeyPair<CryptoKey> | undefined = undefined\n\n async generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean> {\n if (this.generateNewKeyCalled) throw new Error('generateNewKeyForDataOwner called twice')\n if (!this.recoverCalled) throw new Error('generateNewKeyForDataOwner called before recoverAndVerifySelfHierarchyKeys')\n this.generateNewKeyCalled = true\n expect(self.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n return (this.generatedKeyPair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256))\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n if (this.recoverCalled) throw new Error('recoverAndVerifySelfHierarchyKeys called twice')\n this.recoverCalled = true\n expect(keysData).to.have.length(2)\n expect(keysData[0].dataOwner.dataOwner.id).to.equal(hcpsInfo.parentCredentials.dataOwnerId)\n expect(keysData[0].unknownKeys).to.have.members([hcpsInfo.parentCredentials.publicKey])\n expect(keysData[0].unavailableKeys).to.have.members([hcpsInfo.parentCredentials.publicKey])\n expect(keysData[1].dataOwner.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n expect(keysData[1].unknownKeys).to.be.empty\n expect(keysData[1].unavailableKeys).to.be.empty\n return {\n [hcpsInfo.parentCredentials.dataOwnerId]: {\n recoveredKeys: {\n [hcpsInfo.parentCredentials.publicKey.slice(-32)]: await cryptoPrimitives.RSA.importKeyPair(\n 'pkcs8',\n hex2ua(hcpsInfo.parentCredentials.privateKey),\n 'spki',\n hex2ua(hcpsInfo.parentCredentials.publicKey),\n ShaVersion.Sha1\n ),\n },\n keyAuthenticity: {},\n },\n [hcpsInfo.childDataOwnerId]: {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n throw new Error('This method should not be called by this test')\n }\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return false\n }\n })()\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcpsInfo.childUser, password: hcpsInfo.childPassword },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n expect(cryptoStrats.generateNewKeyCalled).to.be.true\n expect(cryptoStrats.recoverCalled).to.be.true\n const keys = Array.from(childApi.dataOwnerApi.getHexPublicKeysOf((await childApi.dataOwnerApi.getCurrentDataOwner()).dataOwner))\n expect(keys).to.have.length(1)\n expect(Array.from(keys)[0]).to.equal(ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(cryptoStrats.generatedKeyPair!.publicKey, 'spki')))\n })\n\n it('If a HCP has no key yet, but the parent does and the key is available the crypto strategies should ask for the generation of a new key to the data owner', async () => {\n async function doTest(initialiseEmptyKeyForChild: boolean) {\n const hcpsInfo = await createNewHcpWithoutKeyAndParentWithKey(env, { initialiseEmptyKeyForChild })\n const cryptoStrats = new (class implements CryptoStrategies {\n generateNewKeyCalled: boolean = false\n generatedKeyPair: KeyPair<CryptoKey> | undefined = undefined\n\n async generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean> {\n if (this.generateNewKeyCalled) throw new Error('generateNewKeyForDataOwner called twice')\n this.generateNewKeyCalled = true\n expect(self.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n return (this.generatedKeyPair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256))\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n throw new Error('This method should not be called by this test')\n }\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return false\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n throw new Error('This method should not be called by this test')\n }\n })()\n const storages = await testStorageWithKeys([\n {\n dataOwnerId: hcpsInfo.parentCredentials.dataOwnerId,\n pairs: [\n {\n keyPair: { privateKey: hcpsInfo.parentCredentials.privateKey, publicKey: hcpsInfo.parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcpsInfo.childUser, password: hcpsInfo.childPassword },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storages.storage,\n keyStorage: storages.keyStorage,\n entryKeysFactory: storages.keyFactory,\n }\n )\n expect(cryptoStrats.generateNewKeyCalled).to.be.true\n const initialisedHcp = (await childApi.dataOwnerApi.getCurrentDataOwner()).dataOwner\n const keys = Array.from(childApi.dataOwnerApi.getHexPublicKeysOf(initialisedHcp))\n expect(keys).to.have.length(1)\n expect(keys[0]).to.equal(ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(cryptoStrats.generatedKeyPair!.publicKey, 'spki')))\n }\n await doTest(false)\n await doTest(true)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"user-encryption-keys-manager-test.js","sourceRoot":"","sources":["../../../../test/icc-x-api/crypto/user-encryption-keys-manager-test.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,iCAA4C;AAE5C,mCAAkC;AAClC,4BAAyB;AACzB,+BAA6B;AAC7B,uDAAmJ;AACnJ,yDAA0F;AAC1F,2EAAuE;AACvE,mDAAgF;AAChF,kDAAqH;AACrH,wCAAqC;AAIrC,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AAEtB,IAAI,GAAa,CAAA;AAEjB,IAAA,gBAAQ,EAAC,aAAa,EAAE;;QACtB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEpB,IAAA,cAAM,EAAC;;gBACL,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAy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AAM,oBAAQ,CAAC,UAAU,CACxC,GAAG,CAAC,QAAQ,EACZ,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,aAAa,EAAE,EAClE,YAAY,EACZ,kBAAgB,EAChB,KAAK,EACL;wBACE,OAAO,EAAE,QAAQ,CAAC,OAAO;wBACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;wBAC/B,gBAAgB,EAAE,QAAQ,CAAC,UAAU;qBACtC,CACF,CAAA;oBACD,IAAA,aAAM,EAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA;oBACpD,MAAM,cAAc,GAAG,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAC,SAAS,CAAA;oBACpF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAA;oBACjF,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;oBAC9B,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAA,cAAM,EAAC,MAAM,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,gBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;gBACvI,CAAC;aAAA;YACD,MAAM,MAAM,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;QACpB,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC;CAAA,CAAC,CAAA","sourcesContent":["import { v4 as uuid } from 'uuid'\nimport { User } from '../../../icc-api/model/User'\nimport { before, describe, it } from 'mocha'\n\nimport { webcrypto } from 'crypto'\nimport 'isomorphic-fetch'\nimport { expect } from 'chai'\nimport { createHcpHierarchyApis, createNewHcpWithoutKeyAndParentWithKey, getEnvironmentInitializer, setLocalStorage } from '../../utils/test_utils'\nimport { TestKeyStorage, TestStorage, testStorageWithKeys } from '../../utils/TestStorage'\nimport { TestCryptoStrategies } from '../../utils/TestCryptoStrategies'\nimport { getEnvVariables, TestVars, UserDetails } from '@icure/test-setup/types'\nimport { CryptoPrimitives, CryptoStrategies, hex2ua, IcureApi, KeyPair, ShaVersion, ua2ab } from '../../../icc-x-api'\nimport { ua2hex } from '@icure/apiV6'\nimport { DataOwnerWithType } from '../../../icc-api/model/DataOwnerWithType'\nimport { CryptoActorStubWithType } from '../../../icc-api/model/CryptoActorStub'\n\nsetLocalStorage(fetch)\n\nlet env: TestVars\n\ndescribe('Key manager', async function () {\n this.timeout(600000)\n\n before(async function () {\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it(`Should not ask crypto strategies to recover available keys`, async () => {\n const apis = await createHcpHierarchyApis(env)\n const storageWithoutParentKey = await testStorageWithKeys([\n {\n dataOwnerId: apis.grandCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.grandCredentials.privateKey, publicKey: apis.grandCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.childCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.childCredentials.privateKey, publicKey: apis.childCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n ])\n const cryptoStrats = new TestCryptoStrategies(undefined, {}, undefined, {\n [apis.parentCredentials.dataOwnerId]: {\n pair: { privateKey: apis.parentCredentials.privateKey, publicKey: apis.parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n })\n await IcureApi.initialise(\n env.iCureUrl,\n { username: apis.childCredentials.user, password: apis.childCredentials.password },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storageWithoutParentKey.storage,\n keyStorage: storageWithoutParentKey.keyStorage,\n entryKeysFactory: storageWithoutParentKey.keyFactory,\n }\n )\n expect(cryptoStrats.recoverAndVerifyCallsParams).to.have.length(1)\n const params = cryptoStrats.recoverAndVerifyCallsParams[0]\n expect(params).to.have.length(3)\n expect(params[0].dataOwner.dataOwner.id).to.equal(apis.grandCredentials.dataOwnerId)\n expect(params[0].unavailableKeys).to.be.empty\n expect(params[0].unknownKeys).to.be.empty\n expect(params[1].dataOwner.dataOwner.id).to.equal(apis.parentCredentials.dataOwnerId)\n expect(params[1].unavailableKeys).to.have.members([apis.parentCredentials.publicKey])\n expect(params[1].unknownKeys).to.have.members([apis.parentCredentials.publicKey])\n expect(params[2].dataOwner.dataOwner.id).to.equal(apis.childCredentials.dataOwnerId)\n expect(params[2].unavailableKeys).to.be.empty\n expect(params[2].unknownKeys).to.be.empty\n })\n\n it('Should not ask crypto strategies to recover keys if all keys are available', async () => {\n const apis = await createHcpHierarchyApis(env)\n const storageWithoutParentKey = await testStorageWithKeys([\n {\n dataOwnerId: apis.grandCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.grandCredentials.privateKey, publicKey: apis.grandCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.parentCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.parentCredentials.privateKey, publicKey: apis.parentCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n {\n dataOwnerId: apis.childCredentials.dataOwnerId,\n pairs: [\n { keyPair: { privateKey: apis.childCredentials.privateKey, publicKey: apis.childCredentials.publicKey }, shaVersion: ShaVersion.Sha1 },\n ],\n },\n ])\n const cryptoStrats = new TestCryptoStrategies()\n await IcureApi.initialise(\n env.iCureUrl,\n { username: apis.childCredentials.user, password: apis.childCredentials.password },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storageWithoutParentKey.storage,\n keyStorage: storageWithoutParentKey.keyStorage,\n entryKeysFactory: storageWithoutParentKey.keyFactory,\n }\n )\n expect(cryptoStrats.recoverAndVerifyCallsParams).to.have.length(0)\n })\n\n it('Should allow to retrieve all keys for a data owner and his parents', async () => {\n const apis = await createHcpHierarchyApis(env)\n const keysData = await apis.childApi.cryptoApi.getEncryptionDecryptionKeypairsForDataOwnerHierarchy()\n async function checkKey(userDetails: UserDetails, key: KeyPair<CryptoKey>) {\n const exportedPrivateKey = ua2hex(await apis.childApi.cryptoApi.primitives.RSA.exportKey(key.privateKey, 'pkcs8'))\n const exportedPublicKey = ua2hex(await apis.childApi.cryptoApi.primitives.RSA.exportKey(key.publicKey, 'spki'))\n expect(exportedPublicKey).to.equal(userDetails.publicKey)\n expect(exportedPrivateKey).to.equal(userDetails.privateKey)\n }\n expect(keysData.self.dataOwnerId).to.equal(apis.childCredentials.dataOwnerId)\n expect(keysData.self.keys).to.have.length(1)\n expect(keysData.self.keys[0].verified).to.be.true\n await checkKey(apis.childCredentials, keysData.self.keys[0].pair)\n expect(keysData.parents).to.have.length(2)\n expect(keysData.parents[0].dataOwnerId).to.equal(apis.grandCredentials.dataOwnerId)\n expect(keysData.parents[0].keys).to.have.length(1)\n await checkKey(apis.grandCredentials, keysData.parents[0].keys[0].pair)\n expect(keysData.parents[1].dataOwnerId).to.equal(apis.parentCredentials.dataOwnerId)\n expect(keysData.parents[1].keys).to.have.length(1)\n await checkKey(apis.parentCredentials, keysData.parents[1].keys[0].pair)\n })\n\n it('If a HCP has no key yet, but the parent does the crypto strategies should first ask to recover the keys for the parent then ask for the generation of a new key to the data owner', async () => {\n const hcpsInfo = await createNewHcpWithoutKeyAndParentWithKey(env)\n const cryptoStrats = new (class implements CryptoStrategies {\n generateNewKeyCalled: boolean = false\n recoverCalled: boolean = false\n generatedKeyPair: KeyPair<CryptoKey> | undefined = undefined\n\n async generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean> {\n if (this.generateNewKeyCalled) throw new Error('generateNewKeyForDataOwner called twice')\n if (!this.recoverCalled) throw new Error('generateNewKeyForDataOwner called before recoverAndVerifySelfHierarchyKeys')\n this.generateNewKeyCalled = true\n expect(self.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n return (this.generatedKeyPair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256))\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n if (this.recoverCalled) throw new Error('recoverAndVerifySelfHierarchyKeys called twice')\n this.recoverCalled = true\n expect(keysData).to.have.length(2)\n expect(keysData[0].dataOwner.dataOwner.id).to.equal(hcpsInfo.parentCredentials.dataOwnerId)\n expect(keysData[0].unknownKeys).to.have.members([hcpsInfo.parentCredentials.publicKey])\n expect(keysData[0].unavailableKeys).to.have.members([hcpsInfo.parentCredentials.publicKey])\n expect(keysData[1].dataOwner.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n expect(keysData[1].unknownKeys).to.be.empty\n expect(keysData[1].unavailableKeys).to.be.empty\n return {\n [hcpsInfo.parentCredentials.dataOwnerId]: {\n recoveredKeys: {\n [hcpsInfo.parentCredentials.publicKey.slice(-32)]: await cryptoPrimitives.RSA.importKeyPair(\n 'pkcs8',\n ua2ab(hex2ua(hcpsInfo.parentCredentials.privateKey)),\n 'spki',\n ua2ab(hex2ua(hcpsInfo.parentCredentials.publicKey)),\n ShaVersion.Sha1\n ),\n },\n keyAuthenticity: {},\n },\n [hcpsInfo.childDataOwnerId]: {\n recoveredKeys: {},\n keyAuthenticity: {},\n },\n }\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n throw new Error('This method should not be called by this test')\n }\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return false\n }\n })()\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcpsInfo.childUser, password: hcpsInfo.childPassword },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: new TestStorage(),\n keyStorage: new TestKeyStorage(),\n }\n )\n expect(cryptoStrats.generateNewKeyCalled).to.be.true\n expect(cryptoStrats.recoverCalled).to.be.true\n const keys = Array.from(childApi.dataOwnerApi.getHexPublicKeysOf((await childApi.dataOwnerApi.getCurrentDataOwner()).dataOwner))\n expect(keys).to.have.length(1)\n expect(Array.from(keys)[0]).to.equal(ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(cryptoStrats.generatedKeyPair!.publicKey, 'spki')))\n })\n\n it('If a HCP has no key yet, but the parent does and the key is available the crypto strategies should ask for the generation of a new key to the data owner', async () => {\n async function doTest(initialiseEmptyKeyForChild: boolean) {\n const hcpsInfo = await createNewHcpWithoutKeyAndParentWithKey(env, { initialiseEmptyKeyForChild })\n const cryptoStrats = new (class implements CryptoStrategies {\n generateNewKeyCalled: boolean = false\n generatedKeyPair: KeyPair<CryptoKey> | undefined = undefined\n\n async generateNewKeyForDataOwner(self: DataOwnerWithType, cryptoPrimitives: CryptoPrimitives): Promise<KeyPair<CryptoKey> | boolean> {\n if (this.generateNewKeyCalled) throw new Error('generateNewKeyForDataOwner called twice')\n this.generateNewKeyCalled = true\n expect(self.dataOwner.id).to.equal(hcpsInfo.childDataOwnerId)\n return (this.generatedKeyPair = await cryptoPrimitives.RSA.generateKeyPair(ShaVersion.Sha256))\n }\n\n async recoverAndVerifySelfHierarchyKeys(\n keysData: {\n dataOwner: DataOwnerWithType\n unknownKeys: string[]\n unavailableKeys: string[]\n }[],\n cryptoPrimitives: CryptoPrimitives\n ): Promise<{\n [p: string]: { recoveredKeys: { [p: string]: KeyPair<CryptoKey> }; keyAuthenticity: { [p: string]: boolean } }\n }> {\n throw new Error('This method should not be called by this test')\n }\n\n dataOwnerRequiresAnonymousDelegation(dataOwner: CryptoActorStubWithType): boolean {\n return false\n }\n\n verifyDelegatePublicKeys(delegate: CryptoActorStubWithType, publicKeys: string[], cryptoPrimitives: CryptoPrimitives): Promise<string[]> {\n throw new Error('This method should not be called by this test')\n }\n })()\n const storages = await testStorageWithKeys([\n {\n dataOwnerId: hcpsInfo.parentCredentials.dataOwnerId,\n pairs: [\n {\n keyPair: { privateKey: hcpsInfo.parentCredentials.privateKey, publicKey: hcpsInfo.parentCredentials.publicKey },\n shaVersion: ShaVersion.Sha1,\n },\n ],\n },\n ])\n const childApi = await IcureApi.initialise(\n env.iCureUrl,\n { username: hcpsInfo.childUser, password: hcpsInfo.childPassword },\n cryptoStrats,\n webcrypto as any,\n fetch,\n {\n storage: storages.storage,\n keyStorage: storages.keyStorage,\n entryKeysFactory: storages.keyFactory,\n }\n )\n expect(cryptoStrats.generateNewKeyCalled).to.be.true\n const initialisedHcp = (await childApi.dataOwnerApi.getCurrentDataOwner()).dataOwner\n const keys = Array.from(childApi.dataOwnerApi.getHexPublicKeysOf(initialisedHcp))\n expect(keys).to.have.length(1)\n expect(keys[0]).to.equal(ua2hex(await childApi.cryptoApi.primitives.RSA.exportKey(cryptoStrats.generatedKeyPair!.publicKey, 'spki')))\n }\n await doTest(false)\n await doTest(true)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'isomorphic-fetch';
|
|
@@ -0,0 +1,333 @@
|
|
|
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 chai_1 = require("chai");
|
|
15
|
+
const crypto_1 = require("crypto");
|
|
16
|
+
const test_utils_1 = require("../../utils/test_utils");
|
|
17
|
+
const types_1 = require("@icure/test-setup/types");
|
|
18
|
+
const HealthElement_1 = require("../../../icc-api/model/HealthElement");
|
|
19
|
+
const Patient_1 = require("../../../icc-api/model/Patient");
|
|
20
|
+
const CodeStub_1 = require("../../../icc-api/model/CodeStub");
|
|
21
|
+
const Identifier_1 = require("../../../icc-api/model/Identifier");
|
|
22
|
+
const HealthElementByHcPartyTagFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyTagFilter");
|
|
23
|
+
const HealthElementByHcPartyCodeFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyCodeFilter");
|
|
24
|
+
const HealthElementByHcPartyIdentifiersVersioningFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter");
|
|
25
|
+
const HealthElementByHcPartyStatusVersioningFilter_1 = require("../../../icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter");
|
|
26
|
+
const VersionFiltering_1 = require("../../../icc-x-api/filters/VersionFiltering");
|
|
27
|
+
(0, test_utils_1.setLocalStorage)(fetch);
|
|
28
|
+
let env;
|
|
29
|
+
function initHcpApiAndPatient() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { api, user } = yield (0, test_utils_1.createNewHcpApi)(env);
|
|
32
|
+
const patient = yield api.patientApi.createPatientWithUser(user, yield api.patientApi.newInstance(user, new Patient_1.Patient({
|
|
33
|
+
id: (0, crypto_1.randomUUID)(),
|
|
34
|
+
firstName: 'Test',
|
|
35
|
+
lastName: 'Patient',
|
|
36
|
+
})));
|
|
37
|
+
return { api, user, patient };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
describe('HealthElement Filters Tests', () => {
|
|
41
|
+
(0, mocha_1.before)(function () {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
this.timeout(600000);
|
|
44
|
+
const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
|
|
45
|
+
env = yield initializer.execute((0, types_1.getEnvVariables)());
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('HealthElementByHcPartyTagFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
// Given - Create a new HCP and initialize the api
|
|
50
|
+
const { api, user, patient } = yield initHcpApiAndPatient();
|
|
51
|
+
const hcpId = user.healthcarePartyId;
|
|
52
|
+
// Target tag to search for
|
|
53
|
+
const targetTagType = 'CD-LIFECYCLE';
|
|
54
|
+
const targetTagCode = 'active';
|
|
55
|
+
const matchingTag = new CodeStub_1.CodeStub({ id: `${targetTagType}|${targetTagCode}|1`, type: targetTagType, code: targetTagCode, version: '1' });
|
|
56
|
+
const nonMatchingTag = new CodeStub_1.CodeStub({ id: 'CD-LIFECYCLE|inactive|1', type: 'CD-LIFECYCLE', code: 'inactive', version: '1' });
|
|
57
|
+
// Helper to create and save a health element
|
|
58
|
+
function createHealthElement(opts) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
|
|
61
|
+
id: (0, crypto_1.randomUUID)(),
|
|
62
|
+
healthElementId: opts.healthElementId,
|
|
63
|
+
tags: opts.tags,
|
|
64
|
+
modified: opts.modified,
|
|
65
|
+
note: 'Test health element',
|
|
66
|
+
}));
|
|
67
|
+
return api.healthcareElementApi.createHealthElementWithUser(user, he);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// 1. A health element with the matching tag and no healthElementId
|
|
71
|
+
const he1 = yield createHealthElement({ tags: [matchingTag] });
|
|
72
|
+
// 2. A health element with the matching tag and a healthElementId
|
|
73
|
+
const he2HealthElementId = (0, crypto_1.randomUUID)();
|
|
74
|
+
const he2 = yield createHealthElement({ tags: [matchingTag], healthElementId: he2HealthElementId });
|
|
75
|
+
// 3. Two health elements with same healthElementId, different modified times:
|
|
76
|
+
// 3a. lowest modified has matching tag
|
|
77
|
+
// 3b. highest modified does not have matching tag (this is the latest version)
|
|
78
|
+
const he3HealthElementId = (0, crypto_1.randomUUID)();
|
|
79
|
+
const he3a = yield createHealthElement({
|
|
80
|
+
tags: [matchingTag],
|
|
81
|
+
healthElementId: he3HealthElementId,
|
|
82
|
+
modified: 1000,
|
|
83
|
+
});
|
|
84
|
+
const he3b = yield createHealthElement({
|
|
85
|
+
tags: [nonMatchingTag],
|
|
86
|
+
healthElementId: he3HealthElementId,
|
|
87
|
+
modified: 2000,
|
|
88
|
+
});
|
|
89
|
+
// 4. Two health elements with same healthElementId, different modified times:
|
|
90
|
+
// 4a. lowest modified does not have matching tag
|
|
91
|
+
// 4b. highest modified has matching tag (this is the latest version)
|
|
92
|
+
const he4HealthElementId = (0, crypto_1.randomUUID)();
|
|
93
|
+
const he4a = yield createHealthElement({
|
|
94
|
+
tags: [nonMatchingTag],
|
|
95
|
+
healthElementId: he4HealthElementId,
|
|
96
|
+
modified: 1000,
|
|
97
|
+
});
|
|
98
|
+
const he4b = yield createHealthElement({
|
|
99
|
+
tags: [matchingTag],
|
|
100
|
+
healthElementId: he4HealthElementId,
|
|
101
|
+
modified: 2000,
|
|
102
|
+
});
|
|
103
|
+
// 5. A health element without the matching tag and no healthElementId
|
|
104
|
+
const he5 = yield createHealthElement({ tags: [nonMatchingTag] });
|
|
105
|
+
// 6. A health element without the matching tag and a healthElementId
|
|
106
|
+
const he6HealthElementId = (0, crypto_1.randomUUID)();
|
|
107
|
+
const he6 = yield createHealthElement({ tags: [nonMatchingTag], healthElementId: he6HealthElementId });
|
|
108
|
+
// When - Use the filter with match method
|
|
109
|
+
const filter = new HealthElementByHcPartyTagFilter_1.HealthElementByHcPartyTagFilter({
|
|
110
|
+
healthcarePartyId: hcpId,
|
|
111
|
+
tagType: targetTagType,
|
|
112
|
+
tagCode: targetTagCode,
|
|
113
|
+
versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
|
|
114
|
+
});
|
|
115
|
+
const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
|
|
116
|
+
// Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
|
|
117
|
+
(0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
|
|
118
|
+
}));
|
|
119
|
+
it('HealthElementByHcPartyCodeFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
// Given - Create a new HCP and initialize the api
|
|
121
|
+
const { api, user, patient } = yield initHcpApiAndPatient();
|
|
122
|
+
const hcpId = user.healthcarePartyId;
|
|
123
|
+
// Target code to search for
|
|
124
|
+
const targetCodeType = 'SNOMED';
|
|
125
|
+
const targetCodeCode = '38341003';
|
|
126
|
+
const matchingCode = new CodeStub_1.CodeStub({ id: `${targetCodeType}|${targetCodeCode}|2`, type: targetCodeType, code: targetCodeCode, version: '2' });
|
|
127
|
+
const nonMatchingCode = new CodeStub_1.CodeStub({ id: 'SNOMED|73211009|2', type: 'SNOMED', code: '73211009', version: '2' });
|
|
128
|
+
// Helper to create and save a health element
|
|
129
|
+
function createHealthElement(opts) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
|
|
132
|
+
id: (0, crypto_1.randomUUID)(),
|
|
133
|
+
healthElementId: opts.healthElementId,
|
|
134
|
+
codes: opts.codes,
|
|
135
|
+
modified: opts.modified,
|
|
136
|
+
note: 'Test health element',
|
|
137
|
+
}));
|
|
138
|
+
return api.healthcareElementApi.createHealthElementWithUser(user, he);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// 1. A health element with the matching code and no healthElementId
|
|
142
|
+
const he1 = yield createHealthElement({ codes: [matchingCode] });
|
|
143
|
+
// 2. A health element with the matching code and a healthElementId
|
|
144
|
+
const he2HealthElementId = (0, crypto_1.randomUUID)();
|
|
145
|
+
const he2 = yield createHealthElement({ codes: [matchingCode], healthElementId: he2HealthElementId });
|
|
146
|
+
// 3. Two health elements with same healthElementId, different modified times:
|
|
147
|
+
// 3a. lowest modified has matching code
|
|
148
|
+
// 3b. highest modified does not have matching code (this is the latest version)
|
|
149
|
+
const he3HealthElementId = (0, crypto_1.randomUUID)();
|
|
150
|
+
const he3a = yield createHealthElement({
|
|
151
|
+
codes: [matchingCode],
|
|
152
|
+
healthElementId: he3HealthElementId,
|
|
153
|
+
modified: 1000,
|
|
154
|
+
});
|
|
155
|
+
const he3b = yield createHealthElement({
|
|
156
|
+
codes: [nonMatchingCode],
|
|
157
|
+
healthElementId: he3HealthElementId,
|
|
158
|
+
modified: 2000,
|
|
159
|
+
});
|
|
160
|
+
// 4. Two health elements with same healthElementId, different modified times:
|
|
161
|
+
// 4a. lowest modified does not have matching code
|
|
162
|
+
// 4b. highest modified has matching code (this is the latest version)
|
|
163
|
+
const he4HealthElementId = (0, crypto_1.randomUUID)();
|
|
164
|
+
const he4a = yield createHealthElement({
|
|
165
|
+
codes: [nonMatchingCode],
|
|
166
|
+
healthElementId: he4HealthElementId,
|
|
167
|
+
modified: 1000,
|
|
168
|
+
});
|
|
169
|
+
const he4b = yield createHealthElement({
|
|
170
|
+
codes: [matchingCode],
|
|
171
|
+
healthElementId: he4HealthElementId,
|
|
172
|
+
modified: 2000,
|
|
173
|
+
});
|
|
174
|
+
// 5. A health element without the matching code and no healthElementId
|
|
175
|
+
const he5 = yield createHealthElement({ codes: [nonMatchingCode] });
|
|
176
|
+
// 6. A health element without the matching code and a healthElementId
|
|
177
|
+
const he6HealthElementId = (0, crypto_1.randomUUID)();
|
|
178
|
+
const he6 = yield createHealthElement({ codes: [nonMatchingCode], healthElementId: he6HealthElementId });
|
|
179
|
+
// When - Use the filter with match method
|
|
180
|
+
const filter = new HealthElementByHcPartyCodeFilter_1.HealthElementByHcPartyCodeFilter({
|
|
181
|
+
healthcarePartyId: hcpId,
|
|
182
|
+
codeType: targetCodeType,
|
|
183
|
+
codeCode: targetCodeCode,
|
|
184
|
+
versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
|
|
185
|
+
});
|
|
186
|
+
const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
|
|
187
|
+
// Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
|
|
188
|
+
(0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
|
|
189
|
+
}));
|
|
190
|
+
it('HealthElementByHcPartyIdentifiersVersioningFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
// Given - Create a new HCP and initialize the api
|
|
192
|
+
const { api, user, patient } = yield initHcpApiAndPatient();
|
|
193
|
+
const hcpId = user.healthcarePartyId;
|
|
194
|
+
// Target identifier to search for
|
|
195
|
+
const matchingIdentifier = new Identifier_1.Identifier({
|
|
196
|
+
system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',
|
|
197
|
+
value: 'test-identifier-123',
|
|
198
|
+
});
|
|
199
|
+
const nonMatchingIdentifier = new Identifier_1.Identifier({
|
|
200
|
+
system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',
|
|
201
|
+
value: 'other-identifier-456',
|
|
202
|
+
});
|
|
203
|
+
// Helper to create and save a health element
|
|
204
|
+
function createHealthElement(opts) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
|
|
207
|
+
id: (0, crypto_1.randomUUID)(),
|
|
208
|
+
healthElementId: opts.healthElementId,
|
|
209
|
+
identifiers: opts.identifiers,
|
|
210
|
+
modified: opts.modified,
|
|
211
|
+
note: 'Test health element',
|
|
212
|
+
}));
|
|
213
|
+
return api.healthcareElementApi.createHealthElementWithUser(user, he);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
// 1. A health element with the matching identifier and no healthElementId
|
|
217
|
+
const he1 = yield createHealthElement({ identifiers: [matchingIdentifier] });
|
|
218
|
+
// 2. A health element with the matching identifier and a healthElementId
|
|
219
|
+
const he2HealthElementId = (0, crypto_1.randomUUID)();
|
|
220
|
+
const he2 = yield createHealthElement({ identifiers: [matchingIdentifier], healthElementId: he2HealthElementId });
|
|
221
|
+
// 3. Two health elements with same healthElementId, different modified times:
|
|
222
|
+
// 3a. lowest modified has matching identifier
|
|
223
|
+
// 3b. highest modified does not have matching identifier (this is the latest version)
|
|
224
|
+
const he3HealthElementId = (0, crypto_1.randomUUID)();
|
|
225
|
+
const he3a = yield createHealthElement({
|
|
226
|
+
identifiers: [matchingIdentifier],
|
|
227
|
+
healthElementId: he3HealthElementId,
|
|
228
|
+
modified: 1000,
|
|
229
|
+
});
|
|
230
|
+
const he3b = yield createHealthElement({
|
|
231
|
+
identifiers: [nonMatchingIdentifier],
|
|
232
|
+
healthElementId: he3HealthElementId,
|
|
233
|
+
modified: 2000,
|
|
234
|
+
});
|
|
235
|
+
// 4. Two health elements with same healthElementId, different modified times:
|
|
236
|
+
// 4a. lowest modified does not have matching identifier
|
|
237
|
+
// 4b. highest modified has matching identifier (this is the latest version)
|
|
238
|
+
const he4HealthElementId = (0, crypto_1.randomUUID)();
|
|
239
|
+
const he4a = yield createHealthElement({
|
|
240
|
+
identifiers: [nonMatchingIdentifier],
|
|
241
|
+
healthElementId: he4HealthElementId,
|
|
242
|
+
modified: 1000,
|
|
243
|
+
});
|
|
244
|
+
const he4b = yield createHealthElement({
|
|
245
|
+
identifiers: [matchingIdentifier],
|
|
246
|
+
healthElementId: he4HealthElementId,
|
|
247
|
+
modified: 2000,
|
|
248
|
+
});
|
|
249
|
+
// 5. A health element without the matching identifier and no healthElementId
|
|
250
|
+
const he5 = yield createHealthElement({ identifiers: [nonMatchingIdentifier] });
|
|
251
|
+
// 6. A health element without the matching identifier and a healthElementId
|
|
252
|
+
const he6HealthElementId = (0, crypto_1.randomUUID)();
|
|
253
|
+
const he6 = yield createHealthElement({ identifiers: [nonMatchingIdentifier], healthElementId: he6HealthElementId });
|
|
254
|
+
// When - Use the filter with match method
|
|
255
|
+
const filter = new HealthElementByHcPartyIdentifiersVersioningFilter_1.HealthElementByHcPartyIdentifiersVersioningFilter({
|
|
256
|
+
hcPartyId: hcpId,
|
|
257
|
+
identifiers: [matchingIdentifier],
|
|
258
|
+
versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
|
|
259
|
+
});
|
|
260
|
+
const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
|
|
261
|
+
// Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
|
|
262
|
+
(0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
|
|
263
|
+
}));
|
|
264
|
+
it('HealthElementByHcPartyStatusVersioningFilter with VersionFiltering.LATEST should return correct health elements', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
+
// Given - Create a new HCP and initialize the api
|
|
266
|
+
const { api, user, patient } = yield initHcpApiAndPatient();
|
|
267
|
+
const hcpId = user.healthcarePartyId;
|
|
268
|
+
// Target status to search for (bit 0: active=0/inactive=1, bit 1: relevant=0/irrelevant=1, bit 2: present=0/absent=1)
|
|
269
|
+
const matchingStatus = 0; // active, relevant, present
|
|
270
|
+
const nonMatchingStatus = 1; // inactive, relevant, present
|
|
271
|
+
// Helper to create and save a health element
|
|
272
|
+
function createHealthElement(opts) {
|
|
273
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
+
const he = yield api.healthcareElementApi.newInstance(user, patient, new HealthElement_1.HealthElement({
|
|
275
|
+
id: (0, crypto_1.randomUUID)(),
|
|
276
|
+
healthElementId: opts.healthElementId,
|
|
277
|
+
status: opts.status,
|
|
278
|
+
modified: opts.modified,
|
|
279
|
+
note: 'Test health element',
|
|
280
|
+
}));
|
|
281
|
+
return api.healthcareElementApi.createHealthElementWithUser(user, he);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// 1. A health element with the matching status and no healthElementId
|
|
285
|
+
const he1 = yield createHealthElement({ status: matchingStatus });
|
|
286
|
+
// 2. A health element with the matching status and a healthElementId
|
|
287
|
+
const he2HealthElementId = (0, crypto_1.randomUUID)();
|
|
288
|
+
const he2 = yield createHealthElement({ status: matchingStatus, healthElementId: he2HealthElementId });
|
|
289
|
+
// 3. Two health elements with same healthElementId, different modified times:
|
|
290
|
+
// 3a. lowest modified has matching status
|
|
291
|
+
// 3b. highest modified does not have matching status (this is the latest version)
|
|
292
|
+
const he3HealthElementId = (0, crypto_1.randomUUID)();
|
|
293
|
+
const he3a = yield createHealthElement({
|
|
294
|
+
status: matchingStatus,
|
|
295
|
+
healthElementId: he3HealthElementId,
|
|
296
|
+
modified: 1000,
|
|
297
|
+
});
|
|
298
|
+
const he3b = yield createHealthElement({
|
|
299
|
+
status: nonMatchingStatus,
|
|
300
|
+
healthElementId: he3HealthElementId,
|
|
301
|
+
modified: 2000,
|
|
302
|
+
});
|
|
303
|
+
// 4. Two health elements with same healthElementId, different modified times:
|
|
304
|
+
// 4a. lowest modified does not have matching status
|
|
305
|
+
// 4b. highest modified has matching status (this is the latest version)
|
|
306
|
+
const he4HealthElementId = (0, crypto_1.randomUUID)();
|
|
307
|
+
const he4a = yield createHealthElement({
|
|
308
|
+
status: nonMatchingStatus,
|
|
309
|
+
healthElementId: he4HealthElementId,
|
|
310
|
+
modified: 1000,
|
|
311
|
+
});
|
|
312
|
+
const he4b = yield createHealthElement({
|
|
313
|
+
status: matchingStatus,
|
|
314
|
+
healthElementId: he4HealthElementId,
|
|
315
|
+
modified: 2000,
|
|
316
|
+
});
|
|
317
|
+
// 5. A health element without the matching status and no healthElementId
|
|
318
|
+
const he5 = yield createHealthElement({ status: nonMatchingStatus });
|
|
319
|
+
// 6. A health element without the matching status and a healthElementId
|
|
320
|
+
const he6HealthElementId = (0, crypto_1.randomUUID)();
|
|
321
|
+
const he6 = yield createHealthElement({ status: nonMatchingStatus, healthElementId: he6HealthElementId });
|
|
322
|
+
// When - Use the filter with match method
|
|
323
|
+
const filter = new HealthElementByHcPartyStatusVersioningFilter_1.HealthElementByHcPartyStatusVersioningFilter({
|
|
324
|
+
hcPartyId: hcpId,
|
|
325
|
+
status: matchingStatus,
|
|
326
|
+
versionFiltering: VersionFiltering_1.VersionFiltering.LATEST,
|
|
327
|
+
});
|
|
328
|
+
const matchedIds = yield api.healthcareElementApi.matchHealthElementsBy(filter);
|
|
329
|
+
// Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6
|
|
330
|
+
(0, chai_1.expect)(matchedIds).to.have.members([he1.id, he2.id, he4b.id]);
|
|
331
|
+
}));
|
|
332
|
+
});
|
|
333
|
+
//# sourceMappingURL=healthelement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"healthelement.js","sourceRoot":"","sources":["../../../../test/icc-x-api/filters/healthelement.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA8B;AAC9B,4BAAyB;AACzB,+BAA6B;AAC7B,mCAAmC;AACnC,uDAAoG;AACpG,mDAAmE;AACnE,wEAAoE;AACpE,4DAAwD;AACxD,8DAA0D;AAC1D,kEAA8D;AAC9D,gHAA4G;AAC5G,kHAA8G;AAC9G,oJAAgJ;AAChJ,0IAAsI;AACtI,kFAA8E;AAE9E,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,SAAe,oBAAoB;;QACjC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,4BAAe,EA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,iBAAiB;YACzB,eAAe,EAAE,kBAAkB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC;YACrC,MAAM,EAAE,cAAc;YACtB,eAAe,EAAE,kBAAkB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;QAEF,yEAAyE;QACzE,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAA;QAEpE,wEAAwE;QACxE,MAAM,kBAAkB,GAAG,IAAA,mBAAU,GAAE,CAAA;QACvC,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAA;QAEzG,0CAA0C;QAC1C,MAAM,MAAM,GAAG,IAAI,2FAA4C,CAAC;YAC9D,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,cAAc;YACtB,gBAAgB,EAAE,mCAAgB,CAAC,MAAM;SAC1C,CAAC,CAAA;QAEF,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QAE/E,uDAAuD;QACvD,IAAA,aAAM,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { before } from 'mocha'\nimport 'isomorphic-fetch'\nimport { expect } from 'chai'\nimport { randomUUID } from 'crypto'\nimport { getEnvironmentInitializer, setLocalStorage, createNewHcpApi } from '../../utils/test_utils'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { HealthElement } from '../../../icc-api/model/HealthElement'\nimport { Patient } from '../../../icc-api/model/Patient'\nimport { CodeStub } from '../../../icc-api/model/CodeStub'\nimport { Identifier } from '../../../icc-api/model/Identifier'\nimport { HealthElementByHcPartyTagFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyTagFilter'\nimport { HealthElementByHcPartyCodeFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyCodeFilter'\nimport { HealthElementByHcPartyIdentifiersVersioningFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyIdentifiersVersioningFilter'\nimport { HealthElementByHcPartyStatusVersioningFilter } from '../../../icc-x-api/filters/HealthElementByHcPartyStatusVersioningFilter'\nimport { VersionFiltering } from '../../../icc-x-api/filters/VersionFiltering'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\nasync function initHcpApiAndPatient() {\n const { api, user } = await createNewHcpApi(env)\n\n const patient = await api.patientApi.createPatientWithUser(\n user,\n await api.patientApi.newInstance(\n user,\n new Patient({\n id: randomUUID(),\n firstName: 'Test',\n lastName: 'Patient',\n })\n )\n )\n\n return { api, user, patient }\n}\n\ndescribe('HealthElement Filters Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('HealthElementByHcPartyTagFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target tag to search for\n const targetTagType = 'CD-LIFECYCLE'\n const targetTagCode = 'active'\n const matchingTag = new CodeStub({ id: `${targetTagType}|${targetTagCode}|1`, type: targetTagType, code: targetTagCode, version: '1' })\n const nonMatchingTag = new CodeStub({ id: 'CD-LIFECYCLE|inactive|1', type: 'CD-LIFECYCLE', code: 'inactive', version: '1' })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { tags: CodeStub[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n tags: opts.tags,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching tag and no healthElementId\n const he1 = await createHealthElement({ tags: [matchingTag] })\n\n // 2. A health element with the matching tag and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ tags: [matchingTag], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching tag\n // 3b. highest modified does not have matching tag (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n tags: [matchingTag],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n tags: [nonMatchingTag],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching tag\n // 4b. highest modified has matching tag (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n tags: [nonMatchingTag],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n tags: [matchingTag],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching tag and no healthElementId\n const he5 = await createHealthElement({ tags: [nonMatchingTag] })\n\n // 6. A health element without the matching tag and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ tags: [nonMatchingTag], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyTagFilter({\n healthcarePartyId: hcpId,\n tagType: targetTagType,\n tagCode: targetTagCode,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyCodeFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target code to search for\n const targetCodeType = 'SNOMED'\n const targetCodeCode = '38341003'\n const matchingCode = new CodeStub({ id: `${targetCodeType}|${targetCodeCode}|2`, type: targetCodeType, code: targetCodeCode, version: '2' })\n const nonMatchingCode = new CodeStub({ id: 'SNOMED|73211009|2', type: 'SNOMED', code: '73211009', version: '2' })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { codes: CodeStub[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n codes: opts.codes,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching code and no healthElementId\n const he1 = await createHealthElement({ codes: [matchingCode] })\n\n // 2. A health element with the matching code and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ codes: [matchingCode], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching code\n // 3b. highest modified does not have matching code (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n codes: [matchingCode],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n codes: [nonMatchingCode],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching code\n // 4b. highest modified has matching code (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n codes: [nonMatchingCode],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n codes: [matchingCode],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching code and no healthElementId\n const he5 = await createHealthElement({ codes: [nonMatchingCode] })\n\n // 6. A health element without the matching code and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ codes: [nonMatchingCode], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyCodeFilter({\n healthcarePartyId: hcpId,\n codeType: targetCodeType,\n codeCode: targetCodeCode,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyIdentifiersVersioningFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target identifier to search for\n const matchingIdentifier = new Identifier({\n system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',\n value: 'test-identifier-123',\n })\n const nonMatchingIdentifier = new Identifier({\n system: 'https://www.ehealth.fgov.be/standards/kmehr/id/ehealth',\n value: 'other-identifier-456',\n })\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { identifiers: Identifier[]; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n identifiers: opts.identifiers,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching identifier and no healthElementId\n const he1 = await createHealthElement({ identifiers: [matchingIdentifier] })\n\n // 2. A health element with the matching identifier and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ identifiers: [matchingIdentifier], healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching identifier\n // 3b. highest modified does not have matching identifier (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n identifiers: [matchingIdentifier],\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n identifiers: [nonMatchingIdentifier],\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching identifier\n // 4b. highest modified has matching identifier (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n identifiers: [nonMatchingIdentifier],\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n identifiers: [matchingIdentifier],\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching identifier and no healthElementId\n const he5 = await createHealthElement({ identifiers: [nonMatchingIdentifier] })\n\n // 6. A health element without the matching identifier and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ identifiers: [nonMatchingIdentifier], healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyIdentifiersVersioningFilter({\n hcPartyId: hcpId,\n identifiers: [matchingIdentifier],\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n\n it('HealthElementByHcPartyStatusVersioningFilter with VersionFiltering.LATEST should return correct health elements', async () => {\n // Given - Create a new HCP and initialize the api\n const { api, user, patient } = await initHcpApiAndPatient()\n const hcpId = user.healthcarePartyId!\n\n // Target status to search for (bit 0: active=0/inactive=1, bit 1: relevant=0/irrelevant=1, bit 2: present=0/absent=1)\n const matchingStatus = 0 // active, relevant, present\n const nonMatchingStatus = 1 // inactive, relevant, present\n\n // Helper to create and save a health element\n async function createHealthElement(opts: { status: number; healthElementId?: string; modified?: number }): Promise<HealthElement> {\n const he = await api.healthcareElementApi.newInstance(\n user,\n patient,\n new HealthElement({\n id: randomUUID(),\n healthElementId: opts.healthElementId,\n status: opts.status,\n modified: opts.modified,\n note: 'Test health element',\n })\n )\n return api.healthcareElementApi.createHealthElementWithUser(user, he)\n }\n\n // 1. A health element with the matching status and no healthElementId\n const he1 = await createHealthElement({ status: matchingStatus })\n\n // 2. A health element with the matching status and a healthElementId\n const he2HealthElementId = randomUUID()\n const he2 = await createHealthElement({ status: matchingStatus, healthElementId: he2HealthElementId })\n\n // 3. Two health elements with same healthElementId, different modified times:\n // 3a. lowest modified has matching status\n // 3b. highest modified does not have matching status (this is the latest version)\n const he3HealthElementId = randomUUID()\n const he3a = await createHealthElement({\n status: matchingStatus,\n healthElementId: he3HealthElementId,\n modified: 1000,\n })\n const he3b = await createHealthElement({\n status: nonMatchingStatus,\n healthElementId: he3HealthElementId,\n modified: 2000,\n })\n\n // 4. Two health elements with same healthElementId, different modified times:\n // 4a. lowest modified does not have matching status\n // 4b. highest modified has matching status (this is the latest version)\n const he4HealthElementId = randomUUID()\n const he4a = await createHealthElement({\n status: nonMatchingStatus,\n healthElementId: he4HealthElementId,\n modified: 1000,\n })\n const he4b = await createHealthElement({\n status: matchingStatus,\n healthElementId: he4HealthElementId,\n modified: 2000,\n })\n\n // 5. A health element without the matching status and no healthElementId\n const he5 = await createHealthElement({ status: nonMatchingStatus })\n\n // 6. A health element without the matching status and a healthElementId\n const he6HealthElementId = randomUUID()\n const he6 = await createHealthElement({ status: nonMatchingStatus, healthElementId: he6HealthElementId })\n\n // When - Use the filter with match method\n const filter = new HealthElementByHcPartyStatusVersioningFilter({\n hcPartyId: hcpId,\n status: matchingStatus,\n versionFiltering: VersionFiltering.LATEST,\n })\n\n const matchedIds = await api.healthcareElementApi.matchHealthElementsBy(filter)\n\n // Then - Should find 1, 2, 4b and not 3a, 3b, 4a, 5, 6\n expect(matchedIds).to.have.members([he1.id, he2.id, he4b.id])\n })\n})\n"]}
|
|
@@ -157,8 +157,8 @@ class ApiFactoryV7 {
|
|
|
157
157
|
masterApi(env) {
|
|
158
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
159
|
const key = {
|
|
160
|
-
privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
161
|
-
publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
160
|
+
privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey)), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
161
|
+
publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey)), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
162
162
|
};
|
|
163
163
|
const apis = yield apiV7_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, new TestCryptoStrategiesV7(key), crypto_1.webcrypto, fetch, {
|
|
164
164
|
storage: new TestStorage_1.TestStorage(),
|
|
@@ -252,8 +252,8 @@ class ApiFactoryV8 {
|
|
|
252
252
|
masterApi(env) {
|
|
253
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
254
|
const key = {
|
|
255
|
-
privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
256
|
-
publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
255
|
+
privateKey: yield cryptoPrimitives.RSA.importKey('pkcs8', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.privateKey)), ['decrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
256
|
+
publicKey: yield cryptoPrimitives.RSA.importKey('spki', (0, icc_x_api_1.ua2ab)((0, icc_x_api_1.hex2ua)(env.masterHcp.publicKey)), ['encrypt'], icc_x_api_1.ShaVersion.Sha1),
|
|
257
257
|
};
|
|
258
258
|
const apis = yield icc_x_api_1.IcureApi.initialise(env.iCureUrl, { username: env.masterHcp.user, password: env.masterHcp.password }, new TestCryptoStrategies_1.TestCryptoStrategies(key), crypto_1.webcrypto, fetch, {
|
|
259
259
|
storage: new TestStorage_1.TestStorage(),
|