OKLAHOMA CITY -- After a long stay in the intensive-care unit, where it has been nursing wounds inflicted by one of its top customers,

Omnicare

(OCR)

finally looks like a company on the mend.

The giant institutional pharmacy still earns less money than it once did, with second-quarter profits falling 25% to $36.8 million, as cut-rate payments from

UnitedHealth

(UNH) - Get Report

continued to weigh on its results.

However, the company managed to handily beat Wall Street targets -- and raise its guidance ahead of a looming courtroom showdown with UnitedHealth -- despite its ongoing headaches.

Excluding special items, Omnicare posted second-quarter earnings of 46 cents a share. Analysts, on average, were expecting earnings of just 39 cents a share.

Omnicare pointed to improvements in its core pharmacy services business, which supplies medications to nursing homes, and its smaller contract research organization when touting its results.

To be sure, Omnicare still faces ongoing challenges in its main business. In addition to lower reimbursements, the pharmacy unit saw drug utilization slip and the number of beds served drop during the latest period. This time, however, the unit managed to offset most of that lost revenue by supplying more high-priced drugs to especially sick patients.

Going forward, Omnicare hopes to overcome its biggest problem of all in October when it is scheduled to meet UnitedHealth in court and fight for the higher payments that it once secured and still feels that it deserves.

Omnicare estimates that UnitedHealth has so far underpaid the company by a whopping $246 million since the giant health insurer suddenly cut its pharmacy payments two years ago.

Meanwhile Omnicare has raised its 2008 guidance. Due to recent improvements in its operating results, the company expects to earn between $1.85 per share and $1.95 per share over the year. If it does, the company could wind up beating Wall Street's current $1.75 target by a large measure.

"We are pleased to report revenues and adjusted diluted earnings per share that exceeded expectations for the quarter," Omnicare CEO Joel Gemunder stated on Thursday. "Our performance, we believe, reflects the progress we are making in the execution of strategies to restore growth, increase profitability and enhance shareholder value."

Clearly, those shareholders liked what they heard. Omnicare's stock jumped 11% to $28.94 after Thursday's positive update.

Express Scripts

(ESRX)

, another big player in the pharmacy arena, posted some major gains as well. The giant pharmacy benefit manager saw its stock jump 8.1% to $72.01 after the company issued bullish guidance of its own.

Express Scripts reported late Wednesday that its second-quarter profits had surged 26% to $192 million, as the company won more business and averaged higher profits on the prescriptions that it filled. The company now expects to earn $3.03 per share to $3.10 per share this year, compared to the $3 that analysts had been forecasting.

An update from rival

CVS-Caremark

(CVS) - Get Report

, issued Thursday morning, looked almost disappointing in comparison. CVS-Caremark missed top-line estimates for the second quarter, with its revenue inching up just 1.9% to $21.1 billion during the recent period. Moreover, the company simply matched profit targets with second-quarter earnings of 60 cents per share. Net income rose just 7.1% to $771 million during the period.

PBM investors, accustomed to phenomenal growth, clearly expected more. They pushed shares of CVS-Caremark down 3.3% to $37.28 following the report.