Contained in the fine print of the 1982 tax bill is what might be considered the perfect piece of legislation: a provision that promises to cut federal spending, promote a humanitarian service and provide comfort to thousands of terminally ill people.

Sponsored by more than half of the Senate and two-thirds of the House, the provision for the first time will permit Medicare funding for the hospice movement, which believes that those who are dying are better off in the loving atmosphere of their homes than they are in hospitals.

The provision, which will go into effect in November, 1983, is expected to give an enormous boost to the infant hospice movement in the United States, which provides care to about 12,000 people a year, most of them terminal cancer patients.

In theory, the new progam would make more than 200,000 elderly persons who die of cancer a year eligible for hospice services paid by Medicare. Most observers think the majority won't use it, however, and the best guess is that by the year 2000 from 60,000 to 120,000 persons will be using hospice services.

Almost 6 percent of all Medicare outlays for aged patients goes for the care of cancer patients in the last six months of life. The cost of this care is double that for the last six months' care of all patients.

Supporters of the hospice funding argued that it is much less expensive to care for the patient at home, forgoing expensive hospital treatment. The Department of Health and Human Services said it has 26 hospice demonstration projects under way that "look promising" but final financial figures won't be in till September, 1983.

The Congressional Budget Office estimated that the provision, after initial startup costs of $1 million a year in 1983 and 1984, would save Medicare $16 million in 1985 and $40 million in 1986. Hospice leaders contend that the savings could be greater.

But the budget-cutting aspect of the provision is not the only reason it stormed through Congress so easily after a relatively brief lobbying campaign led by the National Hospice Education Project.

Underlying the financial motive was a humanitarian purpose: rather than being in a hospital, alone much of the time or surrounded by strangers, receiving often-painful treatment for a disease they know is terminal, terminally ill patients will be able to choose, in effect, to accept the fact of death and go home, hospice supporters said.

There they will receive not only the emotional support and daily companionship of their families, but also a range of services to be financed by Medicare. Hospice movement supporters argue that it is a more dignified way to come to terms with death than hospitalization.

Virtually every congressional district in the country has at least one hospice organization, according to Hugh Westbrook, who co-chaired the lobbying campaign with fellow Floridian Donald Gaetz.

In the United States, the hospice movement focuses largely on home care rather than putting dying patients in special institutions called hospices, as is more common in England.

According to Westbrook, the hospice concept dates back to the Crusades, when in 1064 A.D. the Knights of Malta opened a way-station in Jerusalem to care for Christian pilgrims and crusaders. The modern movement started in London in the mid-1960s, when Dr. Cicely Saunders founded St. Christopher's Hospice. Westbrook said that the movement started in the United States in 1974, when the Rev. Ed Dobihal of Yale Divinity School and Dean Florence Wald of the Yale School of Nursing invited Saunders to help them organize a hospice in New Haven, Conn.

In the eight years since, the number of hospice operations has grown tremendously. Three years ago, there were 59 active hospice operations, according to Irwin Wolkstein, a former high-level HHS official now with Health Policy Alternatives, a consulting firm here.

By June of last year there were about 440 hospice operations in the United States, including one in Northern Virginia, and 350 more under development, Wolkstein said. Gaetz and Westbrook said all hospice groups in the United States are nonprofit.

Hospice treatment is appropriate chiefly for people with progressive fatal diseases, preeminently cancer, not for those who have suffered a stroke or heart attack.

Under the Medicare funding provision, which will expire in 1986 so Congress can review it, a person can get reimbursement for hospice care only if a doctor certifies (and the patient fully understands) that he or she is likely to die in six months.

Overall average costs per patient may not exceed 40 percent of Medicare's normal average outlay for cancer payments in the last six months of life.

The hospice tax bill provision did not sail through without congressional opposition, however. Home health agencies, which already provide various services under Medicare to hundreds of thousands of people at home, contended that the original language of the provision would have excluded them from providing hospice-type care under Medicare and from getting reimbursed for certain new services.

The home health groups range from public agencies that send out visiting nurses to for-profit businesses like Upjohn Health Care Services that arrange for nurses, aides and homemakers for the elderly at home.

The hospice leaders, fearing that home health agencies that do not provide genuine hospice-type care might move in and dilute the effectiveness of the program, wanted very narrow language as to what types of medical service groups could provide the new hospice services.

In addition, they feared that too much latitude might allow some fast-buck operators not in the health field to move in and discredit the program with fraud and abuse.

Morrie Levy, director of the American Federation of Home Health Agencies, said the final language appeared to allow the traditional home health agencies to qualify to provide hospice services under certain conditions and "we are more or less satisfied.