-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
…ctiveOrders(...) that should use OrderType as a parameter, not a java class
…rService.getActiveOrders(...) and OrderService.getOrder(...)
…nateOrderDAO.java implementation
… orders with a matching row in the test_order or drug_order table of their type
</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); |
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.
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
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.
Yes, I mentioned this earlier, I think a SELECT should be used here, too
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.
@djazayeri what do you think?
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 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);
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.
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
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; |
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.
Why do you have these changes here?
Tasks:
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