BC pill before HSG

Al

My doctor asked me to take the pill for the 7 days in which they will do the HSG and the saline ultrasound. Has anyone’s doctor told them this? Do you know why?