Save to es

(don't merge yet)

@czue @dannyroberts 
This should have no real changes on its own, I just pulled out the method that saves to ES.
https://github.com/dimagi/commcare-hq/pull/4393