Peace be upon you. If there is a valid religious excuse for not fasting, you must pay a compensation, which is to feed a needy person three-quarters of a kilogram of food for each day you do not fast. This compensation is paid only once. The compensation for illness can only be given after the illness persists to a point where you cannot fast or make up the fast after the next Ramadan.
According to Grand Ayatollah Khamenei: If there is a valid excuse for not fasting, you must pay a compensation, which is to feed a needy person 750 grams of wheat or bread. This compensation can only be given after the illness continues to a point where you cannot fast or make up the fast due to the time constraint of the next Ramadan approaching.
May you be successful in all good deeds.