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-2654: Unable to edit visit attributes when editing visit details #1562

Closed

Conversation

usamaidrsk
Copy link
Member

@usamaidrsk usamaidrsk commented Jan 4, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

  • Fix error on updating visit attributes, by adding separate handler for visit attribute update.

Screenshots

update-visit-attributes.mp4

Related Issue

O3-2654

Other

@usamaidrsk usamaidrsk marked this pull request as draft January 4, 2024 19:32
@usamaidrsk usamaidrsk marked this pull request as ready for review January 4, 2024 19:55
@vasharma05 vasharma05 changed the title O3-2654 - (Fix): cannot edit a visit attributes (fix) O3-2654: Unable to edit visit attributes when editing visit details Jan 5, 2024
@vasharma05
Copy link
Member

Hi @dkayiwa !
Do you know why are we not able to update the visit attributes in the visit update payload itself? Is there anything we can work out on this? Updating the visit attributes separately will bring up many edge cases.
For more info, please feel free to refer the ticket assigned.

@ibacher
Copy link
Member

ibacher commented Jan 10, 2024

@vasharma05 @usamaidrsk The way to deal with issues like this would be to open in a Jira ticket in the Webservices.REST project that says something like: "Add ability to update attributes as part of the visit payload" with a description of what you're trying to accomplish and what syntax should be supported. You can add the tag "community-priority" in Jira and it should show up on the appropriate board. In most cases like these you're simply looking for a feature no one has ever asked for before, so ask for the feature (which is what a ticket is for).

@vasharma05
Copy link
Member

Hi @ibacher!
I actually thought that this might be a part of the well thought design, rather than not being implemented since no one asked for it. Bad assumption from my side.

I'll create a ticket and update the ticket in the O3-2654.
Thanks a lot @ibacher !

@vasharma05
Copy link
Member

Expecting a better solution with REST Ticket: https://openmrs.atlassian.net/browse/RESTWS-926

@vasharma05 vasharma05 closed this Jan 11, 2024
@ibacher
Copy link
Member

ibacher commented Jan 11, 2024

@vasharma05 hmmm… actually there is an issue with updates vs creates and it comes down to ambiguity in JSON. Ideally, what we want to submit as an edit is something that records the changes we want to make. There are some specified syntaxes for this (JSON Patch and XML Patch) which we don’t support. Without either an explicit patching syntax or sending the full resource with each request, the backend has no way to differentiate between an “append this attribute” request vs a “delete all attributes but this one” request or even a “delete all attributes”.

Theoretically, the principles of REST mean that we should be sending the entire representation of the resource as part of the PUT request, so we do need to be sure (on the front end side) that the update includes the full visit payload with the modifications made.

@ibacher
Copy link
Member

ibacher commented Jan 11, 2024

The main implication of the above is that we cannot request a partial resource and that modifications need to be applied to the fully downloaded resource, which may mean that we need slightly different code to handle “creates” vs “edits”.

@vasharma05
Copy link
Member

This is what I also encountered in the patient registration, when dealing with identifiers. If you see, there were cases handled where a few identifiers were updated, deleted and added simultaneously, which I belive cannot be done in a single REST request, hence I asked @usamaidrsk to follow the same steps here as well.

@usamaidrsk usamaidrsk deleted the fix-error-on-update-visit-attributes branch January 24, 2024 10:55
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.

3 participants