Skip to content

Add exact code/tag service filters with date support#291

Merged
aduchate merged 8 commits intomainfrom
improvement/service-filters-exact-codes-and-date-support
Apr 10, 2026
Merged

Add exact code/tag service filters with date support#291
aduchate merged 8 commits intomainfrom
improvement/service-filters-exact-codes-and-date-support

Conversation

@aduchate
Copy link
Copy Markdown
Contributor

@aduchate aduchate commented Apr 9, 2026

Summary

  • Add 4 new service filters for exact code/tag matching: ServiceByHcPartyCodesFilter, ServiceByHcPartyTagCodesFilter, ServiceByHcPartyPatientCodesFilter, ServiceByHcPartyPatientTagCodesFilter
  • New filters accept Map<String, Collection<String>> (type → codes) enabling multi-type queries in a single filter call
  • Add startValueDate/endValueDate support to existing prefix filters (ServiceByHcPartyCodePrefixFilter, ServiceByHcPartyTagPrefixFilter)
  • Update CouchDB views (Service_by_data_owner_code_prefix.js, Service_by_data_owner_tag_prefix.js) to emit [serviceId, date] tuples for date-based filtering
  • Add month-range optimization for date-bounded queries via FuzzyDates.getMonthRange
  • Add new DAO methods for exact code/tag matching with date filtering

Test plan

  • Integration tests in kraken-cloud ServiceFilterTest covering all new and modified filters
  • Verify prefix filters still match multiple codes (e.g., prefix "TAG" matches "TAG" and "TAGX")
  • Verify exact-match filters only match specified codes
  • Verify multi-type map queries return correct union of results

🤖 Generated with Claude Code

…ti-type maps

- Add 4 new filters: ServiceByHcPartyCodesFilter, ServiceByHcPartyTagCodesFilter,
  ServiceByHcPartyPatientCodesFilter, ServiceByHcPartyPatientTagCodesFilter
- These accept Map<String, Collection<String>> for type->codes, enabling
  multi-type queries in a single filter
- Add startValueDate/endValueDate to existing prefix filters
  (ServiceByHcPartyCodePrefixFilter, ServiceByHcPartyTagPrefixFilter)
- Update CouchDB views to emit [serviceId, date] tuples for date filtering
- Add month-range optimization for date-bounded queries
- Add FuzzyDates.getMonthRange utility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the service filtering API to support (1) exact code/tag matching across multiple code/tag types in one call, and (2) value-date bounded querying for existing prefix-based filters, with DAO/view changes to support date-aware filtering and a month-partition optimization path.

Changes:

  • Added 4 new “exact match” service filters (DTO + domain + core resolvers) accepting Map<String, Collection<String>> plus optional startValueDate/endValueDate.
  • Extended existing code/tag prefix filters (DTO + domain + core resolvers) with optional startValueDate/endValueDate.
  • Updated CouchDB views and DAO methods to return/consume [serviceId, date] values and added month-range optimization via FuzzyDates.getMonthRange.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
mapper/src/main/kotlin/org/taktik/icure/services/external/rest/v2/mapper/filter/FilterMapper.kt Adds mapping support for the new exact-match DTO filters to domain filters.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyTagPrefixFilter.kt Adds optional value-date bounds to existing tag prefix filter DTO.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyCodePrefixFilter.kt Adds optional value-date bounds to existing code prefix filter DTO.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyCodesFilter.kt New DTO for exact code matching across multiple code types with optional date bounds.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyTagCodesFilter.kt New DTO for exact tag matching across multiple tag types with optional date bounds.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyPatientCodesFilter.kt New DTO for exact patient-scoped code matching across types with optional date bounds.
dto/src/main/kotlin/org/taktik/icure/services/external/rest/v2/dto/filter/service/ServiceByHcPartyPatientTagCodesFilter.kt New DTO for exact patient-scoped tag matching across types with optional date bounds.
domain/src/main/kotlin/org/taktik/icure/utils/FuzzyDates.kt Adds getMonthRange helper for month-bucket query optimization.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyTagPrefixFilter.kt Extends domain interface to include optional value-date bounds.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyCodePrefixFilter.kt Extends domain interface to include optional value-date bounds.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyCodesFilter.kt New domain filter interface for exact code matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyTagCodesFilter.kt New domain filter interface for exact tag matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyPatientCodesFilter.kt New domain filter interface for exact patient-scoped code matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/service/ServiceByHcPartyPatientTagCodesFilter.kt New domain filter interface for exact patient-scoped tag matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyTagPrefixFilter.kt Adds date bounds to the domain implementation for tag prefix filter.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyCodePrefixFilter.kt Adds date bounds to the domain implementation for code prefix filter.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyCodesFilter.kt New domain implementation for exact code matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyTagCodesFilter.kt New domain implementation for exact tag matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyPatientCodesFilter.kt New domain implementation for exact patient-scoped code matching.
domain/src/main/kotlin/org/taktik/icure/domain/filter/impl/service/ServiceByHcPartyPatientTagCodesFilter.kt New domain implementation for exact patient-scoped tag matching.
dao/src/main/resources/org/taktik/icure/asyncdao/impl/js/contact/Service_by_data_owner_tag_prefix.js Changes emitted view values to include [serviceId, valueDate/openingDate].
dao/src/main/resources/org/taktik/icure/asyncdao/impl/js/contact/Service_by_data_owner_code_prefix.js Changes emitted view values to include [serviceId, valueDate/openingDate].
dao/src/main/kotlin/org/taktik/icure/asyncdao/ContactDAO.kt Adds new DAO methods for exact match queries + date-bounded variants of prefix queries.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyTagPrefixFilter.kt Adds date bounds + month-bucket optimization path for tag prefix filter resolution.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyCodePrefixFilter.kt Adds date bounds + month-bucket optimization path for code prefix filter resolution.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyTagCodesFilter.kt New core resolver for exact tag matching (multi-type map) with date bounds and month optimization.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyCodesFilter.kt New core resolver for exact code matching (multi-type map) with date bounds and month optimization.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyPatientTagCodesFilter.kt New core resolver for exact patient-scoped tag matching (multi-type map) with date bounds.
core/src/main/kotlin/org/taktik/icure/asynclogic/impl/filter/service/ServiceByHcPartyPatientCodesFilter.kt New core resolver for exact patient-scoped code matching (multi-type map) with date bounds.
core/src/main/kotlin/org/taktik/icure/asyncdao/impl/ContactDAOImpl.kt Implements new DAO methods, adds date filtering for updated views, and adds exact-match query helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

aduchate and others added 3 commits April 9, 2026 17:26
…tion

The cross-product of searchKeys × types × codes (and patientSfks where
applicable) is now built in a single list of keys at the DAO level,
producing one CouchDB query instead of N queries per type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Impl.kt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

aduchate and others added 4 commits April 9, 2026 21:41
Add queryViewByKeysInChunks helper that splits large keys lists into
chunks of daoConfig.viewQueryChunkSize (default 1000) and executes
them in parallel with max daoConfig.viewQueryMaxConcurrency (default 4)
concurrent queries. Applied to all 3 exact-match private helpers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add toFullFuzzyDateTime(), isFuzzyDateAfterOrEqual(), and
isFuzzyDateBeforeOrEqual() to handle comparisons between YYYYMMDD
and YYYYMMDDHHmmss formats correctly:
- Start dates (YYYYMMDD) are padded to 000000 (start of day)
- End dates (YYYYMMDD) are padded to 235959 (end of day, inclusive)

Updated all date comparisons in ContactDAOImpl and domain filter
matches() methods to use the new utilities.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…imit

- Change ContactDAOImpl key cross-products to Sequence<ComplexKey> to avoid
  materializing potentially large lists before chunking
- Update queryViewByKeysInChunks to accept Sequence instead of List
- Move MAX_MONTHS constant from FuzzyDates to filter resolvers and add
  maxMonths parameter to getMonthRange
- Extract maxPossibleFuzzyNowInAllTimeZones() helper in FuzzyDates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aduchate aduchate merged commit 1738df6 into main Apr 10, 2026
@trema96 trema96 deleted the improvement/service-filters-exact-codes-and-date-support branch April 10, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants