def columns(self): registered_column = "registered_total_for_region" if 'district_id' in self.config: registered_column = 'registered_total_for_district' columns = [ DatabaseColumn( "No de PPS (number of PPS registered in that region)", MaxColumn(registered_column, alias='registered')), DatabaseColumn("No de PPS planifie (number of PPS planned)", MaxColumn('planned_total')), DatabaseColumn( "No de PPS avec livrasion cet mois (number of PPS visited this month)", CountUniqueColumn( 'location_id', alias="visited", )), AggregateColumn( "Taux de couverture (coverage ratio)", self.percent_fn, [AliasColumn('registered'), AliasColumn("visited")]), DatabaseColumn( "No de PPS avec donnees soumises (number of PPS which submitted data)", CountUniqueColumn( 'location_id', alias="submitted", )), AggregateColumn("Exhaustivite des donnees", self.percent_fn, [AliasColumn('visited'), AliasColumn('submitted')]), ] if self.config['startdate'].month != self.config['enddate'].month: columns.insert(0, DatabaseColumn('Mois', SimpleColumn('month'))) self.show_total = True return columns
def columns(self): case_table_name = '%s%s_%s' % (TABLE_PREFIX, self.domain.name, MAPPING_NAME_CASES) case_ownership_table_name = '%s%s_%s' % ( TABLE_PREFIX, self.domain.name, MAPPING_NAME_CASE_OWNERSHIP) case_type_filters = [filters.NOTEQ('case_type', 'ccCaseType')] columns = [ DatabaseColumn("case", SimpleColumn('user_id'), format_fn=self.get_user_case_id, sortable=False), DatabaseColumn('formsSubmittedWeek0', CountColumn('date', alias='formsSubmittedWeek0'), sortable=False), DatabaseColumn('formsSubmittedWeek1', CountColumn('date', filters=filters_week1, alias='formsSubmittedWeek1'), sortable=False), DatabaseColumn('formsSubmittedMonth0', CountColumn('date', filters=filters_month0, alias='formsSubmittedMonth0'), sortable=False), DatabaseColumn('casesUpdatedMonth0', CountUniqueColumn('case_id', table_name=case_table_name, filters=filters_month0 + case_type_filters, alias='casesUpdatedMonth0'), sortable=False), DatabaseColumn('casesUpdatedMonth1', CountUniqueColumn('case_id', table_name=case_table_name, filters=filters_month1 + case_type_filters, alias='casesUpdatedMonth1'), sortable=False), DatabaseColumn('totalCases', SumColumn('open_cases', table_name=case_ownership_table_name, filters=case_type_filters, alias='totalCases'), sortable=False) ] columns.extend(self._get_custom_columns()) return columns
def columns(self): registered_column = "registered_total_for_region" if 'district_id' in self.config: registered_column = 'registered_total_for_district' return [ DatabaseColumn( "No de PPS (number of PPS registered in that region)", MaxColumn(registered_column, alias='registered')), DatabaseColumn("No de PPS planifie (number of PPS planned)", MaxColumn('planned_total')), DatabaseColumn( "No de PPS avec livrasion cet mois (number of PPS visited this month)", CountUniqueColumn('location_id', alias="visited", filters=self.filters + [ AND([ GTE('real_date_repeat', "strsd"), LTE('real_date_repeat', "stred") ]) ])), AggregateColumn( "Taux de couverture (coverage ratio)", self.percent_fn, [AliasColumn('registered'), AliasColumn("visited")]), DatabaseColumn( "No de PPS avec donnees soumises (number of PPS which submitted data)", CountUniqueColumn('location_id', alias="submitted", filters=self.filters + [ AND([ GTE('real_date_repeat', "strsd"), LTE('real_date_repeat', "stred") ]) ])), AggregateColumn("Exhaustivite des donnees", self.percent_fn, [AliasColumn('visited'), AliasColumn('submitted')]), ]
def columns(self): return [DatabaseColumn('last_vl_test', CountUniqueColumn('uic'))]
def columns(self): return [DatabaseColumn('first_art', CountUniqueColumn('uic'))]
def columns(self): return [DatabaseColumn('form_completion', CountUniqueColumn('uic'))]
def columns(self): return [ DatabaseColumn('positive_hiv_status', CountUniqueColumn('uic')) ]
def columns(self): return [DatabaseColumn('count_uic', CountUniqueColumn('uic'))]
def columns(self): return [ DatabaseColumn( _("Total number of ASHAs under the Facilitator"), CountUniqueColumn( "case_id", filters=[ EQ('owner_id', 'af'), OR([ISNULL('closed_on'), GTE('closed_on', 'enddate')]), LTE('registration_date', 'enddate') ], alias="total_ashas" ) ), DatabaseColumn( _("Total number of ASHAs for whom functionality checklist was filled"), CountUniqueColumn( "case_id", filters=[ EQ('owner_id', 'af'), EQ('is_checklist', 'is_checklist'), BETWEEN('date', 'startdate', 'enddate') ], alias="total_ashas_checklist" ) ), DatabaseColumn( _("Newborn visits within first day of birth in case of home deliveries"), FunctionalityChecklistColumn('hv_fx_home_birth_visits', whens={1: 1}), ), DatabaseColumn( _("Set of home visits for newborn care as specified in the HBNC guidelines<br/>" "(six visits in case of Institutional delivery and seven in case of a home delivery)"), FunctionalityChecklistColumn('hv_fx_newborns_visited', whens={1: 1}), ), DatabaseColumn( _("Attending VHNDs/Promoting immunization"), FunctionalityChecklistColumn('hv_fx_vhnd', whens={1: 1}), ), DatabaseColumn( _("Supporting institutional delivery"), FunctionalityChecklistColumn('hv_fx_support_inst_delivery', whens={1: 1}), ), DatabaseColumn( _("Management of childhood illness - especially diarrhea and pneumonia"), FunctionalityChecklistColumn('hv_fx_child_illness_mgmt', whens={1: 1}), ), DatabaseColumn( _("Household visits with nutrition counseling"), FunctionalityChecklistColumn('hv_fx_nut_counseling', whens={1: 1}), ), DatabaseColumn( _("Fever cases seen/malaria slides made in malaria endemic area"), FunctionalityChecklistColumn('hv_fx_malaria', whens={1: 1}), ), DatabaseColumn( _("Acting as DOTS provider"), FunctionalityChecklistColumn('hv_fx_dots', whens={1: 1}), ), DatabaseColumn( _("Holding or attending village/VHSNC meeting"), FunctionalityChecklistColumn('hv_fx_vhsnc', whens={1: 1}), ), DatabaseColumn( _("Successful referral of the IUD, " "female sterilization or male sterilization cases and/or providing OCPs/Condoms"), FunctionalityChecklistColumn('hv_fx_fp', whens={1: 1}), ), AggregateColumn( _("<b>Total number of ASHAs who are functional on at least %s of the tasks</b>") % "60%", aggregate_fn=lambda x, y: { 'sort_key': ((x or 0) * 100 / (y or 1)), 'html': '{0}/{1} ({2}%)'.format((x or 0), y, ((x or 0) * 100 // (y or 1))) }, columns=[ FunctionalityChecklistColumn( whens={'hv_percent_functionality >= 60': 1}, alias='percent_functionality'), AliasColumn('total_ashas_checklist') ], format_fn=lambda x: x ), ]
def columns(self): return [ DatabaseColumn('awc_id', SimpleColumn('awc_id')), DatabaseColumn( 'sc_pregnant', CountUniqueColumn( 'doc_id', alias='sc_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'sc'), EQ('pregnant', 'one'), ])), DatabaseColumn( 'st_pregnant', CountUniqueColumn( 'doc_id', alias='st_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'st'), EQ('pregnant', 'one'), ])), DatabaseColumn( 'obc_pregnant', CountUniqueColumn( 'doc_id', alias='obc_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'obc'), EQ('pregnant', 'one'), ])), DatabaseColumn( 'general_pregnant', CountUniqueColumn( 'doc_id', alias='general_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'other'), EQ('pregnant', 'one'), ])), DatabaseColumn( 'total_pregnant', CountUniqueColumn( 'doc_id', alias='total_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('pregnant', 'one'), ])), DatabaseColumn( 'sc_lactating', CountUniqueColumn( 'doc_id', alias='sc_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'sc'), EQ('lactating', 'one'), ])), DatabaseColumn( 'st_lactating', CountUniqueColumn( 'doc_id', alias='st_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'st'), EQ('lactating', 'one'), ])), DatabaseColumn( 'obc_lactating', CountUniqueColumn( 'doc_id', alias='obc_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'obc'), EQ('lactating', 'one'), ])), DatabaseColumn( 'general_lactating', CountUniqueColumn( 'doc_id', alias='general_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('caste', 'other'), EQ('lactating', 'one'), ])), DatabaseColumn( 'total_lactating', CountUniqueColumn( 'doc_id', alias='total_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('lactating', 'one'), ])), DatabaseColumn( 'minority_pregnant', CountUniqueColumn( 'doc_id', alias='minority_pregnant', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('pregnant', 'one'), EQ('minority', 'yes'), ])), DatabaseColumn( 'minority_lactating', CountUniqueColumn( 'doc_id', alias='minority_lactating', filters=self.filters + [ GT('num_rations_distributed', 'twentyone'), EQ('lactating', 'one'), EQ('minority', 'yes'), ])), ]
def columns(self): case_table_name = case_table(self.domain.name) case_ownership_table_name = case_ownership_table(self.domain.name) case_type_filters = [filters.NOTEQ('case_type', 'ccCaseType')] domain_filter = [ filters.EQ('domain', 'domain'), filters.EQ('doc_type', 'form_doc_type') ] columns = [ DatabaseColumn("case", SimpleColumn('user_id', filters=filters_week0('time_end') + domain_filter), format_fn=self.get_user_case_id, sortable=False), DatabaseColumn('formsSubmittedWeek0', CountColumn('instance_id', table_name=FORMDATA_TABLE, filters=filters_week0('time_end') + domain_filter, alias='formsSubmittedWeek0'), sortable=False), DatabaseColumn('formsSubmittedWeek1', CountColumn('instance_id', table_name=FORMDATA_TABLE, filters=filters_week1('time_end') + domain_filter, alias='formsSubmittedWeek1'), sortable=False), DatabaseColumn('formsSubmittedMonth0', CountColumn('instance_id', table_name=FORMDATA_TABLE, filters=filters_month0('time_end') + domain_filter, alias='formsSubmittedMonth0'), sortable=False), DatabaseColumn('casesUpdatedMonth0', CountUniqueColumn('case_id', table_name=case_table_name, filters=filters_month0('date') + case_type_filters, alias='casesUpdatedMonth0'), sortable=False), DatabaseColumn('casesUpdatedMonth1', CountUniqueColumn('case_id', table_name=case_table_name, filters=filters_month1('date') + case_type_filters, alias='casesUpdatedMonth1'), sortable=False), DatabaseColumn('totalCases', SumColumn('open_cases', table_name=case_ownership_table_name, filters=case_type_filters, alias='totalCases'), sortable=False) ] columns.extend(self._get_custom_columns()) return columns
def test_unique_2(self): self._test_view(CountUniqueColumn("sub_region", table_name="region_table"), 3)
def test_unique(self): self._test_view(CountUniqueColumn("user"), 2)
def columns(self): return [ DatabaseColumn('awc_id', SimpleColumn('awc_id')), DatabaseColumn( 'pre_sc_boys_36_72', CountUniqueColumn('doc_id', alias='pre_sc_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'sc'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_sc_girls_36_72', CountUniqueColumn('doc_id', alias='pre_sc_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'sc'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_st_boys_36_72', CountUniqueColumn('doc_id', alias='pre_st_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'st'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_st_girls_36_72', CountUniqueColumn('doc_id', alias='pre_st_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'st'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_obc_boys_36_72', CountUniqueColumn('doc_id', alias='pre_obc_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'obc'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_obc_girls_36_72', CountUniqueColumn('doc_id', alias='pre_obc_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'obc'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_general_boys_36_72', CountUniqueColumn('doc_id', alias='pre_general_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'other'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_general_girls_36_72', CountUniqueColumn('doc_id', alias='pre_general_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('caste', 'other'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_total_boys_36_72', CountUniqueColumn('doc_id', alias='pre_total_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_total_girls_36_72', CountUniqueColumn('doc_id', alias='pre_total_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), ])), DatabaseColumn( 'pre_minority_boys_36_72', CountUniqueColumn('doc_id', alias='pre_minority_boys_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('sex', 'male'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), EQ('minority', 'yes'), ])), DatabaseColumn( 'pre_minority_girls_36_72', CountUniqueColumn('doc_id', alias='pre_minority_girls_36_72', filters=self.filters + [ GTE('pse_days_attended', 'twentyone'), EQ('sex', 'female'), OR([ EQ('age_tranche', 'age_48'), EQ('age_tranche', 'age_60'), EQ('age_tranche', 'age_72'), ]), EQ('minority', 'yes'), ])) ]