If diarrhea is uncomplicated and goes away within a few days, a doctor may not prescribe any treatment. Most bacterial infections of the gastrointestinal tract resolve by themselves in healthy people. In some cases, antibiotics actually prolong the shedding of the pathogen and may lead to carrying the organisms for months ("carrier state"). People with underlying diseases that compromise the immune system, such as cancer or HIV, may be treated with antibiotics since they may not be able to clear the infection on their own.
If the diarrhea is severe, bloody, includes mucus, and/or has lasted for several days to a couple of weeks, then a doctor will often order tests to identify the cause of the diarrhea and then tailor the treatment to the cause.
For viral infections and many pathogenic bacterial infections, the main treatment is to address dehydration to make sure that the person replaces lost fluids and electrolytes. Infants and those with severe dehydration may not be able to drink enough to meet their re-hydration needs and may have to be hospitalized for a short period of time.
Most parasitic infections are treated, although a few may resolve on their own. With some bacterial and parasitic infections, a doctor may treat the entire family even if only one member is obviously affected.
People should talk to their doctor before taking an over-the-counter anti-diarrhea medicine. Diarrhea is one of the methods that the body uses to help rid itself of the infection. Anti-diarrhea medication can slow down or prevent this from happening, potentially prolonging the length of the illness and sometimes making the infection worse.
For diarrhea caused by food sensitivities or intolerances such as lactose intolerance, treatment often involves avoidance of the suspected cause. A diagnosis of celiac disease may require avoidance of all foods containing gluten.