May Allah grant you Shifa.
If you have to take your medicine on regular basis three times a day and fasting is harmful to your health then you can not fast
But if you can organise the timing of the medicine and not harmful to your health then it is wajib fir you to fast and said situation if in the middle of the day you feel medicine is compulsory and anxiety attack comes then yes you take your medicine it is not a sin .saving of life is wajib only you have to pay qadha of that day after the Ramadhan Ul Mubarak.
اللهم اشف كل مريض
امن يجيب المضطر اذا دعاه و يكشف السوء
أمين يا رب العا لمين
Syed Abul qasim Rizvi