Court documents say a Massachusetts teenager charged with killing his math teacher appeared to be "psychotic" after he allegedly attacked a female clinician at a Department of Youth Services detention center in Boston earlier this month.

The details were released Tuesday by a Superior Court judge in response to a motion by The Salem News.

According to the petition to have Philip Chism committed to Worcester Recovery Center and Hospital for 30 days of evaluation and treatment, the 15-year-old was "out of touch with reality" and "yelling, screaming incoherently (and) foaming at the mouth while being restrained by staff."

In court papers released last week at the request of The Salem News, Essex County prosecutors said Chism slipped away from caregivers before the June 2 incident at a youth facility in Boston.

Prosecutor Kate MacDougall said Chism crept along a common hallway "crouched down out of view," followed the woman to a locker room and tried to choke her while holding a pencil. Other workers came to the woman's aid when she screamed.

Chism pleaded not guilty to robbing, raping and killing 24-year-old Danvers High School teacher Colleen Ritzer after following her into a restroom last October. He was 14 at the time.

The Associated Press contributed to this report