The Social Security old-age and disability funds will be in good shape for "many years," barring an unforeseen major recession, but Medicare's hospital trust fund probably will go bankrupt in 1988 or 1990 unless something is done, three Cabinet secretaries said yesterday in the annual trustees' report on the $200-billion-a-year system.

"The Social Security amendments of 1983 have restored the financial integrity of the Social Security cash benefit program," the report said, referring to the bipartisan rescue bill passed by Congress earlier this year to strengthen the old-age and disability funds.

Projections of the future income and outgo of the giant system are made for four sets of economic and demographic assumptions, ranging from optimistic to pessimistic. The "intermediate" scenario is considered to represent the most likely course of events and is generally used in government planning. But some economists have argued that the most pessimistic of the four scenarios may be a more realistic projection.

The trustees said that under all four projections the old-age and disability funds are expected to have enough money to operate normally throughout the 1980s, with combined reserves dipping no lower than 18 to 19 percent of one year's benefits in the mid-1980s and then building rapidly as newly scheduled taxes kick in and favorable demographic factors come into play.

Only a severe recession and economic conditions worse than those envisioned in the pessimistic scenario could create a problem in the near term.

In addition, the report says, "the program is now estimated to be sound" for the next 75 years under all but the pessimistic scenario.

The trustees--the secretaries of the Labor, Treasury and Health and Human Services departments--estimated that the old-age and disability funds would have sufficient money to pay all benefits at least through the year 2060, although balances would begin to decline in the second quarter of the next century as the proportion of aged in the population increased.

Even under the pessimistic scenario, the combined old-age and disability funds would not face depletion until after 2025, the trustees said.

The trustees estimated that under the intermediate scenario the old-age and disability trust funds would have a tiny surplus of 0.02 of 1 percent of taxable payroll over the 75-year period. Before the rescue bill was passed, the two funds had a combined deficit of 1.82 percent of taxable payroll, or about $27 billion a year in 1983 dollars.

Under the pessimistic scenario, there would be a 75-year deficit of 3.51 percent of payroll.

For Medicare's hospital insurance trust fund, the picture is gloomy, though somewhat improved over last year as a result of benefit reductions, cost cuts and some financing improvements enacted by Congress in recent years.

Although the fund is estimated to have a balance of about $11 billion, it is projected to decline rapidly toward the end of the decade as a result of skyrocketing inflation rates for hospital care.

The trustees project that even under the two most optimistic economic scenarios the hospital insurance fund couldn't stay solvent beyond 1996 and 1991, respectively.

Under the intermediate scenario, considered the most likely, the fund would go bankrupt in 1990, and under the pessimistic scenario, in 1988. The trustees said the fund's deficit over the next 25 years would be 1.24 percent of taxable payroll under the intermediate scenario and 2.51 percent under the pessimistic projection.