After more than three years of negotiations, District and federal officials have agreed to a $29.5 million plan to provide community-based mental health services as alternative treatment for patients who are needlessly confined at St. Elizabeths Hospital.

The three-year plan was developed in response to a federal court order directing officials to find less restrictive facilities -- like nursing homes and group homes -- to care for patients who are well enough to live outside the hospital.

U.S. District Court Judge Aubrey E. Robinson issued the order in connection with a class action suit brought on behalf of patients at St. Elizabeths by the Mental Health Law Project in 1975. The proposal must be approved by both the court and attorneys for the patients.

Implementation of the plan is contingent on the city's Department of Human Resources coming up with $15 million by 1982 to pay for its share of the plan, which will include improvement of community mental health centers, renovation of a now vacant, federally owned building into a nursing home and supervised apartments for patients leaving the hospital.

St. Elizabeths expects to reprogram $7.3 million of its current budget over the next three years to help pay for the plan.The Department of Health Education and Welfare, wich runs St. Elizabeths, will help the District seek another $7.2 million from federal sources, such as Medicare and Medicaid reimbursements, according to the plan.

District and federal officials said the plan is to move hospital patients in the community as soon as possible, to expand and improve community mental health services and to provide alternate treatment for patients in the future who would otherwise turn to St. Elizabeths for care.

If the funding becomes available and the plan goes into effect, 310 patients would be relocated from the hospital to community homes by 1980. Of those 310 patients -- all of whom were identified by HEW as well enough to live outside the hospital -- 208 would be housed in apartments, in groups of three, with assistance from DHR social service workers. The remaining 102 patients would need nursing home care.

There are now about 2,000 patients confined to St. Elizabeths. Another 3,400 people receive services in the community through DHR mental health centers.

At the core of the plan, submitted to the court on Feb. 1, are suggestions to improve the way the District, and the hospital, distribute and manage social services for the mentally ill. The plan reviews, among other things, methods for handling patient evaluations, the timely release of patients from the hospital to community centers, the location of suitable housing for outpatients and the licensing and monitoring of group homes.

"We don't have any reason to think funding will be a problem," said James Buford, the HEW project manager for the St. Elizabeths plan. "However we know the plan cannot be implemented without the proper resources," Buford said.

DHR director Albert P. Russo said that Mayor Marion Barry has "reviewed the plan and approved it."

"If we get the resources we are requesting in the 1980... budget, I hope the (310 people) will be out in a year," Russo said.

"But man proposes and Congress disposes," Russo said in a telephone interview.

DHR officials have asked the D.C. City Council to add $4.4 million to its 1980 budget to develop a variety of community living arrangements by June 1980.

These include:

The $2.4 million renovation of a building turned over to HEW by the Department of Housing and Urban Development. The building would be converted into a nursing home with 250 beds, of which 100 would be reserved for District residents. The remainder would be available for non-District residents.

An assisted independent living program to provide 24 rent-subsidized apartments to approximately 72 people in need of regular supervision. Each apartment would house three people. Community workers, employed by DHR, would visit the patients on a regular basis.

Cooperative apartments for approximately 50 people capable of living outside the hospital without supervision. These would also be rent-subsidized apartments that would house two or three people.

Group homes, providing 24-hour supervision, would also be established.

Attorneys with the Medical Health Law Project, a private nonprofit group representing the patients, said they would submit their response to the plan to Judge Robinson early next month.