Ketones in urine DO NOT cause pain. Whoever told you that didn't know what they were talking about.
As to what IS causing your pain, I don't know. You need to go back to the doctor and demand some more tests. Something like that going on for five weeks is just not right.