Hospital participation in Medicare and Medicaid is voluntary. However, as a condition for receiving federal tax exemption for providing health care to the community, not-for-profit hospitals are required to care for Medicare and Medicaid beneficiaries. Also, Medicare and Medicaid account for more than 60 percent of all care provided by hospitals. Consequently, very few hospitals can elect not to participate in Medicare and Medicaid."
Source (American Hospital Association, December 2016): http://www.aha.org/content/16/medicaremedicaidunderpmt.pdf (Sorry it's a PDF)
Edit: updated from 2010 reference to 2016 reference