A rule preventing patients of different sexes from being treated on the same ward was broken thousands of times at Royal United Hospitals Bath last year, new figures show.