I'm sorry to hear about your son and his troubles. I hope I can offer some help though. I work in the Nurse's office in a school district and whenever students have medical issues such as this, we request a written order from his/her doctor stating that the child MUST be able to leave to go to the bathroom when he/she needs to. There are no questions asked, the teacher cannot deny the student to use the restroom when a doctor has ordered that they must be allowed to go. The "teacher notification" as we call it is sent to each and every teacher the student has during the day and they must sign off that they have read the situation and will comply with it.
I know this doesn't make the problem any easier to deal with physically, but it may help in his anxiety with his teachers, knowing that he can't be denied and a scene won't be made in front of the class. If you have already done this and you aren't getting any cooperation from the teachers, you should have a discussion with the School Nurse and she/he can help you find a solution.
I wish you and your son the best...and take care!