The best ways to prevent a bacterial, parasitic, or viral gastrointestinal infection are to not drink water or eat food that may be contaminated and to be careful with sanitation measures such as hand washing. Food that might be contaminated, such as raw meats and eggs, should be cooked thoroughly. Cooked foods and foods that are served raw should not touch any surfaces that may have been contaminated.
If someone in a household has a diarrheal infection, careful hand washing by all family members is recommended. It is best to have the infected person avoid preparing food or drink for others until their infection is over.
When traveling to developing nations, it is best to drink only bottled water, carbonated drinks, and hot cooked foods. Avoid fresh fruits and vegetables, limited to those that you can peel yourself. Food from food vendors is generally not considered safe.
Cases of diarrhea that are caused by foodborne illnesses are monitored on a community and state level. Other than travel-related cases, health officials want to try to determine where your infection came from so that they can address any potential public health concerns. For instance, if your infection is due to contaminated food served at a restaurant or due to a contaminated community water supply, then steps will need to be taken to prevent the spread of the infection.