A woman who pretended to be a nurse at a St. Louis hospital has been sentenced to five years of probation and eight months of house arrest.

“What the hell were you thinking?” U.S. District Judge Henry Autrey asked the defendant in court Wednesday.

Prosecutors say Samantha Rivera, 36, used fake credentials to land a nursing job in the intensive care unit at St. Alexius Hospital, despite having no qualifications.

They say she also lied about her education for a teaching position at Brown Mackie College in Albuquerque, N.M., the St. Louis-Dispatch reported.

Rivera was ordered to repay $21,500 to a staffing agency that placed her at St. Alexius and $28,000 to the nursing school where she taught.

The judge called Rivera’s actions “reprehensible” and said her patients could have been harmed by her “muddling about” in the ICU.

Rivera’s public defender, Charles Banks, said Rivera suffered trauma in her past that caused her “self-destructive, and frankly, bizarre behavior.”

Banks said Rivera was too “emotional” to speak. He read an email written by her in which she acknowledged bottoming out and needing treatment over a long period of time.

“You need to do some serious soul-searching and think about what you did and what could have happened,” the judge said.

The Associated Press contributed to this report.