<commit_before># coding=utf-8

from corehq.apps.reports.datatables import DataTablesHeader, DataTablesColumn
from custom.enikshay.reports.consts import AGE_RANGES
from custom.enikshay.reports.generic import EnikshayReport, EnikshayMultiReport
from custom.enikshay.reports.sqldata.case_finding_sql_data import CaseFindingSqlData
from custom.enikshay.reports.treatment_outcome import AllTBPatientsReport


def get_for_all_ranges(slug, data):
    row = []
    for lower_bound, upper_bound in AGE_RANGES[:-1]:
        row.append(data.get('%s_age_%d_%d' % (slug, lower_bound, upper_bound), 0))

    row.append(data.get('%s_age_%d' % (slug, AGE_RANGES[-1][0]), 0))
    row.append(data.get('%s_total' % slug, 0))
    return row


class CaseFindingAllTBPatientsReport(AllTBPatientsReport):
    report_title = 'Block 1: All TB patients registered in the quarter'

    @property
    def rows(self):
        return super(CaseFindingAllTBPatientsReport, self).rows[1:4]


class AllNewAndRecurrentTBCases(EnikshayReport):
    name = 'Block 2: All new and recurrent TB cases only: from column above'
    slug = 'all_new_and_recurrent_tb_cases'

    @property
    def headers(self):
        return DataTablesHeader(
            DataTablesColumn('Age'),
            DataTablesColumn('0-4'),
            DataTablesColumn('5-14'),
            DataTablesColumn('15-24'),
            DataTablesColumn('25-34'),
            DataTablesColumn('35-44'),
            DataTablesColumn('45-54'),
            DataTablesColumn('55-64'),
            DataTablesColumn(u'≥65'),
            DataTablesColumn('total')
        )

    @property
    def model(self):
        return CaseFindingSqlData(config=self.report_config)<commit_msg>Make headers based on AGE_RANGES variable<commit_after># coding=utf-8

from corehq.apps.reports.datatables import DataTablesHeader, DataTablesColumn
from custom.enikshay.reports.consts import AGE_RANGES
from custom.enikshay.reports.generic import EnikshayReport, EnikshayMultiReport
from custom.enikshay.reports.sqldata.case_finding_sql_data import CaseFindingSqlData
from custom.enikshay.reports.treatment_outcome import AllTBPatientsReport


def get_for_all_ranges(slug, data):
    row = []
    for lower_bound, upper_bound in AGE_RANGES[:-1]:
        row.append(data.get('%s_age_%d_%d' % (slug, lower_bound, upper_bound), 0))

    row.append(data.get('%s_age_%d' % (slug, AGE_RANGES[-1][0]), 0))
    row.append(data.get('%s_total' % slug, 0))
    return row


def get_headers():
    headers = [DataTablesColumn('Age')]
    for age_range in AGE_RANGES:
        if len(age_range) > 1:
            headers.append(DataTablesColumn('%d-%d' % (age_range[0], age_range[1])))
        else:
            headers.append(DataTablesColumn(u'≥%d' % age_range[0]))
    headers.append(DataTablesColumn('Total'))
    return headers


class CaseFindingAllTBPatientsReport(AllTBPatientsReport):
    report_title = 'Block 1: All TB patients registered in the quarter'

    @property
    def rows(self):
        return super(CaseFindingAllTBPatientsReport, self).rows[1:4]


class AllNewAndRecurrentTBCases(EnikshayReport):
    name = 'Block 2: All new and recurrent TB cases only: from column above'
    slug = 'all_new_and_recurrent_tb_cases'

    @property
    def headers(self):
        return DataTablesHeader(
            *get_headers()
        )

    @property
    def model(self):
        return CaseFindingSqlData(config=self.report_config)
{'fraction_non_alphanumeric': 0.1074861637052141, 'fraction_numerical': 0.01543839207690067, 'mean_word_length': 3.8366197183098594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3385334', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1111, 'n_words': 219}