refactor patients filter