Six years ago, James Stancil, 62, a former long-haul trucker, decided to move from Iowa back to his hometown of San Francisco to live with his aging mother. There was just one problem: His enlarged heart, high blood pressure, and diabetes made his body so swollen he couldn’t get on an airplane. Doctors had to drain 75 pounds of fluid before he was well enough to fly. By the time he walked into a public health clinic near his mother’s house, his blood pressure was so high that “people were telling me, ‘You should be dead right about now,'” recalls Stancil, who’s African American and sports a white chinstrap beard. He was put on medications. He also met with a nutritionist, who urged him to cut down on salty, fatty foods like fried chicken and mac and cheese. After he learned to prepare his favorite dishes differently, his blood pressure plummeted; it’s now back to normal.

“Often we just pile on prescriptions and ignore the other half of the equation for wellness, which is food.”

Stancil no longer has to take so many pills. Yet thanks to a new program, he still frequents a pharmacy at Silver Avenue Family Health Center—only this one fills prescriptions for things like pears and squash. The so-called food pharmacy brings together the resources of a food pantry with the acumen of clinical nutritionists and the flair of a farmers market, mostly to tackle high blood pressure and diabetes. Patients who receive a referral can stop by for donated groceries, recipe demonstrations, and cooking tips. Four more of San Francisco’s primary care clinics will host food pharmacies by next year.

Meanwhile, diet-related diseases continue to spread: 1 in 3 adults in the United States have high blood pressure, elevating their risk for heart disease and stroke. More than 7 percent of people have diabetes, mostly Type 2, up from 4.4 percent in 2000. In 2012, the disease cost the country $176 billion in direct medical expenses, plus another $69 billion in decreased productivity. Analysts at Thomson Reuters calculated that reducing employee health risks such as high glucose and blood pressure by just 1 percent could save employers $83 to $103 per person annually.

The program is part of a movement to prevent and manage conditions through diet, not pills. “Often we just pile on prescriptions and ignore the other half of the equation for wellness, which is food,” says the San Francisco public health department’s Dr. Rita Nguyen, who spearheaded the city’s food pharmacy project. A 2015 study in the Journal of Biomedical Education found that only about a quarter of medical students get the recommended 25 hours of nutrition education. And as Nguyen points out, doctors have a financial incentive not to specialize in primary care: They’re paid well to cut out cancer or freeze warts, but not to “spend 15 minutes talking to someone about their diet.”

Even with a doctor’s nudge, eating healthily is easier said than done for poor Americans. Fresh produce is often much more expensive than packaged and fast foods. Most of Nguyen’s patients are on Medicaid, and 65 percent of them lack reliable access to affordable food, a situation experts call “food insecurity.” Food-insecure populations also see higher rates of high blood pressure, high cholesterol, and diabetes.

Even with a doctor’s nudge, eating healthily is easier said than done for poor Americans.

San Francisco’s food pharmacies are some of a handful that have popped up around the country. Many were inspired by Boston Medical Center’s “preventative food pantry,” which opened in 2001 after doctors realized their patients struggled with food insecurity and its associated maladies and couldn’t afford to stock their fridges with fresh veggies and other perishables. The BMC food pantry’s 7,000 monthly visitors now enjoy produce from the hospital’s rooftop garden.

Measuring the impact of food pharmacies can be tricky, says BMC dietetic technician Latchman Hiralall, because patients rely on them only for some of their groceries. But early indicators are encouraging: After a three-month trial at one of San Francisco’s pharmacies, 75 percent of patients reported greater access to healthy foods; about half reported better blood sugar levels, and 38 percent reported lower blood pressure.

The morning I visited the Silver Avenue pharmacy, a sunlit room lined by long wooden tables and a small corner kitchen, a dietitian handed out cookies made from bananas and oats along with printed recipes to about 10 patients. The pharmacy hopes to attract 40 patients every week; currently it sees 10 to 20. Stancil, now a volunteer at the pharmacy, stood next to gleaming silver buckets of yellow onions and red apples. A broad man with close-cropped gray hair and a cane declined to take some fresh carrots. “You like coleslaw?” Stancil asked. “Oh, man—I love it. Carrots are in coleslaw?” the man responded, adding that he had never made it. Stancil nodded and said, “We can show you all that.”