(request, username, interval=7)
return return_context
Calendar view of submissions by CHW, overlaid with their scheduled visits, and whether they made them or not.
Calendar view of submissions by CHW, overlaid with their scheduled visits, and whether they made them or not.
Calendar view of submissions by CHW overlaid with their scheduled visits and whether they made them or not .
def chw_calendar_submit_report(request, username, interval=7):
    """Calendar view of submissions by CHW, overlaid with their scheduled visits, and whether they made them or not."""
    return_context = {}
    return_context['username'] = username
    total_interval = interval
    if 'interval' in request.GET:
        try:
            total_interval = int(request.GET['interval'])
        except ValueError:
            pass

    #secret date ranges
    if 'enddate' in request.GET:
        end_date_str = request.GET.get('enddate', json_format_date(datetime.utcnow()))
        end_date = iso_string_to_date(end_date_str)
    else:
        end_date = datetime.utcnow().date()

    if 'startdate' in request.GET:
        #if there's a startdate, trump interval
        start_date_str = request.GET.get('startdate', json_format_date(datetime.utcnow()))
        start_date = iso_string_to_date(start_date_str)
        total_interval = (end_date - start_date).days

    ret, patients, total_scheduled, total_visited = get_schedule_tally(username,
                                                                       total_interval,
                                                                       override_date=end_date)

    if len(ret) > 0:
        return_context['date_arr'] = ret
        return_context['total_scheduled'] = total_scheduled
        return_context['total_visited'] = total_visited
        return_context['start_date'] = ret[0][0]
        return_context['end_date'] = ret[-1][0]
    else:
        return_context['total_scheduled'] = 0
        return_context['total_visited'] = 0

    return return_context
def chw_calendar_submit_report ( request , username , interval = 7 ) : return_context = { } return_context [ 'username' ] = username total_interval = interval if 'interval' in request . GET : try : total_interval = int ( request . GET [ 'interval' ] ) except ValueError : pass #secret date ranges if 'enddate' in request . GET : end_date_str = request . GET . get ( 'enddate' , json_format_date ( datetime . utcnow ( ) ) ) end_date = iso_string_to_date ( end_date_str ) else : end_date = datetime . utcnow ( ) . date ( ) if 'startdate' in request . GET : #if there's a startdate, trump interval start_date_str = request . GET . get ( 'startdate' , json_format_date ( datetime . utcnow ( ) ) ) start_date = iso_string_to_date ( start_date_str ) total_interval = ( end_date - start_date ) . days ret , patients , total_scheduled , total_visited = get_schedule_tally ( username , total_interval , override_date = end_date ) if len ( ret ) > 0 : return_context [ 'date_arr' ] = ret return_context [ 'total_scheduled' ] = total_scheduled return_context [ 'total_visited' ] = total_visited return_context [ 'start_date' ] = ret [ 0 ] [ 0 ] return_context [ 'end_date' ] = ret [ - 1 ] [ 0 ] else : return_context [ 'total_scheduled' ] = 0 return_context [ 'total_visited' ] = 0 return return_context