Пример #1
0
def single_chw_summary(request):
    """Report for a single CHW""" 
    chw_id = request.GET.get("chw", None)
    chws = CommunityHealthWorker.view("chw/by_clinic", include_docs=True)
    main_chw = CommunityHealthWorker.get(chw_id) if chw_id else None
    
    punchcard_url = ""
    if main_chw:
        punchcard_url = get_punchcard_url(get_data(main_chw.current_clinic_id, chw_id), width=910)
        # patch on extra data for display
        main_chw.last_submission = get_last_submission_date(main_chw.get_id)    
        main_chw.first_submission = get_first_submission_date(main_chw.get_id)    
        main_chw.forms_submitted = get_forms_submitted(main_chw.get_id)    
        forms_breakdown = get_submission_breakdown(main_chw.get_id)
        main_chw.hh_surveys = forms_breakdown[config.CHW_HOUSEHOLD_SURVEY_NAMESPACE]
        main_chw.fus = forms_breakdown[config.CHW_FOLLOWUP_NAMESPACE]
        main_chw.refs = forms_breakdown[config.CHW_REFERRAL_NAMESPACE]
        main_chw.monthly_surveys = forms_breakdown[config.CHW_MONTHLY_SURVEY_NAMESPACE]
        
        # recent monthly surveys
        main_chw.recent_surveys = get_recent_forms(main_chw.get_id, config.CHW_MONTHLY_SURVEY_NAMESPACE)
        
        if not request.datespan.is_valid():
            messages.error(request, request.datespan.get_validation_reason())
            messages.warning(request, "Performance Indicators are not displayed. Please fix the other errors")
            report = {"name": "Partial CHW Summary for %s" % main_chw.formatted_name}
        else:
            report = get_chw_pi_report(main_chw, request.datespan.startdate, request.datespan.enddate)
    else:        
        report = {"name": "CHW Summary"}
    fake_hh_data = []
    now = datetime.now()
    for i in range(3):
        year, month = add_months(now.year, now.month, -i)
        fake_hh_data.append(["%s %s" % (year, month), 100, 200, "25%", "13%"])
        
    return render_to_response(request, "reports/chw_summary.html", 
                              {"report": report,
                               "chw_id": chw_id,
                               "main_chw":    main_chw,
                               "chws":   chws,
                               "punchcard_url":    punchcard_url,
                               "show_dates": False,
                               "hh_data": fake_hh_data, # TODO
                               "fu_data": fake_hh_data, # TODO
                               "ref_data": fake_hh_data # TODO
                               })
Пример #2
0
def chw_pi(request):
    """
    CHW Performance Indicator Report
    """
    # This is currently defunct and combined with the single CHW report.
    chw_id = request.GET.get("chw", None)
    chws = CommunityHealthWorker.view("chw/by_clinic", include_docs=True)
    main_chw = CommunityHealthWorker.get(chw_id) if chw_id else None
    report = { "name": "CHW PI Report" }
    if main_chw:
        if not request.datespan.is_valid():
            messages.error(request, request.datespan.get_validation_reason())
        else:
            report = get_chw_pi_report(main_chw, request.datespan.startdate, request.datespan.enddate)
    return render_to_response(request, "reports/chw_pi.html",
                              {"report": report, "chws": chws, 
                               "main_chw": main_chw,
                               "view_slug": "chw_pi"})
Пример #3
0
def export_chw_pis(request):
    report_slug = "chw_pi"
    chw_id = request.GET.get("chw", None)
    main_chw = CommunityHealthWorker.get(chw_id) 
    report = get_chw_pi_report(main_chw, request.datespan.startdate, request.datespan.enddate)
    return _export_pis(report, report_slug, non_data_cols=2)