Yes, they are allowed to do this. Doctors are not just doctors; they are essentially private businesses, too. A private business can decide to only take clients or patients who can pay in certain ways--e.g. by insurance; by cash; by credit card--by whatever the business wants. So just as some doctors take no insurance and only take cash patients and that is legal, so can a doctor refuse to take a cash patient and only take patients who have insurance coverage.