def get_early_initiation_breastfeeding_data(domain,
                                            config,
                                            loc_level,
                                            location_id,
                                            show_test=False,
                                            icds_features_flag=False):
    group_by = ['%s_name' % loc_level]

    config['month'] = datetime(*config['month'])
    data = AggChildHealthMonthly.objects.filter(**config).values(
        *group_by).annotate(
            birth=Sum('bf_at_birth'),
            in_month=Sum('born_in_month'),
        ).order_by('%s_name' % loc_level)

    if not show_test:
        data = apply_exclude(domain, data)

    chart_data = {
        'blue': [],
    }

    tooltips_data = defaultdict(lambda: {
        'in_month': 0,
        'birth': 0,
    })
    location_launched_status = get_location_launched_status(config, loc_level)
    for row in data:
        if location_launched_status:
            launched_status = location_launched_status.get(row['%s_name' %
                                                               loc_level])
            if launched_status is None or launched_status <= 0:
                continue
        in_month = row['in_month']
        name = row['%s_name' % loc_level]

        birth = row['birth']

        value = (birth or 0) / float(in_month or 1)

        tooltips_data[name]['birth'] += birth
        tooltips_data[name]['in_month'] += (in_month or 0)

        chart_data['blue'].append([name, value])

    chart_data['blue'] = sorted(chart_data['blue'])

    return {
        "tooltips_data":
        dict(tooltips_data),
        "info":
        early_initiation_breastfeeding_help_text(html=True),
        "chart_data": [{
            "values": chart_data['blue'],
            "key": "",
            "strokeWidth": 2,
            "classed": "dashed",
            "color": MapColors.BLUE
        }]
    }
Esempio n. 2
0
 def test_sector_data(self):
     self.assertDictEqual(
         get_early_initiation_breastfeeding_data('icds-cas',
                                                 config={
                                                     'month': (2017, 5, 1),
                                                     'state_id': 'st1',
                                                     'district_id': 'd1',
                                                     'block_id': 'b1',
                                                     'aggregation_level': 4
                                                 },
                                                 location_id='b1',
                                                 loc_level='supervisor'),
         {
             "info":
             early_initiation_breastfeeding_help_text(html=True),
             "tooltips_data": {
                 "s2": {
                     "in_month": 0,
                     "birth": 0
                 },
                 "s1": {
                     "in_month": 1,
                     "birth": 0
                 }
             },
             "chart_data": [{
                 "color": MapColors.BLUE,
                 "classed": "dashed",
                 "strokeWidth": 2,
                 "values": [["s1", 0.0], ["s2", 0.0]],
                 "key": ""
             }]
         })
Esempio n. 3
0
 def test_map_data_right_legend_info(self):
     data = get_early_initiation_breastfeeding_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     expected = early_initiation_breastfeeding_help_text(html=True)
     self.assertEquals(data['rightLegend']['info'], expected)
Esempio n. 4
0
 def test_map_data_right_legend_info(self):
     data = get_early_initiation_breastfeeding_map(
         'icds-cas',
         config={
             'month': (2017, 5, 1),
             'aggregation_level': 1
         },
         loc_level='state'
     )
     expected = early_initiation_breastfeeding_help_text(html=True)
     self.assertEquals(data['rightLegend']['info'], expected)
Esempio n. 5
0
 def test_sector_data(self):
     self.assertDictEqual(
         get_early_initiation_breastfeeding_data(
             'icds-cas',
             config={
                 'month': (2017, 5, 1),
                 'state_id': 'st1',
                 'district_id': 'd1',
                 'block_id': 'b1',
                 'aggregation_level': 4
             },
             location_id='b1',
             loc_level='supervisor'
         ),
         {
             "info": early_initiation_breastfeeding_help_text(html=True),
             "tooltips_data": {
                 "s2": {
                     "in_month": 0,
                     "birth": 0
                 },
                 "s1": {
                     "in_month": 1,
                     "birth": 0
                 }
             },
             "chart_data": [
                 {
                     "color": MapColors.BLUE,
                     "classed": "dashed",
                     "strokeWidth": 2,
                     "values": [
                         [
                             "s1",
                             0.0
                         ],
                         [
                             "s2",
                             0.0
                         ]
                     ],
                     "key": ""
                 }
             ]
         }
     )
Esempio n. 6
0
 def test_data_early_initiation_of_breastfeeding(self):
     self.assertDictEqual(
         get_maternal_child_data(
             'icds-cas', {
                 'month': (2017, 5, 1),
                 'prev_month': (2017, 4, 1),
                 'aggregation_level': 1
             })['records'][2][0], {
                 "redirect": "maternal_and_child/early_initiation",
                 "color": "green",
                 "all": 7,
                 "frequency": "month",
                 "format": "percent_and_div",
                 "help_text": early_initiation_breastfeeding_help_text(),
                 "percent": 128.57142857142856,
                 "value": 4,
                 "label": "Early Initiation of Breastfeeding"
             })
Esempio n. 7
0
 def test_data_early_initiation_of_breastfeeding(self):
     self.assertDictEqual(
         get_maternal_child_data(
             'icds-cas',
             {
                 'month': (2017, 5, 1),
                 'prev_month': (2017, 4, 1),
                 'aggregation_level': 1
             }
         )['records'][2][0],
         {
             "redirect": "maternal_and_child/early_initiation",
             "color": "green",
             "all": 5,
             "frequency": "month",
             "format": "percent_and_div",
             "help_text": early_initiation_breastfeeding_help_text(),
             "percent": 20.000000000000018,
             "value": 2,
             "label": "Early Initiation of Breastfeeding"
         }
     )
Esempio n. 8
0
def get_early_initiation_breastfeeding_map(domain,
                                           config,
                                           loc_level,
                                           show_test=False):
    def get_data_for(filters):
        filters['month'] = datetime(*filters['month'])
        queryset = AggChildHealthMonthly.objects.filter(**filters).values(
            '%s_name' % loc_level,
            '%s_map_location_name' % loc_level).annotate(
                birth=Sum('bf_at_birth'),
                in_month=Sum('born_in_month'),
            ).order_by('%s_name' % loc_level,
                       '%s_map_location_name' % loc_level)

        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    data_for_map, in_month_total, birth_total, average, total = generate_data_for_map(
        get_data_for(config), loc_level, 'birth', 'in_month', 20, 60)

    fills = OrderedDict()
    fills.update({'0%-20%': MapColors.RED})
    fills.update({'20%-60%': MapColors.ORANGE})
    fills.update({'60%-100%': MapColors.PINK})
    fills.update({'defaultFill': MapColors.GREY})

    gender_ignored, age_ignored, chosen_filters = chosen_filters_to_labels(
        config)

    return {
        "slug":
        "early_initiation",
        "label":
        "Percent Early Initiation of Breastfeeding{}".format(chosen_filters),
        "fills":
        fills,
        "rightLegend": {
            "average":
            average,
            "info":
            early_initiation_breastfeeding_help_text(html=True),
            "extended_info": [{
                'indicator':
                'Total Number of Children born in the current month{}:'.format(
                    chosen_filters),
                'value':
                indian_formatted_number(in_month_total)
            }, {
                'indicator':
                ('Total Number of Children who were put to the breast within one hour of birth{}:'
                 .format(chosen_filters)),
                'value':
                indian_formatted_number(birth_total)
            }, {
                'indicator':
                '% children who were put to the breast within one hour of '
                'birth{}:'.format(chosen_filters),
                'value':
                '%.2f%%' % (birth_total * 100 / float(in_month_total or 1))
            }]
        },
        "data":
        dict(data_for_map),
    }
def get_early_initiation_breastfeeding_data(domain,
                                            config,
                                            loc_level,
                                            location_id,
                                            show_test=False):
    group_by = ['%s_name' % loc_level]

    config['month'] = datetime(*config['month'])
    data = AggChildHealthMonthly.objects.filter(**config).values(
        *group_by).annotate(
            birth=Sum('bf_at_birth'),
            in_month=Sum('born_in_month'),
        ).order_by('%s_name' % loc_level)

    if not show_test:
        data = apply_exclude(domain, data)

    chart_data = {
        'blue': [],
    }

    tooltips_data = defaultdict(lambda: {
        'in_month': 0,
        'birth': 0,
    })

    loc_children = get_child_locations(domain, location_id, show_test)
    result_set = set()

    for row in data:
        in_month = row['in_month']
        name = row['%s_name' % loc_level]
        result_set.add(name)

        birth = row['birth']

        value = (birth or 0) / float(in_month or 1)

        tooltips_data[name]['birth'] += birth
        tooltips_data[name]['in_month'] += (in_month or 0)

        chart_data['blue'].append([name, value])

    for sql_location in loc_children:
        if sql_location.name not in result_set:
            chart_data['blue'].append([sql_location.name, 0])

    chart_data['blue'] = sorted(chart_data['blue'])

    return {
        "tooltips_data":
        dict(tooltips_data),
        "info":
        early_initiation_breastfeeding_help_text(html=True),
        "chart_data": [{
            "values": chart_data['blue'],
            "key": "",
            "strokeWidth": 2,
            "classed": "dashed",
            "color": MapColors.BLUE
        }]
    }
Esempio n. 10
0
def get_maternal_child_data(domain,
                            config,
                            show_test=False,
                            icds_feature_flag=False):
    def get_data_for_child_health_monthly(date, filters):

        age_filters = {
            'age_tranche': 72
        } if icds_feature_flag else {
            'age_tranche__in': [0, 6, 72]
        }

        moderately_underweight = exclude_records_by_age_for_column(
            {'age_tranche': 72}, 'nutrition_status_moderately_underweight')
        severely_underweight = exclude_records_by_age_for_column(
            {'age_tranche': 72}, 'nutrition_status_severely_underweight')
        wasting_moderate = exclude_records_by_age_for_column(
            age_filters, wasting_moderate_column(icds_feature_flag))
        wasting_severe = exclude_records_by_age_for_column(
            age_filters, wasting_severe_column(icds_feature_flag))
        stunting_moderate = exclude_records_by_age_for_column(
            age_filters, stunting_moderate_column(icds_feature_flag))
        stunting_severe = exclude_records_by_age_for_column(
            age_filters, stunting_severe_column(icds_feature_flag))
        nutrition_status_weighed = exclude_records_by_age_for_column(
            {'age_tranche': 72}, 'nutrition_status_weighed')
        height_measured_in_month = exclude_records_by_age_for_column(
            age_filters, hfa_recorded_in_month_column(icds_feature_flag))
        weighed_and_height_measured_in_month = exclude_records_by_age_for_column(
            age_filters, wfh_recorded_in_month_column(icds_feature_flag))

        queryset = AggChildHealthMonthly.objects.filter(
            month=date, **filters).values('aggregation_level').annotate(
                underweight=(Sum(moderately_underweight) +
                             Sum(severely_underweight)),
                valid=Sum(nutrition_status_weighed),
                wasting=Sum(wasting_moderate) + Sum(wasting_severe),
                stunting=Sum(stunting_moderate) + Sum(stunting_severe),
                height_measured_in_month=Sum(height_measured_in_month),
                weighed_and_height_measured_in_month=Sum(
                    weighed_and_height_measured_in_month),
                low_birth_weight=Sum('low_birth_weight_in_month'),
                bf_birth=Sum('bf_at_birth'),
                born=Sum('born_in_month'),
                weighed_and_born_in_month=Sum('weighed_and_born_in_month'),
                ebf=Sum('ebf_in_month'),
                ebf_eli=Sum('ebf_eligible'),
                cf_initiation=Sum('cf_initiation_in_month'),
                cf_initiation_eli=Sum('cf_initiation_eligible'))
        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    def get_data_for_deliveries(date, filters):
        queryset = AggCcsRecordMonthly.objects.filter(
            month=date, **filters).values('aggregation_level').annotate(
                institutional_delivery=Sum('institutional_delivery_in_month'),
                delivered=Sum('delivered_in_month'))
        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    current_month = datetime(*config['month'])
    previous_month = datetime(*config['prev_month'])
    del config['month']
    del config['prev_month']

    this_month_data = get_data_for_child_health_monthly(current_month, config)
    prev_month_data = get_data_for_child_health_monthly(previous_month, config)

    deliveries_this_month = get_data_for_deliveries(current_month, config)
    deliveries_prev_month = get_data_for_deliveries(previous_month, config)

    gender_label, age_label, chosen_filters = chosen_filters_to_labels(
        config, default_interval=default_age_interval(icds_feature_flag))

    return {
        'records':
        [[{
            'label':
            _('Underweight (Weight-for-Age)'),
            'help_text':
            underweight_children_help_text(),
            'percent':
            percent_diff('underweight', this_month_data, prev_month_data,
                         'valid'),
            'color':
            'red' if percent_diff('underweight', this_month_data,
                                  prev_month_data, 'valid') > 0 else 'green',
            'value':
            get_value(this_month_data, 'underweight'),
            'all':
            get_value(this_month_data, 'valid'),
            'format':
            'percent_and_div',
            'frequency':
            'month',
            'redirect':
            'maternal_and_child/underweight_children'
        }, {
            'label':
            _('Wasting (Weight-for-Height)'),
            'help_text':
            _(wasting_help_text(age_label)),
            'percent':
            percent_diff('wasting', this_month_data, prev_month_data,
                         'weighed_and_height_measured_in_month'),
            'color':
            'red' if percent_diff('wasting', this_month_data, prev_month_data,
                                  'weighed_and_height_measured_in_month') > 0
            else 'green',
            'value':
            get_value(this_month_data, 'wasting'),
            'all':
            get_value(this_month_data, 'weighed_and_height_measured_in_month'),
            'format':
            'percent_and_div',
            'frequency':
            'month',
            'redirect':
            'maternal_and_child/wasting'
        }],
         [{
             'label':
             _('Stunting (Height-for-Age)'),
             'help_text':
             _(stunting_help_text(age_label)),
             'percent':
             percent_diff('stunting', this_month_data, prev_month_data,
                          'height_measured_in_month'),
             'color':
             'red'
             if percent_diff('stunting', this_month_data, prev_month_data,
                             'height_measured_in_month') > 0 else 'green',
             'value':
             get_value(this_month_data, 'stunting'),
             'all':
             get_value(this_month_data, 'height_measured_in_month'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/stunting'
         }, {
             'label':
             _('Newborns with Low Birth Weight'),
             'help_text':
             _((new_born_with_low_weight_help_text(html=False))),
             'percent':
             percent_diff('low_birth_weight', this_month_data, prev_month_data,
                          'weighed_and_born_in_month'),
             'color':
             get_color_with_red_positive(
                 percent_diff('low_birth_weight', this_month_data,
                              prev_month_data, 'weighed_and_born_in_month')),
             'value':
             get_value(this_month_data, 'low_birth_weight'),
             'all':
             get_value(this_month_data, 'weighed_and_born_in_month'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/low_birth'
         }],
         [{
             'label':
             _('Early Initiation of Breastfeeding'),
             'help_text':
             early_initiation_breastfeeding_help_text(),
             'percent':
             percent_diff('bf_birth', this_month_data, prev_month_data,
                          'born'),
             'color':
             get_color_with_green_positive(
                 percent_diff('bf_birth', this_month_data, prev_month_data,
                              'born')),
             'value':
             get_value(this_month_data, 'bf_birth'),
             'all':
             get_value(this_month_data, 'born'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/early_initiation'
         }, {
             'label':
             _('Exclusive Breastfeeding'),
             'help_text':
             exclusive_breastfeeding_help_text(),
             'percent':
             percent_diff('ebf', this_month_data, prev_month_data, 'ebf_eli'),
             'color':
             get_color_with_green_positive(
                 percent_diff('ebf', this_month_data, prev_month_data,
                              'ebf_eli')),
             'value':
             get_value(this_month_data, 'ebf'),
             'all':
             get_value(this_month_data, 'ebf_eli'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/exclusive_breastfeeding'
         }],
         [{
             'label':
             _('Children initiated appropriate Complementary Feeding'),
             'help_text':
             children_initiated_appropriate_complementary_feeding_help_text(),
             'percent':
             percent_diff('cf_initiation', this_month_data, prev_month_data,
                          'cf_initiation_eli'),
             'color':
             get_color_with_green_positive(
                 percent_diff('cf_initiation', this_month_data,
                              prev_month_data, 'cf_initiation_eli')),
             'value':
             get_value(this_month_data, 'cf_initiation'),
             'all':
             get_value(this_month_data, 'cf_initiation_eli'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/children_initiated'
         }, {
             'label':
             _('Institutional Deliveries'),
             'help_text':
             institutional_deliveries_help_text(),
             'percent':
             percent_diff('institutional_delivery', deliveries_this_month,
                          deliveries_prev_month, 'delivered'),
             'color':
             get_color_with_green_positive(
                 percent_diff('institutional_delivery', deliveries_this_month,
                              deliveries_prev_month, 'delivered')),
             'value':
             get_value(deliveries_this_month, 'institutional_delivery'),
             'all':
             get_value(deliveries_this_month, 'delivered'),
             'format':
             'percent_and_div',
             'frequency':
             'month',
             'redirect':
             'maternal_and_child/institutional_deliveries'
         }]]
    }
Esempio n. 11
0
def get_early_initiation_breastfeeding_map(domain, config, loc_level, show_test=False):

    def get_data_for(filters):
        filters['month'] = datetime(*filters['month'])
        queryset = AggChildHealthMonthly.objects.filter(
            **filters
        ).values(
            '%s_name' % loc_level, '%s_map_location_name' % loc_level
        ).annotate(
            birth=Sum('bf_at_birth'),
            in_month=Sum('born_in_month'),
        ).order_by('%s_name' % loc_level, '%s_map_location_name' % loc_level)

        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    data_for_map, in_month_total, birth_total, average, total = generate_data_for_map(
        get_data_for(config),
        loc_level,
        'birth',
        'in_month',
        20,
        60
    )

    fills = OrderedDict()
    fills.update({'0%-20%': MapColors.RED})
    fills.update({'20%-60%': MapColors.ORANGE})
    fills.update({'60%-100%': MapColors.PINK})
    fills.update({'defaultFill': MapColors.GREY})

    gender_ignored, age_ignored, chosen_filters = chosen_filters_to_labels(config)

    return {
        "slug": "early_initiation",
        "label": "Percent Early Initiation of Breastfeeding{}".format(chosen_filters),
        "fills": fills,
        "rightLegend": {
            "average": average,
            "info": early_initiation_breastfeeding_help_text(html=True),
            "extended_info": [
                {
                    'indicator': 'Total Number of Children born in the given month{}:'.format(chosen_filters),
                    'value': indian_formatted_number(in_month_total)
                },
                {
                    'indicator': (
                        'Total Number of Children who were put to the breast within one hour of birth{}:'
                        .format(chosen_filters)
                    ),
                    'value': indian_formatted_number(birth_total)
                },
                {
                    'indicator': '% children who were put to the breast within one hour of '
                                 'birth{}:'.format(chosen_filters),
                    'value': '%.2f%%' % (birth_total * 100 / float(in_month_total or 1))
                }
            ]
        },
        "data": dict(data_for_map),
    }
Esempio n. 12
0
def get_early_initiation_breastfeeding_data(domain, config, loc_level, location_id, show_test=False):
    group_by = ['%s_name' % loc_level]

    config['month'] = datetime(*config['month'])
    data = AggChildHealthMonthly.objects.filter(
        **config
    ).values(
        *group_by
    ).annotate(
        birth=Sum('bf_at_birth'),
        in_month=Sum('born_in_month'),
    ).order_by('%s_name' % loc_level)

    if not show_test:
        data = apply_exclude(domain, data)

    chart_data = {
        'blue': [],
    }

    tooltips_data = defaultdict(lambda: {
        'in_month': 0,
        'birth': 0,
    })

    loc_children = get_child_locations(domain, location_id, show_test)
    result_set = set()

    for row in data:
        in_month = row['in_month']
        name = row['%s_name' % loc_level]
        result_set.add(name)

        birth = row['birth']

        value = (birth or 0) / float(in_month or 1)

        tooltips_data[name]['birth'] += birth
        tooltips_data[name]['in_month'] += (in_month or 0)

        chart_data['blue'].append([
            name, value
        ])

    for sql_location in loc_children:
        if sql_location.name not in result_set:
            chart_data['blue'].append([sql_location.name, 0])

    chart_data['blue'] = sorted(chart_data['blue'])

    return {
        "tooltips_data": dict(tooltips_data),
        "info": early_initiation_breastfeeding_help_text(html=True),
        "chart_data": [
            {
                "values": chart_data['blue'],
                "key": "",
                "strokeWidth": 2,
                "classed": "dashed",
                "color": MapColors.BLUE
            }
        ]
    }
Esempio n. 13
0
def get_maternal_child_data(domain, config, show_test=False, icds_feature_flag=False):

    def get_data_for_child_health_monthly(date, filters):

        age_filters = {'age_tranche': 72} if icds_feature_flag else {'age_tranche__in': [0, 6, 72]}

        moderately_underweight = exclude_records_by_age_for_column(
            {'age_tranche': 72},
            'nutrition_status_moderately_underweight'
        )
        severely_underweight = exclude_records_by_age_for_column(
            {'age_tranche': 72},
            'nutrition_status_severely_underweight'
        )
        wasting_moderate = exclude_records_by_age_for_column(
            age_filters,
            wasting_moderate_column(icds_feature_flag)
        )
        wasting_severe = exclude_records_by_age_for_column(
            age_filters,
            wasting_severe_column(icds_feature_flag)
        )
        stunting_moderate = exclude_records_by_age_for_column(
            age_filters,
            stunting_moderate_column(icds_feature_flag)
        )
        stunting_severe = exclude_records_by_age_for_column(
            age_filters,
            stunting_severe_column(icds_feature_flag)
        )
        nutrition_status_weighed = exclude_records_by_age_for_column(
            {'age_tranche': 72},
            'nutrition_status_weighed'
        )
        height_measured_in_month = exclude_records_by_age_for_column(
            age_filters,
            hfa_recorded_in_month_column(icds_feature_flag)
        )
        weighed_and_height_measured_in_month = exclude_records_by_age_for_column(
            age_filters,
            wfh_recorded_in_month_column(icds_feature_flag)
        )

        queryset = AggChildHealthMonthly.objects.filter(
            month=date, **filters
        ).values(
            'aggregation_level'
        ).annotate(
            underweight=(
                Sum(moderately_underweight) + Sum(severely_underweight)
            ),
            valid=Sum(nutrition_status_weighed),
            wasting=Sum(wasting_moderate) + Sum(wasting_severe),
            stunting=Sum(stunting_moderate) + Sum(stunting_severe),
            height_measured_in_month=Sum(height_measured_in_month),
            weighed_and_height_measured_in_month=Sum(weighed_and_height_measured_in_month),
            low_birth_weight=Sum('low_birth_weight_in_month'),
            bf_birth=Sum('bf_at_birth'),
            born=Sum('born_in_month'),
            weighed_and_born_in_month=Sum('weighed_and_born_in_month'),
            ebf=Sum('ebf_in_month'),
            ebf_eli=Sum('ebf_eligible'),
            cf_initiation=Sum('cf_initiation_in_month'),
            cf_initiation_eli=Sum('cf_initiation_eligible')
        )
        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    def get_data_for_deliveries(date, filters):
        queryset = AggCcsRecordMonthly.objects.filter(
            month=date, **filters
        ).values(
            'aggregation_level'
        ).annotate(
            institutional_delivery=Sum('institutional_delivery_in_month'),
            delivered=Sum('delivered_in_month')
        )
        if not show_test:
            queryset = apply_exclude(domain, queryset)
        return queryset

    current_month = datetime(*config['month'])
    previous_month = datetime(*config['prev_month'])
    del config['month']
    del config['prev_month']

    this_month_data = get_data_for_child_health_monthly(current_month, config)
    prev_month_data = get_data_for_child_health_monthly(previous_month, config)

    deliveries_this_month = get_data_for_deliveries(current_month, config)
    deliveries_prev_month = get_data_for_deliveries(previous_month, config)

    gender_label, age_label, chosen_filters = chosen_filters_to_labels(
        config,
        default_interval=default_age_interval(icds_feature_flag)
    )

    return {
        'records': [
            [
                {
                    'label': _('Underweight (Weight-for-Age)'),
                    'help_text': underweight_children_help_text(),
                    'percent': percent_diff(
                        'underweight',
                        this_month_data,
                        prev_month_data,
                        'valid'
                    ),
                    'color': 'red' if percent_diff(
                        'underweight',
                        this_month_data,
                        prev_month_data,
                        'valid'
                    ) > 0 else 'green',
                    'value': get_value(this_month_data, 'underweight'),
                    'all': get_value(this_month_data, 'valid'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/underweight_children'
                },
                {
                    'label': _('Wasting (Weight-for-Height)'),
                    'help_text': _(wasting_help_text(age_label)),
                    'percent': percent_diff(
                        'wasting',
                        this_month_data,
                        prev_month_data,
                        'weighed_and_height_measured_in_month'
                    ),
                    'color': 'red' if percent_diff(
                        'wasting',
                        this_month_data,
                        prev_month_data,
                        'weighed_and_height_measured_in_month'
                    ) > 0 else 'green',
                    'value': get_value(this_month_data, 'wasting'),
                    'all': get_value(this_month_data, 'weighed_and_height_measured_in_month'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/wasting'
                }
            ],
            [
                {
                    'label': _('Stunting (Height-for-Age)'),
                    'help_text': _(stunting_help_text(age_label)),
                    'percent': percent_diff(
                        'stunting',
                        this_month_data,
                        prev_month_data,
                        'height_measured_in_month'
                    ),
                    'color': 'red' if percent_diff(
                        'stunting',
                        this_month_data,
                        prev_month_data,
                        'height_measured_in_month'
                    ) > 0 else 'green',
                    'value': get_value(this_month_data, 'stunting'),
                    'all': get_value(this_month_data, 'height_measured_in_month'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/stunting'
                },
                {
                    'label': _('Newborns with Low Birth Weight'),
                    'help_text': _((
                        new_born_with_low_weight_help_text(html=False)
                    )),
                    'percent': percent_diff(
                        'low_birth_weight',
                        this_month_data,
                        prev_month_data,
                        'weighed_and_born_in_month'
                    ),
                    'color': 'red' if percent_diff(
                        'low_birth_weight',
                        this_month_data,
                        prev_month_data,
                        'weighed_and_born_in_month'
                    ) > 0 else 'green',
                    'value': get_value(this_month_data, 'low_birth_weight'),
                    'all': get_value(this_month_data, 'weighed_and_born_in_month'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/low_birth'
                }
            ],
            [
                {
                    'label': _('Early Initiation of Breastfeeding'),
                    'help_text': early_initiation_breastfeeding_help_text(),
                    'percent': percent_diff(
                        'bf_birth',
                        this_month_data,
                        prev_month_data,
                        'born'
                    ),
                    'color': 'green' if percent_diff(
                        'bf_birth',
                        this_month_data,
                        prev_month_data,
                        'born'
                    ) > 0 else 'red',
                    'value': get_value(this_month_data, 'bf_birth'),
                    'all': get_value(this_month_data, 'born'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/early_initiation'
                },
                {
                    'label': _('Exclusive Breastfeeding'),
                    'help_text': exclusive_breastfeeding_help_text(),
                    'percent': percent_diff(
                        'ebf',
                        this_month_data,
                        prev_month_data,
                        'ebf_eli'
                    ),
                    'color': 'green' if percent_diff(
                        'ebf',
                        this_month_data,
                        prev_month_data,
                        'ebf_eli'
                    ) > 0 else 'red',
                    'value': get_value(this_month_data, 'ebf'),
                    'all': get_value(this_month_data, 'ebf_eli'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/exclusive_breastfeeding'
                }
            ],
            [
                {
                    'label': _('Children initiated appropriate Complementary Feeding'),
                    'help_text': children_initiated_appropriate_complementary_feeding_help_text(),
                    'percent': percent_diff(
                        'cf_initiation',
                        this_month_data,
                        prev_month_data,
                        'cf_initiation_eli'
                    ),
                    'color': 'green' if percent_diff(
                        'cf_initiation',
                        this_month_data,
                        prev_month_data,
                        'cf_initiation_eli'
                    ) > 0 else 'red',
                    'value': get_value(this_month_data, 'cf_initiation'),
                    'all': get_value(this_month_data, 'cf_initiation_eli'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/children_initiated'
                },
                {
                    'label': _('Institutional Deliveries'),
                    'help_text': institutional_deliveries_help_text(),
                    'percent': percent_diff(
                        'institutional_delivery',
                        deliveries_this_month,
                        deliveries_prev_month,
                        'delivered'
                    ),
                    'color': 'green' if percent_diff(
                        'institutional_delivery',
                        deliveries_this_month,
                        deliveries_prev_month,
                        'delivered'
                    ) > 0 else 'red',
                    'value': get_value(deliveries_this_month, 'institutional_delivery'),
                    'all': get_value(deliveries_this_month, 'delivered'),
                    'format': 'percent_and_div',
                    'frequency': 'month',
                    'redirect': 'maternal_and_child/institutional_deliveries'
                }
            ]
        ]
    }