S.S.
I'd ask for a referral to a Pediatric GI - and do a little bit of reading on "pyloric stenosis". If that is the problem, the surgery is an easy and permanent fix (no more meds, no more puking).
General description - food goes down the esophagus, in the stomach, through the pyloric sphincter (a valve), and into the small intestine... where it goes on through the intestines and into the diaper.
Stenosis is a narrowing - in this case of that pyloric valve. It's kind of like bypass surgery, making that valve tight makes it hard for the food (or formula) to go into the small intestine. It may be wide enough for formula to trickle out slowly, which would cause spit up (especially on more than a couple of ounces), constipation (because of the slow addition of food and fluids to the intestine, the peristalsis that pushes it along can slow down - causing a backup), but too narrow for the solids - which can 'plug the hole' so to speak in the stomach, causing massive vomiting.
So -that's what I think... but check it out with your doctor.
Good luck.
S.