easy way -- use calcium nutriate as your primary source for nitrogen. build around it... never hve ca issues using that... also, magnesium-sulfate will provide Mg. (epsom salt)
if you run into these issues, it means your fertilizer mix is lacking and it'll only continue to happen.. if oyu have a component of mix that has most or all of your Ca, you can try increasing that product's concentration in your mix. same with Mg obviously. if you cannot devise a formula that doesn't cause other issues, then you need some sort of supplement each time you mix it up or go with a different brand / set of ingredients that allows you to properly feed them.
you'd also have to make sure Mg/Ca are one of the things that can actually be foliar fed -- not all molecules will make it through the stomata and i don't keep a memorized list in my head because i don't foliar feed. i use the roots, because that's what they are made for,lol. Foliar sprays are great to get what is missing to the local area faster in some situations (namely which molecules can traverse the stomata)... but it shouldn't be used as your primary source for ca/mg. Gettng leaves wet everyday is only going to invite problems. a risk you can easily avoid by simply feeding a well-balanced diet. it's s tool.. for specific use.. some just have to do more to feel they are doing something, i believe. keep it simple... plus, you can't leave.. you are shackeld to that plant spraying evey day or it'll have issues.