A 40-year-old man with no significant past medical history presents with a 2-week history of painless jaundice, pale stools, and dark urine. On examination, he is visibly jaundiced and has mild epigastric tenderness. Ultrasound confirms dilated intrahepatic and extrahepatic bile ducts down to the head of the pancreas, but no gallstones are seen. What is the most appropriate next investigation?