Question about resignation

I have been struggling physically and mentally for a while at my job but have the support of my doctor to take a medical leave.

I could use the medical leave note but instead I accepted a job that starts in 4 weeks.

My contract says I have to give 45 days notice. Is this enforceable when I have the support of a doctor to take a medical leave immediately?

I don’t want to leave them in the lurch and am willing to give 3 weeks notice but part of the reason I’m leaving is because I’ve been having panic attacks and struggling to cope on the job.