The United States Supreme Court is the site of the latest Obamacare showdown. (Photo courtesy of Flickr, Creative Commons)

Combine an aging population with Obamacare's influx of newly insured patients, and the long-term prognosis for hospital stocks is stellar. Better yet, there are big opportunities in this sector right now for those with a few gambler genes in their DNA.

Surprised? Don't be. While investors are being warned off hospitals by those worried about the impact of the Obamacare debate raging in the Supreme Court, the threat to the healthcare reform law is not as scary as it seems.

Coming before the court are arguments about whether federally-given Obamacare subsidies (received by 7.5 million people!) are legal. While a ruling in favor of the plaintiffs on this King v. Burwell case could wipe out subsidies and cause insurance to become unaffordable for many, hurting hospital stocks, I'd argue that the impact would be temporary. In the meantime, the uncertainty surrounding this Supreme Court case is keeping many stocks' prices depressed.

If the ruling (expected in June or July) goes unfavorably, we should expect a hiccup in the healthcare industry, but not a lasting hit to hospitals. What's more, hospital stock expert Brian Wright believes the post-ruling potential upside for select hospital companies is more than three times, on average, that of the downside.

For example, Wright sees a short-term trading risk for the biggest for-profit hospital operator HCA Holdings (NYSE:HCA) of around 14%, but an upside of 52% in the event of a favorable court ruling. It's also likely that Congress would quickly enact fixes when faced with the political backlash of 7.5 million people who lost their ability to collect subsidies.

But what if the ruling goes unfavorably and no fix happens? That's possible, isn't it? Sure, anything is possible.

So here's the downside... hospital stocks in that case would likely tumble. Investors who spook easily and sell their holdings would face a nasty loss.

On the other hand, investors who don't spook and hang on should do just dandy long-term. While for-profit hospitals are benefiting from subsidies making insurance affordable for more people, the gains are not nearly as big as they may seem. Analysts have estimated that the loss of subsidies would jeopardize less than 4% of for-profit hospitals' pre-tax earnings.

Here's what those worried about hospital stocks are missing -- and this is why hospitals aren't scared in the face of King v. Burwell. The real benefit to hospitals from healthcare reform is coming from Medicaid expansion, not the federal exchange.

Medicaid expansion driving growth
Under Obamacare, states have the option to expand Medicaid at little cost to the state.

More and more states are doing just that, as Motley Fool health care journalist Bruce Japsen  recently pointed out. In fact, Pennsylvania recently became the ninth state led by a Republican governor to join the expansion, a list that includes Arizona and New Jersey. Recently, Indiana and Montana (which has a Democratic governor) joined the group of Medicaid expansion states. This trend, in addition to an improving economy, is boosting revenues for hospitals, as well as reducing the number of uninsured patients.

This reduction in the number of uninsured has a direct impact on hospitals, which are constantly faced with bad debt. Hospital analysts have estimated that uncompensated emergency care can cost upwards of 35% of total emergency care revenue.  

That's set to change as Medicaid expands. Hospitals are now seeing the same patient who previously came in and didn't have means to pay the bill returning with healthcare coverage. Since hospitals' infrastructure costs are both relatively fixed and extremely high, the reduction in nonpayers makes a big difference in profitability.

Medicaid expansion is therefore a wave investors can ride. As hospitals spend less on charity care, hospital earnings are headed upward, and stock prices should follow.

In other words, since Medicaid is such a boon to hospitals, solid earnings growth is the foreseeable future for these companies, whatever the outcome of King v. Burwell.

There's no end in sight, by the way. Per the Centers for Medicare and Medicaid Services, total U.S. healthcare spending should grow by 5.7% on average annually through 2023 as a result not just of Obamacare and Medicaid expansion, but also as a result of faster projected economic growth and the aging population. And that's all very good news for hospital stock investors.