Broke my fast because of pain

Salamu alaykum,

I broke my fast because of bladder and kidney pain which also went to my right testicle , I think it's because of dehydration. Since when I fast I don't drink a lot of water which caused kidney stones . Is this allowed?