https://github.com/dimagi/core-hq/blob/master/corehq/apps/hqwebapp/static/hqwebapp/js-custom/hq.helpers.js