Reference: http://mufti.af.org.sa/ar/content/المريض-الذي-لا-يرجى-برؤه-يطعم
Question: A man died, leaving a son. He did not fast the month of Ramadhaan due to a legislated (acceptable) reason. Before he died, he set aside [sufficient funds to pay for] the kaffaarah (expiation) for it. And [so], the question is: Is it permissible to fast [whatever remained of his fasts to be made up] on his behalf?
Response: [The question is] why did he not fast [the month of] Ramadhaan?
If it was because he was unable to fast due to a serious and prolonged illness – from which he was not expected to get better, then a poor and needy person should be fed on his behalf for every day [he is unable to fast]. That means for the duration of the month [of Ramadhaan] it will be 45kg of rice. And this is [the case] if he is not fasting due to a [prolonged] illness from which he is not expected to get better. So, if he is mentally sane, then a poor and needy person should be fed on his behalf, and if he is mentally insane, then [any fasts he misses are] not required to be made up, and nor is a poor and needy person to be fed on his behalf [for each day he has missed].