Patients who sue a hospital for medical malpractice are not entitled to records documenting the hospital’s internal examination into what went wrong, the state Supreme Court has ruled, upholding a 2004 law intended to encourage medical professionals to learn from and prevent future mistakes.