There is still significant social prestige to being a doctor that will motivate people to take up the role; the same will be true for other high-paid jobs where there is a lot of training, such as lawyers. This prestige is often a key part of the reason people do the job in the first place; many doctors are paid far less than people working in business or financial services at similar levels of seniority. Finally, the unpleasant jobs mentioned typically are done for a salary well below the cap proposed, and they still have adequate people.