add by_domain function to CommCareCase