It wasn't until the mid-19th century that doctors realized going straight from an autopsy to the maternity ward was not a good idea.
One of the best ways to prevent the spread of the flu and other viruses is to wash your hands. Today, this may seem like common sense to many people (even if they don't all do it properly). Yet it wasn't until the mid-19th century that some doctors in the United States and Europe began to wash their hands before examining patients—and even then, only in certain cases.
An early proponent of hand washing was Ignaz Semmelweis, a Hungarian doctor who worked at the Vienna General Hospital between 1844 and 1848. In 1847, the death of Semmelweis' colleague Jakob Kolletschka led him to a breakthrough. Kolletschka had cut his finger on a scalpel during an autopsy, and developed an infection that killed him. Semmelweis wondered whether a similar type of infection could be happening in the doctors' maternity ward.
Semmelweis realized that, unlike the hospital's midwives, doctors sometimes examined women in the maternity ward after performing autopsies. In the absence of germ theory, Semmelweis theorized Kolletschka had died because "cadaveric matter" entered his body through his wound, and that women in the doctors' ward might also be dying because cadaveric matter from doctors' hands was entering their body through their genitalia.
Semmelweis' response to his theory was pretty good. He started mandating that doctors wash their hands with chlorinated lime after autopsies. And it was a big improvement—between 1848 and 1859, the maternal mortality rate in the doctors' ward dropped to around the same level as the midwives' ward.