(CNN) It took a fight in court, but a 5-year-old girl will be allowed to bring her cannabis-based medicine to school and attend class with other students, according to a ruling by a California administrative court on Friday.

Brooke Adams, a Santa Rosa, California, kindergartner, has Dravet Syndrome . It's a severe and rare form of epilepsy that comes with life-threatening seizures that are unpredictable, frequent and can cause serious damage if not treated quickly. What can help control the seizures, if she gets the medicine fast enough, is cannabis oil. She uses CBD oil as a preventative medication and THC oil as an emergency seizure medication.

The Rincon Valley Union School District previously covered the cost of a private preschool, and a licensed vocational nurse who followed the child on the bus and went with her to class. The nurse stood by, ready with the rescue medication, in case Brooke's had a seizure. But when Brooke's parents met with the district in April to make a plan for kindergarten in a public school, the district declined to place Brooke in a school and refused her access to a school bus. The reason, the district said, was that it had legal concerns about having the cannabis oil on public school property, according to the court documents.

"The assistant superintendent Cathy Myhers had said she would like to have Brooke on campus," said the lawyer for the district Jennifer Nix, but it wasn't clear that it was legal.

Instead, Rincon Valley offered one hour of home instruction a day and continued services of the nurse at home, rather than at school. Brooke's parents wanted her to go to school. Her experience at preschool, interacting with other children and attending class, has helped her grow socially and academically, her family and medical professionals testified.

The parents took the school district to court.

The school district argued that while Brooke made social and intellectual progress attending a preschool, federal and state law prohibited students from having medical cannabis on school grounds. The medicine has been a life saver, according to Brooke's family and her doctor, who testified in court that Brooke cannot function without it.

If treated quickly, Brooke's seizures may not have an immediate side effect, according to her physician, Dr. Joseph Sullivan , the director of the Pediatric Epilepsy Center at UCSF Benioff Children's Hospital in San Francisco. The "cumulative effect of hundreds of seizures over time results in developmental stagnation and intellectual disability," according to Sullivan's testimony. Brooke was having 20 seizures a month when she first saw him for treatment.

Dravet Syndrome has left Brooke with speech and language delays, behavioral and developmental delays and problems with movement and balance. The disease has to be treated daily, but it is "highly resistant to currently available medications."

In Brooke's case, the family tried a number of traditional pharmaceuticals on the market such as Onfi Depakote and Keppra. None seemed to stop the seizures, according to Sullivan, but cannabis oil seemed to work. The medicine has reduced the number of Brooke's seizures and her family said her longest seizure-free period came since she has been using cannabis based medicine. "It was stopping every seizure, which was miracle for us," Jana Adams said.

Myhers, the Rincon Valley assistant superintendent for student services who oversees the district's special education program, testified that a school campus would be the best place to meet Brooke's educational and social development goals, were it not for the illegality of having the medicine on campus. She testified that there was concern that if Brooke did come to campus with the medicine, it "could potentially jeopardize" funding for the district, since the district is supposed to provide a declaration that it is a drug and alcohol-free campus.

The court determined that the nurse and the child were well within the parameters of California's Compassionate Use Act and the 2003 Medical Marijuana Program Act and interpreted those laws to say that qualified patients and their caregivers can have the medicine with them on the bus and on school grounds "if [they] followed the same procedures on a public school campus that she did in the preschool."

"I was definitely relieved and excited and emotional," Jana Adams said. The cannabis, she said, "It's life, life saving, life changing."

She said the drug has made a huge difference in the lives of their entire family. "I've had to stay home with Brooke from vacations and different things and now we can go places as a family, you know, it's, it's totally different," Adams said. "I know that I have confidence that the THC is going to stop the seizure ... I had no idea what the outcome was going to be once she started having a seizure. "

"We are glad to have clarity and we are glad to serve Brooke," said Jennifer Nix the lawyer who represented the school district in this case. "We appreciated that the judge addressed each of our concerns."

The California legislature has tried to clear up potential confusion about the state's compassionate use law when schools are involved. This year, the legislature passed Senate Bill 1127 , which awaits a signature from Gov. Jerry Brown and would allow school districts to create policies permitting parents or a guardian of a qualified student to possess and use medical cannabis at school. Since 2014, Congress has prohibited the US Department of Justice to spend money on prosecuting cannabis-related activities if those activities are allowed under state medical marijuana laws, although the Trump administration has signaled it might change this approach.

Brooke is not the first child to bump into a school district concerned about the legality of the medicine. In a groundbreaking case in April, an Illinois judge ruled in favor of letting 11-year-old Ashley Surin. who has childhood acute lymphoblastic leukemia , attend class with her cannabis-based medicines. In that case, the Illinois attorney general had to agree that there would be no negative legal ramifications for staff who would help Surin with her medicine. A federal judge also had to issue an emergency order to allow her back to school, because Illinois law does not spell out an exception for medical use in a school setting.

JUST WATCHED Parents give son pot for seizures, lose custody Replay More Videos ... MUST WATCH Parents give son pot for seizures, lose custody 01:04

Colorado, Maine, New Jersey and Washington state do allow some students to use medical marijuana at school. As medicinal cannabis becomes more accepted by the American public and medical communities, experts say states are going to have to address it.

Joe Rogoway , the Adams' attorney. hopes that this ruling can become a kind of legal blueprint for schools. "A lot of parents will just give up if they were told you can't take the child to school," Rogoway said. He added his staff was "a little teary eyed" when they got the decision.

"I'm hopeful that people won't have to fight this and school districts will do the right thing and allow children to go to school regardless of the medication they are taking," Rogoway said.

Get CNN Health's weekly newsletter Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

"I never imagined that I would be the one to be fighting for this and having to go through it, but I definitely would do it over again," Jana Adams said. While cases like these are typically private she thought it was important to tell her family's story. "We decided to make it public so that we could help others see the benefits and know that, you know, with the ruling, I think it'll help other school districts know that there shouldn't be an excuse."