Skip to content

UHM-9418 - Migrate lab workflow obs from comment to formNamespaceAndPath - #281

Merged
mseaton merged 8 commits into
masterfrom
UHM-9418
Jul 30, 2026
Merged

UHM-9418 - Migrate lab workflow obs from comment to formNamespaceAndPath#281
mseaton merged 8 commits into
masterfrom
UHM-9418

Conversation

@mseaton

@mseaton mseaton commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

The lab-result form machinery (EncounterForm + its redux-saga submission pipeline) repurposed obs.comment to track which form field/path an obs was recorded from, predating the formNamespaceAndPath field being added to the OpenMRS data model. This blocks comment from being used for its actual clinical purpose (see the companion pihapps lab-result-comments feature).

  • Switches to the purpose-built formNamespaceAndPath field (REST formFieldNamespace/formFieldPath), using a fixed "labworkflow" namespace and /-joined nested path segments (the field only permits one ^ total, so the old ^-joined nesting scheme can't be reused as-is).
  • getFormAndPathFromObs now also verifies formFieldNamespace matches before treating an obs as this app's own, since formFieldPath is shared across OpenMRS applications (e.g. HTML Form Entry).
  • Default obs/encounter REST representations updated to fetch the new fields.
  • Breaking change — version bumped to 2.0.0. Requires a paired data migration (see openmrs-config-pihemr UHM-9418 branch) to convert historical comment-encoded obs before this ships to openmrs-owa-labworkflow (also on a UHM-9418 branch, PR forthcoming) — no dual-read/fallback for old data is implemented.

Test plan

  • npx jest — 63 suites / 242 tests passing
  • npm run lint — no new errors (pre-existing warnings only)
  • Paired liquibase migration and openmrs-owa-labworkflow bump reviewed/merged before release

🤖 Generated with Claude Code

mseaton added 7 commits July 30, 2026 12:39
…ead of comment

The obs.comment column was repurposed to track which form field an obs
was recorded from, blocking it from being used for real clinical
comments. Switch to the purpose-built formNamespaceAndPath field
(exposed as formFieldNamespace/formFieldPath), using a fixed
"labworkflow" namespace and "/"-joined path segments (the field only
allows one "^" total, so nested paths can no longer use "^").
Uses formUtil.setFormAndPathOnObs/hasMatchingFormAndPath (added in the
previous commit) instead of hand-rolling the old comment-based ^-joined
encoding directly in the saga.
Breaking change: obs form/path tracking moved from comment to
formFieldNamespace/formFieldPath.
getFormAndPathFromObs previously keyed entirely off obs.formFieldPath,
which is shared across OpenMRS applications (e.g. HTML Form Entry).
An obs written by another app whose path happened to have 2+ segments
would be mistaken for one of this app's own fields. Now also requires
formFieldNamespace === "labworkflow" before treating an obs as ours.

hasFormAndPath/hasMatchingFormAndPath needed no direct changes since
both already delegate through getFormAndPathFromObs.
…erForm

EncounterForm.initialize() changed to filter obs via formUtil.hasFormAndPath
(instead of comment && comment.includes("^")) as part of the formFieldPath
migration, but this was the one behavior change in the file and had zero
direct test coverage - the existing tests only assert the form renders.

Extract the obs flatten/filter/map logic (including coded/boolean value
unwrapping) into formUtil.existingObsValues(obs), a plain function with
direct unit tests covering: obs with formFieldNamespace/formFieldPath and
a value (included), obs with no formFieldPath (excluded), obs with
formFieldPath but no value (excluded), and coded/boolean value unwrapping.
EncounterForm.jsx now just calls this function and adds the encounter date.

Also clarify the stale "form^path"/comment fixture in EncounterForm.test.jsx
as unrelated 2018-era vitals data that no longer plays any role now that
this code path keys off formFieldNamespace/formFieldPath instead of comment.

@mseaton mseaton left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See review comments.

Comment thread src/components/form/__tests__/EncounterForm.test.jsx Outdated
Comment thread src/features/form/__tests__/sagas.test.js Outdated
Comment thread src/features/form/__tests__/util.test.js Outdated
Comment thread src/features/form/util.js Outdated
…rkflow

react-components is a shared library; hardcoding the formNamespaceAndPath
namespace to "labworkflow" baked a specific downstream consumer's identity
into the library itself. Add a formNamespace prop on EncounterForm, threaded
through the same path formId already uses (prop -> dispatched action ->
saga -> formUtil), defaulting to DEFAULT_FORM_NAMESPACE
("openmrs-react-components") when a consumer doesn't supply one.

Addresses PR review feedback on #281.
@mseaton
mseaton merged commit e3ed357 into master Jul 30, 2026
3 checks passed
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