Issue/1815#1929
Open
MaryamMehd wants to merge 7 commits into
Open
Conversation
… informative messages Previously, when the pre-population service could not retrieve data from the FHIR server (e.g. resource type not supported, permission denied, or no matching data), the failure was either completely silent (playground) or only shown as a vague "view console" message gated behind developer mode. Clinicians had no way to know why fields were left blank. Changes: - Add formatPopulateIssuesForUser() utility that converts an OperationOutcome into plain-English messages distinguishing between server data retrieval failures (not-found) and expression evaluation failures (invalid), so clinicians understand the cause without reading console output - PrePopulateMenuItem: add persistent warning snackbar for both total failure and partial populate (issues present); previously showed nothing in either case - usePopulate: show the formatted issue message to all users regardless of showDeveloperMessages config; previously clinicians in non-developer mode saw no feedback on partial failure - RepopulateAction: replace generic "view console for details" with the same formatted message - Console warnings are preserved in all paths so developers retain full diagnostic detail Relates to issue #1815 Made-with: Cursor
…o match test contract - When showDeveloperMessages is true (developer mode): keep the existing 'View console for details' snackbar so existing tests continue to pass - When showDeveloperMessages is false (clinical users): show the new user-friendly formatted message from formatPopulateIssuesForUser - Restore console.warn(issues) without prefix to match test spy expectations Co-authored-by: Cursor <cursoragent@cursor.com>
…nline warnings Implements per-field pre-population failure indicators so clinicians can see at a glance exactly which fields were not pre-populated, rather than only receiving a general snackbar message. Changes: - sdc-populate: add optional linkId parameter to createInvalidWarningIssue() and record it in OperationOutcomeIssue.expression so consumers can map issues back to specific questionnaire items; pass the linkId at both evaluateExpressions call sites where it is available in scope (initialExpressions and itemPopulationContexts loops) - smart-forms-renderer: add prepopulationWarningLinkIds (Set<string>) to RendererConfig and rendererConfigStore; ItemFieldGrid reads the set and renders an amber 'This field could not be pre-populated.' caption below any field whose linkId is in the set - smart-forms-app: add extractWarningLinkIds() utility that collects linkIds from OperationOutcome.issue[].expression for invalid-coded issues; wire it into PrePopulateMenuItem, usePopulate, and RepopulateAction so the renderer store is updated with affected linkIds after each pre/re-population, and cleared when population succeeds without issues Relates to issue #1815 Co-authored-by: Cursor <cursoragent@cursor.com>
…n rendererConfigStore in usePopulate - Import statement for extractWarningLinkIds and formatPopulateIssuesForUser collapsed to single line - rendererConfigStore?.getState() uses optional chaining so tests that mock @aehrc/smart-forms-renderer without rendererConfigStore do not throw before reaching enqueueSnackbar and console.warn - Inline .getState() chain in RepopulateAction to satisfy prettier Co-authored-by: Cursor <cursoragent@cursor.com>
… warning icons and improve failure messages
Previously, pre-population failures displayed a repeated text warning beneath
every affected field. This commit replaces that approach with a cleaner
group-level indicator and improves the quality of all user-facing messages.
Group-level warning icons (renderer package):
- Add prepopulationWarnings.ts utility with getGroupPrepopWarning(), which
traverses a group's immediate named children (skipping unnamed layout
containers like unlabelled grid groups) to collect affected field names and
the failure reason. Tooltips show contextual names (e.g. "Body height")
rather than repeated generic labels (e.g. "Value, Date performed").
- GroupHeading.tsx: render a WarningAmberIcon + MUI Tooltip on any group whose
descendants have pre-population warnings. Tooltip shows the failure reason
and lists the affected immediate child names.
- GridRow.tsx: same icon + tooltip on grid table row labels when any cell in
that row has a warning.
- ItemFieldGrid.tsx: remove the per-field inline Typography warning text
(replaced by the group-level icon).
- SingleItemView.tsx: remove the per-repeated-item inline Typography warning
(replaced by the group-level icon).
Improved failure messages (smart-forms-app):
- prepopulateIssues.ts:
- Add hasServerSideError() to detect HTTP 5xx responses and surface a
"server returned an error, try again" message to clinicians.
- Add hasMissingContextError() to detect fhirpath.js "undefined environment
variable" errors, distinguishing a missing launch context (%patient not
provided) from a generic expression failure.
- extractWarningMessages() now selects the field-level tooltip reason
per-issue: data not in health history (not-found cascade), missing patient
context (undefined env variable), or standalone expression failure.
- getWarningFieldNames() now prefixes each field name with its immediate
parent group name (e.g. "Body height > Value") so the snackbar debug list
is unambiguous.
- All snackbar messages rewritten in plain clinical language with no
FHIRPath, HTTP codes, or server internals exposed to the clinician.
- usePopulate.tsx: add optional chaining on questionnaireStore access to
prevent a throw in test environments where the store is undefined.
Co-authored-by: Cursor <cursoragent@cursor.com>
…store branch coverage Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.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.
No description provided.