I'm afraid I'm not knowledgeable on employment law etc, so can't advise if they should have / are allowed to question you re this. I understand why you are pissed off though. I've had to fill in medical history forms for jobs, and twice (my two most recent jobs) I have been told that I shouldn't have disclosed certain information.
First time, admin job in a hospital. Put on the form that I have an underactive thyroid that is well controlled with levothyroxine. Had to see the occupational health Dr to have bloods done. She was lovely and said, as she was drawing my blood, that I shouldn't have mentioned it, as once I did she was required to do the bloods, which she didn't really agree with. Second time, another hospital job, this time for an HCA role (career change). I'd had a seizure a couple of years previously, had Neuro consultations, MRIs, EEGs, etc. So they followed up on this (no problem with this at all, in a patient care role they obviously needed to know that I was medically fit and not a risk to patients). Gave permission for them to get medical records from my GP, which were deemed insufficient, despite including notes from all my tests and Neuro consultations. So I had to pay a private Neuro consultant for a check-up and letter saying that I was medically fit for the job. HR told me to never disclose that information on any future job applications, that they appreciated my honesty, but had I not told them, they'd never have found out and that it was all unnecessary.
Seriously fucking frustrating. I will still disclose the information on any future job applications, as in my line of work I believe that my patients deserve for me to be at my best, and were I deemed medically unfit for the job I'd be devestated but accept that it's in the best interest of any patients I'd be working with.
Sorry, I blathered on a lot there
. All that is to say, I understand how bloody annoying it is, and how being completely honest feels like it's detrimental to you sometimes.