The healthcare industry has been one of the fastest-growing over the past two decades. With tens of millions of baby boomers heading toward retirement -- and likely needing more healthcare -- that won't soon change.

That's why today's matchup is so interesting. In one corner, we have an industry heavyweight in Cerner (CERN), the leading provider of information-technology systems in U.S. healthcare. In the other, we have Veeva Systems (VEEV 0.17%), an upstart that is building out a cloud solution specifically designed to help drug companies take products through the approval process and to market.

Two medical professionals working on their computers.

Image source: Getty Images

Between these two, which is the better buy today? That's impossible to answer with 100% precision. But by viewing the question through three different lenses, we can get a better idea.

Sustainable competitive advantages

When we one day create the first time machine, I'm going to jump on it and tell my younger investor self one thing: "Devote almost all your time to researching a company's sustainable competitive advantage." Often referred to as a "moat," this has been -- by far -- the most important metric to study.

Both Veeva and Cerner benefit from a massively important moat in the form of high switching costs. When hospitals starting using Cerner's systems, they become heavily reliant upon them to provide critical data in real time. Switching providers may not only be costly and create headaches for hospitals -- it also puts emergency-room lives on the line.

Likewise, Veeva is becoming more and more ingrained in the ecosystem of pharmaceutical companies. Veeva got its start by offering customer relationship management (CRM) tools for company sales forces. More recently, however, it has spread its wings in offering Veeva Vault -- a solution that allows drug companies to keep mission-critical documents all on a single cloud-based platform as a drug moves through clinical trials.

I would often call such a matchup a draw. But here, I believe that Veeva has a slight edge. The company keeps rolling out new products, signing on more drug companies, and becoming more ingrained in the operating culture of its clients. Recently, Cerner has seen its bookings drop, and its chief rival, privately held Epic Systems, is gaining market share. Veeva has no serious competition in the pure play for pharmaceutical cloud companies.

Winner: Veeva Systems.

Financial fortitude

While it's exciting to see a company aggressively reinvesting in its business -- or offering an outsized dividend -- we can't underestimate the importance of having a sizable cash stash on hand. When companies face hard times -- and they all eventually do -- those with cash on hand have options. Those with lots of debt simply don't.

Here's how Veeva and Cerner stack up in terms of financial fortitude -- keeping in mind that Cerner is valued at roughly three times the size of Veeva:

Company

Cash

Debt

Net Income

Free Cash Flow

Veeva

$511 million

$0

$65 million

$143 million

Cerner

$693 million

$536 million

$653 million

$435 million

Data source: S&P Global Market Intelligence and Yahoo! Finance.

Both these companies have fairly healthy balance sheets. Once again, however, Veeva gets the win. The company's lack of any long-term debt is a very positive sign that it can weather whatever uncertain future lies ahead.

Lately, Cerner's acquisition of Siemens Health Services for $1.3 billion has been looking a little overpriced, as it hasn't delivered the type of revenue growth investors were hoping for.

Winner: Veeva Systems.

Valuation

Finally, we have valuation. While this isn't an exact science, there are some straightforward metrics we can consult to give us an idea of how expensive each stock is, including the ratios of price to earnings (P/E), price to free cash flow (P/FCF), and price-to-earnings divided by growth (PEG):

Company

P/E

P/FCF

PEG

Veeva

85

41

2.6

Cerner

25

41

1.7

Data sources: Yahoo! Finance, E*Trade. P/E represents figures from non-GAAP (generally accepted accounting principles) earnings.

Here we have a different outcome: Cerner is by far the cheaper stock. Even after accounting for the potential for growth (via the PEG ratio), Cerner looks to be trading at a discount to Veeva.

Winner: Cerner.

And the winner is... Veeva Systems

So there you have it: Veeva has a slightly wider moat, and a slightly better balance sheet than Cerner, while Cerner comes in with a more favorable valuation. The moat provided by Veeva -- and its business momentum -- is part of the reason that it occupies over 3% of my real-life portfolio, while I hold no shares of Cerner. I suggest that shareholders with a long-term time horizon and a stomach for some volatility dig deeper into Veeva's story.