Since January 1 of this year, James Barnes has had pretty decent health care. He gets insulin for his diabetes and the needles to inject it, blood pressure medication, access to a psychiatrist and counselor and optometrist, and frequent visits to the doctor, all for free.

Barnes lives in Maryland, one of the dozens of states that expanded Medicaid to people with incomes at or below 138 percent of the poverty level as part of the Affordable Care Act. For Barnes and thousands like him, that expansion has meant access to services like physical therapy, mental-health treatment, x-rays, dialysis, hospice care, eye exams, substance-abuse treatment, podiatrists, and oncologists.

What Barnes does not have, however, is a place to live. Since getting out of jail a year and a half ago, he’s stayed at half a dozen homeless shelters in Baltimore as he’s looked for work. He carries his belongings—and his insulin—with him in two plastic bags, the type you’d get at CVS.

Being homeless doesn’t exactly help Barnes, who is 51, become healthier. When he first started living on the streets, he’d have to borrow a few dollars to buy food to keep his diabetes in check. Even now, he isn’t allowed to bring food into the homeless shelters, so he doesn’t often eat produce or healthy food, instead relying on the starchy, heavy food at soup kitchens. He avoids taking any of his medications that could make him urinate frequently, since it’s so hard to find somewhere to go to the bathroom, and people at homeless shelters often steal his needles and medication.

He hopes he’ll get public housing soon, but “that list is long,” he said. “It probably stretches from here to California.”

James Barnes carries his belongings around Baltimore in plastic bags. (Alana Semuels)

The federal government will spend $931 billion on the Medicaid expansion between now and 2022, according to the Congressional Budget Office. Some of that money will be spent taking care of homeless people like Barnes, who can be particularly expensive to treat. Homelessness exacerbates all kinds of diseases, including diabetes. Those without homes are three to six times more likely to get ill than housed people. Homelessness also makes it more difficult for people with mental health and substance abuse issues to get treatment.

One of the best ways to keep homeless people healthy, studies have found, is to give them somewhere to live—the so-called “housing first” model, which gets the homeless off the streets and saves hospitals money in caring for them.

That’s led many advocates for the homeless to wonder—if we’re spending so much money through Obamacare to expand health coverage for poor people, why not spend it to house some of them, too?

“All I’m saying is, if I can take care of someone at a lower cost by providing them with housing, why wouldn’t the federal government let me?” said Dr. Mitch Katz, the director of the Los Angeles County Department of Health Services.

Katz is one of the pioneers in the "housing first" movement. More than a decade ago in San Francisco, he started noticing that he was treating the same homeless patients again and again. They often came to public hospitals for detox or mental health issues, and their health care would costs tens of thousands of dollars. But the thinking at the time was that homeless people were supposed to get their mental-health and substance-abuse issues under control, then they’d get public housing.

“I wondered why we spent $40,000, $60,000, $80,000 to care for someone due to illnesses they got because they were homeless when we could house them for less money,” he said.

So the city of San Francisco’s health department decided to use some of its budget to lease buildings in the Tenderloin district, and house the homeless patients they saw the most frequently in the emergency room. They asked the residents to pay 30 percent of their income, which meant they sometimes received about $200 a month per tenant, and sometimes got nothing. They soon found that using health department funds to pay for housing actually saved San Francisco money.

“Emergency room visits, acute hospital stays were much shorter, there were just a ton of factors that went down,” said Marc Trotz, who was the director of San Francisco’s Housing and Urban Health program. “It cost us about $1,500 per unit per month to house someone, but a hospital stay could be about $3,000 to $5,000 per night.”

Katz and Trotz developed 1,500 housing units in San Francisco. They have now brought the model to Los Angeles, where they plan to develop 10,000 units linked to the health system. The funds to house the “high-end” users of the hospital system came out of the health department’s budget, not out of Medicaid.

“There’s a growing acceptance of the idea that for homeless people, housing is a valuable health service,” he said. “That’s the health service that’s going to help them the most.”

But the expansion of Medicaid in California this year has meant Katz’s neediest patients now have access to case managers, mental health clinicians, and free medicine. But not somewhere to live.

Not that he’s asking for more money, he says. He just wants the state to allow housing to be counted as an expense under the state program, Medical. It will save the program money, he says—no more expensive CT scans for someone suffering from exposure, since they’ll have shelter on cold and rainy nights.

I asked Katz what would prevent people from abusing the program—giving up housing that they pay for in order to get free housing from the health department, for example. But, he pointed out, people don’t frequently drop their health insurance to go on Medicaid or give up their job to go on Social Security.

“Often, what we have is just the opposite,” he said. “We will house somebody and then they’ll get sober and they’ll get their mental health treated and they’ll leave our building for a much nicer building.”

Studies show that the strategy has worked. In Denver, emergency room costs for homeless individuals fell 73 percent after they were placed in supportive housing, a total of $31,545 per patient. Detox visits were reduced by 82 percent, which meant a savings of $8,732 per person. Incarceration and emergency shelter visits were also down significantly. Utah, a state run by Republicans, decreased homelessness 72 percent with a housing first program, cutting costs per person to $8,000 from $19,000.

Mark Schumann used to be that homeless guy you’d see on the street sometimes, walking around drunk or having a mental breakdown. Once, he took a bunch of pills and passed out in the bushes of a Maryland suburb; a passer-by saw him and called 9-1-1. Schumann coded in the ambulance, but paramedics were able to save him. Then, about three years ago, he got into public housing. He rapidly stabilized: He was able to tame his issues with alcohol, manage his diabetes, and turn his life around.

“It’s pretty remarkable what housing can do,” said Schumann, who is gray-haired and easy-going, and wears a small earring in one ear. “You have a place to keep fresh food, your own refrigerator, a place to relax. On the streets, you don’t relax.”

He’s become an advocate for the homeless, and writes for a newspaper called Word on the Street, targeted at people who don’t have anywhere to live.

Schumann’s story is a happy one, but it’s a rare one, too. The public housing rolls in Baltimore, where Schumann lives, and other cities are hopelessly backlogged. At last count, Baltimore had 25,000 people in public housing, and another 25,000 on the waiting list. Nationally, 1.2 million households live in public housing units, and even more get vouchers from the government. But cuts to the voucher funding programs have left fewer people than ever able to access the housing.

“The broader reality is that, as a country, we’re spending roughly 40 percent of what we spent in 1979 before contemporary homelessness,” said Kevin Lindamood, the CEO of Health Care for the Homeless, a Baltimore organization that works with Schumann and provides health services to low-income people in the city. “The safety net isn’t there in the way it once was, and there’s not enough housing to go around.”

Lindamood says people like Schumann are balancing on a three-legged stool, comprised of health care, housing, and income.

“Since Jan. 1, the health care leg has gotten a lot stronger,” he said. “But the other two just aren’t there.”

Paying for housing for high-need people could save money for shelters, too, points out Adam Schneider, who also works at Health Care for the Homeless in Baltimore. A family of four costs $27 per person, per night to be housed in a shelter in Baltimore, he said. If they’re in the shelter for 60 days, the county is spending $6,480 just to house them in a shelter; it could easily take that money and find an apartment to house them for a year.

“That would be the far more human, effective, and efficient way,” he said.

Some states allow Medicaid dollars to pay for hospice care or long-term nursing facilities, said Dennis Culhane, a Penn professor who has studied housing and homelessness. But strictly speaking, Medicaid dollars can not be spent on housing alone. States are allowed to petition the federal government to use Medicaid dollars in creative ways, though, and Chicago has asked the government to use the money for housing units. New York state has built some affordable housing complexes using Medicaid money.

But that's come under criticism from some, including Bruce Vladeck, who administered Medicaid and Medicare in the Clinton administration.

"Medicaid is supposed to be health insurance, and not every problem somebody has is a health care problem," he told WNYC.

The National Alliance to End Homelessness puts out a report every year showing where homelessness has increased and where it has decreased across the country. In some states, the number of homeless people grew, and in others it declined. The states where homelessness decreased last year were also the ones that paid for supportive housing, said Nan Roman, the group's CEO. Utah saw a 7 percent decrease between 2013 and 2014; homelessness in Colorado dropped 42 percent.

Roman hopes the report will show cities that paying for housing works. But she knows that in an era of cost-cutting and financial austerity, Medicaid could be the simpler way of finding money. Not that it will be easy.

“In the housing world," she said, "getting Medicaid to pay for housing is like the golden fleece.”