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

TRUNK-4173: Refactor OrderService.getOrders #781

Closed
wants to merge 9 commits into from
Closed

TRUNK-4173: Refactor OrderService.getOrders #781

wants to merge 9 commits into from

Conversation

coldcue
Copy link
Contributor

@coldcue coldcue commented Mar 12, 2014

Tasks:

  • Replace the current OrderService.getOrders(..) and other methods in the OrderService interface
  • Implement the changed methods in the OrderServiceImpl
  • Remove @ignore from handle_shouldVoidTheOrdersEncountersAndObservationsAssociatedWithThePatient(), and update the test to pass by excluding voided orders.

This branch will be rebased upon merging TRUNK-4287 #731 or something similar

</preConditions>
<comment>Test if there's any order which has no type, then set all orders with a matching row in the test_order or drug_order table of their type</comment>
<sql>
UPDATE orders SET orders.order_type = 1 WHERE orders.order_id IN (SELECT drug_order.order_id FROM drug_order);
Copy link
Member

Choose a reason for hiding this comment

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

Am starting to think setting the order type to 1 or 2 is wrong because these are not guanranteed to be the primary key values unless in the changesets that inserts them these are defined as the ids. Some implementations will pre-populate the order_type table and these ids will differ. The possible solutions are:
1- Either hard code the ids for test and drug order types and use them here as 1and 2
2- Set should set the order_type by selecting the order_type_id for the row where the java_class matches drug order or test order type respectively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I mentioned this earlier, I think a SELECT should be used here, too

Copy link
Member

Choose a reason for hiding this comment

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

@djazayeri what do you think?

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 mysql variables should be used (with preconditions), like:

SELECT @drug_order_type_id := order_type.order_type_id  FROM order_type WHERE order_type.java_class_name LIKE "org.openmrs.DrugOrder";

UPDATE orders SET orders.order_type = @drug_order_type_id WHERE orders.order_id IN (SELECT drug_order.order_id FROM drug_order);

Copy link
Member

Choose a reason for hiding this comment

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

We support other DBMSs, so we can't use DB specific feature really, we strive to our best to use standard liquibase tags where possible and not hard code SQL

@wluyima
Copy link
Member

wluyima commented Mar 15, 2014

This pull request looks invalid, i doubt if even the code compiles, i will fix everything

@@ -85,6 +85,8 @@

private CareSetting careSetting;

private OrderType orderType;
Copy link
Member

Choose a reason for hiding this comment

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

Why do you have these changes here?

@wluyima wluyima closed this Mar 15, 2014
@coldcue coldcue deleted the TRUNK-4173 branch March 15, 2014 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants