HIV transmission from mother to child is a major, and preventable, factor in the ongoing prevalence of AIDS in Africa. While transmission rates are below 5% with effective prenatal treatment, the World Health Organization says they can range up to 45% without treatmentunfortunately, a common situation in the developing world.

Postnatal testing, then, is often vital in spotting infections in newborns, and treating them. But even as testing has become more accessible in Africa, it has remained slow, with devastating resultsuntreated infant HIV is usually fatal within a year. The problem isn’t just the time needed for the actual tests, but also the unpredictable ways that samples traveled from clinics to labs.

To tackle the problem, Mozambique brought in logistics expert Jérémie Gallien, a professor at the London Business School. Before looking at health systems, Gallien had consulted on retail logistics, including for the fast-fashion chain Zara and a dominant online seller he prefers not to name. And he’s found common ground between selling sweaters and saving lives.

Gallien says the basic conundrum of medical planning is the same as that in retailstriking the right balance between instant gratification and system-wide agility. When a retailer puts all its stock in stores instead of distribution centers, or a medical authority puts all of its drugs in clinics instead of a central facility, they can sell or treat patients at those locations much more quickly. But if they bet wrong on demand, moving materials where they’re needed becomes much more challenging.

MORE: Snapchat Teams Up with (RED) to Fight AIDS

Balancing those concerns comes down to understanding a specific problem, and in Mozambique, Gallien, with co-authors Sarang Deo and Jónas Oddur Jónasson, found a surprising answer. To speed the return of test results, they recommended that testing facilities, instead of dispersed, be highly centralized. While slightly slowing average sample transportation times, the added efficiency in test processing would more than make up for it.

That conclusion was based on tons of data, gathered through partnerships with the Clinton Health Access Initiative and the National Institute of Health in Mozambique. “We got access to a data set of more than a year of shipments from clinics to the labs, then back, time stamped,” says Gallien. That was more than 30,000 records, also including information on patient outcomes and engagement.

Those records let Gallien get a precise but broad-scale view of transit times, which averaged 10 days.

“Increasing the transportation time to 13 days, you end up needing two lab locations,” he says. That would have led to a more complex problem of which samples go to which labwhich Gallien compares to the retail relationship between customers and warehouses.

The data also revealed a more complex human component of the problemthe relationship between turnaround time and caretaker followup. When test results took more than 30 days, babies’ mothers were much less likely to come back to get their resultsor treatment.

“There’s all kinds of stigma and psychological impact having to do whether you transmitted the virus to your infant,” says Gallien. “It’s [a] very challenging, difficult psychological context in the first place,” and the discouragement of slow test results can trigger disengagement. Though far less dire, it’s not hard to see the parallels in retailspeedy fulfillment makes it easier for customers to make decisions, and stick with them.

Authorities in Mozambique are still processing Gallien’s recommendations, but he says Uganda has already begun to implement a similar set of solutions. The move to data-based planning, he says, opens up big possibilities for improving global healthcare.

“Particularly in these environments where there’s limited resources, limited timethis could really improve outcomes.”

Sign up for Data Sheet, Fortune’s daily newsletter about the business of technology.

Watch to learn more about the global fight against AIDS: