(CNN) A federal court judge in California on Monday ordered the US government to make immediate changes to how it treats undocumented immigrant children it has placed in secure facilities.

The court's orders ranged from very specific demands, such as to get informed consent or a court order before giving children psychotropic medications at the Shiloh Treatment Center in Texas, to sweeping orders requiring the government to stop imposing conditions that have led to months of delays before it releases minors to parents or relatives.

CNN previously reported on the wide-ranging abuses at Shiloh and other facilities described by children in sworn declaration in the case that led to Monday's order. These included cases of children being forcibly medicated, assaulted, and restrained for long periods of time, among other allegations.

In her ruling, US District Court Judge Dolly Gee agreed that the government had violated terms of a high-profile settlement, reached in 1997, that dictates how children are treated within the system run by the federal Office of Refugee Resettlement (ORR).

She ordered the government to transfer out of Shiloh all children except those a licensed psychiatrist or psychologist determines pose a danger to themselves or others.

Read More