-
Notifications
You must be signed in to change notification settings - Fork 248
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
(feat) O3-2117: Save orders on a new encounter if there is no encounter #1727
(feat) O3-2117: Save orders on a new encounter if there is no encounter #1727
Conversation
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.
Thanks for working on this, @usamaidrsk. I've left a few suggestions
packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
Outdated
Show resolved
Hide resolved
@@ -116,21 +124,27 @@ const OrderBasket: React.FC<DefaultWorkspaceProps> = ({ | |||
<InlineNotification | |||
kind="error" | |||
title={t('errorCreatingAnEncounter', 'Error when creating an encounter')} | |||
subtitle={t('tryReopeningTheWorkspaceAgain', 'Please try launching the workspace again')} |
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 think it's best to show the original message here instead of the error message from the backend, which we're already logging to the console on line 67.
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 think that's right.
Just what I thought that given on creating the encounter we're adding orders too, then if the error was from the orders, showing the exact message might be helpful to the user what exactly is the issue.
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.
Dennis may be the leading authority on UI copy; I would defer to him @usamaidrsk .
packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
Outdated
Show resolved
Hide resolved
329e58a
to
856641d
Compare
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.
A few changes
08f3f41
to
641f32f
Compare
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.
LGTM
import { type OrderPost, useSystemVisitSetting, useVisitOrOfflineVisit } from '@openmrs/esm-patient-common-lib'; | ||
import { orderBasketStore, type OrderBasketStore } from '@openmrs/esm-patient-common-lib/src/orders/store'; |
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.
Is it possible to use a single import statement?
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.
You'll likely need to make sure that those exports are re-exported from https://github.com/openmrs/openmrs-esm-patient-chart/blob/main/packages/esm-patient-common-lib/src/orders/index.ts first. That might need to happen in a separate PR.
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.
This needs to be exported from the @openmrs/esm-patient-common-lib
or else we will very likely end up with multiple copies of the orderBasketStore
, since this import means that each app will load it's own copy.
To explain: code from things listed as peerDependencies
like @openmrs/esm-patient-common-lib
is treated as an external by Webpack, meaning this will compile to code that ensures @openmrs/esm-patient-common-lib
is loaded and load the exports from the named module. Code imported from @openmrs/esm-patient-common-lib/src/...
, however, does not get converted into an external, so the code ends up imported here like in a normal dependency, meaning you're working with an app-local copy of the orderBasketStore
.
It's technically ok to do this with type-only imports, because those are not part of the runtime code, so none of that code makes it into the final bundle.
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.
As discussed with @brandones , moving the implementation of saving the encounter and orders to the common-lib
seemed like a better idea. Therefore, I have created the postOrdersOnNewEncounter
function in the postOrders.ts file.
import { type OrderPost, useSystemVisitSetting, useVisitOrOfflineVisit } from '@openmrs/esm-patient-common-lib'; | ||
import { orderBasketStore, type OrderBasketStore } from '@openmrs/esm-patient-common-lib/src/orders/store'; |
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.
You'll likely need to make sure that those exports are re-exported from https://github.com/openmrs/openmrs-esm-patient-chart/blob/main/packages/esm-patient-common-lib/src/orders/index.ts first. That might need to happen in a separate PR.
@@ -116,21 +124,27 @@ const OrderBasket: React.FC<DefaultWorkspaceProps> = ({ | |||
<InlineNotification | |||
kind="error" | |||
title={t('errorCreatingAnEncounter', 'Error when creating an encounter')} | |||
subtitle={t('tryReopeningTheWorkspaceAgain', 'Please try launching the workspace again')} |
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.
Dennis may be the leading authority on UI copy; I would defer to him @usamaidrsk .
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.
LGTM
@jayasanka-sack The E2E tests kept getting canceled? Any idea what that's about? Can we go ahead and merge this or would we risk breaking the E2E tests? |
Hey, I checked out the recordings, and it looks like the UI isn't doing anything after clicking the save button. Since other PRs and the main branch don't have this issue, it seems like this problem was introduced in this PR. Recordings: |
Thanks @jayasanka-sack ! Ok @usamaidrsk we need to fix the E2E tests. |
I ran the test locally but couldn't reproduce this behavior. The key difference when running E2E tests on GitHub compared to running them locally is that we don't use the dev server on GitHub. Instead, we build the frontend and serve it, which is somewhat similar to the dev3 environment. However, I reviewed the trace from the report and found these console errors:
|
Ah, I understand now. We don't package Meanwhile, @usamaidrsk I wonder why the UI silenced the error. We should display an error message to the user if something goes wrong. |
Thanks for the follow up @jayasanka-sack , however all errors are displayed by an inline notification on the UI. Not sure why it is skipping that on the tests |
packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
Outdated
Show resolved
Hide resolved
…ter' into ft-send-orders-on-creating-enconter
Ok, since this is an E2E bug I'm going to go ahead and merge. |
Would you expect E2E tests to pass once this got merged in, @brandones? Still failing for new PRs surprisingly. |
They should, but unfortunately the patient-common-lib is embedded in lots of places that are not the chart, so we may not be using the latest version in tests. |
Requirements
Summary
This PR adds the functionality to save orders along with creating a new encounter if one didn't exist. Before two transactions existed, i.e one to create encounter first and then create orders.
Screenshots
add-orders-on-creating-encounters.mp4
Related Issue
O3-2117
Other