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-3001: Form engine shouldn't send encounterDatetime when saving a new form #131

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

vasharma05
Copy link
Member

@vasharma05 vasharma05 commented Mar 27, 2024

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

Since we are facing issues with users not being able to save forms, in case their systems aren't/can't sync with the NTP servers.

If their computer has their time ahead with even 1~2 sec, they get the error from the BE that the encounter date-time is in the future.

Fix: We will not send the encounter date and time from the client's system and the server will add the date and time itself.

Screenshots

Before

Screen.Recording.2024-03-27.at.14.56.05.mov

After

Screen.Recording.2024-03-27.at.14.58.38.mov

Related Issue

https://issues.openmrs.org/browse/O3-3001

Other

None

@donaldkibet
Copy link
Member

Thanks @vasharma05, this is much needed fix. Looking at it, we might also want to expand this to not include encounterDatetime set through the UI, if the currentDate is same as the encounterDatetime IMO this is to enable RDE when picking dates in the past cc @ojwanganto

@ojwanganto
Copy link

ojwanganto commented Mar 27, 2024

Thanks @vasharma05 and @donaldkibet. We have, indeed, encountered this a number of times in our deployments and am happy to see a fix. Adding to @donaldkibet's point, how do we want to handle encounter date on the UI such that we can also support RDE? I wish there was an intelligent way of determining this in-prior to help add or exclude encounter datetime from the payload.

Copy link
Member

@mks-d mks-d left a comment

Choose a reason for hiding this comment

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

@vasharma05 no unit tests? Given the critically of the issues that have arisen around this, it would definitely be good to state clearly through unit tests what the expected outcomes are in different situations... (when the encounter datetime is provided, when the encounter datetime isn't provided, etc).

Cc @rbuisson

@@ -189,6 +189,11 @@ export class EncounterAdapter implements ValueAdapter {
encounterDatetime: string,
utcOffset: string
) {
console.log({ encounterDatetime });
Copy link
Member

Choose a reason for hiding this comment

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

Surely this is a leftover?

@icrc-jofrancisco
Copy link
Contributor

I just want to point out that there are modules where this value apparently may be necessary, such as fast-data-entry. I would ask that before approving/merging, you consider this scenario to make sure nothing breaks or comes up with an update for other modules.
CC: @vasharma05 , @mks-d , @donaldkibet
Thanks

@vasharma05
Copy link
Member Author

Hi @icrc-jofrancisco!
What are the specific flows that require the encounter date time?
AFAIK, the forms where the users fill in the encounter date time in the form itself works as expected.
Please let me know.
Thanks!

@vasharma05
Copy link
Member Author

Looking at it, we might also want to expand this to not include encounterDatetime set through the UI, if the currentDate is same as the encounterDatetime IMO this is to enable RDE when picking dates in the past cc @ojwanganto

Hi @donaldkibet @ojwanganto, yes RDE flows must be discussed thorougly..I believe the RDE flow can be discussed for sure, but since this is a critical bug, we can take that separately.

@icrc-jofrancisco
Copy link
Contributor

Hi @icrc-jofrancisco! What are the specific flows that require the encounter date time? AFAIK, the forms where the users fill in the encounter date time in the form itself works as expected. Please let me know. Thanks!

For example, I was thinking about this scenario.
As I said above, I didn't do any "exhaustive" analysis, and it's probably not even related. If it's not, ignore it.
Thanks,

@ibacher
Copy link
Member

ibacher commented Apr 3, 2024

Looking at it, we might also want to expand this to not include encounterDatetime set through the UI, if the currentDate is same as the encounterDatetime

Indeed. Although, for this, we need some reasonable definition of "same" since I think "===" is very likely to lead right back to the initial issue.

@icrc-jofrancisco In the case of that flow, payload.encounterDatetime (if not collected on the form) will be null and set to the current time anyway (handleEncounterCreate is called after the call to generateFormPayload, which is the thing changed here).

@vasharma05
Copy link
Member Author

Hi @ibacher @denniskigen , requesting your review in this PR.
Thanks!

yarn.lock Outdated
Copy link
Member

Choose a reason for hiding this comment

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

What are these changes to the lockfile owing to, @vasharma05?

@ibacher
Copy link
Member

ibacher commented Apr 4, 2024

I think the other case we need to consider is editing existing forms and this makes something like the rule @donaldkibet suggested essential before we can merge this in.

@vasharma05 vasharma05 force-pushed the fix/encounterDatetime branch 2 times, most recently from 53e4be0 to d116ad5 Compare April 5, 2024 09:00
@vasharma05 vasharma05 force-pushed the fix/encounterDatetime branch from d116ad5 to b6ac1ff Compare April 5, 2024 09:01
@vasharma05
Copy link
Member Author

Hi @ibacher !
I've added a video capture of editing the saved form with time being in future.
Please review.
Thanks!

Screen.Recording.2024-04-06.at.16.26.13.mov

@vasharma05 vasharma05 requested a review from denniskigen April 8, 2024 10:05
@vasharma05
Copy link
Member Author

Hi @ibacher @denniskigen , please re-review the changes.
Thanks!

@ibacher
Copy link
Member

ibacher commented Apr 9, 2024

Thanks @vasharma05!

@ibacher ibacher changed the title (fix) O3-3001: Form engine shouldn't send encounterDatetime when saving a new form (fix) O3-3001: Form engine shouldn't send encounterDatetime when saving a new form Apr 9, 2024
@ibacher ibacher merged commit 884b8a4 into main Apr 9, 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.

7 participants