For years, the New York State Office of Mental Health has maintained a detailed database for sharing the psychiatric histories of people who rely on the social safety net — a tool that, when used correctly, can ensure the state’s most vulnerable people receive adequate care.

But the database, known as PSYCKES, was not consistently used by one of the most crucial pieces of that safety net: hospitals, which have sometimes discharged homeless mentally ill people without using the tool to communicate with shelters and care teams that provide outpatient treatment. In some cases, those discharges preceded subway shovings and other random acts of violence by the homeless people after their illnesses went untreated.

Now the state has issued a new set of detailed guidelines for hospitals to follow when caring for severely mentally ill patients, urging them to more proactively communicate with care teams and other outside organizations to prevent the patients from deteriorating and hurting themselves or someone else.

The state issued the guidance late last month after receiving questions from The New York Times, which was preparing to publish an investigation that revealed preventable institutional breakdowns of homeless shelters, hospitals, specialized treatment teams and other organizations. The breakdowns preceded more than 90 acts of violence in the past decade, The Times found.

Responding to the article on Monday, the state comptroller, Thomas P. DiNapoli, described it as a “wake-up call.”

“New York City’s shelters too often do not provide mental health services when they are clearly badly needed,” said Mr. DiNapoli, whose auditors last year documented failures by the city to place mentally ill people in mental health shelters. “The consequences of failing to help those most in need can be dire, far-reaching and tragically violent.”

A spokeswoman for the New York City Council speaker, Adrienne E. Adams, said that the Council had taken steps to address gaps in the city’s mental health care system, but that the speaker intended to push for more changes.

“Too often, our systems fail people with the greatest needs,” the spokeswoman said, adding that the Council would ensure people had access to well-funded programs and would encourage coordination among agencies. “The Council will continue to push for proven solutions at the scale needed in our city,” she said.

Among the main findings of the Times report was a widespread failure among the agencies and programs that make up the city’s social safety net — homeless shelters, private and public hospitals and outpatient treatment teams — to share basic information about the people in their care.

The Times found that the hospitals, which have seen an influx of psychiatric patients in recent years, have often discharged homeless people in crisis before they were stable, sometimes with disastrous consequences.

In one case, a Queens hospital released a man who was still psychotic in the middle of the night without notifying his outpatient treatment team, records show. Hours later, he turned up at his grandmother’s apartment in the Bronx and stabbed her caregiver 37 times, nearly killing her.

In an interview, Ann Marie T. Sullivan, the commissioner of the Office of Mental Health, said that the state was focused on closing the types of communication gaps documented by the Times investigation.

She said the new guidance was a step in the right direction and might ensure that medical providers made more informed decisions about treatment. While the guidance is not binding at this point, the state is moving to make it mandatory as a regulation, Ms. Sullivan said.

“We’re going to be making sure that there’s a significant improvement in the communication across providers,” Ms. Sullivan said. “It’s very important that hospitals speak with the housing provider or that they speak with the outpatient team or with whoever the person is connected to. It is critical.”

New York released PSYCKES, an acronym for Psychiatric Services and Clinical Knowledge Enhancement System, as a statewide database in 2008. It costs the state more than $1.5 million a year to maintain the database, which allows different agencies to access detailed information about a patient’s mental health diagnoses, hospital visits and shelter history. It also has contact information for their various treatment providers. The database is updated weekly, state officials said, and it tracks the medical histories of some eight million people on Medicaid. It has more than 16,000 users across hospitals, managed-care programs and other health care providers.

Even so, some providers who use the system said the database’s information was often outdated, and as a result, many medical providers do not rely on it.

The new guidelines explicitly encourage hospitals to contact outpatient care teams as a routine part of the discharge process even if the patient does not have the capacity to consent. Following such guidance might have made a difference in several cases reviewed by The Times.

In one, a homeless man diagnosed with schizoaffective disorder visited five hospital emergency rooms from April to June 2020 as his outpatient treatment team desperately searched for him, records show.

Despite telling doctors that he was hearing voices and that he wanted to kill himself, he was quickly discharged each time. None of the doctors or hospital workers informed his outpatient team, whose contact information should have been readily accessible in the PSYCKES database and was listed in the hospital’s internal system. A week after his final hospital visit, he pushed a 92-year-old woman into a fire hydrant on the street in Manhattan’s Gramercy Park, injuring her.

The new guidance for hospitals extended beyond just the database. It also encouraged doctors to consider a patient’s history in making discharge decisions, and instructed medical staff to enroll eligible people for outpatient care if they were not already connected with treatment.

One man with a history of homelessness had been hospitalized dozens of times from 2017 to 2022 for psychiatric problems, records and interviews show. In that time, he had attacked a man with a hammer in Brooklyn in April 2021 after he was released from a hospital. The following year, weeks after the same hospital let him go again, he shoved a stranger onto the subway tracks. The man’s psychiatric treatment records reflect that medical staff had not connected him to an intensive outpatient treatment team, which might have helped stabilize him.

The failures to consult the database were not limited to hospitals, The Times found.

When homeless people enter the New York City shelter system, for example, they are supposed to be assessed for psychiatric issues and sent to shelters where they can get services and support.

Among the options are dedicated mental health shelters for people with psychiatric conditions. But many of the workers who place people into those shelters do not have access to the PSYCKES database, and health privacy laws bar them from checking it without a client’s consent.

In one instance, The Times found, a shelter worker missed signs of mental illness in a man with bipolar disorder, and could not access his psychiatric history. He was never sent to a mental health shelter, and instead deteriorated in other shelters that did not meet his needs. He assaulted a stranger on a subway platform in 2021, sending him tumbling onto the tracks and injuring him.

The state said it had recently created a way to use PSYCKES to flag psychiatric issues in homeless people for shelter workers, which would help them place people into mental health shelters. The workers can access this “mental health flag” without client consent.

The Department of Social Services, which runs the city’s shelters, said it had begun testing the new PSYCKES tool this year. But it was unclear whether shelter workers were using it.

Andy Newman contributed reporting.