Repository navigation
fix(instrument-utils): leave measures on unrevealed dynamic questions out of the results summary - #1606
Merged
joshunrau merged 2 commits intoOct 4, 2026
Conversation
…lts summary The results summary looked up a const measure's value and label by the measure's own key instead of its `ref`, which is what the API stores. A measure keyed apart from its field showed another field's value, showed "NA", or threw when the key named no field at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… out of the results summary A const measure on a dynamic form field whose render function returned null for the submitted data still appeared in the results summary as "<label>: NA" whenever the measure had a label, although the respondent never saw the question. Without a label it was dropped only because its label could not be resolved, and logged a spurious error. The summary now skips a const measure whose field is a dynamic one that the data keeps hidden, whether or not it has a label. A static field left unanswered still shows as NA. Closes DouglasNeuroInformatics#1098 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #1098
What changed
Two fixes to
computeInstrumentMeasures, which only feeds the results summary (after submission and on the datahub record page). Exports, tables and graphs use the measures the API stores, so they are unaffected.ref. The summary looked up a const measure's value and label by its key ininstrument.measuresrather than bymeasure.ref, which is what the API stores. A measure keyed apart from its field showed another field's value, showed "NA", or threw aTypeErrorwhen the key named no field. To indexdatabyrefwithout a suppression, the measures record is widened toInstrumentMeasures<any, Language>. Under an interactive instrument'sJsondata type,ConditionalKeysturnsrefinto a union ofJson[]members. The widening also makes the@ts-expect-erroron the computed branch unnecessary.kind: 'dynamic'and itsrender(data)returnsnull(the newisFieldHiddeninform.ts, which builds ongetFormFields), the measure is skipped quietly, whether or not it has a label. Before, a labeled measure showed "Label: NA", and an unlabeled one disappeared only because its label lookup failed, which also logged a spuriousconsole.error. An optional static field the respondent saw and skipped still shows "NA".The
InstrumentSummarytest fixture getscontent: {}: the summary now reads a form's content for its const measures, and real form instruments always have one.Verification
instrument-utils):src/__tests__/measures.test.tscovers a measure keyed apart from its ref, a labeled measure on a hidden dynamic field (absent) and on a revealed one (present), an unlabeled hidden one (absent, with noconsole.error), and an unanswered static field (still present).src/__tests__/form.test.tscoversisFieldHidden. Each new test failed before its fix.testing/src/specs/playground.spec.tsadds two cases for a form whose pet-name question appears only when "Has Pet" is true: the name's measure is absent when the toggle is false and listed when it is true. With the fix reverted, the "absent" case fails withExpected: 0, Received: 1.pnpm lintpasses (34/34).pnpm testpasses (1585/1585). On chromium, the playground spec passes 14/14, andinstrument-completion,form-block,form-resetandsubject-detailpass 21/21.Not run: the full
pnpm test:e2esuite, and the firefox project. Neither new e2e test is@smoke.Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com