HELP!!

Danielle • I have a 6 year old son and am pregnant with baby number 3! I had a miscarriage and am now 36 weeks!
So I am around 4 weeks pregnant (by my last period) my hcg level is 200 and I was having really bad abdominal pain, I went to the ER and they told me I had a UTI and gave me macrobid which is suppose to be pregnancy safe. I'm not sure how long I had the UTI but I just know the one day my stomach was hurting so bad so i went in and had it. Can a UTI cause a miscarriage??? I am so so worried