I have blood in my urine and sudden urgency to pee. I can not even make to the bathroom at times. Also some pain in my flanks not so much when I pee.?

Multiple causes. Visible blood in the urine, along with urgency to urinate can have multiple causes, including infection or other inflammatory bladder condition, bladder or urethral stone, or tumor/cancer. Cancer is of particular concern if you are over 40 and or a smoker. Infection would be the most common. cause. Best to have this evaluated promptly.