Allscripts Healthcare Solutions, Inc. MDRX reported second-quarter 2021 earnings on Aug 5. The quarterly results have managed to impress investors as the stock moved up 1.5% to close at $17.39 on Aug 6.The company’s delivered adjusted earnings per share (“EPS”) of 23 cents in the second quarter of 2021, up 35.3% year over year. The figure surpassed the Zacks Consensus Estimate by 27.8%.GAAP EPS for the quarter was 15 cents a share against the year-earlier loss of 5 cents per share.Revenues in DetailAllscripts registered revenues of $373.7 million in the second quarter, up 1.2% year over year. The figure surpassed the Zacks Consensus Estimate by 0.3%.For second-quarter 2021, bookings came in at $180 million, up 9.8% from the prior-year quarter, driven by robust demand across the company’s full solutions portfolio.Segment DetailsIn the quarter under review, revenues at the Software delivery, support and maintenance segment amounted to $219.6 million on a reported basis, down 1.8% from the year-ago quarter's tally.The Client services segment’s revenues totaled $154.1 million, up 5.8% from the year-ago quarter's figure.Allscripts Healthcare Solutions, Inc. Price, Consensus and EPS Surprise Allscripts Healthcare Solutions, Inc. price-consensus-eps-surprise-chart | Allscripts Healthcare Solutions, Inc. QuoteMargin TrendIn the quarter under review, Allscripts’ gross profit rose 8.8% to $182 million. Gross margin expanded 340 basis points (bps) to 48.6%.Selling, general & administrative expenses fell 28% to $79.1 million. Research and development expenses went up 11.3% year over year to $51.2 million. Adjusted operating expenses of $130 million decreased 16.4% year over year.Adjusted operating profit totaled $51 million, reflecting a 363.1% surge from the prior-year quarter. Adjusted operating margin in the second quarter expanded a huge 1075 bps to 13.8%.Financial PositionAllscripts exited the second quarter of 2021 with cash and cash equivalents of $229.3 million compared with $513.4 million at the end of the first quarter. Long-term debt at the end of the second quarter of 2021 was $421.3 million compared with $169.4 million at the end of the first quarter.Cumulative net cash provided by operating activities (continuing operations) at the end of the second quarter was $125.1 million compared to cumulative net cash used in operating activities (continuing operations) of $19.7 million a year ago.2021 GuidanceAllscripts reaffirmed its prior current-year revenue view at $1.50 billion, at par with the Zacks Consensus Estimate.Our TakeAllscripts exited the second quarter of 2021 with better-than-expected results. The year-over-year uptick in both top and bottom lines, along with surge in total bookings during the reported quarter, is impressive. Revenues from the Client services segment also rose during the quarter, which is encouraging. Over the past few months, Allscripts has entered into a slew of collaborations, raising our confidence on the stock.Management is also upbeat about its strong domestic and global pipeline for health systems, which further buoys our optimism on the stock. The company also expects to benefit from investments it has made to deliver Sunrise as the platform of health, which will be delivered in the cloud through its partnership with Microsoft. Expansion of both margins is another positive.On the flip side, Allscripts witnessed a decline in its Software delivery unit revenues during the second quarter. The company also experienced residual delays in closing some new deals, particularly with large health systems market and in international regions where recovery from the pandemic has been more uneven, raising our apprehension about the continued pandemic-led impacts. Additionally, Allscripts is exposed to integration risks. Intense competition in the niche space is also a concern.Zacks Rank and Other Key PicksAllscripts currently has a Zacks Rank #2 (Buy).A few other top-ranked stocks in the broader medical space that have announced their quarterly results are Encompass Health Corporation EHC, West Pharmaceutical Services, Inc. WST and Bio-Rad Laboratories, Inc. BIO.Encompass Health, carrying a Zacks Rank #2, reported second-quarter 2021 adjusted EPS of $1.17, which beat the Zacks Consensus Estimate by 15.8%. Second-quarter revenues of $1.3 billion outpaced the consensus mark by 1.5%. You can see the complete list of today’s Zacks #1 Rank (Strong Buy) stocks here.West Pharmaceutical reported second-quarter 2021 adjusted EPS of $2.46, which surpassed the Zacks Consensus Estimate by 41.4%. Second-quarter revenues of $723.6 million outpaced the Zacks Consensus Estimate by 8.7%. It currently carries a Zacks Rank #2.Bio-Rad reported second-quarter 2021 adjusted EPS of $3.54, surpassing the Zacks Consensus Estimate by 86.3%. Revenues of $715.9 million surpassed the Zacks Consensus Estimate by 17.3%. It currently sports a Zacks Rank #1. Time to Invest in Legal Marijuana If you’re looking for big gains, there couldn’t be a better time to get in on a young industry primed to skyrocket from $17.7 billion back in 2019 to an expected $73.6 billion by 2027. After a clean sweep of 6 election referendums in 5 states, pot is now legal in 36 states plus D.C. Federal legalization is expected soon and that could be a still greater bonanza for investors. Even before the latest wave of legalization, Zacks Investment Research has recommended pot stocks that have shot up as high as +285.9%. You’re invited to check out Zacks’ Marijuana Moneymakers: An Investor’s Guide. It features a timely Watch List of pot stocks and ETFs with exceptional growth potential.Today, Download Marijuana Moneymakers FREE >>Want the latest recommendations from Zacks Investment Research? Today, you can download 7 Best Stocks for the Next 30 Days. Click to get this free report Allscripts Healthcare Solutions, Inc. (MDRX): Free Stock Analysis Report BioRad Laboratories, Inc. (BIO): Free Stock Analysis Report West Pharmaceutical Services, Inc. (WST): Free Stock Analysis Report Encompass Health Corporation (EHC): Free Stock Analysis Report To read this article on Zacks.com click here.