The U.S. Court of Appeals here dealt a blow to the D.C. school system's employe drug testing program yesterday, ruling that drug urinalysis may be included as part of a worker's regular physical examination only if the test used could show that the employe was under the influence of drugs on the job.

No drug urine test can do that; rather, they show if drugs have been used recently, which can be as long as weeks previously. Some blood tests can show present influence.

Although the unanimous opinion by a three-judge panel came in a legally narrow case brought by a school bus aide, attorneys for several national federal employe unions said the decision could have a major effect on other cases before the court because the judges said that such drug testing must be job- related and that applicable tests must show on-the-job impairment.

Those are key issues in the other cases, which primarily involve unannounced, random testing of employes.

The panel ruled that the safety of schoolchildren and employes outweighed the specific employe's privacy interest in the case, and it lifted the part of a broad injunction that required a finding of probable cause for drug urine tests administered during routine physical examinations.

At the same time, the court said that such urine tests would have to show whether the employe was under the influence at the time the test was administered.

"The ruling means that the school system can't do any testing," said Arthur B. Spitzer of the American Civil Liberties Union, which brought the case on behalf of Juanita M. Jones, who was fired in 1985 after a drug test indicated marijuana use.

"It is clear that the school system could not constitutionally test its employees for drugs in the manner Jones was tested, and our analysis should not be read to suggest the contrary," Judge Harry T. Edwards wrote for the the three-judge panel that included Judges Douglas H. Ginsburg and Kenneth Starr. Ginsburg withdrew his nomination to the Supreme Court Nov. 7 after acknowledging that he smoked marijuana while a Harvard University law professor in 1979.

The ruling "is very, very important," said Elaine Kaplan, assistant counsel of the National Treasury Employees Union, one of the groups contesting President Reagan's 1986 executive order permitting federal employe drug testing programs. "If it can't measure impairment, it's not work-related, and the testing can't be done without reasonable suspicion or probable cause," she said.

"This case puts the burden on the government to prove that there's a work-related need for testing . . . , not merely a public policy assertion," said Joe Goldberg, a spokesman for the American Federation of Government Employees, which is also challenging the presidential order.

But Assistant U.S. Attorney General Richard K. Willard said that because the questions before the court were so limited, it would be "hard to apply the ruling to a situation where off-duty drug use is prohibited as well."

"The decision does not tell you a whole lot about how the court will deal with issues not before them," Willard said.

Although the federal government was not a party to the D.C. school case, the Justice Department filed a friend-of-the-court brief, urging reversal of U.S. District Judge Louis F. Oberdorfer's injunction against all drug testing of D.C. school employes unless officials had probable cause.

One federal government lawyer said that the court's ruling that the test would have to show impairment was a giant "hooker" in a case that appeared to have the practical effect of negating a legal victory for the school system.

"We are glad to be out from under the injunction," said Assistant Corporation Counsel Charles L. Reischel, who argued the case for the D.C. school system.

He said the impact of the decision "is tied to a particular school superintendent's directive," which prohibits employes from being under the influence of drugs while on school premises.

"What happens if we change the directive?" asked Reischel. "We'll have to think very seriously about whether it has any impact beyond this case," he said.

Goldberg of the American Federation of Government Employees said the decision was "heartening" to public employe unions because there have been so few major court decisions in the field. "For example, the court has put to rest the argument that urine testing does not constitute a search," Goldberg said.

The court ruled that even though employes were allowed to provide the urine samples without physical monitoring, the tests required of school transportation employes were protected under the Fourth Amendment because of the "intrusion" that would come when the sample was analyzed.