Can a Medicare participating hospital refuse a needed surgery on a Medicare patient?

Providers are not required to take Medicare (or Medicaid) patients. Hospitals are required to provide emergency care regardless of ability to pay.