Beispiel #1
0
def _is_valid_status(facility, date, status_type):
    if status_type not in const.NEEDED_STATUS_TYPES:
        return False
    groups = HistoricalLocationGroup.objects.filter(
        date__month=date.month,
        date__year=date.year,
        location_id=facility.sql_location
    )
    if (not facility.metadata.get('group', None)) and (groups.count() == 0):
        return False

    if groups.count() > 0:
        codes = [group.group for group in groups]
    else:
        try:
            latest_group = HistoricalLocationGroup.objects.filter(
                location_id=facility.sql_location
            ).latest('date')
            if date.date() < latest_group.date:
                return False
            else:
                codes = [facility.metadata['group']]
        except HistoricalLocationGroup.DoesNotExist:
            codes = [facility.metadata['group']]
    dg = DeliveryGroups(date.month)
    if status_type == SupplyPointStatusTypes.R_AND_R_FACILITY:
        return dg.current_submitting_group() in codes
    elif status_type == SupplyPointStatusTypes.DELIVERY_FACILITY:
        return dg.current_delivering_group() in codes
    return True
Beispiel #2
0
def _is_valid_status(facility, date, status_type):
    if status_type not in const.NEEDED_STATUS_TYPES:
        return False
    groups = HistoricalLocationGroup.objects.filter(
        date__month=date.month,
        date__year=date.year,
        location_id=facility.sql_location)
    if (not facility.metadata.get('group', None)) and (groups.count() == 0):
        return False

    if groups.count() > 0:
        codes = [group.group for group in groups]
    else:
        try:
            latest_group = HistoricalLocationGroup.objects.filter(
                location_id=facility.sql_location).latest('date')
            if date.date() < latest_group.date:
                return False
            else:
                codes = [facility.metadata['group']]
        except HistoricalLocationGroup.DoesNotExist:
            codes = [facility.metadata['group']]
    dg = DeliveryGroups(date.month)
    if status_type == SupplyPointStatusTypes.R_AND_R_FACILITY:
        return dg.current_submitting_group() in codes
    elif status_type == SupplyPointStatusTypes.DELIVERY_FACILITY:
        return dg.current_delivering_group() in codes
    return True
Beispiel #3
0
def _is_valid_status(facility, date, status_type):
    if status_type not in const.NEEDED_STATUS_TYPES:
        return False

    code = facility.metadata.get('group')
    if not code:
        return False
    dg = DeliveryGroups(date.month)
    if status_type == SupplyPointStatusTypes.R_AND_R_FACILITY:
        return dg.current_submitting_group() == code
    elif status_type == SupplyPointStatusTypes.DELIVERY_FACILITY:
        return dg.current_delivering_group() == code
    return True
Beispiel #4
0
def _is_valid_status(facility, date, status_type):
    if status_type not in const.NEEDED_STATUS_TYPES:
        return False

    code = facility.metadata.get('group')
    if not code:
        return False
    dg = DeliveryGroups(date.month)
    if status_type == SupplyPointStatusTypes.R_AND_R_FACILITY:
        return dg.current_submitting_group() == code
    elif status_type == SupplyPointStatusTypes.DELIVERY_FACILITY:
        return dg.current_delivering_group() == code
    return True
Beispiel #5
0
    def rows(self):

        if self.config['org_summary']:

            def prepare_processing_info(data):
                return {'total': data[0] - (data[1] + data[2]), 'complete': 0}

            org_summary = self.config['org_summary'][0]
            total = org_summary.total_orgs
            avg_lead_time = org_summary.average_lead_time_in_days
            if avg_lead_time:
                avg_lead_time = "%.1f" % avg_lead_time

            endmonth = self.config['enddate'].month
            dg = DeliveryGroups(month=endmonth)

            rr_data = RandRSubmissionData(config=self.config).rows[0]
            delivery_data = DeliverySubmissionData(config=self.config).rows[0]

            submitting_group = dg.current_submitting_group(month=endmonth)
            processing_group = dg.current_processing_group(month=endmonth)
            delivery_group = dg.current_delivering_group(month=endmonth)

            (rr_complete, rr_total) = (rr_data.complete,
                                       rr_data.total) if rr_data else (0, 0)
            if delivery_data:
                (delivery_complete, delivery_total) = (delivery_data.complete,
                                                       delivery_data.total)
            else:
                (delivery_complete, delivery_total) = (0, 0)

            processing_numbers = prepare_processing_info(
                [total, rr_total, delivery_total])

            return {
                "processing_total": processing_numbers['total'],
                "processing_complete": processing_numbers['complete'],
                "submitting_total": rr_total,
                "submitting_complete": int(rr_complete),
                "delivery_total": delivery_total,
                "delivery_complete": int(delivery_complete),
                "delivery_group": delivery_group,
                "submitting_group": submitting_group,
                "processing_group": processing_group,
                "total": total,
                "avg_lead_time": avg_lead_time,
            }
        else:
            return None
Beispiel #6
0
    def rows(self):

        if self.config['org_summary']:

            def prepare_processing_info(data):
                return {
                    'total': data[0] - (data[1] + data[2]),
                    'complete': 0
                }

            org_summary = self.config['org_summary'][0]
            total = org_summary.total_orgs
            avg_lead_time = org_summary.average_lead_time_in_days
            if avg_lead_time:
                avg_lead_time = "%.1f" % avg_lead_time

            endmonth = self.config['enddate'].month
            dg = DeliveryGroups(month=endmonth)

            rr_data = RandRSubmissionData(config=self.config).rows[0]
            delivery_data = DeliverySubmissionData(config=self.config).rows[0]

            submitting_group = dg.current_submitting_group(month=endmonth)
            processing_group = dg.current_processing_group(month=endmonth)
            delivery_group = dg.current_delivering_group(month=endmonth)

            (rr_complete, rr_total) = (rr_data.complete, rr_data.total) if rr_data else (0, 0)
            if delivery_data:
                (delivery_complete, delivery_total) = (delivery_data.complete, delivery_data.total)
            else:
                (delivery_complete, delivery_total) = (0, 0)

            processing_numbers = prepare_processing_info([total, rr_total, delivery_total])

            return {
                "processing_total": processing_numbers['total'],
                "processing_complete": processing_numbers['complete'],
                "submitting_total": rr_total,
                "submitting_complete": rr_complete,
                "delivery_total": delivery_total,
                "delivery_complete": delivery_complete,
                "delivery_group": delivery_group,
                "submitting_group": submitting_group,
                "processing_group": processing_group,
                "total": total,
                "avg_lead_time": avg_lead_time,
            }
        else:
            return None
def _is_valid_status(facility, date, status_type):
    if status_type not in NEEDED_STATUS_TYPES:
        return False
    groups = HistoricalLocationGroup.objects.filter(
        date__month=date.month,
        date__year=date.year,
        location_id=facility.sql_location
    )
    if (not facility.metadata.get('group', None)) and (groups.count() == 0):
        return False

    if groups.count() > 0:
        code = groups[0].group
    else:
        code = facility.metadata['group']
    dg = DeliveryGroups(date.month)
    if status_type == SupplyPointStatusTypes.R_AND_R_FACILITY:
        return code == dg.current_submitting_group()
    elif status_type == SupplyPointStatusTypes.DELIVERY_FACILITY:
        return code == dg.current_delivering_group()
    return True
def _is_valid_status(facility, date, type):
    if type not in NEEDED_STATUS_TYPES:
        return False
    facility = Location.get(docid=facility)
    groups = HistoricalLocationGroup.objects.filter(
        date__month=date.month,
        date__year=date.year,
        location_id=facility.sql_location
    )
    if (not facility.metadata.get('groups', [])) and (groups.count() == 0):
        return False

    if groups.count() > 0:
        code = groups[0].group
    else:
        code = facility.metadata['groups'][0]
    dg = DeliveryGroups(date.month)
    if type.startswith('rr'):
        return code == dg.current_submitting_group()
    elif type.startswith('del'):
        return code == dg.current_delivering_group()
    return True