Australia's largest private hospitals operator said late on Thursday it had agreed to buy Spire Healthcare in a deal that values its London-listed rival at $3.71 billion including the debt on its balance sheet.