It seems that you might be having acute urinary tract infection
or some kidney stone problem as you got severe pain
and passing blood.
Go for urine check up and ultra sound
to find out cause of problem.
Chance of having pregnancy
is less likely as you got your period in August after you had sex in July.
Take plenty of water.
Ok and take care.