Everyone has E Coli bacteria in their bowels. (They form part of the normal digestive process). However a few particular strains of E. Coli are able to get from the intestines into the bloodstream, which can lead to extremely unpleasant consequences.
Those nasty strain of bacteria will be present within the faeces of an infected person. If they fail to observe proper hygiene (i.e. washing their hands after using the loo), the bacteria can be transferred elsewhere, with the greatest risk to other people being if the infected person handles food which is then eaten by someone else.
Within a hospital setting, the standards of hygiene are high (and a patient is unlikely to be serving you food which they've prepared), so the chances of becoming infected through visiting someone with an E coli infection are effectively zero.
I'd be far more concerned about visiting someone with pneumonia, as the bacteria and viruses which can lead to that condition are probably airborne and thus pushed in your direction every time the patient exhales.
Chris