After spraying a solution to numb the patient’s throat, the doctor inserts an endoscope—a thin, flexible, lighted tube—down the throat, through the stomach, and into the small intestine. The doctor turns on an ultrasound attachment to the scope that produces sound waves to create visual images of the pancreas and bile ducts.