Pain to the sides of my middle back when I lay flat on my back or lay on my side. Sometimes feel the pain radiate into my ribs. Severe pain after slee?

Spinal compression. Sounds like you may have compression on your thoracic vertebrae, for which you need to see your primary doctor and get some imaging studies done. The good news here is that in most such cases physical therapy would be of great relief. Good luck??