My son went through this between 4th and 5th grade. He missed a LOT of school, and we were called out of work many times by the school nurse because the first thing the school does when a kid throws up is call the parents to come and get them! He would throw up 4-5 times a week, mostly in the morning before school, although he did at other times as well. He seemed to do much better on weekends, school breaks, and over the summer. Figures, right! Of course everyone thought it was school-related, but nothing added up. His teachers loved him, he had a lot of friends, and he did well in class.
It took 9 months of us testing everything and ruling out things to narrow down what was going on. We tested for blockages, ulcers, celiac disease, bacteria in his stomach, swallowing reflex - EVERYTHING they could thing of. They put him on vitamins to increase his vitamin D and iron, and Zantac in case it was acid reflux. We started eliminating certain foods, one at a time for a month each, from his diet to see if it was an intolerance or allergy. They put him on a gluten and wheat free diet for 3 months.
Nothing changed. He was still throwing up. Eventually they had us see a psychologist, who diagnosed Rumination Syndrome. (he did not rechew his food lol - that would have made him puke even more just thinking about doing that!
) It is an eating disorder that is relatively involuntary - it is the body being trained to throw up because of something that happened previously - in DS's case, we traced it back to the week 4th grade started and he got very very sick with a virus that landed him in the ER because they were afraid he had appendicitis. They believe that he subsequently "trained" his body to throw up, which after a while became involuntary. DS hated it - he hates attention and the spotlight, so it was torture to him to have his teachers and classmates watch him run out of the room trying not to throw up, or having to ask to go to the nurses office because his stomach hurt, which it did All The Time. It started to affect his personality - he was so sad and felt hopeless that he would ever feel good and healthy again.
We did behavior therapy - every time he felt like he was going to throw up, he was to take 10 long, deep breaths and really focus and concentrate on the deep breathing. Apparently the body cannot throw up AND deep breathe at the same time (I'm sure there are exceptions so YMMV), so he had to essentially re-train his body to hold his food down. It worked for him - the episodes because fewer and farther between, and now he is in 6th grade and hasn't complained about feeling like he was going to throw up in almost a year.
Also, DS12 has had terrible headaches since he was about 4 and was officially diagnosed with migraines around the same time as the Rumination Syndrome diagnosis - this was a separate diagnosis - but the neurologist did say that it seems that kids with one often also have the other.
FYI on Gluten/Celiac Disease - it is not an "allergy" - it is an autoimmune disorder where the body attacks the protein found in wheat, barley, rye, etc in the small intestine. The attack damages and smooths out the villi that lines the walls of the small intestine, which affects the absorption of nutrients. There are other symptoms as well - nausea, vomiting, intestinal issues, flu-like symptoms, etc. True Celiac Disease can be diagnosed by a blood test and biopsy of the small intestine (DS12 had both done, and yes, the biopsy is done in the hospital in a surgical setting under anesthesia) to visually inspect the villi and see if it is damaged in the way that is consistent with Celiac. If someone has it, they shouldn't consume ANYTHING containing gluten - even crumbs from the toaster or using the same plate that had gluten on it can lead to an attack and the damage of the intestine. Having DS12 on a gluten free diet for 3 months was one of the hardest things I have ever had to do. I did not trust ANYTHING or ANYONE to feed him except for me...I was so scared of cross-contamination. And all of the people claiming they have a "gluten allergy" just because they think it sounds cool, or because one of the Kardashians went gluten-free, don't help - it becomes a joke and not taken seriously for those who really need it. My SIL who was a server all through college just told a story about how they wouldn't take gluten "allergies" very seriously at her work. I wasn't surprised.