The writers decided to have a scene where Lisa and Bart visit Homer before his surgery and were unsure of how to do it, so they approached James L. Brooks, who made up the entire scene on the spot.
The opening sequence of the episode is a parody of C.O.P.S. (1988); it was not in the original animatic and added later because the episode was too short to fit in its required 22-minute length.
The phone number for Dr. Nick was 1-800-DOCTORB in the original broadcast. The number was for an actual medical clinic, whose lawyers forced the producers to change it to 1-600-DOCTORB for syndication, DVD, and streaming.
The idea for the episode came from James L. Brooks, who pitched the idea of Homer having a heart attack. However, the writers disagreed with such a heavy topic as this.