Risk is increased in the following situations:
Mechanical: any structural abnormalities in the urinary tract, vesicoureteral reflux (urine from the bladder flowing back into the ureter), kidney stones, urinary tract catheterization, ureteral stents or drainage procedures (e.g., nephrostomy), pregnancy, neurogenic bladder (e.g., due to spinal cord damage, spina bifida or multiple sclerosis) and prostate disease (e.g., benign prostatic hyperplasia) in men
Constitutional: diabetes mellitus, immunocompromised states
Behavioral: change in sexual partner within the last year, spermicide use
Positive family history (close family members with frequent urinary tract infections)

Diagnosis
Laboratory examination
Analysis of the urine may show signs of urinary tract infection. Specifically, the presence of nitrite and white blood cells on a urine test strip in patients with typical symptoms are sufficient for the diagnosis of pyelonephritis, and are an indication for empirical treatment. Blood tests such as a complete blood count may show neutrophilia. Microbiological culture of the urine, with or without blood cultures and antibiotic sensitivity testing are useful for establishing a formal diagnosis, and are considered mandatory. Imaging studies
If a kidney stone is suspected (e.g. on the basis of characteristic colicky pain or the presence of a disproportionate amount of blood in the urine), a kidneys, ureters, and bladder x-ray (KUB film) may assist in identifying radioopaque stones. Where available, a noncontrast helical CT scan with 5 millimeter sections is the diagnostic modality of choice in the radiographic evaluation of suspected nephrolithiasis. All stones are detectable on CT scans except very rare stones composed of certain drug residues in the urine.
A perinephric abscess (infection around the kidney) and/or pyonephrosis may develop in severe cases of pyelonephritis. Xanthogranulomatous pyelonephritis
Xanthogranulomatous pyelonephritis is an unusual form of chronic pyelonephritis characterized by granulomatous abscess formation, severe kidney destruction, and a clinical picture that may resemble renal cell carcinoma and other inflammatory kidney parenchymal diseases. Most affected individuals present with recurrent fevers and urosepsis, anemia, and a painful kidney mass. Other common manifestations include kidney stones and loss of function of the affected kidney. Bacterial cultures of kidney tissue are almost always positive. Microscopically, there are granulomas and lipid-laden macrophages (hence the term xantho-, which means yellow in ancient Greek). It is found in roughly 20% of specimens from surgically managed cases of pyelonephritis. Prevention
In people who experience recurrent urinary tract infections, additional investigations may identify an underlying abnormality. Occasionally, surgical intervention is necessary to reduce the likelihood of recurrence. If no abnormality is identified, some studies suggest long-term preventive treatment with antibiotics, either daily or after sexual activity. In children at risk for recurrent urinary tract infections, not enough studies have been performed to conclude prescription of long-term antibiotics have a net positive benefit. Drinking cranberry juice does not appear to provide much if any benefit in decreasing urinary tract infections. Management
In people suspected of having pyelonephritis, a urine culture and antibiotic sensitivity test is performed, so therapy can eventually be tailored on the basis of the infecting organism. As most cases of pyelonephritis are due to bacterial infections, antibiotics are the mainstay of treatment.