Is it safe?

About two months ago I went to the hospital for a UTI and was prescribed two medications for it. Unfortunately I took it almost a week and the symptoms disappeared so I figured I should stop taking them. Now I'm experiencing the same symptoms and I wanna take the meds but I'm not sure if they'd still be okay to take? I was in the hospital about a week ago and had 2 rounds of steroid injections. I don't know if that'll affect anything. I'm currently 30 weeks. Should I take the meds for the UTI?