Are you 100% sure that it was positive stress that got you into the ER? I myself distinguish between stress (=anxiety of not meeting goals in time), and positive motivation (=joy, and not the caffeine one). Sadly, I haven't had much of the second type in recent years, but it's something I'm working on. It sounds as if your HPA axis gets super worked up and your body enters fight or flight mode, causing your heart to go crazy. That's what kept happening to me until I actively took care of the underlying stresses or beliefs I have while coding ("I'm not gonna make it" / "I won't have the time to finish it" / "I won't finish this task today but I desperately want to"...). I didn't get heart symptoms, but rather fatigue and anhedonia.
Just some thoughts on caffeine, since I think stress in programmers is often caused by it, or covered up:
I only very rarely have caffeine, and rather do vitamins if I need to be more stress resistant (Vit C, D, K2, Pantethine and sometimes B vitamins). That way I'm not fooled by the motivation that comes with caffeine, which somehow covers up what I really want to do. If I have caffeine I get giddy about the thought of writing this and that tool, while I couldn't care less when off caffeine.