def apply_rule(self, case, now):
        if self.deleted:
            raise Exception("Attempted to call apply_rule on a deleted rule")

        if not self.active:
            raise Exception("Attempted to call apply_rule on an inactive rule")

        if not isinstance(case, (CommCareCase, CommCareCaseSQL)) or case.domain != self.domain:
            raise Exception("Invalid case given")

        if case.is_deleted:
            # Exclude deleted cases
            return False

        if case.closed:
            return False

        if self.rule_matches_case(case, now):
            return self.apply_actions(case)
        return False
Returns True if the case was closed, False otherwise.
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/data_interfaces/models.py/AutomaticUpdateRule.apply_rule