It hasn't been an easy year for CVS Health (NYSE:CVS) or its main competitor in the retail pharmacy space, Walgreens Boots Alliance (NASDAQ:WBA). Every time Amazon makes a move into their territory, the stocks swoon. 

Both are trying to turn their retail locations into more than just retail pharmacies, but they're going about it in very different ways. Let's compare the two and find out which is most likely to continue thriving in an uncertain new market for healthcare services.

Woman facing a wall with two arrows in chalk pointing in different directions.

Image source: Getty Images.

The case for Walgreens Boots Alliance

Check out the latest Walgreens Boots Alliance earnings call transcript.

According to Walgreens, turning its U.S. stores into community health hubs is at the core of its strategy. At the moment, though, the company still doesn't know how it's going to make that happen.

One thing's certain, though: Walgreens isn't jumping into anything headfirst. Right now, Walgreens can offer laboratory services at 26 locations through a partnership with LabCorp that will expand to 600 locations over the next four years.

Instead of buying a health insurer outright, Walgreens began a tiny joint venture with one of the largest insurers in the U.S., Humana (NYSE:HUM), last summer. The partners started a pilot project in Kansas City to offer senior-focused health services at a handful of primary care clinics connected to Walgreens pharmacies.

The Humana-Walgreens joint venture will record profits or losses as a stand-alone entity, and won't expand any further unless it actually makes money. Humana serves millions of Medicare patients across the country, and if the pilot project really does remove costs from the healthcare system, many of those patients might start getting all their prescriptions filled at Walgreens.

During the three months ended Nov. 30, 2018, comparable store sales rose just 1% compared with the previous-year period. When Walgreens adds in sales from recently acquired stores, though, U.S. sales rose 14.4% on year.

Unfortunately, sales from Walgreens' international pharmacy segment slipped 5.9% compared with the previous-year period. As the U.K.'s Brexit deadline approaches without any agreement, weak U.K. market conditions that have been pressuring the segment will probably continue or worsen in 2019.

WBA Dividend Chart

WBA Dividend data by YCharts.

Walgreens has boosted trailing free cash flow by 148% over the past five years, but profits have stagnated since 2016. That hasn't stopped the company from steadily raising its dividend payout while repurchasing all the shares it created to acquire a 26% equity stake in AmerisourceBergen a few years ago.

At recent prices, Walgreens offers a meager 2.4% dividend yield, but it could grow quickly in the years ahead. The company used just 28% of free cash flow to make dividend payments over the past year, which means some big payout raises could be around the corner. 

Healthcare providers hanging out in the pharmacy.

Image source: Getty Images.

The case for CVS Health

Check out the latest CVS Health earnings call transcript.

When it comes to vertical integration, CVS Health isn't afraid to dive in headfirst. In 2006 it acquired Caremark, a pharmacy benefits management (PBM) business that was almost as large as CVS Health's retail operation at the time. CVS Health financed the deal with shares of its own stock and managed to keep raising its dividend payout. 

All-stock deals between different industries rarely work out as hoped, but CVS Health's Caremark acquisition has been a roaring success. The company has raised its payout 925% since announcing the deal and repurchased most of the shares it created.

CVS Health has frozen its dividend while it performs a gigantic $70 billion cash-and-stock deal for one of America's largest insurance companies, Aetna. By becoming the company that pays the bills, CVS truly has a chance to turn its retail locations into community health hubs. 

Unfortunately for CVS, a federal judge doesn't want the two companies to fully merge operations until he's worked out more details, such as data privacy between the two companies. The government shutdown has stalled the process, and it's still uncertain how much control CVS Health will have over its new health insurance business.

At recent prices, CVS Health offers a nice 3.1% dividend yield, but it might not move much in the near term. The company has paused payout raises and share buybacks until its debt-to-adjusted-EBITDA ratio falls from 4.6 following the deal to 3, which could happen in a couple short years.

The better buy

Walgreens Boots Alliance seems like the safer option at the moment, but it's going to remain heavily dependent on its retail pharmacy operation for a long time. Now that Amazon has entered the prescription drug arena, that's more than a little unnerving.

It's probably just a matter of time before CVS Health can begin integrating its new health insurance business and squeezing out some cost savings. Given the company's track record with Caremark and its unique new position, it has a pretty good chance of combining services in a way that drives profits through the roof. That makes CVS Health the better stock to buy right now.