D.C. Village, the city's troubled home for the elderly, has regained federal Medicaid certification for all of its 530 beds for the first time in five years, halting the loss of federal aid that has totaled $1.5 million since last March, the city announced yesterday.

However, at Forest Haven, the city's facility for the mentally retarded in Laurel, 240 of the 400 beds still are not in compliance with the federal health care standards, costing the city $500,000 a month, Deparment of Human Services Director James Buford said. On the Positive side, he announced that DHS moved 111 residents from Forest Haven to homes in the District, 10 more than it was required to do under a 1978 court order, he said.

In a mixed review of his department's record in the fiscal year that ended a week ago, Buford said that the agency balanced its budget for the first time, but only by employing "extraordinary" and one-time financial strategies that will not prevent serious budget problems in the current fiscal year.

City Council member Polly Shackleton (D-Ward 3), who heads the council's human services committee, said DHS "needs to be credited for doing a good job and we are obviously delighted they were able to do it."

Last March, DHS voluntarily withdrew all D.C. Village beds from Medicaid, the federal health plan for the needy, after it was cited by Department of Health and Human Services investigators in January for hundreds of deficiencies, including shortages of clothing for patients, medical supplies, staff and sanitary equipment.

The city has gradually improved its performance at D.C. Village, located in Southwest Washington near the Blue Plains sewage treatment plant, by closing beds, redistributing staff and by reducing the number of patients from 625 to 530, according to DHS' long-term care administrator, Paul Lavigne.

Forest Haven's lack of federal approval to receive Medicaid reimbursements has cost the city $5 million since September 1980, and the facility is likely to continue to be uncertified until at least Dec. 1, largely because of staffing shortages, Buford said. The institution has at least 50 staff vacancies and a shortage of occupational and physical therapists, he said.

Vincent Gray, executive director of the D.C. Association for Retarded Citizens, commended the city's efforts at relocating the Forest Haven residents, but noted that nearly 100 of them were moved in the last two months before the deadline, a rate that "does not allow a lot of attention to detail." More than 600 residents remain at the institution.

Buford also unveiled a new system for safeguarding nearly $1.4 million in personal funds of Forest Haven residents. A former D.C. government accounting officer, Lemuel Taylor, was convicted in U.S. District Court in Baltimore last month of stealing and misappropriating $40,000 of those funds when he had control of the accounts during 1979 and 1980.

Buford said there will be a computerized tracking system, with a computer terminal at Forest Haven to update residents' finances daily and a companion terminal at the office of the DHS controller to monitor accounts. Semiannual audits will be conducted of all residents' accounts, he said.

Buford, obviously pleased with the newly balanced budget, said that DHS balanced its budget in part by:

* Collecting $5 million from D.C. hospitals that received too much in medicaid payments from the city over the last eight years.

* Retroactively billing the federal government for $4 million in welfare payments for children the city had placed in foster care. The city had been receiving payments for fewer than 400 such children, while as many as 1,800 were qualified.