The Yalkut Yosef cites Poskim who require washing one's hands after leaving a hospital, due to the possibility that the remains of deceased patients, Heaven forbid, may have been present during the person's stay in the hospital.
The common custom, however, as the Yalkut Yosef adds, does not follow this opinion. The reason is that washing is required only when one went to a funeral, or to a cemetery, specifically intending to be in the presence of the deceased. It is perhaps only after intentionally being in the presence of a deceased person that one is required to wash his hands. Those who go into a hospital, of course, have no intention to place themselves in the presence of a dead person, and the custom is therefore not to require washing one's hands after leaving a hospital.

