Ensure date basis merges do not de-duplicate dates in population counts#1041
Open
lukedegruchy wants to merge 4 commits into
Open
Ensure date basis merges do not de-duplicate dates in population counts#1041lukedegruchy wants to merge 4 commits into
lukedegruchy wants to merge 4 commits into
Conversation
Pin the expected behaviour for CDO-714: when a Measure's population basis is a
non-boolean primitive type and a CQL expression yields duplicate values within
a single subject, each occurrence must be counted. The population count should
match the expression's list length, not the deduped set size.
New tests under cqf-fhir-cr (no production code changes):
- DuplicateTypeIntraSubjectTest exercises the single-Measure path against three
basis flavours, each tripping a distinct dedup code path inside
HashSetForFhirResourcesAndCqlTypes:
* CQL Date ({ @2025-07-03, @2025-07-03, @2025-07-04 }) -- fails today via
the CqlType / EqualEvaluator.equal path.
* CQL Integer ({ 42, 42, 43 }) -- fails today via default HashSet semantics
using Integer's value-based equals/hashCode.
* FHIR IPrimitiveType<String> (Patient.address[0].line yielding duplicate
"dup-line" primitives) -- passes today as a regression guard: HAPI's Base
does not override equals, so identity semantics keep distinct instances.
- MultiMeasureDuplicateTypeIntraSubjectTest runs all four basis Measures
(date, integer, FHIR string, boolean) through R4MultiMeasureService in a
single call to confirm the bug reproduces along that orchestration path and
that the boolean baseline stays at 1.
Shared fixture at
cqf-fhir-cr/src/test/resources/.../measure/r4/DuplicateTypeIntraSubject/.
Also adds MultiMeasure.SelectedMeasureReport#logReportJson() so MultiMeasure
tests can dump the MeasureReport JSON at any point in the fluent chain,
matching the single-Measure SelectedMeasureReport#logReportJson helper.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Disable the CqlType dedup branches in HashSetForFhirResourcesAndCqlTypes so distinct runtime.Date (and other no-equals-override CqlType) instances survive default HashSet identity semantics. The two @2025-07-03 instances in the CDO-714 fixture's initial-population now count as 2 separate occurrences, and the population reports 3 instead of 2. Scope is intentionally tactical. A survey of what the CQL engine returns shows the bug surface spans every CQL primitive type (Boolean, Integer, Long, Decimal, String, Date, DateTime, Time) plus every CQL composite (Quantity, Ratio, Code, Concept, CodeSystem, ValueSet, Interval, Tuple). The disabled CqlType branches alone unblock CQL Date, the FHIR-string regression case, and the boolean baseline -- the realistic CDO-714 surface today. Java primitives that the engine returns (notably java.lang.Integer, java.lang.String) still dedup via default HashSet using their own value-based equals/hashCode, so the integer assertion in DuplicateTypeIntraSubjectTest and the integer Measure in the MultiMeasure chain are @disabled / removed and explicitly point at the PRP below. The holistic basis-aware-storage redesign that would cover all the deferred cases is captured in PRPs/prp-population-basis-primitive-duplicate-counting.md. It is sequenced after the CQL 5.0 (cql1) ExpressionResult type changes land, since cql1 will materially shift the return-type table. CqlDate-specific unit tests in HashSetForFhirResourcesAndCqlTypesTest are @disabled with the same PRP pointer -- they assert the dedup behaviour the tactical fix removes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Formatting check succeeded! |
…-and-fhir-resources-sets
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #1040