From the symptoms that you have mentioned, the first possibility that comes to my mind is gall bladder colic or biliary colic. It can be due to cholecystitis(inflammation of gall bladder) or gall bladder stones. I would suggest an ultrasound abdomen to confirm the diagnosis. Other possibilities are irritable bowel syndrome, hepatitis(inflammation of the liver), kidney stones, pneumonia, musculoskeletal pain, lower rib fracture and malignancy. Irritation of the nerves supplying this area can also cause pain. Irritation can be due to nerve compression or pinching due to any spine related pathology.
In females,ovarian pathology can cause such symptoms. You should get an ultrasound right upper abdominal area done to confirm the diagnosis.
It is very difficult to precisely confirm a diagnosis without examination and investigations and the answer is based on the medical information provided. For exact diagnosis, you are requested to consult your doctor. I sincerely hope that helps. Take care and please do keep me posted on how you are doing.
You may wish to have your MD run tests for Gastrointestional Diseases like Irritable Bowel, Chrones, etc. Swelling and bloating could be indicative of these.