While half of all Massachusetts hospitals received an “A” for safety from a national nonprofit healthcare ratings agency, nine hospitals in the state received barely passing grades.

According to the latest batch of ratings from ratings agency Leapfrog, which analyzes infection scores and hospital operations to compare hospitals for safety, 31 hospitals in Massachusetts out of 60 received an “A” grade. Only seven other states had a higher percentage of hospitals that received A’s. But still, some…