Skip to content

Fix multi-component stratifier alignment for list + scalar (CDO-715)#1042

Draft
lukedegruchy wants to merge 1 commit into
mainfrom
ld-20260629-stratifiers-multi-component-report-strata
Draft

Fix multi-component stratifier alignment for list + scalar (CDO-715)#1042
lukedegruchy wants to merge 1 commit into
mainfrom
ld-20260629-stratifiers-multi-component-report-strata

Conversation

@lukedegruchy
Copy link
Copy Markdown
Contributor

A boolean (subject) basis stratifier with two components — one returning a per-patient List and one returning a per-patient scalar — emitted one stratum per component value with a single component, instead of one stratum per unique (list-element, scalar) tuple with both components.

Root cause: collectFunctionRowKeys only collected alignment row keys from function (Map) results, so a scalar component sharing a subject with an iterable component fell back to a subject-only row key. The iterable's composite per-element keys and the scalar's subject-only key never intersected, producing disjoint single-component strata.

Generalize the collector (renamed collectAlignmentRowKeys) to also gather row keys from iterable results, so scalars expand alongside list elements via the existing expandScalarToAlignmentRowKeys path. Tighten the scalar fallback: when the stratifier has multi-value components but a given subject produced none (empty Map or List), the subject contributes no stratum — matching the existing empty-list semantic.

Adds single-subject and multi-subject MeasureStratifierTest cases plus a CohortBooleanMultiComponentListScalarStrat fixture that pairs the existing "Distinct Encounter Statuses" list expression with the "Gender Stratification String" scalar.

A boolean (subject) basis stratifier with two components — one returning
a per-patient List and one returning a per-patient scalar — emitted one
stratum per component value with a single component, instead of one
stratum per unique (list-element, scalar) tuple with both components.

Root cause: collectFunctionRowKeys only collected alignment row keys from
function (Map) results, so a scalar component sharing a subject with an
iterable component fell back to a subject-only row key. The iterable's
composite per-element keys and the scalar's subject-only key never
intersected, producing disjoint single-component strata.

Generalize the collector (renamed collectAlignmentRowKeys) to also
gather row keys from iterable results, so scalars expand alongside list
elements via the existing expandScalarToAlignmentRowKeys path. Tighten
the scalar fallback: when the stratifier has multi-value components but
a given subject produced none (empty Map or List), the subject
contributes no stratum — matching the existing empty-list semantic.

Adds single-subject and multi-subject MeasureStratifierTest cases plus a
CohortBooleanMultiComponentListScalarStrat fixture that pairs the
existing "Distinct Encounter Statuses" list expression with the
"Gender Stratification String" scalar.

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

Formatting check succeeded!

@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant