Here you need to understand pain is just a symptom and the cause is different. So you need to cure the cause because this pain is basically a protective mechanism of body. When there is pain we come to know there is some thing wrong.
For your flank pain it can be due to various reasons like kidney stone,
obstructive uropathy, inflammation of kidney and upper
urinary tract,
polycystic kidney disease, urologic disease,
acute appendicitis, bladder infection,
bladder cancer,
hydronephrosis,etc. You can check further on your own.
So to treat you first we need to know what is the cause of this pain. For this I suggest you to do ultrasound abdomen , urinen test and blood report and then visit a good nephro as well
urologist and take treatment as per the report and diagnosis. If you are not happy with current doctor treatment plan you can always check with second doctor.
For your joint pain please specify which joint is paining and since when ? But just in general I suggest to use hot and cold pack on your joint and do take suggestion from ortho as well physio for further treatment after detail check up for joint pain.
I am sure this will be useful if you follow it step by step.
Take care.