In the US, i is very common to have to authorize employers to see your medical records or you just won't get hired. By not hiring people they consider "high risk" they used to be able to keep their medical insurance expenses down. "Preexisting conditions" is a very hot topic here in the health care debate. In 2014 discrimination because of preexisting conditions was prohibited but there are always exceptions.
People with mental health issues can't be required to state this on their application. Once they get a job offer, however, they can be required to undergo an exam and to give their medical records to the employer for evaluation. If they decide you might not be able to do the job with "reasonable accommodation", the offer can be withdrawn. ("Reasonable" is always an opinion.) Or you can be officially denied employment for reason "X" when it was really reason "Y" hiding in the back of the employer's mind if you catch my meaning. The ball is now in your court to prove they are wrong.
Now if you are enlisting in the military or applying for a position the government considers sensitive, you can be denied employment if anything at all shows up on your records because your clearance might be denied. (The clearance process is a classified government activity and not up to the employer. They decide if you are a security risk and there is no appeal.) Had I been diagnosed for depression or Asperger's or ADD at the time, I could not have spent 6 years in the National Guard nor could I have worked in aerospace for 9 years.