The relevant legislation says:
MED.A.020 Decrease in medical fitness
(a) Licence holders shall not exercise the privileges of their licence and
related ratings or certificates at any time when they:
(1) are aware of any decrease in their medical fitness that might render
them unable to safely exercise those privileges;
(2) take or use any prescribed or non-prescribed medication that is likely
to interfere with the safe exercise of the privileges of the applicable
licence; or
(3) receive any medical, surgical or other treatment that is likely to
interfere with flight safety.
(b) In addition, licence holders shall, without undue delay, seek aero-
medical advice when they:
(1) have undergone a surgical operation or invasive procedure;
(2) have commenced the regular use of any medication;
(3) have suffered any significant personal injury involving incapacity to
function as a member of the flight crew;
(4) have been suffering from any significant illness involving incapacity to
function as a member of the flight crew;
(5) are pregnant;
(6) have been admitted to hospital or medical clinic; or
(7) first require correcting lenses.
Source:
https://www.easa.europa.eu/sites/def...ents-Jun20.pdf