What causes pain in the upper right back and it goes around to front under ribs.
Could be facet joint narrowing ordiscogrnic
Could be your heart. Go to your family doctor and get an ECG done, or, if s/he doesn't have such an apparatus, get a referral to the nearest cardiologist.
Because your medical conditions, your primary physician need to evaluate, upper back pain emerged from different medical conditions.