I believe they are. The purpose of reference checks is to get a better understanding of how the candidate may be as a future employee at their workplace. Therefore, unexplained absences and how many, if substantial, may impact their decision because they want to know how reliable and committed the candidate may be. Medical absences should not be considered by the employer. The medical reason (as opposed to the general nature of the reason) should not be asked by the employer either. They are allowed to ask questions where they are directly relevant to the nature of the candidate as a future employee. They are not allowed to be asking questions outside of this, such as personal questions about your marital status etc.
However, in this case, I would say this question is perfectly fine.