A 20-year-old male presents with epigastric pain radiating to the back for 2 months, accompanied by acid regurgitation and nocturnal pain. He has had similar episodes in the past and 3 previous episodes of melena. Which of the following is the preferred diagnostic test?