Repository navigation
Conversation
saveQuestionnaireResponse built the whole resource in one object literal, which called qrToHTML on the incoming clone before subject, author and authored were replaced. Every save therefore wrote a narrative heading carrying the previous save's Patient, Author and Date Authored values, so the narrative no longer represented the resource content. Set the metadata first, then generate text.div from the updated resource. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #2086
The problem
When a form is saved,
QuestionnaireResponse.authoredis updated, but the "Date Authored" value in the narrative heading is not. The narrative no longer represents the resource content. Example resource showing the mismatch.The cause
saveQuestionnaireResponseinapps/smart-forms-app/src/api/saveQr.tsbuilt the whole saved resource in a single object literal:qrToHTMLwas called on the incoming clone, beforesubject,authorandauthoredwere replaced. Every save therefore wrote a narrative carrying the previous save's values.This affects all three fields in the narrative heading —
PatientandAuthoras well asDate Authored— thoughDate Authoredis the one that changes on every save and so is the one that shows up.The change
Set the metadata first, then generate
text.divfrom the updated resource:No change to
qrToHTMLitself — it was always rendering faithfully, just from the wrong input.Testing
Added a regression test to
saveQr.test.tsthat saves a response carrying stalesubject,authorandauthored, then assertsqrToHTMLreceived the fresh values. Confirmed it fails against the old ordering:saveQr.test.ts+preview.test.tsnpm run lint(repo root)tsc --noEmitfor the appThe renderer build was not needed — nothing under
packages/smart-forms-renderer/src/changed.🤖 Generated with Claude Code