visas are issued with a 90 days validity but when you stamp into Thailand within that period you get stamped in for the period of the visa. Its simple to plan
You can apply for a 60 day extension of stay based on being married to a Thai. That will give you the time you need to season the required 400k. Sorry to hear about the heart attack