Back pain after lying down

Patient: I am 73 years old and am having pain in my back towards the right side which presents itself after I get up from sleep or lying down for a long time. This has been happening for the past week or so.

Symptoms: The pain seems to be in the rib bones but improves substantially after I wake up and move around for about a half hour. I sleep straight on my back. I have been sleeping on a foam mattress all this while but since this has occurred, have changed to a different mattress with not much change. The pain is only at the moment when I get up and persisting for upto a half hour thereafter with diminishing intensity.

Doctor: