A footnote in Wal-Mart's second quarter earnings release this week highlighted one of the many effects of more people gaining health insurance under the Affordable Care Act: its pharmacies are no longer as profitable.

The retail giant blamed weak quarterly earnings that underperformed expectations partly on challenges facing its U.S. pharmacy business.

"Let’s talk about pharmacy," Greg Foran, president and chief executive of Wal-Mart U.S., said during the call. The company is seeing lower reimbursement rates from drug insurance plans and a decline in high-margin cash transactions, he said, "reflecting a marketplace shift in which more customers are now benefiting from greater drug insurance coverage."

Wal-Mart reported in the call that its  health and wellness business was growing, including an increase in prescriptions filled, but that the profit margins are lower than expected.

The company's struggles are being seen throughout the pharmacy industry, which remains profitable even if the margins are getting thin, said Adam Fein, president of Pembroke Consulting.

It's one of the dirty secrets of the pharmacy industry that uninsured people frequently pay more for drugs than those with insurance, Fein said. That's because the prescription drug plans can use their clout and scale to negotiate lower reimbursement rates with the pharmacies, while uninsured people pay more.

[Why two brand name erectile dysfunction drugs are not the same price.]

In addition, Fein said Wal-Mart, which runs the third largest pharmacy business in the U.S. bringing in an estimated $18.8 billion in revenue, has made strategic decisions that may have made it more vulnerable to this shift.

In 2006, Wal-Mart began offering offering hundreds of  generic prescription drugs for $4. That was novel because retail pharmacies haven't traditionally competed on the price of prescription drugs, which are largely hidden from consumers and attracted people who were paying full price for drugs, without insurance.

"They have many more cash-paying customers  than the average pharmacies, and as those people got insurance, the insurance companies decided in some cases they would pay less than what Wal-Mart was getting from the cash- paying customers," Fein said.

Wal-Mart also participates in preferred pharmacy networks, in which pharmacies agree to cut the price of a drug charged to an insurer, in order to get more customers in the door. Those extra store visits may not be as profitable as hoped, Fein said.

Foran, the Wal-Mart chief executive, said that the pressures on Wal-Mart's pharmacy business were expected to continue through the end of the fiscal year. Higher spending on labor and theft of products also played a role in its disappointing quarterly earnings.

Analysts said the pharmacy business remains highly competitive, despite the fact that another major retailer sold their pharamacy business earlier this year. In June, CVS Health agreed to buy Target's 1,660 pharmacies for $1.9 billion.

The industry is not likely to see the same wave of mergers that has hit the health insurance industry, said Morningstar senior analyst Vishnu Lekraj.

"You may see the government push back more on mergers within the retail pharmacy part of the supply chain, given the government wants healthcare costs to be slowed," Lekraj said. "The way to do that is a lot of competition in the pharmacy space."