You have not mentioned if you have an obstruction due to the stones.
Most likely you are having it along with infection.
What are the findings of urine routine and culture tests.
The cortical thinning and scarring you mentioned is due to Chronic Pyelonephritis
which is a result of persistant or recurrent infection of urinary tract
and results in gradual damage to kidneys function.
Along with the cystogram get a urine culture done and decide further treatment accordingly.