ERCP (endoscopic retrograde cholangiopancreatography) is a procedure used to diagnose and treat diseases of the liver, pancreas, and bile ducts. It involves the use of an endoscope (a flexible tube with a camera) and contrast dye to visualize the HPB system and may be used to remove gallstones or to place stents in the bile ducts.