They appear to be two different problem not related to each other...
1 PALPITATIONS > You ought to have basic blood tests (including thyroid) / ECHOcardiogram
- to exclude Mitral Valve Prolapse
and so on / Holter (24 or 48 hours ambulatory monitoring of heart beats) to document and analyse the palpitation. Occasionally, more depending on their results! May be the dose of beta-blocker
needs to be tailored...or you may need a different drug...
2 URINE - it could be infection and/or stone. Have the urine tested for routine and culture.
But the pain is in flanks - if it is as you say over over rib cage, go for X-ray chest / Sonography
of kidney gall bladder
etc Antispasmodics and plenty of oral fluids will help in the mean time