A month ago, Beth Israel Deaconess Medical Center in Boston was in trouble. Its Italian supplier of swabs for coronavirus tests had been forced to halt shipments. The hospital was unable to reach a deal with another supplier, Puritan Medical Products in Maine, that was struggling with surging demand. Doctors had barely a week’s worth of the crucial swabs left.

So Ramy Arnaout, a 43-year-old pathologist, put out calls for help. Among others, he contacted old classmates from the Massachusetts Institute of Technology. Twenty-two frantic days later, the first of four prototypes were clinically validated.

Now, hundreds of thousands of these swabs — called nasopharyngeal swabs because they reach deep into nasal passages — are being churned out each day with the help of 3-D printers. By next week, production should be up to more than a million swabs every day, Arnaout said.

The scarcity of swabs has helped to hobble coronavirus testing in the United States. But that gap in the supply chain is starting to be filled by private ad hoc efforts, 3-D printing and do-it-yourself ingenuity. Tech executives, start-up founders, factory owners and engineers have applied a hacker mentality to get testing and other vital parts of the national response working more smoothly.

More than 100 brewers and distillers began manufacturing alcohol-based hand sanitizer after consumers and businesses plowed through inventories. Tech workers have built online platforms to help hospitals vet the new gray market of Chinese test suppliers. And teenagers started turning out face shields for medical workers on 3-D printers.

But few efforts have moved more swiftly, more collaboratively or — so far, it seems — more successfully than the quest to produce the nasopharyngeal swab, a sterile disposable medical device sometimes mistaken for its low-tech, cotton-topped cousin, the Q-Tip.

“The big thing was, we were able to get from the identification of swab shortages to the first clinically validated, high-quality 3-D manufacturing in 22 days,” Arnaout said. “That wasn’t an accident.” In some cases, each swab prototype underwent 20 design iterations — and all of them were posted online. “We ran a radically open and transparent process,” he said.

The Food and Drug Administration does not require specific approval for swabs, but the manufacturers have asked the FDA to grant their designs emergency use authorizations in order to qualify for federal contracts.

The breakthrough on the mundane-sounding swabs is critical. Three months into the covid-19 crisis, bottlenecks in the supply chain have been slowing down testing, limiting the identification of carriers of the disease and hampering the public health response. Perhaps no item has been in shorter supply than the specialized swabs — a 15-centimeter (nearly six-inch) nylon-based stick, three millimeters wide and a little narrower at the flexible neck, coated with a material called flock that works to effectively collect the virus from deep in the upper respiratory passage.

“A nasopharyngeal swab not a joke. It goes about four inches into your head,” Arnaout said. “It has to be thin, long and flexible enough to get around the nasal anatomy, but it has to be stiff enough that you can twirl it to pick up nasal secretions you’re going to do testing on. They tell us in medical school that if the patient isn’t complaining, then you’re not doing it right.”

Now, individual hospitals and companies, having given up on a coordinated national strategy, are pursuing their own solutions and winning regulatory approvals needed to manufacture and use on a massive scale. And many of them — using 3-D printing — are finding ways around the traditional swabs made mostly by Puritan and Copan, the Italian manufacturer.

EnvisionTec, a maker of 3-D printers in Dearborn, Mich., since 2002, is one of the four new manufacturers working with Beth Israel Deaconess. It began producing nasopharyngeal swabs for coronavirus testing last week, after making 17 changes to its initial design.

The company is teaming up with a network of 500 affiliated medical labs that already use EnvisionTec printers to make medical devices such as dentures and mouth guards. They are now making 200,000 testing swabs a day and have the capacity to make 1 million a day, said chief executive Al Siblani.

Siblani said those labs had largely sent home their employees during the pandemic because their work had been deemed “nonessential.” They are gradually returning, he said, to make testing swabs on 3-D printers already designed to make safe, medical-grade products.

“All these dental labs, we are turning back on and bringing people back to work,” Siblani said.

Siblani, 50, who immigrated to Michigan from Lebanon as a teenager, has worked on the swab project while recovering from covid-19. He believes he contracted the coronavirus in March, while installing equipment at a nearby hospital.

His fever peaked at 102, with a persistent dry cough, but he kept working from an apartment he rented to avoid infecting his family. Siblani called the illness harrowing because of the anxiety caused by the lack of a known cure for covid-19. The swab project kept him focused as he recovered after about a week.

“It was a personal mission as much as it was a business decision,” he said.

Siblani has been in contact with Vice President Pence’s office in hopes of getting federal funding through the Defense Production Act to produce more swabs faster. In addition to the network of labs with EnvisionTec printers, the company has more than 100 printers at its facility in Dearborn and can produce five more printers a day, with each machine capable of producing 100 swabs per hour, 24 hours a day.

If the funding comes through, Siblani predicts his company and its affiliated labs could make 1.5 million testing swabs a day. He said the swab consortium already is poised to make 4 million to 5 million a day.

The White House already has said it will use the Defense Production Act to help Puritan Medical Products, one of the few traditional manufacturers of testing swabs in the United States, substantially expand its capacity and open a second manufacturing facility near its headquarters in Guilford, Maine.

Puritan, a century-old family business that has its roots in making toothpicks and Popsicle sticks, has long been a leading source of medical testing products, with much of the wood coming from the abundant timber sources in central Maine. The new facility, which could open next month, will be designed to make 20 million testing swabs a month, with the potential to add more.

“We’re proud to be in the fight to produce the products to help defeat this crisis,” said Timothy Templet, executive vice president of global sales, whose grandfather founded the business that now employs 550.

Money provided through the Defense Production Act — Templet declined to disclose how much — is making possible the new facility, including the manufacturing equipment. Puritan shipped 1.5 million swabs for coronavirus testing this week, including 450,000 to the Federal Emergency Management Agency for distribution to various states.

Although Puritan is the leading U.S.-based maker of diagnostic swabs, Templet said he was not surprised that other companies are getting into the business at a time of global crisis.

“This isn’t going away,” he said. “We make diagnostic swabs. That’s what we do.”

In the Beth Israel consortium, Carbon, a maker of 3-D printers, has teamed up with Resolution Medical, a Minneapolis-based maker of medical devices, to produce nasopharyngeal swabs. Medical experts, including members of a Stanford Health Care task force, helped develop that swab model using material ordinarily used for dental implants.

“The idea captured our imagination,” so Stanford fast-tracked its own study of the swab prototype, said Sridhar Seshadri, vice president of cancer, cardiovascular, radiology and transplant for Stanford Health Care. “This is going into somebody’s nostrils, so you have to be super safe.”

When the task force tried to sterilize the first batch of swabs from Resolution Medical, disaster struck. The sample swabs came out of the autoclave, a machine that sterilizes medical equipment with heat, visibly bent. The task force sent a photo of the results and soon learned that 3-D-printed swabs have to be inserted into autoclaves horizontally or they can melt.

“Then it was nail-biting for a few hours to see if the swabs came out right the next round, and they did,” Seshadri said.

Resolution Medical is now producing 100,000 this week using Carbon’s 3-D printers and is planning to expand capacity to more than 1 million in future weeks.

Arnaout said that one advantage of having an array of swab makers is that if one has a supply problem, the entire chain is less likely to break down.

HP, formerly known as Hewlett-Packard, learned of Beth Israel Deaconess’s plight because Annette Friskopp, global head and general manager of HP Specialty Printing Systems, had worked with hospital leaders. She and Lihua Zhao, head of the 3-D lab at HP Labs, coordinated the push for a new swab. A research and development lab in San Diego, one of three that HP has worldwide, was redirected to solve the problem.

“Within 48 hours, we had designed, printed, and shipped the prototypes for testing,” Zhao said in an email.

Unlike the other prototype makers, though, HP isn’t going to manufacture them itself. It is in late-stage talks with its partners and customers for them to start making the swabs.

Arnaout at Beth Israel said the hospital has been working to iron out other supply shortages. At one point, it looked as though the hospital would run out of the vials and fluid used to transport swabs to testing facilities. The fluid recipe was online. And when the hospital ran out of the vials, it found other tubes the same size. Hospital volunteers began adding fluid to tubes “to the tune of thousands of tubes a week,” Arnaout said. “We turned into a little factory here at Beth Israel.”

Another new swab producer is Origin, a San Francisco-based company providing software engineering to users of 3-D printers, among other things.

But when city residents were ordered to stay home, Origin’s 40 employees, deemed nonessential, turned to solving supply problems, in one case adapting snorkeling masks and filters to protect health workers. When it learned about the Boston hospital’s quest, the firm jumped in.

Now, a month later, it has become a medical device manufacturer that has passed a clinical trial test and is regulated by the FDA. Instead of delivering some 3-D printers to customers, Origin is using them to make swabs. Soon, it will be producing more than a million a week.

“If you told me a month ago that this is what our company would be doing and this is where we’d be, I’d have thought you were crazy,” said Chris Prucha, the Michigan-born chief executive of Origin. “But here we are.”