I would definitely contact the patient advocate at the hospital and tell them how you were treated. Being denied care because of a pain contract is wrong on all accounts especially when the care did not and would not have required pain medication. Also, I would absolutely dispute the bill or at least a portion of it because you did not receive care.
In the future, I would not mention the pain contract unless/until pain relief is offered. Not suggesting you be dishonest but unfortunately, some medical staff automatically assume the worst.
Hope you are feeling better now.