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

(feat) O3-2117: Save orders and encounters in the same transaction #1727

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

usamaidrsk
Copy link
Contributor

@usamaidrsk usamaidrsk commented Mar 10, 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

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

@denniskigen denniskigen changed the title (feat) O3-2117: Save oders on creating encounter (feat) O3-2117: Save orders and encounters in the same transaction Mar 19, 2024
Copy link
Member

@denniskigen denniskigen left a 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

@@ -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')}
Copy link
Member

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.

Copy link
Contributor Author

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.

@usamaidrsk usamaidrsk force-pushed the ft-send-orders-on-creating-enconter branch from 329e58a to 856641d Compare April 15, 2024 11:24
Copy link
Member

@vasharma05 vasharma05 left a comment

Choose a reason for hiding this comment

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

A few changes

Comment on lines +81 to +88
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));
}
}
Copy link
Member

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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants