There is quite an extensive list of medical conditions that could lead to temporary or permanent invalidity of your driving licence, either as a consequence of the condition itself, or because of the medical prescriptions you are required to take to help you deal with the condition. The complete list is on the dgt website.
DGT Driving with Medical Problems
, at the end of the pdf file, Annexo IV, as of page 78.
Other conditions, like Diabetes for example, will be covered by point 1.7 as mostly affects vision / ´capacidad visual´.
In general, if the intervals your specialist prescribes to have your vision or other essential capacity evaluated are smaller than the regular renewal periods for the categories on your licence, the validity of your licence will be restricted accordingly. For Diabetes 2 in most cases a restriction to 3 years for car licence.