O3-5316: Implement urgency-based sorting in OrderService#5730
O3-5316: Implement urgency-based sorting in OrderService#5730RajPrakash681 wants to merge 2 commits intoopenmrs:masterfrom
Conversation
- Add getOrders() method with sortBy and sortOrder parameters to OrderService interface - Implement multi-field sorting in OrderServiceImpl (urgency and/or dateActivated) - Add 4 comprehensive test cases to verify sorting functionality - Add test dataset XML file with urgency variations for testing - Support both ascending and descending sort orders - Prioritize STAT/ON_SCHEDULED_DATE over ROUTINE orders when sorting by urgency
|
@RajPrakash681 |
|



Description of what I changed
This PR updates the REST module to delegate urgency-based sorting to the core
OrderServiceinstead of implementing business logic in the REST layer.Changes Made:
OrderResource1_10.java: UpdateddoSearch()method to call the newOrderService.getOrders()method withsortByandsortOrderparameterssortOrders(),compareByUrgency(),compareByDate(),containsField()) as they now exist in openmrs-coreOrderController1_10Test.javaremain to verify proper parameter passing and API response formatArchitecture Alignment:
This change follows OpenMRS best practices where:
API Usage (unchanged):
Execution Flow:
sortByandsortparametersOrderService.getOrders(..., sortBy, sortOrder)Issue I worked on
See https://issues.openmrs.org/browse/O3-5316
Related Core PR: This PR depends on the core implementation being merged first:
getOrders()overload with sorting support toOrderServiceNote: This PR should only be merged AFTER the core PR is merged and released.
Checklist: I completed these to help reviewers :)
My IDE is configured to follow the code style of this project.
I have added tests to cover my changes.
OrderController1_10Test.javaverify REST API properly delegates to coreI ran
mvn clean packageright before creating this pull request and added all formatting changes to my commit.All new and existing tests passed.
My pull request is based on the latest changes of the master branch.
Additional Context
Why This Refactoring Was Necessary:
Initial implementation placed sorting logic in the REST module, but from the feedback i received correctly identified that business logic should reside in openmrs-core, not in presentation layer modules. The REST module should act as a thin wrapper around the Java API.
Dependency Update Required: