Non-subject value stratifier — scalar expression support (#909)#1030
Open
lukedegruchy wants to merge 6 commits into
Open
Non-subject value stratifier — scalar expression support (#909)#1030lukedegruchy wants to merge 6 commits into
lukedegruchy wants to merge 6 commits into
Conversation
…basis CV measure When a CONTINUOUSVARIABLE Encounter-basis measure uses a Patient-context scalar expression as its stratifier component criteria (e.g. `define "Age": AgeInYearsAt(end of "Measurement Period")`) instead of a CQL function taking the population resource, the engine routes through the scalar-fallback NON_SUBJECT_VALUE path. Group-level aggregation is correct, but stratum measureScore is never computed and the stratum-level measure-observation population is missing both the cqfm-aggregateMethod and the extension-aggregationMethodResult extensions. Adds a self-contained dataset (10 patients, 12 encounters - identical to the ContinuousVariableObservationEncounterBasis fixtures) and a failing test mirroring continuousVariableResourceMeasureObservationEncounterBasisAvg, where the only meaningful difference is the stratifier expression form. No production fix in this commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Formatting check succeeded! |
MeasureMultiSubjectEvaluator.getResourcesForSubjects previously ran normalizePopulationKey on MEASUREOBSERVATION subjectResources, but those entries are Set<Map<input, output>> — yielding String.valueOf(map) garbage instead of real resource IDs. Scalar non-subject stratifiers on continuous-variable measures ended up with bogus resourceIdsForSubjectList, no intersection with the Map keys in downstream stratum scoring, and a null measureScore per stratum. The new MEASUREOBSERVATION branch flattens Map.keySet() through normalizePopulationKey, mirroring getPopulationResourceKeySet:929-938. The regression test added in b0155b4 now passes. Also drops a stray logger.info("1234: ...") debug statement from the same method. Test coverage for the four #909 scenarios: - Case 1 (non-subject + function): already covered. - Case 2 (non-subject + scalar): CV regression test now green; hardens MeasureStratifierTest.ratioResourceValueStratAge with per-stratum score assertions (was stratum-count-only). - Case 3 (subject + function = error): new MeasureStratifierTest.cohortBooleanValueStratFunctionStratifierInvalid plus a CohortBooleanValueStratFunctionStratifier.json fixture pin the InvalidRequestException from FunctionEvaluationHandler.validateStratifierExpressionTypes. - Case 4 (subject + scalar): already covered. Adds direct unit coverage of all four cases against MeasureMultiSubjectEvaluator via a new nested Issue909 class in MeasureMultiSubjectEvaluatorTest. The case-2 unit test exercises a MEASUREOBSERVATION population so the fix is pinned at unit level. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ct-stratifier-expression-scalar-failing-test
|
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.



This branch closes the remaining gap for issue #909: a stratifier with a non-subject (non-boolean) population basis and a scalar (non-function) component expression must evaluate the expression in subject context and apply that single value to every resource for the subject. The previously failing regression test for the continuous-variable + scalar-stratifier combination now passes, and test coverage is extended so all four (basis × expression-type) quadrants of #909 are exercised at multiple levels.
MeasureMultiSubjectEvaluator.getResourcesForSubjectsforMEASUREOBSERVATIONpopulations: previously the helper rannormalizePopulationKeyon the population'sSet<Map<inputResource, outputValue>>entries, producingString.valueOf(map)strings instead of real resource IDs, which left every continuous-variable stratum with a nullmeasureScorewhen the stratifier was scalar.ContinuousVariableResourceMeasureObservationTest.continuousVariableObservationEncounterBasisNonFunctionStratifierexercising the failing path end-to-end on a continuous-variable Encounter-basis measure.MeasureMultiSubjectEvaluatorvia a newIssue909nested class, including aMEASUREOBSERVATIONpopulation in case 2 so the fix is pinned at the unit level (the test fails without the fix).cohortBooleanValueStratFunctionStratifierInvalid) plus fixture that exercise the existing upstream validator path for case 3 (subject basis + CQL function = error), which had no test before.MeasureStratifierTest.ratioResourceValueStratAgewith per-stratum score assertions (it previously only asserted stratum count, and would have passed even before the fix).