Long years of medical education left Dr. John Hewitt, 32, well trained in pediatrics but ill-equipped to tackle the rigors of the medical marketplace.

With a hefty debt and no patients in sight, he began making house calls to the far corners of Washington. Then, tiring of long hours on the road, he switched specialties.

Hewitt now practices emergency medicine in 24-hour shifts at a Chestertown, Md., hospital more than 80 miles from his home. "I'd love to go into private practice. But right now, I need something I can really count on," he says. "But I'm doing better than a lot of my classmates. They still haven't gotten their careers squared away yet."

Hewitt and his struggling classmates are part of an explosion in the medical profession that has meant good news for patients -- expanded office hours and better care in traditionally underserved areas -- but trouble for some young doctors. With the number of physicians growing faster than the number of patients, some new doctors face a bruising education in economics.

Washington is one of the places where the competition is keenest. In December 1982, there were 573 doctors in the District for every 100,000 residents, giving the city a higher physician density than any state, according to the American Medical Association. Maryland, with 300 physicians for every 100,000 residents, ranked third among states in 1982; Virginia ranked 19th, with 197.

Among cities, only San Francisco and Portland, Ore., have higher physician densities than the District.

The number of doctors in the Montgomery County Medical Society jumped from 500 to 1,300 between 1976 and 1984; the Fairfax County Medical Society increased from 220 to 700 members over the same period, according to officials of the two groups.

The local situation reflects a larger national trend: The total physician population nearly doubled between 1960 and 1982, growing three times faster than the population. By the year 2000 there will be an excess of 145,000 doctors, according to a study commissioned by the U.S. Department of Health and Human Services.

There are early indications that the competition is affecting doctors' businesses. From 1982 to 1983, the number of patient visits per physician declined an average of 5.2 percent nationwide. In the northeast part of the country, the decline was 7.8 percent.

Dr. Katherine Alley, a general surgeon, considers herself lucky. Faced with a saturated job market upon completing her residency six years ago at George Washington University, she considered additional training or even leaving the area. At the last minute, she was offered a salaried position at Group Health Association. This year she is opening a private practice.

Like Alley, many young doctors who want to practice in Washington are learning to compromise. Rather than opening their own offices, they join the group practices of older physicians. They practice outside the Beltway, far from the glamor of Northwest's "doctor corridor." Many look for salaried jobs with hospitals, health maintenance organizations or emergency clinics.

"The influx of physicians into Washington over the past 10 years has been incredible," said internist and gastroenterologist Dr. Donald O'Kieffe, a longtime practitioner in the area. "It's a buyer's market. Physicians are bending over backwards to please patients."

The cold competitive facts begin to hit home this time of year, as medical residents all around the country, including some 800 at Georgetown, George Washington and Howard universities, near completion of their programs on July 1.

Facing large debts -- an average of $24,000 per graduate nationally -- and high start-up costs, many young doctors in the District are unable to consider a solo practice downtown.

Some turn to traditionally underserved parts of the metropolitan area. Hewitt, for example, estimated that nearly 70 percent of his house calls were to Medicaid families. A spokesman for the Greater Southeast Community Hospital Foundation said the number of doctors in his mixed-income neighborhood has tripled since 1977.

Although the surplus is not forcing doctors to move into impoverished neighborhoods that usually lack physician services, it has been good news for patients in mixed lower- and middle-class neighborhoods in the inner city.

"Black physicians aren't staying in Northwest," said Dr. Barrington Barnes, an Northeast internist for 21 years. "It's unrealistic to think that they could open up a new practice on K Street and survive. Instead, they're coming out into these neighborhoods."

Despite the improvements, traditionally underserved corners of the city, such as Anacostia or far Northeast, still lack enough physicians. "It's exceedingly difficult to live totally on Medicaid," said Dr. Arthur Hoyte, former District commissioner of public health, now at Georgetown University Medical School. "Reimbursement is low and payments are slow in coming. When you compound this with the problems of crime -- living in a fortress, behind plexiglass double doors -- you have no real incentive to practice there."

The real impact of the doctor glut has been on the suburbs, outlying counties or the Eastern Shore. The western corner of Fairfax County, the I-270 corridor of Montgomery County and the southeast edge of Frederick County report the most dramatic growth, according to local medical societies. "Doctors start out wanting to practice downtown, in the more glamorous part of the metropolitan area," says O'Kieffe. "But they start moving backwards, until they find their niche somewhere outside the Beltway."

Even well-established, older physicians are shifting their sights to these fast-growing regions, hoping to keep up their numbers of patient visits by treating young families new to the area. Many physicians who once practiced exclusively in downtown Washington or Alexandria now spend one or two days a week in new offices in Burke, Gaithersburg and other outlying towns, according to John Fitzgerald, executive director of the Fairfax County medical society and Dr. Marvin Schneider, president-elect of the Montgomery County medical society.

Increasingly, Fitzgerald and Schneider said, physicians are making home visits or extending office hours to evenings and Saturdays. When they leave town for a weekend, it now is common for physicians to refer their patients to another physician rather than sending them off -- perhaps forever -- to the nearby emergency clinic.

Group practices, one refuge for young doctors unable or unwilling to start out alone, are getting harder to come by in the Washington area. Fitzgerald said his society receives at least four calls a month from physicians looking for work, but not even one call a year from practices needing another physician.

Some physicians are joining new types of practice arrangements, such as emergency centers or health maintenance organizations. Others go on salary at local hospitals. Still others put their names on the roster of hospital emergency rooms, to admit patients as they come in.

"In the past, young doctors would take emergency room cases only the first year or two out of school," said Schneider. "Now, a lot of them have been doing emergency room work for six or seven years. They have to, out of economic necessity."

Those facing the toughest time are the specialists, particularly cardiologists, psychiatrists and gastroenterologists. General surgeons and internists, who represent 8 percent and 22 percent of the city's physician population respectively, are also facing increased competition.

"We have specialists up to our eyeballs," said Schneider. "The only way to survive is to look for a procedure that others aren't doing, so they'll have more to offer."

The competition creates pressure in other areas, as well. "In tough times, it's not just your skill but your personality that matters," said O'Kieffe. "In the old days, people accepted a doctor's personality for what it was. In a patient glut, they'd survive. But now it is not just your skill but your attitude -- or the attitude of your receptionist or insurance person -- that matters."

"The good days are gone," said Fitzgerald. "Doctors aren't so complacent anymore. They're more anxious to meet the needs of patients. They know that they're no longer the only show in town."