Refactor patient api endpoints