refactoring - using the renamed method to getSortedEncounters.