Went off on my boss

So I have been in a bad mood lately because I am ttc and started my period 2 days ago. This period I have gotten some bad diarrhea. This morning I kept having to run to the bathroom with bad cramps and period poops. Eventually my boss started getting upset and started asking everyone what my problem was and getting annoyed with me that I kept going to the bathroom. The last time I went just to pee (it had been a few hours since I had my last bm) and he said "hurry up I am tired of you going in the bathroom just so you can waste time at work." This set me off so I told him in a fairly angry tone that if he must know I am on my period and it makes my stomach hurt so to leave me alone. He didn't say a word after that and now that I have calmed down I am kind of embarrassed. What would you have done?