Upper endoscopy is a medical procedure that allows doctors to visually examine the upper gastrointestinal tract, which includes the esophagus, stomach, and the first part of the small intestine (duodenum). This procedure is crucial for diagnosing conditions related to peptic ulcer disease and gastroesophageal reflux disease (GERD), as it enables direct observation of any abnormalities, lesions, or inflammation in these areas, guiding further treatment decisions.