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 and encounters in the same transaction #1727
base: main
Are you sure you want to change the base?
(feat) O3-2117: Save orders and encounters in the same transaction #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.
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
const orders: Array<OrderPost> = []; | ||
for (let grouping in patientItems) { | ||
const groupOrders = patientItems[grouping]; | ||
for (let i = 0; i < groupOrders.length; i++) { | ||
const order = groupOrders[i]; | ||
orders.push(postDataPrepFunctions[grouping](order, patientUuid, null)); | ||
} | ||
} |
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.
Instead of getting the orders
from the store, the orders should be passed via the function arguments.
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.
Also, the function createEmptyEncounter
should be renamed to saveOrdersWithNewEncounter
, since we are also saving the orders in the same encounter request.
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