Nashville-based HCA was ordered Thursday by a Missouri judge to pay $162 million because the hospital giant failed to make the required upgrades to a group of older hospitals it purchased in Kansas City in 2003, according to a report in The New York Times.

The ruling stemmed from a 2009 lawsuit filed against the company in connection with its purchase of a dozen hospitals from Health Midwest about a decade ago.

As part of the deal, HCA (NYSE: HCA) said it would make up to $450 million in improvements in the hospitals within the first four years following the deal. In addition, the company also agreed to provide comparable levels of charity care for a decade following the deal.

However, a community foundation established as a result of the deal said that the company had only spent less than half of the promised amount on hospital upgrades. The company countered that it has met its obligations by investment in new hospitals in the area rather than fixing the old ones.

The judge, however, ruled that the agreement specifically called for the upgrades to the older facilities.

Also in the ruling, the judge called for a review on HCA’s charitable care at the hospitals to see if it met those requirements of the deal as well. The court appointed a special accountable to review the company’s level of charity care; the community foundation claims the company had lowered the charity care at many of the hospitals since the deal.

In an e-mailed statement to the Times, a spokesman for HCA said the company was disappointed in the court’s ruling and intended to appeal.