Exemple #1
0
def provider_list(request):
    nonhtml, tables = get(request, (["provider", Q()], ))
    if nonhtml:
        return nonhtml
    context = {
        "app": app,
        "provider": tables[0],
    }
    return as_html(request, "providerlist.html", context)
Exemple #2
0
def provider_list(request):
    nonhtml, tables = get(request, (["provider", Q()],))
    if nonhtml:
        return nonhtml
    context = {
		"app": app,
        "provider": tables[0],
    }
    return as_html(request, "providerlist.html", context)
Exemple #3
0
def search_view(request):
    term = request.GET.get("q")
    query = Q(id__icontains=term) | \
            Q(first_name__icontains=term) | \
            Q(last_name__icontains=term)

    nonhtml, tables = get(request, [ ["case", query], ])
    if nonhtml: 
        return nonhtml

    return as_html(request, "searchview.html", { "search": tables[0], })
Exemple #4
0
def district_view(request):
    district = request.GET.get("d")
    context = {
		"app": app,
        "districts": Zone.objects.all(),
    }
    if district:
        nonhtml, tables = get(request, (["case", Q(zone=district)],))
        if nonhtml:
            return nonhtml
        context["cases"] = tables[0]

    return as_html(request, "districtview.html", context)
Exemple #5
0
def district_view(request):
    district = request.GET.get("d")
    context = {
        "app": app,
        "districts": Zone.objects.all(),
    }
    if district:
        nonhtml, tables = get(request, (["case", Q(zone=district)], ))
        if nonhtml:
            return nonhtml
        context["cases"] = tables[0]

    return as_html(request, "districtview.html", context)
Exemple #6
0
def provider_view(request, object_id):
    provider = get_object_or_404(Provider, id=object_id)
    nonhtml, tables = get(request, (["case", Q(provider=provider)], [
        "message", Q(sent_by=provider.user)
    ], ["event", Q(content_type="provider", object_id=provider.pk)]))
    if nonhtml:
        return nonhtml
    context = {
        "app": app,
        "object": provider,
        "cases": tables[0],
        "messages": tables[1],
        "event": tables[2]
    }
    return as_html(request, "providerview.html", context)
Exemple #7
0
def search_view(request):
    term = request.GET.get("q")
    query = Q(id__icontains=term) | \
            Q(first_name__icontains=term) | \
            Q(last_name__icontains=term)

    nonhtml, tables = get(request, [
        ["case", query],
    ])
    if nonhtml:
        return nonhtml

    return as_html(request, "searchview.html", {
        "search": tables[0],
    })
Exemple #8
0
def provider_view(request, object_id):
    provider = get_object_or_404(Provider, id=object_id)
    nonhtml, tables = get(request, (
        ["case", Q(provider=provider)],
        ["message", Q(sent_by=provider.user)],
        ["event", Q(content_type="provider", object_id=provider.pk)]
        ))
    if nonhtml:
        return nonhtml
    context = {
		"app": app,
        "object": provider,
        "cases": tables[0],
        "messages": tables[1],
        "event": tables[2]
    }
    return as_html(request, "providerview.html", context)
Exemple #9
0
def case_view(request, object_id):
    case = get_object_or_404(Case, id=object_id)
    nonhtml, tables = get(request, [
        ["malnutrition", Q(case=case)],
        ["diagnosis", Q(case=case)],
        ["malaria", Q(case=case)],
        ["event", Q(content_type="case", object_id=object_id)],
        ])

    if nonhtml:
        return nonhtml

    results = ReportMalnutrition.objects\
        .filter(Q(case=case)).exclude(muac=None)\
        .order_by("-entered_at")\
        .values_list("muac", "entered_at")
    results1 = [ [ time.mktime(r[1].timetuple()) * 1000,  r[0] ] for r in results ]

    muac_data = [{'data': results1, 'label': "Muac"}]
    
    g = FlotGraph()
    g.set_data(muac_data)
    g.set_xaxis_mode("time")
    g.set_key_position(0)
    g.set_display_title("Muac over time")
    g.set_width(400)
    g.set_height(200)
    g.set_title("muac")
    g.set_zoomable(1)
    g.set_key_position(1)
    g.set_xaxis_min_ticksize("[1, \"day\"]")
    g.set_time_format("%b %d")
    g.generate_javascript()

    context = {
		"app": app,
        "object": case,
        "malnutrition": tables[0],
        "diagnosis": tables[1],
        "malaria": tables[2],
        "event": tables[3],
        "graph": g,
        "raw_data": results1,
    }
    return as_html(request, "caseview.html", context)
Exemple #10
0
def case_view(request, object_id):
    case = get_object_or_404(Case, id=object_id)
    nonhtml, tables = get(request, [
        ["malnutrition", Q(case=case)],
        ["diagnosis", Q(case=case)],
        ["malaria", Q(case=case)],
        ["event", Q(content_type="case", object_id=object_id)],
        ])

    if nonhtml:
        return nonhtml

    context = {
		"app": app,
        "object": case,
        "malnutrition": tables[0],
        "diagnosis": tables[1],
        "malaria": tables[2],
        "event": tables[3],
    }
    return as_html(request, "caseview.html", context)
Exemple #11
0
def dashboard(request):
    nonhtml, tables = get(request, [
        ["case", Q()],
        ["event", Q()],
        ["message", Q()],
    ])
    if nonhtml:
        return nonhtml

    has_provider = True
    context = {
		"app": app,
        "case_table": tables[0],
        "event_table": tables[1],
        "message_table": tables[2]
    }    

    try:
        mobile = request.user.provider.mobile
        if request.method == "POST":
            messageform = MessageForm(request.POST)
            if messageform.is_valid():
                result = message_users(mobile, **messageform.cleaned_data)
                context["msg"] = result
        else:
            messageform = MessageForm()
    except ObjectDoesNotExist:
        has_provider = False
        messageform = None

    context.update({
			"app": app,
            "message_form": messageform,
            "has_provider": has_provider,
            "summary": get_summary(),
            "graph": get_graph()
        })

    return as_html(request, "dashboard.html", context)
Exemple #12
0
def dashboard(request):
    nonhtml, tables = get(request, [
        ["case", Q()],
        ["event", Q()],
        ["message", Q()],
    ])
    if nonhtml:
        return nonhtml

    has_provider = True
    context = {
        "app": app,
        "case_table": tables[0],
        "event_table": tables[1],
        "message_table": tables[2]
    }

    try:
        mobile = request.user.provider.mobile
        if request.method == "POST":
            messageform = MessageForm(request.POST)
            if messageform.is_valid():
                result = message_users(mobile, **messageform.cleaned_data)
                context["msg"] = result
        else:
            messageform = MessageForm()
    except ObjectDoesNotExist:
        has_provider = False
        messageform = None

    context.update({
        "app": app,
        "message_form": messageform,
        "has_provider": has_provider,
        "summary": get_summary(),
        "graph": get_graph()
    })

    return as_html(request, "dashboard.html", context)