All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Fasting on behalf of your friend in the month of Sha’baan is not valid, and the reward of fasting will not automatically go to her, because it is not permissible for anyone to fast on behalf of anyone else.
Zakariyah Al-Ansaari said in his book Asna Al-Mataalib:
"It is not valid to fast on behalf of a living person without any difference of opinion among the scholars. This is so whether this person is exempted from fasting or not [..] Ar-Ramli said in his footnote (commenting on the statement of Al-Ansaari): ‘His saying: ‘It is not valid to fast on behalf of a living person’; this was reported in the explanation of the book of Imaam Muslim that it is the consensus (of the scholars).'" [End of quote]
However, some jurists are of the view that it is permissible for you to fast for yourself and then supplicate Allah to make the reward of your fasting for her. This is what is called gifting the reward, and there is a difference of opinion about it among the jurists. Some of them are of the view that it is permissible and some of them are of the view that it is not permissible. Hence, it is better to fast for your own self and supplicate Allah earnestly to cure her.
With regard to her fasting in Ramadan, then as long as she is sick and takes medication during the day based on the doctor's instructions, then she is entitled to break the fast as Allah Says (what means): {So whoever amongst you is ill or on a journey [during them] - then an equal number of days [are to be made up].} [Quran 2:184]
If she breaks the fast due to the disease, then she does not have to expiate. However, in the future, she must make up for the days she broke the fast, if her illness is curable and she can make them up.
As for changing the time of taking the medicine to the night instead of the day so that she can fast, then she has to consult her doctor.
A psychiatrist told us that the medicine which is given to the patient of the disease you mentioned varies depending on the severity of the disease. It also depends on the difference of the quality of the medicine. Some medicine can be taken once at night and some must be taken twice, once at night and another time during the day, while drinking a lot of water.
Since this is the case, then she is entitled to break the fast and continue taking the prescribed medication until she meets her doctor and asks him about the possibility of taking the medicine at night.
We ask Allah to cure her and cure all the Muslim patients.
Allah knows best.