Skip to content

fix: eForm Print now always saves to the eChart#2489

Open
D3V41 wants to merge 1 commit into
developfrom
fix/eform-print-always-saves
Open

fix: eForm Print now always saves to the eChart#2489
D3V41 wants to merge 1 commit into
developfrom
fix/eform-print-always-saves

Conversation

@D3V41

@D3V41 D3V41 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Issue

The floating eForm toolbar's Print button prints but does not always save to the eChart. When a form is filled using the mouse only (e.g. clicking checkboxes on the HPV Test requisition), Print produces the printout but the eForm is missing from the patient's eForms list. Typing a single character before printing makes it save.

image

Cause

remotePrint() in eform_floating_toolbar.js guarded its save behind needToConfirm. Each eForm sets needToConfirm to true only on a keyboard keyup event, so mouse-only input left it false - and with the flag defined but false, neither save branch ran.

From eform_floating_toolbar.js:
image

From HPV Test eform:
image

Fix

Have remotePrint() call remoteSave() unconditionally. No change detection is needed because the eForm is already marked as dirty by the auto-populated fields, such as the patient name and provider name.

Summary by Sourcery

Bug Fixes:

  • Always save the eForm to the eChart when printing, regardless of input method or dirty-form detection state.

Summary by cubic

Printing an eForm now always saves it to the patient’s eChart, fixing cases where mouse-only input didn’t persist. Printed forms will consistently appear in the patient’s eForms list.

  • Bug Fixes
    • remotePrint() now always calls remoteSave(); removed the needToConfirm check.
    • Resolves missed saves when forms were filled via mouse only (e.g., HPV Test).

Written for commit eeeeaa6. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • After printing an eForm, the app now saves changes consistently every time.
    • Removed cases where saving depended on confirmation-related conditions, reducing the chance of losing updates after print actions.

@D3V41 D3V41 self-assigned this Jul 3, 2026
@sourcery-ai

sourcery-ai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Simplifies eForm printing logic so that printing always triggers a save to the eChart, fixing cases where mouse-only interactions failed to persist the form.

Flow diagram for updated remotePrint save behavior

flowchart TD
    A[remotePrint] --> B{parent.opener exists}
    B -->|yes| C[hailMary]
    B -->|no| D[skip hailMary]
    C --> E[remoteSave]
    D --> E[remoteSave]
Loading

File-Level Changes

Change Details Files
Ensure printing an eForm always saves it, regardless of change detection flags.
  • Removed conditional logic around the needToConfirm flag in the remotePrint function.
  • Deleted the branch that only saved when needToConfirm was true.
  • Deleted the fallback branch that saved only when needToConfirm was undefined (no dirty detection).
  • Replaced both branches with an unconditional remoteSave call from remotePrint, so all printed eForms are saved.
src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA eeeeaa6.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 86645978-6ac3-4391-a837-b5f26d99544b

📥 Commits

Reviewing files that changed from the base of the PR and between 5f49a01 and eeeeaa6.

📒 Files selected for processing (1)
  • src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js

📝 Walkthrough

Walkthrough

The remotePrint() function in eform_floating_toolbar.js was changed to always invoke remoteSave() after the print action, removing the previous conditional logic that only saved based on the needToConfirm flag.

Changes

Remote Print Save Behavior

Layer / File(s) Summary
Unconditional save after print
src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js
remotePrint() now always calls remoteSave() after the print fallback, removing the prior needToConfirm-based conditional save logic.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: Print now always triggers a save to the eChart.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/eform-print-always-saves

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new remoteSave() call in remotePrint() is indented with spaces while the surrounding code uses tabs; align the indentation style with the rest of the file for consistency.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `remoteSave()` call in `remotePrint()` is indented with spaces while the surrounding code uses tabs; align the indentation style with the rest of the file for consistency.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix: Always save eForm to eChart when printing from floating toolbar

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Make Print always trigger an eForm save before printing.
• Fix mouse-only form interactions failing to persist to the patient eForms list.
• Remove reliance on needToConfirm keyboard-driven dirty detection during printing.
Diagram

graph TD
  A["Floating toolbar"] --> B["remotePrint()"] --> C["remoteSave()"] --> D[("eChart / eForms list")]
  B --> E["Print output"]

  subgraph Legend
    direction LR
    _ui["UI"] ~~~ _fn["JS function"] ~~~ _db[("Persistence")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Expand dirty detection to mouse events
  • ➕ Preserves intent of saving only when modified
  • ➕ Avoids extra save calls on print
  • ➖ Requires changes across many eForms and event handlers
  • ➖ Easy to miss interaction patterns (checkboxes, radio buttons, auto-populated fields)
  • ➖ Higher regression risk and harder to validate comprehensively
2. Treat `needToConfirm === false` as 'unknown' and still save on print
  • ➕ Smaller change than reworking dirty detection everywhere
  • ➕ Keeps some semantics around needToConfirm
  • ➖ Still couples correctness to a fragile, inconsistently-set global flag
  • ➖ Harder to reason about than a single unconditional save rule

Recommendation: Prefer the PR’s approach: printing is a user-significant action that should always persist the current eForm state. An unconditional remoteSave() in remotePrint() is the most reliable fix, avoids dependence on inconsistent per-eForm dirty detection, and directly addresses the mouse-only interaction gap.

Files changed (1) +2 / -16

Bug fix (1) +2 / -16
eform_floating_toolbar.jsAlways save eForm when printing from the floating toolbar +2/-16

Always save eForm when printing from the floating toolbar

• Simplifies 'remotePrint()' by removing 'needToConfirm'-gated branches and calling 'remoteSave()' unconditionally. This ensures eForms filled via mouse-only interactions are persisted to the patient’s eForms list when printed.

src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the remotePrint function in eform_floating_toolbar.js by removing conditional checks on needToConfirm and always calling remoteSave() when an eForm is printed. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Admin print save error 🐞 Bug ≡ Correctness
Description
remotePrint() now always calls remoteSave(), which attempts a form submission even when an eForm is
being viewed in the admin/template context where it is not submittable. In that case getEForm()
returns null and submitEForm() shows a save error alert after printing.
Code

src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[R429-430]

+    // Always save the eForm when it is printed
+    remoteSave();
Evidence
Admin-view eForms are explicitly non-submittable and do not set an action; remotePrint() now
always calls remoteSave(), and when no saveable form exists submitEForm() calls
showErrorAlert() which displays a save failure message.

src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[390-431]
src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[57-76]
src/main/webapp/eform/efmshowform_data.jsp[85-113]
src/main/webapp/js/oscar-alert.js[55-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`remotePrint()` unconditionally calls `remoteSave()`. When the toolbar is used on an eForm that is rendered for admin viewing (non-submittable), `getEForm()` cannot find a saveable form (no `saveEForm` and no `addEForm.do` action), so `submitEForm()` triggers `showErrorAlert()` after printing.

### Issue Context
- Admin-view eForms are created with demographic `-1` and do not set an action for submission.
- `submitEForm()` explicitly errors when `getEForm()` returns null.

### Fix Focus Areas
- Add a guard in `remotePrint()` to only call `remoteSave()` when `getEForm()` returns a form (or otherwise detect the non-submittable/admin view and skip saving).

- src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[390-431]
- src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[57-76]
- src/main/webapp/eform/efmshowform_data.jsp[85-113]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Duplicate submit handler 🐞 Bug ⚙ Maintainability
Description
remoteSave() binds a new jQuery submit handler on every call; since remotePrint() now always calls
remoteSave(), repeated Print clicks will accumulate duplicate handlers. This causes redundant
spinner work and makes the page behavior harder to reason about over time.
Code

src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[R429-430]

+    // Always save the eForm when it is printed
+    remoteSave();
Evidence
remoteSave() adds a submit handler each invocation, and the PR change guarantees remoteSave() is
called on every print, increasing the likelihood of repeated bindings during normal use.

src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[81-88]
src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[390-431]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`remoteSave()` currently does `jQuery('form').on('submit', ...)` each time it runs, which stacks event handlers. With `remotePrint()` now always invoking `remoteSave()`, users who print multiple times can quickly accumulate duplicate submit handlers.

### Issue Context
The handler only needs to be attached once per page load. Rebinding should be avoided by using a namespaced handler + `off(...)` or by moving the binding to `DOMContentLoaded`.

### Fix Focus Areas
- Change the spinner binding to be idempotent (e.g., `jQuery('form').off('submit.oscarSpin').on('submit.oscarSpin', ...)`) or move it to initialization.

- src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[81-88]
- src/main/webapp/eform/eformFloatingToolbar/eform_floating_toolbar.js[390-431]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@D3V41 D3V41 requested a review from LiamStanziani July 3, 2026 18:01

@LiamStanziani LiamStanziani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

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.

2 participants