Skip to content
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

(fix) O3-2872: Fix inconsistent data when editing obsGroups in an encounter #125

Merged
merged 15 commits into from
Mar 15, 2024

Conversation

icrc-loliveira
Copy link
Contributor

@icrc-loliveira icrc-loliveira commented Feb 19, 2024

Issue: https://openmrs.atlassian.net/browse/O3-2872

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

On the O3, while editing a question inside of an ObsGroup only the edited questions are saved, voiding the other questions inside of the same ObsGroup.
This happens because the request only sends the questions that have been changed and the core will void the existing ObsGroup with all the existing questions to create a new one with the questions that came from the request.

In addiction, if an ObsGroup is empty (with all questions voided) it will void the existing ObsGroup and create a new empty one, which doesn't make sense.

1 - Create a form with an ObsGroup
image
image

2 - Edit the ObsGroup and you will notice that only the edit concept is there.
image
Request:

{
   ...
   "obs":[
      {
         "groupMembers":[
            {
               "concept":"4c2e4613-e438-411e-93fd-f68667fdac21",
               "value":"bf68787c-0074-11ea-8d71-362b9e155667",
               "formFieldNamespace":"O3",
               "formFieldPath":"physicalViolenceVictim~2"
            }
         ],
         "uuid":"1ab651d0-e584-4bae-81d0-3c3259499705",
         "formFieldNamespace":"O3",
         "formFieldPath":"__LpvKGGLHu~3"
      }
   ],
   ...
}

image

3 - Remove all ObsGroup questions and will notice that an ObsGroup has been saved but has no questions.
image

Request:

{
   ...
   "obs":[
      {
         "value":"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
         "uuid":"291ad219-2513-401b-9685-98dde61cf23d",
         "formFieldNamespace":"O3",
         "formFieldPath":"experiencePhysicalEmotionalViolence~2"
      },
      {
         "groupMembers":[
            {
               "uuid":"c89846c6-8bce-4e70-9ae8-24f34b8782fc",
               "voided":true
            }
         ],
         "uuid":"43a492d3-c2e6-4e0d-91f3-9c6f5df181a4",
         "formFieldNamespace":"O3",
         "formFieldPath":"__pFtptGqot~3"
      }
   ],
   ...
}

image

Screenshots

Related Issue

Other

@icrc-loliveira
Copy link
Contributor Author

Hello @ibacher Please review this PR.

@ojwanganto
Copy link

CC @donaldkibet @denniskigen

@denniskigen denniskigen changed the title O3 2872 - Projects OpenMRS 3.x Add epic O3-2872 Inconsistent data when editing obsGroups in an encounter (fix) O3-2872: Fix inconsistent data when editing obsGroups in an encounter Feb 19, 2024
Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

Thanks @icrc-loliveira! I think this needs some small adjustments, but the basic idea looks right.

@icrc-psousa
Copy link
Contributor

Hi @ibacher, I believe the last requested changes are now addressed. Could you please review and confirm if everything is in order?

@ibacher
Copy link
Member

ibacher commented Mar 7, 2024

Code looks good, but the tests are failing...

@icrc-loliveira
Copy link
Contributor Author

Hello @ibacher,
I know, sorry for the long time to fix this. It should be ready now.

@ibacher ibacher merged commit cd4fe7b into openmrs:main Mar 15, 2024
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.

4 participants