Exemplo n.º 1
0
def get_age_filters(beta):
    if beta:
        return [NOT(EQ('age_tranche', 'age_72'))]
    return [
        AND([
            NOT(EQ('age_tranche', 'age_0')),
            NOT(EQ('age_tranche', 'age_6')),
            NOT(EQ('age_tranche', 'age_72'))
        ])
    ]
Exemplo n.º 2
0
 def filters(self):
     filters = [
         EQ('xmlns', 'xmlns'),
         NOT(EQ('date_last_vl_test', 'empty_date_last_vl_test'))
     ]
     if 'hiv_status' in self.config and self.config['hiv_status']:
         filters.append(EQ('hiv_status', 'hiv_status'))
     if 'client_type' in self.config and self.config['client_type']:
         filters.append(EQ('client_type', 'client_type'))
     if 'age_range' in self.config and self.config['age_range']:
         filters.append(EQ('age_range', 'age_range'))
     if 'district' in self.config and self.config['district']:
         filters.append(EQ('district', 'district'))
     if ('date_last_vl_test_start' in self.config
             and self.config['date_last_vl_test_start']
             and 'date_last_vl_test_end' in self.config
             and self.config['date_last_vl_test_end']):
         filters.append(
             BETWEEN('date_last_vl_test', 'date_last_vl_test_start',
                     'date_last_vl_test_end'))
     if 'undetect_vl' in self.config and self.config['undetect_vl']:
         filters.append(EQ('undetect_vl', 'undetect_vl'))
     if 'user_id' in self.config and self.config['user_id']:
         filters.append(
             IN('user_id',
                get_INFilter_bindparams('user_id', self.config['user_id'])))
     if 'organization' in self.config and self.config['organization']:
         filters.append(EQ('organization', 'organization'))
     return filters
 def filters(self):
     filters = super(AggChildHealthMonthlyDataSource, self).filters
     if not self.show_test:
         filters.append(NOT(IN('state_id', get_INFilter_bindparams('excluded_states', self.excluded_states))))
     if 'month' in self.config and self.config['month']:
         filters.append(BETWEEN('month', 'two_before', 'month'))
     return filters
Exemplo n.º 4
0
 def filters(self):
     filters = [
         EQ('aggregation_level', 'aggregation_level'),
         EQ('month', 'previous_month')
     ]
     if not self.show_test:
         filters.append(NOT(IN('state_id', get_INFilter_bindparams('excluded_states', self.excluded_states))))
     return filters
Exemplo n.º 5
0
 def filters(self):
     filters = super(PPSAvecDonnees, self).filters
     filters.append(
         AND([
             GTE('real_date_repeat', "strsd"),
             LTE('real_date_repeat', "stred")
         ]))
     if 'archived_locations' in self.config:
         filters.append(NOT(IN('location_id', 'archived_locations')))
     return filters[1:]
 def filters(self):
     filters = super(AggCCSRecordMonthlyDataSource, self).filters
     if not self.show_test:
         filters.append(
             NOT(
                 IN(
                     'state_id',
                     get_INFilter_bindparams('excluded_states',
                                             self.excluded_states))))
     if 'month' in self.config and self.config['month']:
         filters.append(EQ('month', 'month'))
     return filters
Exemplo n.º 7
0
 def filters(self):
     #We have to filter data by real_date_repeat not date(first position in filters list).
     #Filtering is done directly in columns method(CountUniqueColumn).
     filters = super(ConventureData, self).filters
     filters.append(
         AND([
             GTE('real_date_repeat', "strsd"),
             LTE('real_date_repeat', "stred")
         ]))
     if 'archived_locations' in self.config:
         filters.append(NOT(IN('location_id', 'archived_locations')))
     return filters[1:]
Exemplo n.º 8
0
    def filters(self):
        filters = []
        infilter_params = get_INFilter_bindparams('excluded_states', self.excluded_states)

        if not self.show_test:
            filters.append(NOT(IN('state_id', infilter_params)))

        for key, value in six.iteritems(self.config):
            if key == 'domain' or key in infilter_params or 'age' in key:
                continue
            filters.append(EQ(key, key))
        return filters
Exemplo n.º 9
0
 def filters(self):
     filters = [
         EQ('xmlns', 'xmlns'),
         NOT(EQ('first_art_date', 'empty_first_art_date'))
     ]
     if 'hiv_status' in self.config and self.config['hiv_status']:
         filters.append(
             IN(
                 'hiv_status',
                 get_INFilter_bindparams('hiv_status',
                                         self.config['hiv_status'])))
     if 'client_type' in self.config and self.config['client_type']:
         filters.append(
             IN(
                 'client_type',
                 get_INFilter_bindparams('client_type',
                                         self.config['client_type'])))
     if 'age_range' in self.config and self.config['age_range']:
         filters.append(
             IN(
                 'age_range',
                 get_INFilter_bindparams('age_range',
                                         self.config['age_range'])))
     if 'district' in self.config and self.config['district']:
         filters.append(
             IN(
                 'district',
                 get_INFilter_bindparams('district',
                                         self.config['district'])))
     if ('first_art_date_start' in self.config
             and self.config['first_art_date_start']
             and 'first_art_date_end' in self.config
             and self.config['first_art_date_end']):
         filters.append(
             BETWEEN('first_art_date', 'first_art_date_start',
                     'first_art_date_end'))
     if 'user_id' in self.config and self.config['user_id']:
         filters.append(
             IN('user_id',
                get_INFilter_bindparams('user_id', self.config['user_id'])))
     return filters
 def get_columns(self, filters):
     return [
         DatabaseColumn('month', SimpleColumn('month')),
         AggregateColumn(
             '% Weighing efficiency (Children <5 weighed)',
             percent_num, [
                 SumColumn(
                     'nutrition_status_weighed',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))]),
                 SumColumn(
                     'wer_eligible',
                     alias='wer_eligible',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))])
             ],
             slug='status_weighed'),
         AggregateColumn(
             '% Height measurement efficiency (Children <5 measured)',
             percent_num, [
                 SumColumn(
                     'height_measured_in_month',
                     alias='height_measured_in_month_less_5',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))]),
                 SumColumn(
                     'height_eligible',
                     alias='height_eligible',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))])
             ],
             slug='status_height_efficiency'),
         DatabaseColumn(
             'Total number Unweighed',
             SumColumn('nutrition_status_unweighed',
                       filters=filters +
                       [NOT(EQ('age_tranche', 'age_72'))])),
         AggregateColumn(
             'Percent Children severely underweight (weight for age)',
             percent_num, [
                 SumColumn(
                     'nutrition_status_severely_underweight',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))]),
                 AliasColumn('nutrition_status_weighed')
             ],
             slug='severely_underweight'),
         AggregateColumn(
             'Percent Children moderately underweight (weight for age)',
             percent_num, [
                 SumColumn(
                     'nutrition_status_moderately_underweight',
                     filters=filters + [NOT(EQ('age_tranche', 'age_72'))]),
                 AliasColumn('nutrition_status_weighed')
             ],
             slug='moderately_underweight'),
         AggregateColumn('Percent Children normal (weight for age)',
                         percent_num, [
                             SumColumn('nutrition_status_normal',
                                       filters=filters +
                                       [NOT(EQ('age_tranche', 'age_72'))]),
                             AliasColumn('nutrition_status_weighed')
                         ],
                         slug='status_normal'),
         AggregateColumn(
             'Percent children with severe acute malnutrition (weight-for-height)',
             percent_num, [
                 SumColumn(wasting_severe_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 SumColumn(wfh_recorded_in_month_column(self.beta),
                           alias='weighed_and_height_measured_in_month',
                           filters=filters + get_age_filters(self.beta))
             ],
             slug='wasting_severe'),
         AggregateColumn(
             'Percent children with moderate acute malnutrition (weight-for-height)',
             percent_num, [
                 SumColumn(wasting_moderate_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 AliasColumn('weighed_and_height_measured_in_month')
             ],
             slug='wasting_moderate'),
         AggregateColumn(
             'Percent children normal (weight-for-height)',
             percent_num, [
                 SumColumn(wasting_normal_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 AliasColumn('weighed_and_height_measured_in_month')
             ],
             slug='wasting_normal'),
         AggregateColumn(
             'Percent children with severe stunting (height for age)',
             percent_num, [
                 SumColumn(stunting_severe_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 SumColumn(hfa_recorded_in_month_column(self.beta),
                           alias='height_measured_in_month',
                           filters=filters + get_age_filters(self.beta))
             ],
             slug='stunting_severe'),
         AggregateColumn(
             'Percent children with moderate stunting (height for age)',
             percent_num, [
                 SumColumn(stunting_moderate_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 AliasColumn('height_measured_in_month')
             ],
             slug='stunting_moderate'),
         AggregateColumn(
             'Percent children with normal (height for age)',
             percent_num, [
                 SumColumn(stunting_normal_column(self.beta),
                           filters=filters + get_age_filters(self.beta)),
                 AliasColumn('height_measured_in_month')
             ],
             slug='stunting_normal'),
         AggregateColumn(
             'Percent children immunized with 1st year immunizations',
             lambda x, y, z: ((x or 0) + (y or 0)) * 100 / float(z or 1), [
                 SumColumn('fully_immunized_on_time'),
                 SumColumn('fully_immunized_late'),
                 SumColumn('fully_immunized_eligible')
             ],
             slug='fully_immunized'),
         AggregateColumn(
             'Percent Children breastfed at birth',
             percent_num,
             [SumColumn('bf_at_birth'),
              SumColumn('born_in_month')],
             slug='breastfed_at_birth'),
         AggregateColumn(
             'Percent Children exclusively breastfed',
             percent_num,
             [SumColumn('ebf_in_month'),
              SumColumn('ebf_eligible')],
             slug='exclusively_breastfed'),
         AggregateColumn(
             'Percent Children initiated appropriate complementary feeding',
             percent_num, [
                 SumColumn('cf_initiation_in_month'),
                 SumColumn('cf_initiation_eligible')
             ],
             slug='cf_initiation'),
         AggregateColumn(
             'Perecent children complementary feeding',
             percent_num,
             [SumColumn('cf_in_month'),
              SumColumn('cf_eligible')],
             slug='complementary_feeding'),
         AggregateColumn(
             'Percentage of children consuming atleast 4 food groups',
             percent_num,
             [SumColumn('cf_diet_diversity'),
              AliasColumn('cf_eligible')],
             slug='diet_diversity'),
         AggregateColumn(
             'Percentage of children consuming adequate food',
             percent_num,
             [SumColumn('cf_diet_quantity'),
              AliasColumn('cf_eligible')],
             slug='diet_quantity'),
         AggregateColumn(
             'Percentage of children whose mothers handwash before feeding',
             percent_num,
             [SumColumn('cf_handwashing'),
              AliasColumn('cf_eligible')],
             slug='handwashing'),
         DatabaseColumn('Children (0 - 28 Days) Seeking Services',
                        SumColumn('valid_in_month',
                                  filters=filters +
                                  [EQ('age_tranche', 'age_0')],
                                  alias='zero'),
                        slug='zero'),
         DatabaseColumn('Children (28 Days - 6 mo) Seeking Services',
                        SumColumn('valid_in_month',
                                  filters=filters +
                                  [EQ('age_tranche', 'age_6')],
                                  alias='one'),
                        slug='one'),
         DatabaseColumn('Children (6 mo - 1 year) Seeking Services',
                        SumColumn('valid_in_month',
                                  filters=filters +
                                  [EQ('age_tranche', 'age_12')],
                                  alias='two'),
                        slug='two'),
         DatabaseColumn('Children (1 year - 3 years) Seeking Services',
                        SumColumn('valid_in_month',
                                  filters=filters + [
                                      OR([
                                          EQ('age_tranche', 'age_24'),
                                          EQ('age_tranche', 'age_36')
                                      ])
                                  ],
                                  alias='three'),
                        slug='three'),
         DatabaseColumn('Children (3 years - 6 years) Seeking Services',
                        SumColumn('valid_in_month',
                                  filters=filters + [
                                      OR([
                                          EQ('age_tranche', 'age_48'),
                                          EQ('age_tranche', 'age_60'),
                                          EQ('age_tranche', 'age_72')
                                      ])
                                  ],
                                  alias='four'),
                        slug='four'),
         AggregateColumn(
             'Percent of children born in month with low birth weight',
             percent_num, [
                 SumColumn('low_birth_weight_in_month'),
                 SumColumn('weighed_and_born_in_month')
             ],
             slug='low_birth_weight')
     ]
Exemplo n.º 11
0
def get_age_filters(beta):
    return [
        NOT(EQ('age_tranche', 'age_72'))
    ]
Exemplo n.º 12
0
 def filters(self):
     filters = super(RecapPassageData, self).filters
     if 'location_id' in self.config:
         filters.append(EQ("location_id", "location_id"))
     filters.append(NOT(EQ('product_id', 'empty_prd_code')))
     return filters
Exemplo n.º 13
0
 def filters(self):
     filters = super(DateSource, self).filters
     if 'location_id' in self.config:
         filters.append(EQ('location_id', 'location_id'))
     filters.append(NOT(EQ('product_id', 'empty_prd_code')))
     return filters
Exemplo n.º 14
0
def _locations_filter(archived_locations):
    return NOT(
        IN('location_id',
           get_INFilter_bindparams('archived_locations', archived_locations)))
Exemplo n.º 15
0
 def columns(self):
     columns = self.get_columns_by_loc_level
     agg_columns = [
         AggregateColumn('Weighing efficiency (in month)',
                         percent, [
                             SumColumn('nutrition_status_weighed',
                                       filters=self.filters +
                                       [NOT(EQ('age_tranche', 'age_72'))]),
                             SumColumn('wer_eligible',
                                       filters=self.filters +
                                       [NOT(EQ('age_tranche', 'age_72'))])
                         ],
                         slug='percent_weight_efficiency'),
         AggregateColumn(
             'Height measurement efficiency (in month)',
             percent, [
                 SumColumn('height_measured_in_month',
                           alias='height_measured_in_month_all'),
                 SumColumn('height_eligible',
                           filters=self.filters + [
                               AND([
                                   NOT(EQ('age_tranche', 'age_0')),
                                   NOT(EQ('age_tranche', 'age_6')),
                                   NOT(EQ('age_tranche', 'age_72'))
                               ])
                           ])
             ],
             slug='height_measurement'),
         DatabaseColumn('Total number of unweighed children (0-5 Years)',
                        SumColumn('nutrition_status_unweighed',
                                  filters=self.filters +
                                  [NOT(EQ('age_tranche', 'age_72'))]),
                        slug='total_number_unweighed'),
         AggregateColumn(
             'Percentage of severely underweight children',
             percent, [
                 SumColumn('nutrition_status_severely_underweight',
                           filters=self.filters +
                           [NOT(EQ('age_tranche', 'age_72'))]),
                 SumColumn('nutrition_status_weighed',
                           filters=self.filters +
                           [NOT(EQ('age_tranche', 'age_72'))]),
             ],
             slug='percent_severe_underweight'),
         AggregateColumn(
             'Percentage of moderately underweight children',
             percent, [
                 SumColumn('nutrition_status_moderately_underweight',
                           filters=self.filters +
                           [NOT(EQ('age_tranche', 'age_72'))]),
                 SumColumn('nutrition_status_weighed',
                           filters=self.filters +
                           [NOT(EQ('age_tranche', 'age_72'))]),
             ],
             slug='percent_moderate_underweight'),
         AggregateColumn('Percentage of normal weight-for-age children',
                         percent, [
                             SumColumn('nutrition_status_normal',
                                       filters=self.filters +
                                       [NOT(EQ('age_tranche', 'age_72'))]),
                             SumColumn('nutrition_status_weighed',
                                       filters=self.filters +
                                       [NOT(EQ('age_tranche', 'age_72'))]),
                         ],
                         slug='percent_normal_weight'),
         AggregateColumn(
             'Percentage of children with severe wasting',
             percent, [
                 SumColumn(
                     wasting_severe_column(self.beta),
                     filters=self.filters + get_age_filters(self.beta)),
                 SumColumn(
                     'weighed_and_height_measured_in_month',
                     alias='weighed_and_height_measured_in_month',
                     filters=self.filters + get_age_filters(self.beta))
             ],
             slug='percent_severe_wasting'),
         AggregateColumn(
             'Percentage of children with moderate wasting',
             percent, [
                 SumColumn(
                     wasting_moderate_column(self.beta),
                     filters=self.filters + get_age_filters(self.beta)),
                 AliasColumn('weighed_and_height_measured_in_month')
             ],
             slug='percent_moderate_wasting'),
         AggregateColumn(
             'Percentage of children with normal weight-for-height',
             percent, [
                 SumColumn(
                     wasting_normal_column(self.beta),
                     filters=self.filters + get_age_filters(self.beta)),
                 AliasColumn('weighed_and_height_measured_in_month')
             ],
             slug='percent_normal_wasting'),
         AggregateColumn(
             'Percentage of children with severe stunting',
             percent, [
                 SumColumn(
                     stunting_severe_column(self.beta),
                     filters=self.filters + get_age_filters(self.beta)),
                 SumColumn(
                     'height_measured_in_month',
                     alias='height_measured_in_month',
                     filters=self.filters + get_age_filters(self.beta))
             ],
             slug='percent_severe_stunting'),
         AggregateColumn('Percentage of children with moderate stunting',
                         percent, [
                             SumColumn(stunting_moderate_column(self.beta),
                                       filters=self.filters +
                                       get_age_filters(self.beta)),
                             AliasColumn('height_measured_in_month')
                         ],
                         slug='percent_moderate_stunting'),
         AggregateColumn(
             'Percentage of children with normal height-for-age',
             percent, [
                 SumColumn(
                     stunting_normal_column(self.beta),
                     filters=self.filters + get_age_filters(self.beta)),
                 AliasColumn('height_measured_in_month')
             ],
             slug='percent_normal_stunting'),
         AggregateColumn('Percent of newborns with low birth weight',
                         percent, [
                             SumColumn('low_birth_weight_in_month'),
                             SumColumn('weighed_and_born_in_month')
                         ],
                         slug='newborn_low_birth_weight'),
         AggregateColumn(
             'Percentage of children with completed 1 year immunizations',
             lambda x, y, z: '%.2f%%' % ((
                 (x or 0) + (y or 0)) * 100 / float(z or 1)), [
                     SumColumn('fully_immunized_on_time'),
                     SumColumn('fully_immunized_late'),
                     SumColumn('fully_immunized_eligible')
                 ],
             slug='percent_completed_1year_immunizations'),
         AggregateColumn(
             'Percentage of children breastfed at birth',
             percent,
             [SumColumn('bf_at_birth'),
              SumColumn('born_in_month')],
             slug='percent_breastfed_at_birth'),
         AggregateColumn(
             'Percentage of children exclusively breastfeeding',
             percent,
             [SumColumn('ebf_in_month'),
              SumColumn('ebf_eligible')],
             slug='percent_ebf'),
         AggregateColumn(
             'Percentage of children initiated complementary feeding (in the past 30 days)',
             percent, [
                 SumColumn('cf_initiation_in_month'),
                 SumColumn('cf_initiation_eligible')
             ],
             slug='percent_initiated_on_cf'),
         AggregateColumn(
             'Percentage of children initiated appropriate complementary feeding',
             percent, [SumColumn('cf_in_month'),
                       SumColumn('cf_eligible')],
             slug='percent_appropriate_cf'),
         AggregateColumn(
             'Percentage of children receiving complementary feeding with adequate diet diversity',
             percent,
             [SumColumn('cf_diet_diversity'),
              AliasColumn('cf_eligible')],
             slug='percent_cf_diet_diversity'),
         AggregateColumn(
             'Percentage of children receiving complementary feeding with adequate diet quanity',
             percent,
             [SumColumn('cf_diet_quantity'),
              AliasColumn('cf_eligible')],
             slug='percent_cf_diet_quanity'),
         AggregateColumn(
             "Percentage of children receiving complementary feeding "
             "with appropriate handwashing before feeding",
             percent,
             [SumColumn('cf_handwashing'),
              AliasColumn('cf_eligible')],
             slug='percent_cf_handwashing_before_feeding'),
     ]
     return columns + agg_columns
Exemplo n.º 16
0
 def filters(self):
     filter = super(TauxDeRuptures, self).filters
     filter.append("total_stock_total = 0")
     if 'archived_locations' in self.config:
         filter.append(NOT(IN('location_id', 'archived_locations')))
     return filter
Exemplo n.º 17
0
 def filters(self):
     filters = super(NombreData, self).filters
     if 'archived_locations' in self.config:
         filters.append(NOT(IN('location_id', 'archived_locations')))
     return filters