There is something that happens to people temporarily when they are in ICU for extended times. It is called ICU psychosis. It is due to the medications, the 24 hour a day time frame, which doesn't allow the person to distinguish between day or night, and the loss of "person" that happens there.
It goes away once the person gets out of ICU and into a normal environment.
Family can help a lot with this by merely talking and even reading to the person, maybe bringing in some family pics to look at. And also it is important to bring in a calendar and make them aware of the time and day it is.
Open heart surgery all by itself causes many to have depression, sometimes it goes away, sometimes it needs medication.
I know that Joe had all of these things at one time or another. And he did recover from it. He took antidepressants, though, for many years, and they helped.