Following Brexit many countries now require a medical certificate for non-lucrative residence visa's such as Spain and Portugal requiring an examination, and urine test following a medical questionnaire. This is usually within 3 months of the application date and states you have been examined and are free of any contagious diseases according to the International Health Regulation 2005. A bilingual certificate can be supplied. These are useful for students, digital nomads and remote work visas.
This should be issued no more than 90 days before your appointment date.