Ashley Hautzenrader, 22, was sentenced to five years of probation in lieu of prison time

An Iowa woman who tried to flush her newborn down a toilet before leaving the baby for dead in a hospital trash can has avoided jail.

Ashley Hautzenrader, 22, was sentenced Friday to five years of probation in lieu of prison time after previously pleading guilty to child endangerment and abandonment.

Hautzenrader was initially charged with attempted murder but the charges were dropped last month as part of a plea deal, the Iowa Press Citizen reported.

Police say she had entered a bathroom at the John Colloton Pavillion at the University of Iowa Hospitals and Clinics in Iowa City in May 2016, where she delivered the baby.

Hautzenrader then tried to flush the baby down the toilet, claiming she thought it was stillborn. When that didn't work, she put the child in a pillowcase and left it a trash can, according to University of Iowa police.

A hospital employee found the newborn alive a short while later.

Hautzenrader, of Davenport, Iowa, admitted dumping her baby but claimed she had believed the baby was stillborn because the child did not cry, according to the criminal complaint.

After putting her child in the trash, Hautzenrader reportedly cleaned up the bathroom and left the scene.

Hautzenrader gave birth to the child in a bathroom at the University of Iowa Hospitals and Clinics (above, file photo) in Iowa City on May 8, 2016

Hautzenrader's Facebook page show her cuddling her other child (above), who was born sometime in 2014. In numerous pictures, the child has a breathing tube attached to her nose and a tracheotomy

She had also claimed to have not realized she was pregnant when she entered the restroom.

'I'm just asking you to listen and try to understand what I've been through,' she told the court.

She claims she was at the hospital because her other child, who has a heart condition, had been admitted to the intensive care unit.

Hautzenrader said she had no idea that she was pregnant before she went into labor.

A psychiatrist who assessed her said he believes the mother was suffering from PTSD and pregnancy denial after her first child's serious illness.

On Friday, Judge Marsha Bergen told the courtroom that it was 'not an easy decision' to give Hautzenrader probation instead of prison, but had to consider her lack of previous convictions, age and her pledge to seek treatment for her post-traumatic stress disorder.

Hautzenrader was initially charged with attempted murder but the charges were dropped last month as part of a plea deal. Pictured left, the 22-year-old cuddles her toddler daughter, and right, the 22-year-old in costume

Hautzenrader (above), of Davenport, Iowa, admitted dumping her baby but claimed she had believed the baby was stillborn because the child did not cry, according to the criminal complaint

Officials have refused to release information regarding the identity of the child's father, according to the Register.

Online court records show an order from May 2015 after Hautzenrader petitioned for paternity and child support for a baby girl she previously gave birth to, WHO-TV reports.

Her daughter, believed to have been born sometime in 2014, suffers from health issues.

Several pictures, spanning from November 2014 until recently, on Hautzenrader's Facebook page show her cuddling the girl, who has a breathing tube attached to her nose and a tracheotomy.