The flank pain is consistent with a urinary tract infection (UTI) and one would expect to see white blood cells (WBCs) in association with infection, perhaps with some red blood cells (RBCs); maybe, maybe not. To have pain and primarily RBCs, elevated levels of uric acid in the urine and/or acid urine is a common cause of stones. Renal stones may be quite small, yet painful, and can be associated with intermittent blood in the urine. The absence of RBCs in the urine should not lead to another diagnosis such as intercostal muscle strain, although that diagnosis and stones could easily co-exist.
You may want to get an opinion from a second urologist or, perhaps better, consult with a kidney specialist called a nephrologist. Stones or no stones, the cause of the blood in your urine must be determined. That it is intermittent does, in no way, diminish the importance of it as a sign of disease that must be diagnosed.