TRUNK-6492: Add filtering methods to Encounter for voided orders and diagnoses. #5595
+83
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of what I changed -
This PR addresses an inconsistency in the Encounter API where getOrders() and getDiagnoses() return both active and voided items by default, unlike newer Encounter properties such as Conditions and Allergies.
To improve API flexibility while preserving backward compatibility, this change introduces overloaded methods that allow callers to explicitly control whether voided items are included:
getOrders(boolean includeVoided)
getDiagnoses(boolean includeVoided)
The existing getOrders() and getDiagnoses() methods were left unchanged to avoid breaking legacy code that depends on direct access to the underlying Hibernate-managed collections.
This allows client code and downstream consumers (including REST) to retrieve only non-voided orders and diagnoses without duplicating filtering logic.
Issue I worked on
https://issues.openmrs.org/browse/TRUNK-6418
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.
- Existing behavior of getOrders() and getDiagnoses() remains unchanged.
- I ran mvn clean package right 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.