Exemple #1
0
 def data_providers(self):
     config = self.report_config
     if self.location:
         if self.location.location_type.name.upper() == 'FACILITY':
             self.use_datatables = True
             return [
                 InventoryHistoryData(config=config),
                 RandRHistory(config=config),
                 Notes(config=config),
                 RecentMessages(config=config),
                 RegistrationData(config=dict(loc_type='FACILITY',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='DISTRICT',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='REGION', **config),
                                  css_class='row_chart_all')
             ]
         else:
             self.use_datatables = False
             return [
                 RandRSubmissionData(config=config),
                 DistrictSummaryData(config=config),
                 SohSubmissionData(config=config),
                 DeliverySubmissionData(config=config),
                 ProductAvailabilitySummary(config=config,
                                            css_class='row_chart_all')
             ]
     else:
         return []
Exemple #2
0
 def data_providers(self):
     config = self.report_config
     data_providers = []
     if config['location_id']:
         data_providers = [
             RandRSubmissionData(config=config, css_class='row_chart_all')
         ]
         location = get_location(config['location_id'])
         if location.location_type_name in ['REGION', 'MSDZONE', 'MOHSW']:
             data_providers.append(
                 RRStatus(config=config, css_class='row_chart_all'))
         elif location.location_type_name == 'FACILITY':
             return [
                 InventoryHistoryData(config=config),
                 RandRHistory(config=config),
                 Notes(config=config),
                 RecentMessages(config=config),
                 RegistrationData(config=dict(loc_type='FACILITY',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='DISTRICT',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='REGION', **config),
                                  css_class='row_chart_all')
             ]
         else:
             data_providers.append(
                 RRReportingHistory(config=config,
                                    css_class='row_chart_all'))
     return data_providers
Exemple #3
0
    def rows(self):
        rows = []
        if self.config['org_summary']:
            locations = SQLLocation.objects.filter(
                parent__location_id=self.config['location_id'])
            for child in locations:
                try:
                    org_summary = OrganizationSummary.objects.filter(
                        date__range=(self.config['startdate'],
                                     self.config['enddate']),
                        location_id=child.location_id)
                except OrganizationSummary.DoesNotExist:
                    return []

                self.config['org_summary'] = org_summary
                rr_data = RandRSubmissionData(config=self.config).rows[0]

                fp_partial = partial(rr_format_percent,
                                     denominator=rr_data.total)

                total_responses = 0
                total_possible = 0
                group_summaries = GroupSummary.objects.filter(
                    org_summary__date__lte=self.config['startdate'],
                    org_summary__location_id=child.location_id,
                    title=SupplyPointStatusTypes.R_AND_R_FACILITY)

                for group_summary in group_summaries:
                    if group_summary:
                        total_responses += group_summary.responded
                        total_possible += group_summary.total
                hist_resp_rate = rr_format_percent(total_responses,
                                                   total_possible)

                url = make_url(
                    RRreport, self.config['domain'],
                    '?location_id=%s&filter_by_program=%s&'
                    'datespan_type=%s&datespan_first=%s&datespan_second=%s',
                    (child.location_id, self.config['program'],
                     self.config['datespan_type'],
                     self.config['datespan_first'],
                     self.config['datespan_second']))

                rows.append([
                    link_format(child.name, url),
                    fp_partial(rr_data.on_time),
                    fp_partial(rr_data.late),
                    fp_partial(rr_data.not_submitted),
                    fp_partial(rr_data.not_responding), hist_resp_rate
                ])

        return rows