A federal judge has cleared the way for a trial against two senior Department of Correction officials in a case alleging deliberate indifference to an inmate’s medical needs and retaliation for threatening a lawsuit.

The ruling from U.S. District Judge Karen Schreier comes after two years of legal wrangling over the prison’s post-surgical treatment of James Elmer Shaw, an inmate serving a 40-year sentence for attempted murder and aggravated assault.

More:Tablets to replace lawyer and paralegal for South Dakota inmates

Shaw spent three days in disciplinary segregation immediately following a 2015 knee surgery for demanding a handicap cell.

He was denied ice and the ability to elevate his knee while there, and was investigated for purportedly stealing his own medical records after announcing his plans to file a lawsuit about it.

Shaw sued Associate Warden Troy Ponto, Unit Manager Al Madsen and seven others, alleging violations of the U.S. Constitution’s protections against cruel and unusual punishment.

He is representing himself.

More:South Dakota inmate sues over lack of air conditioning in prison

Schreier dismissed the case against the other seven defendants with her Sept. 29 order, but wrote that a jury ought to decide if Ponto and Madsen violated Shaw’s rights.

Both men are open to a jury trial over deliberate indifference. Ponto is also exposed to a charge of retaliation against Shaw.

Court documents say Madsen admitted to denying Shaw's request for pain meds and ice, but he argued that he hadn’t seen the medical orders. Other DOC employees testified, however, that medical orders follow inmates who move from one cell to another within the facility.

Shaw initially alleged that he was denied pain medication during his time in the special housing unit (SHU), but DOC records showed that he was ultimately given medicine.

Even so, the judge wrote that the prison officials' behavior towards a person who'd just returned from surgery could be seen as evidence of deliberate cruelty.

“There is a question of fact as to whether Madsen was deliberately indifferent to Shaw’s medical needs,” Schreier wrote.

More:Coddling inmates with technology? Readers react to tablet story

In November 2015, after Shaw told prison employees of his plans to file a complaint, Ponto ordered a search of Shaw's cell, which resulted in another visit to disciplinary housing. This time, the move was to search Shaw’s cell for his own medical records, which he’d asked for several times.

Schreier wrote that a jury ought to decide if the move was meant to punish Shaw for taking his complaints to court.

“The court finds that a cell search paired with being placed in the SHU could be considered an adverse action that would chill an ordinary person from taking part in a protected activity,” she wrote.

The DOC has yet to respond to the Schreier order.