I have a colleague (call them "Joe") in my PhD math program who told me that they approached a certain professor (call them "Dr. X") to ask them to be their advisor. Joe seemed very interested and capable to do research with Dr. X. However, Dr. X told Joe that they didn't want to do research with them because they had health issues. Namely, Joe delayed taking the qualifying exams because of a kidney stone surgery (a laser lithotripsy). Despite this, Joe took the qualifying exams and did very well. Dr. X still had a bias against Joe and did not want them in their research group because of their health problems.
Yes, this is an actual story that happened to a friend of mine.
Is there any basis in the professor not wanting to take Joe as their student? Or, are there legality issues? I know an employer cannot discriminate with regards to disabilities or health condition, but does this apply to prospective PhD supervisors?