updated the encounters query to always pick the latest in case of multiple occurencies of the same encounter type on the same day