Skip to content

(chore) Tidy up cruft in O3 form schemas#68

Merged
denniskigen merged 11 commits into
openmrs:mainfrom
denniskigen:fix/tidy-ampathforms-cruft
May 5, 2026
Merged

(chore) Tidy up cruft in O3 form schemas#68
denniskigen merged 11 commits into
openmrs:mainfrom
denniskigen:fix/tidy-ampathforms-cruft

Conversation

@denniskigen
Copy link
Copy Markdown
Member

@denniskigen denniskigen commented Apr 24, 2026

No logic changes — this is a hygiene pass across the 8 O3 form schemas included in the demo content package. Drops placeholder values, empty-string options, redundant duplicates, and dead hide blocks that never fire. Also fixes one user-visible label typo ("Diarrea" → "Diarrhea" in the Covid 19 form).

Most of what gets removed is demonstrably dead. The AmpathFormsLoader computes Form UUIDs deterministically from (name, version), so placeholder uuid: "xxxx" fields are ignored. The backend reads encounter (the name); encounterType is migrated from encounter at runtime if missing, so empty or duplicate encounterType entries add nothing. questionOptions.required has zero reads in openmrs-esm-form-engine-lib. hideWhenExpression: "false" or "" always evaluates falsy, so the hide never fires. And 47 isExpanded: "true" strings become booleans (both work per schema, but boolean is the intent).

All real logic stays: age/sex/HIV/pregnancy conditionals, PHQ-9 calculation and page skip, historicalExpression prefill, intent behaviours, rich conceptMappings, and the correct encounter: "<name>" + encounterType: "<uuid>" dual pattern where it's already set up that way.

Follows #67 (filename normalization)

- Remove placeholder `description` field ("Test Form 1 Description")
- Fix `isExpanded: "true"` (string) to `true` (boolean)
- Remove empty-string `min`, `max`, `showDate` from questionOptions

Keeps `encounter: "Consultation"` — the AmpathFormsLoader reads this
field (not `encounterType`) and resolves it by name via
encounterService.getEncounterType(String).
- Remove redundant `encounterType` field. AmpathFormsLoader reads
  `encounter`, not `encounterType`, and the frontend form engine
  migrates `encounter` -> `encounterType` at runtime.
- Remove placeholder `uuid: "xxxx"`. The backend computes the Form
  UUID deterministically from (name, version) via
  Utils.generateUuidFromObjects, so the JSON-level uuid field is
  ignored.
- Remove redundant `questionOptions.required` from both child
  questions. The field-level `required` is the schema-defined
  location and is what the form engine reads.
- Remove empty `validators: []` cruft.
- Fix `isExpanded: "true"` (string) to `true` (boolean).
- Remove empty `encounterType: ""` and `uuid: ""` root fields.
  The backend AmpathFormsLoader ignores the JSON `uuid` (computes
  it from name+version) and reads `encounter`, not `encounterType`.
- Fix `isExpanded: "true"` (string) to `true` (boolean).
- Remove placeholder `uuid: "xxxx"` (ignored by backend loader)
- Remove `weeksList: ""` on Time of Procedure (dead data, not read by
  form engine)
- Remove `step: 1` on Estimated Blood Loss (not in schema, not read)
- Remove `showDate: "false"` on Estimated Blood Loss (engine checks
  isTrue(); explicit "false" equivalent to omitting)
- Fix `isExpanded: "true"` (string) to `true` (boolean)
- Remove placeholder `uuid: "xxxx"`
- Fix `isExpanded: "true"` (string) to `true` (boolean) in both
  sections
- Fix typo in symptom label: "Diarrea" -> "Diarrhea"
- Fix `isExpanded: "true"` (string) to `true` (boolean) in all four
  sections
- Remove 10 dead `hide` blocks with `hideWhenExpression: "false"` on
  question-level behaviours. The expression evaluates to false, so
  the element is never hidden. Preserves the legitimate page-level
  `hideWhenExpression` on PHQ-9 Additional Questions that skips the
  page when the PHQ-2 screen is negative.
- Remove empty `rows: ""` on Clinician Notes textarea
- Fix `isExpanded: "true"` (string) to `true` (boolean) in all four
  sections
- Remove 24 empty `validators: []` arrays from questions
- Remove empty `encounterType: ""` and `uuid: ""` root fields
- Fix `isExpanded: "true"` (string) to `true` (boolean) in 16
  sections
- Remove 7 dead `hide` blocks with empty `hideWhenExpression: ""`.
  Empty expressions evaluate to falsy, so the element is never
  hidden; the block has no effect.
- Remove 3 empty `"hide": {}` objects (no expression, same net
  effect).
- Preserves all real conditional logic (age-based, HIV status,
  pregnancy, sex-based, chief-complaint-driven questions).
@denniskigen denniskigen changed the title (chore) Tidy up cruft in AMPATH form schemas (chore) Tidy up cruft in O3 form schemas Apr 24, 2026
Ward Admission was the only form in this directory without either an
`encounter` name or `encounterType` UUID. Iniz resolves the "Admission"
name to the corresponding encounter type UUID at ingest, matching the
convention used by the other forms in this directory.
@denniskigen denniskigen requested a review from ibacher April 27, 2026 20:51
Two follow-up fixes to this branch:

- ipd_admission_request-core_demo.json: revert the addition of
  `"encounter": "Admission"` at the top of the file. The form already
  declares `"encounter": "Transfer Request"` further down, so the new
  line was a duplicate JSON key that parsers silently dropped (the last
  occurrence wins). Whether `Transfer Request` is the right encounter
  type is a separate question; if it needs to change, that belongs in
  its own behavior-changing PR.

- structured_soap_note-core_demo.json: strip the remaining 23 empty
  `validators: []` arrays for consistency with the cleanup already
  applied to test_results_entry_form_v2-core_demo.json.
Copy link
Copy Markdown
Contributor

@NethmiRodrigo NethmiRodrigo left a comment

Choose a reason for hiding this comment

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

Thanks @denniskigen!

@denniskigen denniskigen merged commit 44d6783 into openmrs:main May 5, 2026
1 check 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