The musical episode of 'Scrubs' this past week was due to a medical condition of the guest star. Once the aneurism pressing against her brain was corrected, everybody was back to "normal". This makes the episode similar to an episode of 'Chicago Hope', but it's not a link.
The splainin for the song and dance routines is markedly different from what happened in "Once More With Feeling", the musical episode of 'Buffy The Vampire Slayer'. Those characters were forced into a little song, a little dance (but without the seltzer down their pants) by the demon known as Sweet.
His raison d'etre can be connected to other musical episodes like the one from 'Seventh Heaven', as well as to entire series like 'Cop Rock', 'Hull High', and 'That's Life'. His most recent addition to his Crossover Hall of Fame credentials (inducted in October of 2005) would be the TV movie "High School Musical".