@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
|
@@ -49,10 +49,14 @@ __exportStar(require("./ContactByHcPartyTagCodeDateFilter"), exports);
|
|
|
49
49
|
__exportStar(require("./ContactByServiceIdsFilter"), exports);
|
|
50
50
|
__exportStar(require("./DeviceByHcPartyFilter"), exports);
|
|
51
51
|
__exportStar(require("./DeviceByIdsFilter"), exports);
|
|
52
|
+
__exportStar(require("./HealthElementByHcPartyCodeFilter"), exports);
|
|
52
53
|
__exportStar(require("./HealthElementByHcPartyFilter"), exports);
|
|
53
54
|
__exportStar(require("./HealthElementByHcPartyIdentifiersFilter"), exports);
|
|
55
|
+
__exportStar(require("./HealthElementByHcPartyIdentifiersVersioningFilter"), exports);
|
|
54
56
|
__exportStar(require("./HealthElementByHcPartySecretForeignKeysFilter"), exports);
|
|
57
|
+
__exportStar(require("./HealthElementByHcPartyStatusVersioningFilter"), exports);
|
|
55
58
|
__exportStar(require("./HealthElementByHcPartyTagCodeFilter"), exports);
|
|
59
|
+
__exportStar(require("./HealthElementByHcPartyTagFilter"), exports);
|
|
56
60
|
__exportStar(require("./HealthElementByIdsFilter"), exports);
|
|
57
61
|
__exportStar(require("./HealthcarePartyByIdsFilter"), exports);
|
|
58
62
|
__exportStar(require("./HealthcarePartyByNameFilter"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../icc-x-api/filters/filters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAiD;AAOjD,6DAAyD;AACzD,+CAA2C;AAC3C,yDAAqD;AACrD,uFAAmF;AACnF,yFAAqF;AACrF,+FAA2F;AAC3F,qFAAiF;AACjF,yGAAqG;AACrG,2FAAuF;AAEvF,uCAAsC;AACtC,qEAAiE;AACjE,uHAAmH;AACnH,6DAAyD;AACzD,uGAAmG;AAGnG,qEAAiE;AAoBjE,mDAAgC;AAChC,qDAAkC;AAClC,uDAAoC;AACpC,+DAA4C;AAC5C,wDAAqC;AACrC,mDAAgC;AAChC,qDAAkC;AAClC,oDAAiC;AACjC,sEAAmD;AAClD,wEAAqD;AACtD,qDAAkC;AAClC,mDAAgC;AAChC,2DAAwC;AACxC,6EAA0D;AAC1D,sEAAmD;AACnD,8DAA2C;AAC3C,0DAAuC;AACvC,sDAAmC;AACnC,iEAA8C;AAC9C,4EAAyD;AACzD,kFAA+D;AAC/D,wEAAqD;AACrD,6DAA0C;AAC1C,+DAA4C;AAC5C,gEAA6C;AAC7C,mEAAgD;AAChD,uEAAoD;AACpD,+DAA4C;AAC5C,uDAAoC;AACpC,mEAAgD;AAChD,oEAAiD;AACjD,qEAAkD;AAClD,wEAAqD;AACrD,yEAAsD;AACtD,kEAA+C;AAC/C,mEAAgD;AAChD,6EAA0D;AAC1D,sEAAmD;AACnD,2DAAwC;AACxC,oFAAiE;AACjE,4EAAyD;AACzD,+DAA4C;AAC5C,uDAAoC;AACpC,0EAAuD;AACvD,2DAAwC;AACxC,sEAAmD;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bstractFilterPatient } from '../../icc-api/model/AbstractFilterPatient'\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\nimport { AbstractFilterService } from '../../icc-api/model/AbstractFilterService'\nimport { Service } from '../../icc-api/model/Service'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { IntersectionFilter } from './IntersectionFilter'\nimport { UnionFilter } from './UnionFilter'\nimport { ComplementFilter } from './ComplementFilter'\nimport { PatientByHcPartyAndActiveFilter } from './PatientByHcPartyAndActiveFilter'\nimport { PatientByHcPartyAndAddressFilter } from './PatientByHcPartyAndAddressFilter'\nimport { PatientByHcPartyAndExternalIdFilter } from './PatientByHcPartyAndExternalIdFilter'\nimport { PatientByHcPartyAndSsinsFilter } from './PatientByHcPartyAndSsinsFilter'\nimport { PatientByHcPartyDateOfBirthBetweenFilter } from './PatientByHcPartyDateOfBirthBetweenFilter'\nimport { PatientByHcPartyDateOfBirthFilter } from './PatientByHcPartyDateOfBirthFilter'\n\nimport { add, format } from 'date-fns'\nimport { PatientByHcPartyFilter } from './PatientByHcPartyFilter'\nimport { PatientByHcPartyGenderEducationProfessionFilter } from './PatientByHcPartyGenderEducationProfessionFilter'\nimport { PatientByIdsFilter } from './PatientByIdsFilter'\nimport { PatientByHcPartyNameContainsFuzzyFilter } from './PatientByHcPartyNameContainsFuzzyFilter'\n\nimport GenderEnum = Patient.GenderEnum\nimport { ContactByHcPartyFilter } from './ContactByHcPartyFilter'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { AbstractFilterMaintenanceTask } from '../../icc-api/model/AbstractFilterMaintenanceTask'\nimport { Code } from '../../icc-api/model/Code'\nimport { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\nimport { Invoice } from '../../icc-api/model/Invoice'\nimport { AbstractFilterInvoice } from '../../icc-api/model/AbstractFilterInvoice'\nimport { User } from '../../icc-api/model/User'\nimport { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { AbstractFilterHealthcareParty } from '../../icc-api/model/AbstractFilterHealthcareParty'\nimport {Tarification} from \"../../icc-api/model/Tarification\"\nimport {AbstractFilterPricing} from \"../../icc-api/model/AbstractFilterPricing\"\nimport {Insurance} from \"../../icc-api/model/Insurance\"\nimport {AbstractFilterInsurance} from \"../../icc-api/model/AbstractFilterInsurance\"\n\nexport * from './AllCodesFilter'\nexport * from './AllDevicesFilter'\nexport * from './AllDocumentsFilter'\nexport * from './AllHealthcarePartiesFilter'\nexport * from './AllInsurancesFilter'\nexport * from './AllUsersFilter'\nexport * from './AllPricingFilter'\nexport * from './CodeByIdsFilter'\nexport * from './CodeByRegionTypeCodeVersionFilter'\n export * from './CodeByRegionTypeLabelLanguageFilter'\nexport * from './ComplementFilter'\nexport * from './ConstantFilter'\nexport * from './ContactByHcPartyFilter'\nexport * from './ContactByHcPartyPatientTagCodeDateFilter'\nexport * from './ContactByHcPartyTagCodeDateFilter'\nexport * from './ContactByServiceIdsFilter'\nexport * from './DeviceByHcPartyFilter'\nexport * from './DeviceByIdsFilter'\nexport * from './HealthElementByHcPartyFilter'\nexport * from './HealthElementByHcPartyIdentifiersFilter'\nexport * from './HealthElementByHcPartySecretForeignKeysFilter'\nexport * from './HealthElementByHcPartyTagCodeFilter'\nexport * from './HealthElementByIdsFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './HealthcarePartyByNameFilter'\nexport * from './HealthcarePartyByTagCodeFilter'\nexport * from './HealthcarePartyByIdentifiersFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './IntersectionFilter'\nexport * from './InvoiceByHcPartyCodeDateFilter'\nexport * from './PatientByHcPartyAndActiveFilter'\nexport * from './PatientByHcPartyAndAddressFilter'\nexport * from './PatientByHcPartyAndExternalIdFilter'\nexport * from './PatientByHcPartyAndIdentifiersFilter'\nexport * from './PatientByHcPartyAndSsinFilter'\nexport * from './PatientByHcPartyAndSsinsFilter'\nexport * from './PatientByHcPartyDateOfBirthBetweenFilter'\nexport * from './PatientByHcPartyDateOfBirthFilter'\nexport * from './PatientByHcPartyFilter'\nexport * from './PatientByHcPartyGenderEducationProfessionFilter'\nexport * from './PatientByHcPartyNameContainsFuzzyFilter'\nexport * from './PatientByHcPartyNameFilter'\nexport * from './PatientByIdsFilter'\nexport * from './ServiceByContactsAndSubcontactsFilter'\nexport * from './ServiceByHcPartyFilter'\nexport * from './ServiceByHcPartyIdentifiersFilter'\nexport * from './ServiceByHcPartyHealthElementIdsFilter'\nexport * from './ServiceByHcPartyTagCodeDateFilter'\nexport * from './ServiceByIdsFilter'\nexport * from './ServiceBySecretForeignKeys'\nexport * from './UnionFilter'\nexport * from './UserByIdsFilter'\nexport * from './MaintenanceTaskByHcPartyAndIdentifiersFilter'\nexport * from './MaintenanceTaskByHcPartyAndTypeFilter'\nexport * from './MaintenanceTaskByIdsFilter'\nexport * from './MaintenanceTaskAfterDateFilter'\nexport * from './TopicByHcPartyFilter'\nexport * from './TopicByParticipantFilter'\nexport * from './MessageByHcPartyFilter'\nexport * from './MessageByHcPartyTransportGuidFilter'\nexport * from './LatestMessageByHcPartyTransportGuidFilter'\n\nexport class Filter {\n public static patient(): PatientFilterBuilder {\n return new PatientFilterBuilder()\n }\n}\n\nexport type AbstractFilter<T> =\n | (T extends Patient\n ? AbstractFilterPatient\n : T extends Contact\n ? AbstractFilterContact\n : T extends Service\n ? AbstractFilterService\n : T extends HealthcareParty\n ? AbstractFilterHealthcareParty\n : T extends Device\n ? AbstractFilterDevice\n : T extends MaintenanceTask\n ? AbstractFilterMaintenanceTask\n : T extends Code\n ? AbstractFilterCode\n : T extends HealthElement\n ? AbstractFilterHealthElement\n : T extends Insurance\n ? AbstractFilterInsurance\n : T extends Invoice\n ? AbstractFilterInvoice\n : T extends User\n ? AbstractFilterUser\n : T extends Tarification\n ? AbstractFilterPricing\n : never)\n | ConstantFilter<T>\n | IntersectionFilter<T>\n | UnionFilter<T>\n | ComplementFilter<T>\n\nconst f: AbstractFilterContact = new ComplementFilter<Contact>(new ContactByHcPartyFilter({}), new ContactByHcPartyFilter({}))\n\nabstract class FilterBuilder<T> {\n // This is the current generator for the filter, when we call build(), filterProvider() is going to be called\n filterProvider?: () => AbstractFilter<T>\n // This is the method that is called each time we chain a filter to another filter. The default behaviour is to\n // return a FilterBuilder with the provider set to the last element in the chain, except when we use combination\n // operators like or()/and()/… . After one of those, the composer is set to a function that will return a FilterBuilder\n\n protected constructor(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ) {\n this.filterProvider = filterProvider\n composer && (this.composer = composer)\n }\n\n // that combines the existing filterBuilder with the filter definition we just added.\n composer: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T> = (\n thisFilterBuilder: FilterBuilder<T>,\n otherFilterBuilder: FilterBuilder<T>\n ) => otherFilterBuilder\n\n abstract build(): AbstractFilter<T>\n\n abstract clone(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ): FilterBuilder<T>\n\n listOf(elements: T[]): FilterBuilder<T> {\n return this.clone(() => new ConstantFilter<T>(elements) as AbstractFilter<T>)\n }\n\n /**\n * There are two ways of doing and, or, …\n *\n * 1) for (...) or (...) we use the syntax ... .or((builder) => builder...)\n * ex: youngerThan(65).or((b) => b.olderThan(18).and().gender(M)) means any gender < 65 or male > 18\n * 2) for ((...) or ...) we use the syntax ... .or().…\n * ex: youngerThan(65).or().olderThan(18).and().gender(M) means males between 18 and 65\n *\n * When 1) is used we do not have to wait for anything to provide a resolved builder that can later be combined with extra elements in the chain.\n * In other words, we can build the current filter chain up to the or/and/… and we can build what is inside the or/and/… brackets and we can set\n * the filterProvider of the returned Builder to () => UnionFilter([leftHand.build(), innerBrackets.build()]).\n *\n * When 2) is used, things get more tricky because we will have to do an or/and/… between what we have on the leftHand and with what we do not have\n * yet on the right hand. What we do in that situation is to set the filterProvider() to undefined because calling build() without having provided a\n * rightHand doesn't make sense. We set a composer that is going to be called the next time we chain a filter.\n *\n * @param filterBuilderFactory\n */\n\n and(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new IntersectionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n or(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new UnionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n minus(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new ComplementFilter<T>(leftHandFilter, rightHandFilter) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n private makeLazyLeftRightFilterBuilder(\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const leftHandFilterBuilder: FilterBuilder<T> = this\n const leftHandFilter = leftHandFilterBuilder.build() // Freeze the leftHand filter\n\n return leftHandFilterBuilder.filterProvider\n ? this.clone(\n undefined, //filter provider is indeterminate until we have performed a composition\n (unused: FilterBuilder<T>, rightHandFilterBuilder: FilterBuilder<T>) => {\n // because we freeze the leftHand in the state it is right now, we are not going to use its value when the composition occurs\n const rightHandFilter = rightHandFilterBuilder.build()\n\n return rightHandFilter\n ? this.clone(leftHandRightHandFiltersCombiner(leftHandFilter, rightHandFilter), rightHandFilterBuilder.composer)\n : rightHandFilterBuilder //Can this happen ?\n }\n )\n : this\n }\n\n private makeEagerLeftRightFilterBuilder(\n rightHandFilterBuilderFactory: (it: FilterBuilder<T>) => FilterBuilder<T>,\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n const rightHandFilterBuilder = rightHandFilterBuilderFactory(this)\n return this.filterProvider ? this.clone(leftHandRightHandFiltersCombiner(this.build(), rightHandFilterBuilder.build())) : this\n }\n}\n\nclass PatientFilterBuilder extends FilterBuilder<Patient> {\n hcpId?: string\n\n constructor(\n filterProvider?: () => AbstractFilter<Patient>,\n hcpId?: string,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ) {\n super(filterProvider, composer)\n this.hcpId = hcpId\n }\n\n clone(\n filterProvider?: () => AbstractFilter<Patient>,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ): FilterBuilder<Patient> {\n return new PatientFilterBuilder(filterProvider, this.hcpId, composer)\n }\n\n listOf(elements: Patient[]): PatientFilterBuilder {\n return new PatientFilterBuilder(() => new ConstantFilter<Patient>(elements) as AbstractFilter<Patient>)\n }\n\n and(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.and(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n or(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.or(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n minus(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.minus(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n forHcp(hcpId: string): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(this.filterProvider, hcpId)) as PatientFilterBuilder\n }\n\n all(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyFilter({ healthcarePartyId: this.hcpId }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n activePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: true }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n inactivePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: false }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n byAddress(searchString?: string, postalCode?: string, houseNumber?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndAddressFilter({\n healthcarePartyId: this.hcpId,\n searchString,\n postalCode,\n houseNumber,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withExternalId(externalId: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndExternalIdFilter({\n healthcarePartyId: this.hcpId,\n externalId: externalId,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withSsins(ssins: string[]): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndSsinsFilter({ healthcarePartyId: this.hcpId, ssins: ssins }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n withDateOfBirthBetween(from?: number, to?: number): PatientFilterBuilder {\n return this.composer(\n this,\n this.clone(\n () =>\n new PatientByHcPartyDateOfBirthBetweenFilter({\n healthcarePartyId: this.hcpId,\n minDateOfBirth: from,\n maxDateOfBirth: to,\n })\n )\n ) as PatientFilterBuilder\n }\n\n byDateOfBirth(dateOfBirth: number): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyDateOfBirthFilter({\n healthcarePartyId: this.hcpId,\n dateOfBirth: dateOfBirth,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n olderThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(10000101, parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')))\n }\n\n youngerThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')), 99991231)\n }\n\n byGenderEducationProfession(gender?: GenderEnum, education?: string, profession?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyGenderEducationProfessionFilter({\n healthcarePartyId: this.hcpId,\n gender: gender,\n education: education,\n profession: profession,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n byIds(ids: string[]): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(() => new PatientByIdsFilter({ ids: ids }), this.hcpId)) as PatientFilterBuilder\n }\n\n searchByName(name: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyNameContainsFuzzyFilter({\n healthcarePartyId: this.hcpId,\n searchString: name,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n build(): AbstractFilter<Patient> {\n return this.filterProvider?.() || this.all().build()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../icc-x-api/filters/filters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAiD;AAOjD,6DAAyD;AACzD,+CAA2C;AAC3C,yDAAqD;AACrD,uFAAmF;AACnF,yFAAqF;AACrF,+FAA2F;AAC3F,qFAAiF;AACjF,yGAAqG;AACrG,2FAAuF;AAEvF,uCAAsC;AACtC,qEAAiE;AACjE,uHAAmH;AACnH,6DAAyD;AACzD,uGAAmG;AAGnG,qEAAiE;AAoBjE,mDAAgC;AAChC,qDAAkC;AAClC,uDAAoC;AACpC,+DAA4C;AAC5C,wDAAqC;AACrC,mDAAgC;AAChC,qDAAkC;AAClC,oDAAiC;AACjC,sEAAmD;AACnD,wEAAqD;AACrD,qDAAkC;AAClC,mDAAgC;AAChC,2DAAwC;AACxC,6EAA0D;AAC1D,sEAAmD;AACnD,8DAA2C;AAC3C,0DAAuC;AACvC,sDAAmC;AACnC,qEAAkD;AAClD,iEAA8C;AAC9C,4EAAyD;AACzD,sFAAmE;AACnE,kFAA+D;AAC/D,iFAA8D;AAC9D,wEAAqD;AACrD,oEAAiD;AACjD,6DAA0C;AAC1C,+DAA4C;AAC5C,gEAA6C;AAC7C,mEAAgD;AAChD,uEAAoD;AACpD,+DAA4C;AAC5C,uDAAoC;AACpC,mEAAgD;AAChD,oEAAiD;AACjD,qEAAkD;AAClD,wEAAqD;AACrD,yEAAsD;AACtD,kEAA+C;AAC/C,mEAAgD;AAChD,6EAA0D;AAC1D,sEAAmD;AACnD,2DAAwC;AACxC,oFAAiE;AACjE,4EAAyD;AACzD,+DAA4C;AAC5C,uDAAoC;AACpC,0EAAuD;AACvD,2DAAwC;AACxC,sEAAmD;AACnD,2EAAwD;AACxD,sEAAmD;AACnD,uDAAoC;AACpC,+DAA4C;AAC5C,gDAA6B;AAC7B,oDAAiC;AACjC,iFAA8D;AAC9D,0EAAuD;AACvD,+DAA4C;AAC5C,mEAAgD;AAChD,yDAAsC;AACtC,6DAA0C;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QAAQ,CAAC,CAAA;IAC9G,CAAC;IAED,2BAA2B,CAAC,MAAmB,EAAE,SAAkB,EAAE,UAAmB;QACtF,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,EACJ,IAAI,oBAAoB,CACtB,GAAG,EAAE,CACH,IAAI,iGAA+C,CAAC;YAClD,iBAAiB,EAAE,IAAI,CAAC,KAAK;YAC7B,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,SAAS;YACpB,UAAU,EAAE,UAAU;SACvB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,GAAa;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,oBAAoB,CAAC,GAAG,EAAE,CAAC,IAAI,uCAAkB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAyB,CAAA;IACtI,CAAC;IAED,YAAY,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,QAAQ,CAClB,IAAI,EACJ,IAAI,oBAAoB,CACtB,GAAG,EAAE,CACH,IAAI,iFAAuC,CAAC;YAC1C,iBAAiB,EAAE,IAAI,CAAC,KAAK;YAC7B,YAAY,EAAE,IAAI;SACnB,CAAC,EACJ,IAAI,CAAC,KAAK,CACX,CACsB,CAAA;IAC3B,CAAC;IAED,KAAK;;QACH,OAAO,CAAA,MAAA,IAAI,CAAC,cAAc,oDAAI,KAAI,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAA;IACtD,CAAC;CACF","sourcesContent":["import { ConstantFilter } from './ConstantFilter'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { AbstractFilterPatient } from '../../icc-api/model/AbstractFilterPatient'\nimport { AbstractFilterContact } from '../../icc-api/model/AbstractFilterContact'\nimport { AbstractFilterService } from '../../icc-api/model/AbstractFilterService'\nimport { Service } from '../../icc-api/model/Service'\nimport { Contact } from '../../icc-api/model/Contact'\nimport { IntersectionFilter } from './IntersectionFilter'\nimport { UnionFilter } from './UnionFilter'\nimport { ComplementFilter } from './ComplementFilter'\nimport { PatientByHcPartyAndActiveFilter } from './PatientByHcPartyAndActiveFilter'\nimport { PatientByHcPartyAndAddressFilter } from './PatientByHcPartyAndAddressFilter'\nimport { PatientByHcPartyAndExternalIdFilter } from './PatientByHcPartyAndExternalIdFilter'\nimport { PatientByHcPartyAndSsinsFilter } from './PatientByHcPartyAndSsinsFilter'\nimport { PatientByHcPartyDateOfBirthBetweenFilter } from './PatientByHcPartyDateOfBirthBetweenFilter'\nimport { PatientByHcPartyDateOfBirthFilter } from './PatientByHcPartyDateOfBirthFilter'\n\nimport { add, format } from 'date-fns'\nimport { PatientByHcPartyFilter } from './PatientByHcPartyFilter'\nimport { PatientByHcPartyGenderEducationProfessionFilter } from './PatientByHcPartyGenderEducationProfessionFilter'\nimport { PatientByIdsFilter } from './PatientByIdsFilter'\nimport { PatientByHcPartyNameContainsFuzzyFilter } from './PatientByHcPartyNameContainsFuzzyFilter'\n\nimport GenderEnum = Patient.GenderEnum\nimport { ContactByHcPartyFilter } from './ContactByHcPartyFilter'\nimport { Device } from '../../icc-api/model/Device'\nimport { AbstractFilterDevice } from '../../icc-api/model/AbstractFilterDevice'\nimport { MaintenanceTask } from '../../icc-api/model/MaintenanceTask'\nimport { AbstractFilterMaintenanceTask } from '../../icc-api/model/AbstractFilterMaintenanceTask'\nimport { Code } from '../../icc-api/model/Code'\nimport { AbstractFilterCode } from '../../icc-api/model/AbstractFilterCode'\nimport { HealthElement } from '../../icc-api/model/HealthElement'\nimport { AbstractFilterHealthElement } from '../../icc-api/model/AbstractFilterHealthElement'\nimport { Invoice } from '../../icc-api/model/Invoice'\nimport { AbstractFilterInvoice } from '../../icc-api/model/AbstractFilterInvoice'\nimport { User } from '../../icc-api/model/User'\nimport { AbstractFilterUser } from '../../icc-api/model/AbstractFilterUser'\nimport { HealthcareParty } from '../../icc-api/model/HealthcareParty'\nimport { AbstractFilterHealthcareParty } from '../../icc-api/model/AbstractFilterHealthcareParty'\nimport { Tarification } from '../../icc-api/model/Tarification'\nimport { AbstractFilterPricing } from '../../icc-api/model/AbstractFilterPricing'\nimport { Insurance } from '../../icc-api/model/Insurance'\nimport { AbstractFilterInsurance } from '../../icc-api/model/AbstractFilterInsurance'\n\nexport * from './AllCodesFilter'\nexport * from './AllDevicesFilter'\nexport * from './AllDocumentsFilter'\nexport * from './AllHealthcarePartiesFilter'\nexport * from './AllInsurancesFilter'\nexport * from './AllUsersFilter'\nexport * from './AllPricingFilter'\nexport * from './CodeByIdsFilter'\nexport * from './CodeByRegionTypeCodeVersionFilter'\nexport * from './CodeByRegionTypeLabelLanguageFilter'\nexport * from './ComplementFilter'\nexport * from './ConstantFilter'\nexport * from './ContactByHcPartyFilter'\nexport * from './ContactByHcPartyPatientTagCodeDateFilter'\nexport * from './ContactByHcPartyTagCodeDateFilter'\nexport * from './ContactByServiceIdsFilter'\nexport * from './DeviceByHcPartyFilter'\nexport * from './DeviceByIdsFilter'\nexport * from './HealthElementByHcPartyCodeFilter'\nexport * from './HealthElementByHcPartyFilter'\nexport * from './HealthElementByHcPartyIdentifiersFilter'\nexport * from './HealthElementByHcPartyIdentifiersVersioningFilter'\nexport * from './HealthElementByHcPartySecretForeignKeysFilter'\nexport * from './HealthElementByHcPartyStatusVersioningFilter'\nexport * from './HealthElementByHcPartyTagCodeFilter'\nexport * from './HealthElementByHcPartyTagFilter'\nexport * from './HealthElementByIdsFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './HealthcarePartyByNameFilter'\nexport * from './HealthcarePartyByTagCodeFilter'\nexport * from './HealthcarePartyByIdentifiersFilter'\nexport * from './HealthcarePartyByIdsFilter'\nexport * from './IntersectionFilter'\nexport * from './InvoiceByHcPartyCodeDateFilter'\nexport * from './PatientByHcPartyAndActiveFilter'\nexport * from './PatientByHcPartyAndAddressFilter'\nexport * from './PatientByHcPartyAndExternalIdFilter'\nexport * from './PatientByHcPartyAndIdentifiersFilter'\nexport * from './PatientByHcPartyAndSsinFilter'\nexport * from './PatientByHcPartyAndSsinsFilter'\nexport * from './PatientByHcPartyDateOfBirthBetweenFilter'\nexport * from './PatientByHcPartyDateOfBirthFilter'\nexport * from './PatientByHcPartyFilter'\nexport * from './PatientByHcPartyGenderEducationProfessionFilter'\nexport * from './PatientByHcPartyNameContainsFuzzyFilter'\nexport * from './PatientByHcPartyNameFilter'\nexport * from './PatientByIdsFilter'\nexport * from './ServiceByContactsAndSubcontactsFilter'\nexport * from './ServiceByHcPartyFilter'\nexport * from './ServiceByHcPartyIdentifiersFilter'\nexport * from './ServiceByHcPartyHealthElementIdsFilter'\nexport * from './ServiceByHcPartyTagCodeDateFilter'\nexport * from './ServiceByIdsFilter'\nexport * from './ServiceBySecretForeignKeys'\nexport * from './UnionFilter'\nexport * from './UserByIdsFilter'\nexport * from './MaintenanceTaskByHcPartyAndIdentifiersFilter'\nexport * from './MaintenanceTaskByHcPartyAndTypeFilter'\nexport * from './MaintenanceTaskByIdsFilter'\nexport * from './MaintenanceTaskAfterDateFilter'\nexport * from './TopicByHcPartyFilter'\nexport * from './TopicByParticipantFilter'\nexport * from './MessageByHcPartyFilter'\nexport * from './MessageByHcPartyTransportGuidFilter'\nexport * from './LatestMessageByHcPartyTransportGuidFilter'\n\nexport class Filter {\n public static patient(): PatientFilterBuilder {\n return new PatientFilterBuilder()\n }\n}\n\nexport type AbstractFilter<T> =\n | (T extends Patient\n ? AbstractFilterPatient\n : T extends Contact\n ? AbstractFilterContact\n : T extends Service\n ? AbstractFilterService\n : T extends HealthcareParty\n ? AbstractFilterHealthcareParty\n : T extends Device\n ? AbstractFilterDevice\n : T extends MaintenanceTask\n ? AbstractFilterMaintenanceTask\n : T extends Code\n ? AbstractFilterCode\n : T extends HealthElement\n ? AbstractFilterHealthElement\n : T extends Insurance\n ? AbstractFilterInsurance\n : T extends Invoice\n ? AbstractFilterInvoice\n : T extends User\n ? AbstractFilterUser\n : T extends Tarification\n ? AbstractFilterPricing\n : never)\n | ConstantFilter<T>\n | IntersectionFilter<T>\n | UnionFilter<T>\n | ComplementFilter<T>\n\nconst f: AbstractFilterContact = new ComplementFilter<Contact>(new ContactByHcPartyFilter({}), new ContactByHcPartyFilter({}))\n\nabstract class FilterBuilder<T> {\n // This is the current generator for the filter, when we call build(), filterProvider() is going to be called\n filterProvider?: () => AbstractFilter<T>\n // This is the method that is called each time we chain a filter to another filter. The default behaviour is to\n // return a FilterBuilder with the provider set to the last element in the chain, except when we use combination\n // operators like or()/and()/… . After one of those, the composer is set to a function that will return a FilterBuilder\n\n protected constructor(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ) {\n this.filterProvider = filterProvider\n composer && (this.composer = composer)\n }\n\n // that combines the existing filterBuilder with the filter definition we just added.\n composer: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T> = (\n thisFilterBuilder: FilterBuilder<T>,\n otherFilterBuilder: FilterBuilder<T>\n ) => otherFilterBuilder\n\n abstract build(): AbstractFilter<T>\n\n abstract clone(\n filterProvider?: () => AbstractFilter<T>,\n composer?: (thisFilterBuilder: FilterBuilder<T>, otherFilterBuilder: FilterBuilder<T>) => FilterBuilder<T>\n ): FilterBuilder<T>\n\n listOf(elements: T[]): FilterBuilder<T> {\n return this.clone(() => new ConstantFilter<T>(elements) as AbstractFilter<T>)\n }\n\n /**\n * There are two ways of doing and, or, …\n *\n * 1) for (...) or (...) we use the syntax ... .or((builder) => builder...)\n * ex: youngerThan(65).or((b) => b.olderThan(18).and().gender(M)) means any gender < 65 or male > 18\n * 2) for ((...) or ...) we use the syntax ... .or().…\n * ex: youngerThan(65).or().olderThan(18).and().gender(M) means males between 18 and 65\n *\n * When 1) is used we do not have to wait for anything to provide a resolved builder that can later be combined with extra elements in the chain.\n * In other words, we can build the current filter chain up to the or/and/… and we can build what is inside the or/and/… brackets and we can set\n * the filterProvider of the returned Builder to () => UnionFilter([leftHand.build(), innerBrackets.build()]).\n *\n * When 2) is used, things get more tricky because we will have to do an or/and/… between what we have on the leftHand and with what we do not have\n * yet on the right hand. What we do in that situation is to set the filterProvider() to undefined because calling build() without having provided a\n * rightHand doesn't make sense. We set a composer that is going to be called the next time we chain a filter.\n *\n * @param filterBuilderFactory\n */\n\n and(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new IntersectionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n or(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new UnionFilter<T>([leftHandFilter, rightHandFilter]) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n minus(filterBuilderFactory?: (it: FilterBuilder<T>) => FilterBuilder<T>): FilterBuilder<T> {\n const combiner = (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () =>\n new ComplementFilter<T>(leftHandFilter, rightHandFilter) as AbstractFilter<T>\n\n return filterBuilderFactory ? this.makeEagerLeftRightFilterBuilder(filterBuilderFactory, combiner) : this.makeLazyLeftRightFilterBuilder(combiner)\n }\n\n private makeLazyLeftRightFilterBuilder(\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const leftHandFilterBuilder: FilterBuilder<T> = this\n const leftHandFilter = leftHandFilterBuilder.build() // Freeze the leftHand filter\n\n return leftHandFilterBuilder.filterProvider\n ? this.clone(\n undefined, //filter provider is indeterminate until we have performed a composition\n (unused: FilterBuilder<T>, rightHandFilterBuilder: FilterBuilder<T>) => {\n // because we freeze the leftHand in the state it is right now, we are not going to use its value when the composition occurs\n const rightHandFilter = rightHandFilterBuilder.build()\n\n return rightHandFilter\n ? this.clone(leftHandRightHandFiltersCombiner(leftHandFilter, rightHandFilter), rightHandFilterBuilder.composer)\n : rightHandFilterBuilder //Can this happen ?\n }\n )\n : this\n }\n\n private makeEagerLeftRightFilterBuilder(\n rightHandFilterBuilderFactory: (it: FilterBuilder<T>) => FilterBuilder<T>,\n leftHandRightHandFiltersCombiner: (leftHandFilter: AbstractFilter<T>, rightHandFilter: AbstractFilter<T>) => () => AbstractFilter<T>\n ) {\n const rightHandFilterBuilder = rightHandFilterBuilderFactory(this)\n return this.filterProvider ? this.clone(leftHandRightHandFiltersCombiner(this.build(), rightHandFilterBuilder.build())) : this\n }\n}\n\nclass PatientFilterBuilder extends FilterBuilder<Patient> {\n hcpId?: string\n\n constructor(\n filterProvider?: () => AbstractFilter<Patient>,\n hcpId?: string,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ) {\n super(filterProvider, composer)\n this.hcpId = hcpId\n }\n\n clone(\n filterProvider?: () => AbstractFilter<Patient>,\n composer?: (thisFilterBuilder: FilterBuilder<Patient>, otherFilterBuilder: FilterBuilder<Patient>) => FilterBuilder<Patient>\n ): FilterBuilder<Patient> {\n return new PatientFilterBuilder(filterProvider, this.hcpId, composer)\n }\n\n listOf(elements: Patient[]): PatientFilterBuilder {\n return new PatientFilterBuilder(() => new ConstantFilter<Patient>(elements) as AbstractFilter<Patient>)\n }\n\n and(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.and(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n or(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.or(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n minus(filterBuilderFactory?: (it: PatientFilterBuilder) => PatientFilterBuilder): PatientFilterBuilder {\n return super.minus(filterBuilderFactory as any) as PatientFilterBuilder\n }\n\n forHcp(hcpId: string): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(this.filterProvider, hcpId)) as PatientFilterBuilder\n }\n\n all(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyFilter({ healthcarePartyId: this.hcpId }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n activePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: true }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n inactivePatients(): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndActiveFilter({ healthcarePartyId: this.hcpId, active: false }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n byAddress(searchString?: string, postalCode?: string, houseNumber?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndAddressFilter({\n healthcarePartyId: this.hcpId,\n searchString,\n postalCode,\n houseNumber,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withExternalId(externalId: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyAndExternalIdFilter({\n healthcarePartyId: this.hcpId,\n externalId: externalId,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n withSsins(ssins: string[]): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(() => new PatientByHcPartyAndSsinsFilter({ healthcarePartyId: this.hcpId, ssins: ssins }), this.hcpId)\n ) as PatientFilterBuilder\n }\n\n withDateOfBirthBetween(from?: number, to?: number): PatientFilterBuilder {\n return this.composer(\n this,\n this.clone(\n () =>\n new PatientByHcPartyDateOfBirthBetweenFilter({\n healthcarePartyId: this.hcpId,\n minDateOfBirth: from,\n maxDateOfBirth: to,\n })\n )\n ) as PatientFilterBuilder\n }\n\n byDateOfBirth(dateOfBirth: number): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyDateOfBirthFilter({\n healthcarePartyId: this.hcpId,\n dateOfBirth: dateOfBirth,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n olderThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(10000101, parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')))\n }\n\n youngerThan(age: number): PatientFilterBuilder {\n return this.withDateOfBirthBetween(parseInt(format(add(new Date(), { years: -age }), 'yyyyMMdd')), 99991231)\n }\n\n byGenderEducationProfession(gender?: GenderEnum, education?: string, profession?: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyGenderEducationProfessionFilter({\n healthcarePartyId: this.hcpId,\n gender: gender,\n education: education,\n profession: profession,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n byIds(ids: string[]): PatientFilterBuilder {\n return this.composer(this, new PatientFilterBuilder(() => new PatientByIdsFilter({ ids: ids }), this.hcpId)) as PatientFilterBuilder\n }\n\n searchByName(name: string): PatientFilterBuilder {\n return this.composer(\n this,\n new PatientFilterBuilder(\n () =>\n new PatientByHcPartyNameContainsFuzzyFilter({\n healthcarePartyId: this.hcpId,\n searchString: name,\n }),\n this.hcpId\n )\n ) as PatientFilterBuilder\n }\n\n build(): AbstractFilter<Patient> {\n return this.filterProvider?.() || this.all().build()\n }\n}\n"]}
|
|
@@ -86,7 +86,7 @@ class IccReceiptXApi extends icc_api_1.IccReceiptApi {
|
|
|
86
86
|
*/
|
|
87
87
|
setClearReceiptAttachment(receipt, blobType, attachment) {
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
return yield this.setReceiptAttachmentForBlobType(receipt.id, receipt.rev, blobType, attachment);
|
|
89
|
+
return yield this.setReceiptAttachmentForBlobType(receipt.id, receipt.rev, blobType, (0, utils_1.ua2ab)(attachment));
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAG1C,kDAAiD;AAEjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;AAEtD,MAAa,cAAe,SAAQ,uBAAa;IAC/C,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,OAAO,CAAC,CAAC,CAAA;IAC7I,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC9B,cAAuB,EACxC,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,EAAE,SAAS,CAAC,CAAA;QAVtC,WAAM,GAAN,MAAM,CAAe;QACrB,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,mBAAc,GAAd,c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CAAA;IACpJ,CAAC;CACF;AA3QD,wCA2QC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName } from './utils'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Receipt))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly 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.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. 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 * - 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 receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt({\n ...(r ?? {}),\n _type: 'org.taktik.icure.entities.Receipt',\n id: r?.id ?? this.crypto.primitives.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: r?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\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.Receipt(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n receipt,\n EntityWithDelegationTypeName.Receipt,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachmentForBlobType(rcpt.id!, rcpt.rev!, blobType, <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const { encryptedData, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, EntityWithDelegationTypeName.Receipt, attachment, (r) =>\n this.modifyReceipt(r)\n )\n return await this.setReceiptAttachmentForBlobType(receipt.id!, updatedEntity?.rev ?? receipt.rev!, blobType, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachmentForBlobType(receipt.id!, receipt.rev!, blobType, attachment)\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const retrieved = await this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x))\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachment(receipt.id!, attachmentId),\n (x) => validator(x)\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given receipt\n */\n async hasWriteAccess(receipt: models.Receipt): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: EntityWithDelegationTypeName.Receipt })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt 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 receipt.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n return (await this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Receipt>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, EntityWithDelegationTypeName.Receipt)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyReceipt(entityWithEncryptionKey) : receipt\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Receipt,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareReceipt(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Receipt\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Receipt })\n }\n\n getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Receipt }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Receipt }, delegates)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-receipt-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-receipt-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA0C;AAG1C,kDAAiD;AAEjD,0EAAgG;AAChG,4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AAO,CAAC,oBAAoB;oBAClD,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;oBAC/C,oBAAoB,EAAE,+CAAsB,CAAC,KAAK;oBAClD,cAAc,EAAE,OAAO,CAAC,cAAc;iBACvC;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAChC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,CAAC,CAAA;IACjI,CAAC;IAED,mBAAmB,CAAC,MAAsB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IAC7G,CAAC;IAED,uCAAuC,CAAC,MAAsB,EAAE,SAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IACpJ,CAAC;CACF;AA3QD,wCA2QC","sourcesContent":["import { IccReceiptApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as _ from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName, ua2ab } from './utils'\n\nexport class IccReceiptXApi extends IccReceiptApi implements EncryptedEntityXApi<models.Receipt> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Receipt))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly 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.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of receipt with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param r initialised data for the receipt. 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 * - 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 receipt.\n */\n async newInstance(\n user: models.User,\n r: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Receipt> {\n const receipt = new models.Receipt({\n ...(r ?? {}),\n _type: 'org.taktik.icure.entities.Receipt',\n id: r?.id ?? this.crypto.primitives.randomUuid(),\n created: r?.created ?? new Date().getTime(),\n modified: r?.modified ?? new Date().getTime(),\n responsible: r?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: r?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: r?.codes ?? [],\n tags: r?.tags ?? [],\n })\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.Receipt(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n receipt,\n EntityWithDelegationTypeName.Receipt,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n logReceipt(user: models.User, docId: string, refs: Array<string>, blobType: string, blob: ArrayBuffer) {\n return this.newInstance(user, { documentId: docId, references: refs })\n .then((rcpt) => this.createReceipt(rcpt))\n .then((rcpt) => (blob.byteLength != 0 ? this.setReceiptAttachmentForBlobType(rcpt.id!, rcpt.rev!, blobType, <any>blob) : Promise.resolve(rcpt)))\n }\n\n /**\n * Adds an attachment to a receipt, encrypting it on client side using the encryption keys of the provided receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async encryptAndSetReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n const { encryptedData, updatedEntity } = await this.crypto.xapi.encryptDataOf(receipt, EntityWithDelegationTypeName.Receipt, attachment, (r) =>\n this.modifyReceipt(r)\n )\n return await this.setReceiptAttachmentForBlobType(receipt.id!, updatedEntity?.rev ?? receipt.rev!, blobType, encryptedData)\n }\n\n /**\n * Adds an unencrypted attachment to a receipt.\n * @param receipt a receipt.\n * @param blobType the type of the attachment.\n * @param attachment a attachment for the receipt.\n * @return the updated receipt.\n */\n async setClearReceiptAttachment(receipt: models.Receipt, blobType: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Receipt> {\n return await this.setReceiptAttachmentForBlobType(receipt.id!, receipt.rev!, blobType, ua2ab(attachment))\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n */\n async getAndDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<ArrayBuffer> {\n const retrieved = await this.getAndTryDecryptReceiptAttachment(receipt, attachmentId, (x) => validator(x))\n if (!retrieved.wasDecrypted) throw new Error(`No valid key found to decrypt data of receipt ${receipt.id}.`)\n return retrieved.data\n }\n\n /**\n * Gets the attachment of a receipt and tries to decrypt it using the encryption keys of the receipt.\n * @param receipt a receipt.\n * @param attachmentId id of the attachment of this receipt to retrieve.\n * @param validator optionally a validator function which checks if the decryption was successful. In cases where the receipt has many encryption\n * keys and it is unclear which one should be used this function can help to detect bad decryptions.\n * @return an object containing:\n * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.\n * - wasDecrypted: if the data was successfully decrypted or not\n */\n async getAndTryDecryptReceiptAttachment(\n receipt: models.Receipt,\n attachmentId: string,\n validator: (decrypted: ArrayBuffer) => Promise<boolean> = () => Promise.resolve(true)\n ): Promise<{ data: ArrayBuffer; wasDecrypted: boolean }> {\n return await this.crypto.xapi.tryDecryptDataOf(\n { entity: receipt, type: EntityWithDelegationTypeName.Receipt },\n await this.getReceiptAttachment(receipt.id!, attachmentId),\n (x) => validator(x)\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given receipt\n */\n async hasWriteAccess(receipt: models.Receipt): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: receipt, type: EntityWithDelegationTypeName.Receipt })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt 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 receipt.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Receipt> {\n return this.shareWithMany(receipt, { [delegateId]: options })\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Receipt> {\n return (await this.tryShareWithMany(receipt, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing receipt with other data owners, allowing them to access the non-encrypted data of the receipt and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param receipt the receipt 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 * receipt does not have encrypted content.\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 receipt: models.Receipt,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Receipt>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(receipt, EntityWithDelegationTypeName.Receipt)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyReceipt(entityWithEncryptionKey) : receipt\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Receipt,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareReceipt(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Receipt\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Receipt })\n }\n\n getEncryptionKeysOf(entity: models.Receipt): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Receipt }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Receipt, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Receipt }, delegates)\n }\n}\n"]}
|
package/icc-x-api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IccAgendaApi, IccAnonymousAccessApi, IccAuthApi, IccBeefactApi, IccBeresultexportApi, IccBeresultimportApi, IccBesamv2Api, IccCalendarItemTypeApi, IccClassificationTemplateApi, IccEntityrefApi, IccEntitytemplateApi, IccFrontendmigrationApi, IccGroupApi, IccIcureApi, IccInsuranceApi, IccKeywordApi, IccMedexApi, IccMedicallocationApi, IccPatientApi, IccPermissionApi, IccPlaceApi, IccPubsubApi, IccReplicationApi, IccTarificationApi, IccTimeTableApi, IccTmpApi } from '../icc-api';
|
|
1
|
+
import { IccAccesslogApi, IccAgendaApi, IccAnonymousAccessApi, IccAuthApi, IccBeefactApi, IccBeresultexportApi, IccBeresultimportApi, IccBesamv2Api, IccCalendarItemTypeApi, IccClassificationTemplateApi, IccEntityrefApi, IccEntitytemplateApi, IccFrontendmigrationApi, IccGroupApi, IccIcureApi, IccInsuranceApi, IccKeywordApi, IccMedexApi, IccMedicallocationApi, IccPatientApi, IccPermissionApi, IccPlaceApi, IccPubsubApi, IccReplicationApi, IccTarificationApi, IccTimeTableApi, IccTmpApi } from '../icc-api';
|
|
2
2
|
import { IccUserXApi } from './icc-user-x-api';
|
|
3
3
|
import { IccCryptoXApi } from './icc-crypto-x-api';
|
|
4
4
|
import { IccContactXApi } from './icc-contact-x-api';
|
|
@@ -69,18 +69,21 @@ export { NativeCryptoPrimitivesBridge } from './crypto/NativeCryptoPrimitivesBri
|
|
|
69
69
|
export { hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of, getShaVersionForKey } from './crypto/utils';
|
|
70
70
|
export { SecretIdUseOption } from './crypto/SecretIdUseOption';
|
|
71
71
|
export interface BasicApis {
|
|
72
|
+
readonly accessLogApi: IccAccesslogApi;
|
|
73
|
+
readonly agendaApi: IccAgendaApi;
|
|
72
74
|
readonly authApi: IccAuthApi;
|
|
73
75
|
readonly codeApi: IccCodeXApi;
|
|
74
|
-
readonly
|
|
75
|
-
readonly permissionApi: IccPermissionApi;
|
|
76
|
-
readonly insuranceApi: IccInsuranceApi;
|
|
76
|
+
readonly deviceApi: IccDeviceXApi;
|
|
77
77
|
readonly entityReferenceApi: IccEntityrefApi;
|
|
78
|
-
readonly agendaApi: IccAgendaApi;
|
|
79
78
|
readonly groupApi: IccGroupApi;
|
|
80
79
|
readonly healthcarePartyApi: IccHcpartyXApi;
|
|
81
|
-
readonly
|
|
80
|
+
readonly icureApi: IccIcureApi;
|
|
81
|
+
readonly insuranceApi: IccInsuranceApi;
|
|
82
82
|
readonly patientApi: IccPatientApi;
|
|
83
|
+
readonly permissionApi: IccPermissionApi;
|
|
84
|
+
readonly pricingApi: IccTarificationApi;
|
|
83
85
|
readonly roleApi: IccRoleApi;
|
|
86
|
+
readonly userApi: IccUserXApi;
|
|
84
87
|
}
|
|
85
88
|
export interface Apis extends BasicApis {
|
|
86
89
|
readonly calendarItemTypeApi: IccCalendarItemTypeApi;
|
package/icc-x-api/index.js
CHANGED
|
@@ -335,6 +335,10 @@ class IcureApiImpl {
|
|
|
335
335
|
this.useLiteCompatibilityMode = useLiteCompatibilityMode;
|
|
336
336
|
this.latestGroupsRequest = Promise.resolve(latestMatches);
|
|
337
337
|
}
|
|
338
|
+
get pricingApi() {
|
|
339
|
+
var _a;
|
|
340
|
+
return ((_a = this._pricingApi) !== null && _a !== void 0 ? _a : (this._pricingApi = new icc_api_1.IccTarificationApi(this.host, this.params.headers, this.groupSpecificAuthenticationProvider, this.fetch)));
|
|
341
|
+
}
|
|
338
342
|
get recoveryApi() {
|
|
339
343
|
return this.cryptoInitInfos.recoveryApi;
|
|
340
344
|
}
|