would it be worth porting this function to be more accessible in the casexml app and then calling it? https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/commtrack/models.py#L329