-
Notifications
You must be signed in to change notification settings - Fork 41
Ensure date basis merges do not de-duplicate dates in population counts #1041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
lukedegruchy
wants to merge
5
commits into
main
Choose a base branch
from
ld-20260528-cql-types-and-fhir-resources-sets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e9003cd
Add failing tests for intra-subject duplicate-value dedup (CDO-714)
lukedegruchy 0c52eea
Tactical fix for date-basis intra-subject duplicate dedup (CDO-714)
lukedegruchy 31d260b
Remove commented out code in HashSetForFhirResourcesAndCqlTypes.
lukedegruchy 648fdc7
Merge remote-tracking branch 'origin/main' into ld-20260528-cql-types…
lukedegruchy 2f8e9cf
Replace references to my git repo directories.
lukedegruchy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
232 changes: 232 additions & 0 deletions
232
PRPs/prp-population-basis-primitive-duplicate-counting.md
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
115 changes: 115 additions & 0 deletions
115
...ir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/DuplicateTypeIntraSubjectTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| package org.opencds.cqf.fhir.cr.measure.r4; | ||
|
|
||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.opencds.cqf.fhir.cr.measure.common.MeasurePopulationType; | ||
| import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given; | ||
|
|
||
| /** | ||
| * Integration test pinning the expected behaviour for CDO-714. | ||
| * | ||
| * <p>When a Measure has a non-boolean population basis and a CQL expression for a population | ||
| * yields duplicate values within a single subject, each occurrence is a discrete data point and | ||
| * the population count must include the duplicates. | ||
| * | ||
| * <p>This test covers three flavours of "primitive" basis that the evaluator must handle: | ||
| * <ul> | ||
| * <li><b>CQL Date</b> ({@code System.Date} → {@code runtime.Date}) yielded by a literal list | ||
| * expression. The tactical CDO-714 fix disables the {@code CqlType} dedup branches in | ||
| * {@code HashSetForFhirResourcesAndCqlTypes} so distinct {@code runtime.Date} instances | ||
| * survive default {@link java.util.HashSet} identity semantics and the count reflects every | ||
| * yielded date. | ||
| * <li><b>CQL Integer</b> ({@code System.Integer} → {@code java.lang.Integer}) yielded by a | ||
| * literal list expression. <b>Deferred to the holistic fix</b>: {@code Integer} is neither | ||
| * {@code IBaseResource} nor {@code CqlType}, and {@code Integer}'s value-based | ||
| * {@code equals}/{@code hashCode} still dedups in the default {@link java.util.HashSet} | ||
| * path. See {@code PRPs/prp-population-basis-primitive-duplicate-counting.md}. | ||
| * <li><b>FHIR primitive</b> ({@link org.hl7.fhir.instance.model.api.IPrimitiveType}) yielded by | ||
| * walking {@code Patient.address[0].line}. Regression guard: HAPI FHIR primitive instances | ||
| * are neither {@code IBaseResource} nor {@code CqlType}, and {@code Base.equals} is not | ||
| * overridden, so default {@link java.util.HashSet} identity semantics keep distinct | ||
| * instances. The tactical fix must (and does) preserve this. | ||
| * </ul> | ||
| * | ||
| * @see <a href="https://simpaticois.atlassian.net/browse/CDO-714">CDO-714</a> | ||
| */ | ||
| @SuppressWarnings("squid:S2699") | ||
| class DuplicateTypeIntraSubjectTest { | ||
|
|
||
| private static final Given GIVEN = Measure.given().repositoryFor("DuplicateTypeIntraSubject"); | ||
|
|
||
| @Test | ||
| void cqlDateBasis_intraSubjectDuplicates_populationReport_includesDuplicates() { | ||
| GIVEN.when() | ||
| .measureId("DuplicateTypeIntraSubjectDateBasisMeasure") | ||
| .periodStart("2025-01-01") | ||
| .periodEnd("2025-12-31") | ||
| .reportType("population") | ||
| .evaluate() | ||
| .then() | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .report(); | ||
| } | ||
|
|
||
| @Test | ||
| void cqlDateBasis_intraSubjectDuplicates_subjectReport_includesDuplicates() { | ||
| GIVEN.when() | ||
| .measureId("DuplicateTypeIntraSubjectDateBasisMeasure") | ||
| .subject("Patient/patient-a") | ||
| .periodStart("2025-01-01") | ||
| .periodEnd("2025-12-31") | ||
| .evaluate() | ||
| .then() | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .report(); | ||
| } | ||
|
|
||
| // Deferred: the CQL engine returns java.lang.Integer for CQL Integer literals, which has | ||
| // value-based equals/hashCode and dedups via default HashSet semantics. The tactical | ||
| // CDO-714 fix (disabling CqlType branches in HashSetForFhirResourcesAndCqlTypes) does not | ||
| // reach the java.lang.Integer path. The holistic fix is captured in | ||
| // PRPs/prp-population-basis-primitive-duplicate-counting.md and is sequenced after the | ||
| // CQL 5.0 (cql1) ExpressionResult type changes land. | ||
| @Disabled("CDO-714 — deferred to PRPs/prp-population-basis-primitive-duplicate-counting.md") | ||
| @Test | ||
| void cqlIntegerBasis_intraSubjectDuplicates_populationReport_includesDuplicates() { | ||
| GIVEN.when() | ||
| .measureId("DuplicateTypeIntraSubjectIntegerBasisMeasure") | ||
| .periodStart("2025-01-01") | ||
| .periodEnd("2025-12-31") | ||
| .reportType("population") | ||
| .evaluate() | ||
| .then() | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .report(); | ||
| } | ||
|
|
||
| @Test | ||
| void fhirStringBasis_intraSubjectDuplicates_populationReport_includesDuplicates() { | ||
| GIVEN.when() | ||
| .measureId("DuplicateTypeIntraSubjectFhirStringBasisMeasure") | ||
| .periodStart("2025-01-01") | ||
| .periodEnd("2025-12-31") | ||
| .reportType("population") | ||
| .evaluate() | ||
| .then() | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .report(); | ||
| } | ||
| } |
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
71 changes: 71 additions & 0 deletions
71
...st/java/org/opencds/cqf/fhir/cr/measure/r4/MultiMeasureDuplicateTypeIntraSubjectTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package org.opencds.cqf.fhir.cr.measure.r4; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.opencds.cqf.fhir.cr.measure.common.MeasurePopulationType; | ||
| import org.opencds.cqf.fhir.cr.measure.r4.MultiMeasure.Given; | ||
|
|
||
| /** | ||
| * MultiMeasure integration test pinning CDO-714 behaviour across the {@link R4MultiMeasureService} | ||
| * orchestration path. | ||
| * | ||
| * <p>Runs three Measures in the same evaluation call against a single patient: a CQL-Date-basis | ||
| * Measure with intra-subject duplicate dates, a FHIR-string-basis Measure with intra-subject | ||
| * duplicate {@link org.hl7.fhir.instance.model.api.IPrimitiveType} strings, and a boolean-basis | ||
| * Measure used as an unaffected baseline. | ||
| * | ||
| * <p>The date-basis Measure reports a population count of {@code 3} (each duplicate counted) under | ||
| * the tactical CDO-714 fix; the FHIR-string-basis Measure also reports {@code 3}; and the | ||
| * boolean-basis Measure stays at {@code 1}. | ||
| * | ||
| * <p>The CQL-Integer-basis Measure is deliberately excluded from this chain — the tactical fix | ||
| * does not reach the {@code java.lang.Integer} dedup path. The full multi-basis assertion | ||
| * (date / integer / FHIR string / boolean) will be restored when the holistic fix lands; see | ||
| * {@code PRPs/prp-population-basis-primitive-duplicate-counting.md}. | ||
| * | ||
| * @see <a href="https://simpaticois.atlassian.net/browse/CDO-714">CDO-714</a> | ||
| */ | ||
| @SuppressWarnings("squid:S2699") | ||
| class MultiMeasureDuplicateTypeIntraSubjectTest { | ||
|
|
||
| private static final Given GIVEN = MultiMeasure.given().repositoryFor("DuplicateTypeIntraSubject"); | ||
|
|
||
| @Test | ||
| void multiMeasure_dateBasis_fhirStringBasis_booleanBasis_countsAreBasisAware() { | ||
| // CQL-Integer-basis Measure intentionally omitted from this chain; see class JavaDoc and | ||
| // PRPs/prp-population-basis-primitive-duplicate-counting.md for the deferred coverage. | ||
| var when = GIVEN.when() | ||
| .measureId("DuplicateTypeIntraSubjectDateBasisMeasure") | ||
| .measureId("DuplicateTypeIntraSubjectFhirStringBasisMeasure") | ||
| .measureId("DuplicateTypeIntraSubjectBooleanBasisMeasure") | ||
| .periodStart("2025-01-01") | ||
| .periodEnd("2025-12-31") | ||
| .reportType("population") | ||
| .evaluate(); | ||
|
|
||
| when.then() | ||
| .hasBundleCount(1) | ||
| .hasMeasureReportCount(3) | ||
| .measureReport("http://example.com/Measure/DuplicateTypeIntraSubjectDateBasisMeasure") | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .up() | ||
| .measureReport("http://example.com/Measure/DuplicateTypeIntraSubjectFhirStringBasisMeasure") | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(3) | ||
| .up() | ||
| .up() | ||
| .up() | ||
| .measureReport("http://example.com/Measure/DuplicateTypeIntraSubjectBooleanBasisMeasure") | ||
| .firstGroup() | ||
| .population(MeasurePopulationType.INITIALPOPULATION) | ||
| .hasCount(1) | ||
| .up() | ||
| .up() | ||
| .up() | ||
| .report(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
/Users/luke/development/smile-digital-health/git/clintel-repos/..may have been included in repo paths by mistake?