Uh-oh -- it looks like someone needs to run down to the nearest Walgreens Boots Alliance (WBA 3.69%) and buy something for its shareholders' headaches. The pharmacy stock recently fell hard in response to a quarterly earnings call marred by a $6.15 billion operating loss.

Walgreens is a big company with a lot of moving pieces, and some of those pieces are heading in the right direction. It took investors a little time to sort out all the ups and downs, but the stock quickly recovered most of its post-earnings-call losses.

Is it time to sell shares of Walgreens, or is the latest dip an opportunity to buy a top healthcare stock at a discount? At recent prices, the stock offers a 5.2% dividend yield, and that dividend has increased in each of the past 47 years. Let's measure the company's recent challenges against its opportunities to see if it can continue this legendary streak.

Why Walgreens tanked

On Wednesday, Jan. 8, Walgreens reported results from its fiscal first quarter that ended on Nov. 30, 2022. The top-line figures were downright disturbing. The company reported an operating loss of $6.2 billion, which reflects a one-time charge of $6.5 billion to settle opioid-related lawsuits.

After accounting for taxes and a $900 million gain from selling shares of AmerisourceBergen, the company reported a net loss of $3.7 billion. That did not compare well to a $3.6 billion net gain in the previous-year period.

Why Walgreens recovered

Walgreens' U.S. healthcare segment is outperforming expectations. You may recall that in 2021, the pharmacy operator became a majority owner in a primary care provider called VillageMD. The major U.S. health insurance provider Cigna owns a minority stake.

Walgreens' stock quickly recovered from its recent dip, partly because investors noticed the VillageMD venture is more successful than expected. In November, VillageMD acquired Summit Health-CityMD, a leading primary, specialty, and urgent care provider, for around $8.9 billion.

Before VillageMD bought Summit Health, Walgreens expected more than 600 of its retail pharmacies to have a colocated Village MD primary care practice by 2025. The acquisition of Summit Health raised the number of VillageMD's provider locations to 680 practically overnight.

The big push into primary care appears to be succeeding. During its fiscal first-quarter earnings call, management raised expectations for its U.S. healthcare segment. Instead of an expected revenue range between $11 billion and $12 billion that management issued in October, the company currently expects the segment to contribute between $14.5 and $16 billion in 2025.

Keep holding

A few months ago, Walgreens was expecting positive cash flows from its U.S. healthcare segment in fiscal 2024. Successful execution of the Summit Health-CityMD acquisition, though, has management convinced this segment can begin producing positive adjusted earnings before interest, taxes, depreciation, and amortization (EBITDA) before its current fiscal year ends this August.

Walgreens' recent progress toward becoming more than just a retail pharmacy chain is a welcome achievement. That said, its joint venture with Cigna feels like a half-measure that Walgreens should have completed several years ago.

WBA Free Cash Flow Chart

WBA Free Cash Flow data by YCharts

In comparison, instead of trying to partner with a health insurance benefits management company, CVS Health went out and acquired one outright in 2018. CVS Health's acquisition of Aetna for $69 billion has led to enormous cash flows that Walgreens can only dream of.

CVS Health paused dividend raises for a few years to help pay for its acquisition of Aetna. Despite the pause, CVS Health's payout growth over the past decade outpaced Walgreens' by a mile.

Over the past year, Walgreens issued dividend payments that exceeded the amount of free cash flow its operation generated over the past year. Thanks to a surprising success from its VillageMD venture, Walgreens has a chance to get back on track and continue its long history of modest dividend raises.

If this stock is already in your portfolio, keeping it there makes sense. Buying the Walgreens stock, though, doesn't seem like a smart move right now.