U.S. Border Patrol officers waited as a 10-year-old girl in Texas with cerebral palsy underwent emergency surgery and then detained her, after first discovering she was an undocumented immigrant at a checkpoint on her way to the hospital, according to immigrant rights advocates and her family.

The child, Rosa Maria Hernandez, was released from the hospital on Wednesday but can’t return home to her parents after her emergency gallbladder surgery, said Priscila Martinez of the Workers Defense Action Fund, who is in communication with the girl’s attorney and family. Instead, Rosa Maria was transferred from Corpus Christi to San Antonio and held by the government. She was still in custody as of Thursday morning, and her attorney said she could be there for weeks or even months.

Officials told Rosa Maria’s attorney that she will be processed as an unaccompanied minor in the same manner as children apprehended at the border without their parents, Martinez said. The girl has been in the U.S. since she was about 3 months old and lives with her family in Laredo, Texas. Her mother, Felipa De La Cruz, is also undocumented, according to the Corpus Christi Caller-Times.

Rosa Maria’s grandfather, who is a legal permanent resident, and a cousin who is a U.S. citizen both offered to sponsor her so she could be released, but government officials refused, attorney Leticia Gonzalez told reporters on Thursday.

The Customs and Border Protection agency confirmed that Border Patrol officers discovered Rosa Maria was undocumented when she and an adult cousin, who is a U.S. citizen, went through a checkpoint inside the U.S. while traveling from a hospital in Laredo to one in Corpus Christi.

Border agents then “escorted her and her cousin to a Corpus Christi hospital where she could receive appropriate medical care,” the agency said in a statement.

“The Laredo Sector Border Patrol is committed to enforcing the immigration laws of this nation... Per the immigration laws of the United States, once medically cleared she will be processed accordingly,” the agency said.

They’re treating her like a hardened convict who has been taken to the hospital for treatment. Rep. Joaquin Castro (D-Texas)

Gonzalez, Rosa Maria’s attorney, said that border agents did not simply escort her and her cousin to the hospital ― they also went inside and waited outside her room, even following her when she was taken to tests and surgery. When the girl was discharged, four border patrol agents were initially standing outside her room, which frightened her, Gonzalez said.

“It’s stunning that federal agents would be waiting outside the hospital room of a 10-year-old girl with cerebral palsy,” Rep. Joaquin Castro (D-Texas) told reporters Thursday. “They’re treating her like a hardened convict who has been taken to the hospital for treatment.”

De La Cruz said Thursday that her daughter is confused about what’s happening and wants to go home. Through a translator, De La Cruz said she’d told Rosa Maria that “she was only there because she was recovering, and that when she was recovered, she could come be with me.”

President Donald Trump and his administration have said their focus in immigration enforcement is on deporting criminals and protecting the border. But Border Patrol officers also have made arrest of people not being targeted. In June, the acting director of Immigration and Customs Enforcement ― which is separate from Customs and Border Protection ― said that all undocumented immigrants “should look over your shoulder, and... need to be worried.”

Both Customs and Border Protection and ICE have “sensitive locations” policies that instruct agents and officers to avoid conducting arrests or other enforcement at medical facilities, schools, places of worship and rallies.

Rosa Maria’s detention highlights not just a possible violation of the “sensitive locations” policy, but also a problem with checkpoints for many undocumented immigrants living in the United States. Border agents operate up to 100 miles away from the border, so it can be difficult for undocumented immigrants to get around ― including when they’re seeking medical treatment ― without going through checkpoints in border regions. What happened to Rosa Maria could make other undocumented immigrants more fearful about seeking help, Astrid Dominguez of the American Civil Liberties Union of Texas told reporters on Thursday.

She said that CBP should change its policies at checkpoints for people seeking medical attention. In this case, Dominguez said, CBP should have used discretion “with basic humanity” and allowed the child to go back to her parents.

“Don’t believe the idea DHS propagates that it is the only law enforcement agency anywhere without discretion,” she said. “No rule should be so inflexible and no enforcement regime as harsh as” the one that traumatized Rosa Maria.

This article has been updated with additional comments and other information.