def get_business_rule_output(self, hosts, services, macromodulations, timeperiods):
        got_business_rule = getattr(self, 'got_business_rule', False)
        if got_business_rule is False or self.business_rule is None:
            return ""
        output_template = self.business_rule_output_template
        if not output_template:
            return ""
        macroresolver = MacroResolver()
        elts = re.findall(r"\$\((.*)\)\$", output_template)
        if not elts:
            child_template_string = ""
        else:
            child_template_string = elts[0]
        children_output = ""
        ok_count = 0
        items = self.business_rule.list_all_elements()
        for item_uuid in items:
            if item_uuid in hosts:
                item = hosts[item_uuid]
            elif item_uuid in services:
                item = services[item_uuid]
            if item.last_hard_state_id == 0:
                ok_count += 1
                continue
            data = item.get_data_for_checks(hosts)
            children_output += macroresolver.resolve_simple_macros_in_string(child_template_string,
                                                                             data,
                                                                             macromodulations,
                                                                             timeperiods)
        if ok_count == len(items):
            children_output = "all checks were successful."
        template_string = re.sub(r"\$\(.*\)\$", children_output, output_template)
        data = self.get_data_for_checks(hosts)
        output = macroresolver.resolve_simple_macros_in_string(template_string, data,
                                                               macromodulations, timeperiods)
        return output.strip()