When Boston Medical Center needed a way for patients to access healthy, fresh food, it turned to its roof.

When people step into a hospital, they’re often looking for an answer to a problem. What’s wrong with my stomach? Can the pain in my hand go away? How do I feel better?

While nurses and doctors are there to solve those problems, they’re also working to prevent future ones. Simplified, a hospital’s job is twofold: react and prevent.

On the roof of the Boston Medical Center, they’re preventing by growing.

The hospital’s 2,658-square-foot rooftop farm grows fresh produce for its food-insecure patients. These patients are referred to the Boston Medical Center’s Preventative Food Pantry. There, they gain access to over 25 crops and can take home fresh food for their entire household every two weeks.

“The Preventive Food Pantry helps fill the gap for those who would otherwise be unable to access affordable, nutritious food, and this expansion further demonstrates BMC’s commitment to addressing the underlying social factors that affect a patient’s health,” Thea James, MD, vice president of mission and associate chief medical officer at BMC, said in a news release.

Kale, carrots, onions, cauliflower, eggplants and radishes are all grown in the rooftop plant beds, creating over 6,000 pounds of food each year. A little under half goes directly home with patients, and the remainder is used for the hospital’s cafeteria, teaching kitchen and in-house farmers market, which is held in the lobby every week during the summer months.

The food pantry opened in 2001, and the garden opened in 2016 to provide the pantry with more fresh produce.

“BMC for a long time has had a mission that food is medicine,” farm manager Lindsay Allen told WHDH.

The foods we eat can be a direct indicator of how healthy we are. Studies show that eating more processed and fried foods can increase the risk of heart disease, diabetes and death. But the reverse is true, too: People who consume more fresh fruits and vegetables are likely to live longer and healthier lives.

With that in mind, BMC got to growing. Patients are given a prescription to the pantry, where a registered dietician helps them customize a plan and pick out food based on their health needs. The patient can also pick up food for their entire household. In 2017, the pantry worked with over 83,000 individuals.

“When they provide a patient with a prescription, it becomes part of your medical care. It’s more like going to the pharmacy. They do not hesitate to come,” Latchman Hiralall, manager of the Food Pantry, told Boston Magazine.

But the benefits extend past healthy eating for patients and in the cafeteria. It cuts down on the hospital’s carbon footprint, collects stormwater, creates green space and reduces the energy required by absorbing heat that would otherwise warm a building.

If farm visitors listen closely, they’ll hear a faint buzz. The farm is home to two honeybee hives, which pollinate the crops and produce honey.

The Boston Medical Center isn’t the only hospital that’s thought of this green idea. Across the country, green roofs are gaining popularity as a way to help eradicate food deserts.

At the John Theurer Cancer Center at Hackensack University Medical Center in New Jersey, patients visit the hospital’s terrace garden and pick vegetables and herbs to incorporate into their meals. Lenox Hill Hospital in New York City transformed its black slate roof into an urban garden five years ago. The space grows herbs and small crops, like strawberries and tomatillos, for the kitchen team to use and for the staff to take home.

As of 2017, 54% of the country’s hospitals are in urban centers. Those hospitals’ patients and staff are more likely to have a hard time finding green space and affordable, healthy food. Rooftop gardens can solve both of those problems, offering a place where people can experience the therapeutic benefits of nature and gain access to fresh food.

So the next time you’re walking past a hospital, look up and you might find something green.

More: Why Green Classrooms Could Be the Schools of the Future