Refactor medication count by class using macro.