New data is bringing to light the unmet needs of ex-prisoners living with HIV.

Researchers at the University of North Carolina and Texas Christian University reviewed the transition of HIV-infected individuals from incarceration back into their communities. They found 40 percent of the individuals interviewed were unable to sustain viral suppression six months after community re-entry.

“There’s a connection between the HIV epidemic and the mass incarceration epidemic we have in this country,” Dr. David Wohl, co-director of HIV Services at the North Carolina Department of Corrections, told NBC News.

Dr. Wohl, who is also a professor at the UNC School of Medicine, said many people have an upside-down view of HIV among prisoners. He says it is widely believed, for example, that prisoners contract HIV while incarcerated, when the truth is that most are infected before entering prison.

“The reality is that we do a really good job of locking up people who have risk factors for HIV,” he said. “That’s a byproduct of who we lock up. We lock up people of color and people who have mental health issues.”

A 2015 study from the Urban Institute pointed out that more than half of all inmates in jails and state prisons are mentally ill. And black Americans are incarcerated five times more than white Americans, according to the Sentencing Project.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Related: Report Examines Challenges for Aging Latinos Living With HIV

Dr. Wohl said that the biggest challenge facing ex-prisoners with HIV is continuing their care after they are released. In prison, care is regimented.

“By and large, people get great HIV care in prison,” Dr. Wohl said. “But when they get out, they come back to a system that isn’t taking care of them, and they have to face issues with housing and employment.

“Getting out is something people want to do, but it’s stressful, and taking care of your virus might not be the most important thing to do,” he added.

Related: LGBTQ People Face Unique Challenges in the Criminal Justice System

Dr. Wohl said he's tackling this dilemma using a “kitchen sink” approach. In tandem with HIV Services in North Carolina’s Department of Corrections, counselors are brought in to discuss treatment with prisoners who are slated for release, and actors portray what it’s like to get out and find care. A needs assessment is done, and a cell phone is provided for free that is programmed to remind ex-prisoners to take their medicine.

While HIV care in prison is regimented, Dr. Wohl said treatment is not without its challenges. For example, preexisting stigmas against those with HIV are amplified in the prison system, he said, noting many prisoners don’t want to stand in a public line to receive their HIV medicine and face being ostracized — or worse.

For vulnerable communities, the structural obstacles are manifold: They are overrepresented in the criminal justice system but do not have adequate access to health care outside of it. Dr. Wohl argues this makes the issue of ex-prisoners struggling with managing their HIV a problem for policymakers.

“Really what’s needed is great policy that doesn’t lead to people getting incarcerated at the rates we’re seeing right now,” Dr. Wohl said. “The writing on the wall is that these people aren’t given a fair chance.”

Follow NBC Out on Twitter, Facebook and Instagram