Gerardo Valerio-Romero was in Utah County custody, accused of repeatedly sexually abusing an 8-year-old relative, when he was diagnosed with cancer.

The day after the medical determination, the 49-year-old Mexican citizen was in LDS Hospital receiving cancer treatment, marking the start of an ongoing saga that exposed a rift between the county’s sheriff and its commission as well as medical bills that threaten to top $1 million.

Even at a discount, Valerio-Romero’s cancer treatments have drained the county jail’s medical budget. His case is set for trial early next month, and he’s caught the interest of federal immigration officials who will look at possibly deporting him if he’s acquitted. Until then, he’s in Utah’s court system, where his case is stalled and costs from his treatment continue to climb.

“It’s a Catch-22,” Sheriff Jim Tracy said.

U.S. Immigration and Customs Enforcement placed a detainer on Valerio-Romero when he was arrested in March 2017, meaning ICE asked to be notified when he was convicted or acquitted on six counts of felony aggravated sexual abuse of a child. (He also faces eight felony charges related to forgery and one count of unlawful possession of another person’s identification.)

“A detainer is basically saying, ‘Hey, listen, when you’re going to be releasing him, let us know so that we can pick this guy up,’” ICE spokesman Carl Rusnok said Wednesday.

Valerio-Romero’s trial has twice been delayed, once last August at the request of prosecutors and again in December, when he asked for a new attorney and rejected a plea deal offered by the state (the details of which haven’t been disclosed).

The defendant has waived his right to a speedy trial, the court docket shows.

His next three-day trial is scheduled to begin Aug. 8. It’s unclear whether he’ll be ready to stand trial. If not, Tracy said, his medical treatment will continue to ring up costs for the county.

Valerio-Romero has pleaded not guilty to all charges against him. Court filings indicate he may have used the name Jesus Melgoza for work and cashing checks. His attorney, Clayton Simms, didn’t respond to a request for comment Wednesday.

The case was catapulted to the public spotlight early this month, when Tracy took the microphone during public comment at a County Commission meeting and announced he is quitting, partially over the inmate’s medical bills. His last day is Aug. 3.

Commissioners said at the time they were caught off guard by Tracy’s abrupt resignation. They said they believed the office could shift money around to cover immediate costs before the commission can meet next month and adjust its budget.

Commissioner Nathan Ivie was also critical of Valerio-Romero, saying he “shouldn’t even be in this country” because of a prior conviction.

Tracy said Valerio-Romero’s previous conviction wasn’t an offense for which he could be deported.

The sheriff said he was frustrated with the county’s funding of his department over the past 10 years. While he said Valerio-Romero’s case isn’t the only reason he’s quitting, he said Wednesday that things came to a head when he asked for emergency budget help from the commission.

He said commissioners will vote early next month — just after his exit — on emergency funding through year’s end.

“The solution to this problem … was adding additional money,” Tracy said. “This guy pops up with a million-dollar [problem], which we don’t even have. That’s why there was the crisis. The solution has always been from Day One you’re going to have to transfer money” to cover medical costs.

“It’s a mess,” he added. “That’s the final straw that broke the back.”