A court-appointed psychiatrist confirmed that Andrew Tahmooressi, who has been imprisoned on gun charges in Mexico for nearly six months, has Post-Traumatic Stress Disorder, a diagnosis his lawyer said could soon lead to his freedom.

The prosecution psychiatrist was sworn in at Tijuana federal court Monday, and went directly to the prison in Tecate where Tahmooressi is being held to evaluate him, Tahmooressi's attorney, Fernando Benitez, said. Because Mexico's constitution requires prison to be rehabilitative and there is no treatment available there for PTSD, Benitez said a judge could order his release.

 Tahmooressi has been held since March 31, when he says he mistakenly crossed into Mexico with three legally-purchased and registered guns in his truck. If he is convicted, he faces six to 21 years in prison.

“If our expert and the state's expert both agree there is no rehabilitation to be had for Andrew … then we have a very good shot of making a constitutional argument and we might cut this whole thing short,” Benitez said.

If things go as the defense hopes, Benitez said he would then file a motion for a mistrial based on humanitarian grounds, which could happen as early as this week. If that happens, Benitez says the judge will then have a week to consider the mistrial motion.

Tahmooressi, 26, mistakenly crossed the boder near San Diego, with all his possessions in his pickup, including three legally-owned guns. Bringing weapons into Mexico is a violation of the country's federal law. Complicating Tahmooressi's plight at the time of his arrest was that he had military-grade weapons and ammunition, as defined by Mexican statute.

He was in the San Diego area for treatment of combat-related PTSD, having recently moved from Florida, and had all of his possessions, including the legally-purchased weapons, in his vehicle when he was stopped at the border.

More On This...

Tahmooressi served two tours of duty in Afghanistan, where he was involved in an IED attack that destroyed his vehicle. Because of his leadership and heroism in the field, Tahmooressi received a battlefield promotion to sergeant.

Dan Gallo is a Fox News Channel Field Producer based in Los Angeles. Follow him on Twitter: @DanGallo