Regarding a PhD advisor rejecting student due to health problems I have a colleague (call them &quot;Joe&quot;) in my PhD math program who told me that they approached a certain professor (call them &quot;Dr. X&quot;) 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?
In most cases, discrimination on the basis of disability or illness is wrong and in many places it is also illegal.  This applies in places where PhD students are considered employees and in places where they are not.
However, there are certain exceptions.  If the disability makes it impossible or unreasonably costly for the student to conduct their duties, discrimination might be permitted.  If the student has a health problem that makes the research unsafe, then discrimination might be mandatory.