-
Notifications
You must be signed in to change notification settings - Fork 103
O3-4257: Fix obsGroup children visibility when parent hideWhenExpression evaluates to true #653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RajPrakash681
wants to merge
10
commits into
openmrs:main
Choose a base branch
from
RajPrakash681:fix/O3-4257-obsgroup-hide-children
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+411
−42
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eb663d8
O3-4257: Fix obsGroup children visibility when parent hideWhenExpress…
RajPrakash681 48c74f2
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 13c569c
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 45afca2
Add test form with hide property defined directly at field level
RajPrakash681 93a0ca0
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 e5ef7d2
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 9f2643f
Fix obsGroup children to inherit parent hideWhenExpression during beh…
RajPrakash681 af110de
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 d07a993
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 f5f9253
Merge branch 'main' into fix/O3-4257-obsgroup-hide-children
RajPrakash681 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
116 changes: 116 additions & 0 deletions
116
__mocks__/forms/rfe-forms/obs-group-hide-direct-test-form.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| { | ||
| "name": "ObsGroup HideWhen Direct Test Form", | ||
| "version": "1", | ||
| "published": true, | ||
| "retired": false, | ||
| "pages": [ | ||
| { | ||
| "label": "Test Page", | ||
| "sections": [ | ||
| { | ||
| "label": "Test Section", | ||
| "isExpanded": "true", | ||
| "questions": [ | ||
| { | ||
| "label": "Show Group?", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "radio", | ||
| "concept": "1587AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "answers": [ | ||
| { | ||
| "concept": "1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Yes" | ||
| }, | ||
| { | ||
| "concept": "1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "No" | ||
| } | ||
| ] | ||
| }, | ||
| "id": "showGroupDirect", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| } | ||
| }, | ||
| { | ||
| "id": "testGroupDirect", | ||
| "label": "Test Group Direct (Should hide when 'No' is selected)", | ||
| "type": "obsGroup", | ||
| "questionOptions": { | ||
| "rendering": "group", | ||
| "concept": "1c70c490-cafa-4c95-9fdd-a30b62bb78b8" | ||
| }, | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "showGroupDirect === '1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'" | ||
| }, | ||
| "questions": [ | ||
| { | ||
| "label": "Child Question 1 - Text Direct", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "text", | ||
| "concept": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
| }, | ||
| "id": "childTextDirect", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| } | ||
| }, | ||
| { | ||
| "label": "Child Question 2 - Number Direct", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "number", | ||
| "concept": "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
| }, | ||
| "id": "childNumberDirect", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| } | ||
| }, | ||
| { | ||
| "label": "Child Question 3 - Radio Direct", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "radio", | ||
| "concept": "1587AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "answers": [ | ||
| { | ||
| "concept": "1535AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Option A" | ||
| }, | ||
| { | ||
| "concept": "1534AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Option B" | ||
| } | ||
| ] | ||
| }, | ||
| "id": "childRadioDirect", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "availableIntents": [], | ||
| "processor": "EncounterFormProcessor", | ||
| "uuid": "da24c540-cc83-43bc-978f-c1ef180a497f", | ||
| "referencedForms": [], | ||
| "encounterType": "79c1f50f-f77d-42e2-ad2a-d29304dde2fe" | ||
| } |
146 changes: 146 additions & 0 deletions
146
__mocks__/forms/rfe-forms/obs-group-hide-test-form.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| { | ||
| "name": "ObsGroup HideWhen Test Form", | ||
| "version": "1", | ||
| "published": true, | ||
| "retired": false, | ||
| "pages": [ | ||
| { | ||
| "label": "Test Page", | ||
| "sections": [ | ||
| { | ||
| "label": "Test Section", | ||
| "isExpanded": "true", | ||
| "questions": [ | ||
| { | ||
| "label": "Show Group?", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "radio", | ||
| "concept": "1587AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "answers": [ | ||
| { | ||
| "concept": "1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Yes" | ||
| }, | ||
| { | ||
| "concept": "1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "No" | ||
| } | ||
| ] | ||
| }, | ||
| "id": "showGroup", | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| }, | ||
| "validators": [] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "testGroup", | ||
| "label": "Test Group (Should hide when 'No' is selected)", | ||
| "type": "obsGroup", | ||
| "questionOptions": { | ||
| "rendering": "group", | ||
| "concept": "1c70c490-cafa-4c95-9fdd-a30b62bb78b8" | ||
| }, | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "showGroup === '1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'" | ||
| }, | ||
| "validators": [] | ||
| } | ||
| ], | ||
| "questions": [ | ||
| { | ||
| "label": "Child Question 1 - Text", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "text", | ||
| "concept": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
| }, | ||
| "id": "childText", | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| }, | ||
| "validators": [] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "label": "Child Question 2 - Number", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "number", | ||
| "concept": "5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ||
| }, | ||
| "id": "childNumber", | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| }, | ||
| "validators": [] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "label": "Child Question 3 - Radio", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "radio", | ||
| "concept": "1587AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "answers": [ | ||
| { | ||
| "concept": "1535AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Option A" | ||
| }, | ||
| { | ||
| "concept": "1534AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "label": "Option B" | ||
| } | ||
| ] | ||
| }, | ||
| "id": "childRadio", | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "required": "false", | ||
| "unspecified": "false", | ||
| "hide": { | ||
| "hideWhenExpression": "false" | ||
| }, | ||
| "validators": [] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "availableIntents": [], | ||
| "processor": "EncounterFormProcessor", | ||
| "uuid": "da24c540-cc83-43bc-978f-c1ef180a497f", | ||
| "referencedForms": [], | ||
| "encounterType": "79c1f50f-f77d-42e2-ad2a-d29304dde2fe" | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming the issue is related to how form intents are handled in the
src/utils/forms-loader.ts, is it necessary to make changes in this file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the fix by reverting
obs-group.component.tsxto its original state (before commit eb663d8), and the tests FAILED without those changes. This proves that both fixes are necessary:The forms-loader.ts fix ensures children inherit the parent's hide property at form load time.
The obs-group.component.tsx changes provide runtime filtering by checking isHidden and isParentHidden to properly hide the children.
The two layers work together one at form loading, one at rendering.
The testing demonstrated that:
Without
obs-group.component.tsxchanges: Tests FAIL (groups and children still render when they should be hidden)