Skip to content

MLW-1852: Fix TypeError in ART Mastercard duplicate-encounter validation for header form - #287

Merged
mseaton merged 1 commit into
masterfrom
MLW-1852
Sep 17, 2026
Merged

mseaton merged 1 commit into
masterfrom
MLW-1852

Conversation

@mseaton

@mseaton mseaton commented Sep 17, 2026

Copy link
Copy Markdown
Member

Summary

  • setupEncDupsValidation() in mastercard.js calls flowsheet.getFlowsheet(formName) and immediately dereferences the result's encounterTypeUuid, without checking for undefined.
  • The flowsheet header form is never registered via flowsheet.addFlowsheet() (only the repeatable visit forms are), so getFlowsheet() returns undefined when called for the header form. Since setupForm() in htmlformentryui's flowsheet.js invokes the afterSetupForm extension hook (which calls setupEncDupsValidation) for the header form too, entering/editing the header throws Uncaught TypeError: Cannot read properties of undefined (reading 'encounterTypeUuid').
  • Fix adds an early guard that skips duplicate-encounter validation when there's no registered flowsheet for the current form (i.e. the header form), since that check is only meaningful for the repeatable visit forms.
  • Also bumps htmlformentryVersion to 7.3.0-SNAPSHOT to pick up the companion fix in openmrs-module-htmlformentry (HTML-894) for local verification of a related "Enter New ART Visit" bug. This should be reverted to a released version before merge once HTML-894 is released.

Test plan

  • Open a patient's ART Mastercard flowsheet and enter/edit the header form — confirm no TypeError in console
  • Confirm duplicate-encounter validation still works correctly when entering/editing an ART Visit (non-header) encounter

🤖 Generated with Claude Code

…ion for header form

setupEncDupsValidation() in mastercard.js dereferenced
flowsheet.getFlowsheet(formName) without checking for undefined. This
throws "Cannot read properties of undefined (reading 'encounterTypeUuid')"
whenever the flowsheet header form is entered/edited, since the header
form is never registered via flowsheet.addFlowsheet() (only the
repeatable visit forms are) so getFlowsheet() returns undefined for it.

Guard against this and skip duplicate-encounter validation for the
header form, since that check only applies to the repeatable visit
forms.

Also bumps htmlformentryVersion to 7.3.0-SNAPSHOT to pick up the
companion fix in openmrs-module-htmlformentry (HTML-894) for local
verification.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mseaton
mseaton merged commit 79f8bb7 into master Sep 17, 2026
@mseaton
mseaton deleted the MLW-1852 branch September 17, 2026 15:56
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.

1 participant