Ejemplo n.º 1
0
def child_delay(request, *args, **kwargs):
    """ """
    category = 'child_delay'
    context = {'user': request.user}
    context.update({"category": category, "message": u"Recherche "})

    patients = [patient.last_data_event() \
                for patient in Patient.by_uren.all().order_by("create_date")\
                .all_uren() if patient.is_late and not
                patient.last_data_event().is_output]

    for patient in patients:
        patient.url_details_child = reverse("details_child", \
                                                args=[patient.patient.id])

    #pour mettre 20 rapport par page
    paginator = FlynsarmyPaginator(list(patients), 20, adjacent_pages=10)

    if patients:
        page = request.GET.get('page', 1)
        try:
            patients_list = paginator.page(page)
        except PageNotAnInteger:
            patients_list = paginator.page(1)
        except EmptyPage:
            patients_list = paginator.page(paginator.num_pages)
        # affiche une erreur Http404 si l'on de passe la page est vide
    else:
        patients_list = []

    context.update({'patients': patients_list})
    return render(request, 'child_delay.html', context)
Ejemplo n.º 2
0
def children(request):
    context = {'category': 'children', 'user': request.user}
    context.update({"message": u"Recherche "})

    patients = Patient.by_uren.all().order_by("-create_date").all_uren()

    if request.method == "POST":
        form_r = ResearchForm(request.POST)
        form = ChildrenForm(request.POST)
        if "health_center" in request.POST:
            if request.POST.get('health_center'):
                patients = Patient.by_uren.all().filter(health_center__code=request \
                                   .POST.get('health_center')).all_uren()
        if "search_patient" in request.POST:
            if request.POST.get('search_patient'):
                val = request.POST.get('search_patient').title()
                query = (Q(first_name__contains=val)
                         | Q(last_name__contains=val)
                         | Q(surname_mother__contains=val)
                         | Q(nut_id__contains=val))

                patients = Patient.by_uren.all().filter(query).all_uren()

                if not patients:
                    context.update({
                        "message":
                        u"Votre requête ne trouve"
                        u"aucun patient. \n"
                    })
    else:
        form = ChildrenForm()
        form_r = ResearchForm()

    for patient in patients:
        patient.url_patient = reverse("details_child", args=[patient.id])

    #pour mettre 20 rapport par page
    paginator = FlynsarmyPaginator(list(patients), 20, adjacent_pages=10)

    if patients:
        page = request.GET.get('page', 1)
        try:
            patients_list = paginator.page(page)
        except PageNotAnInteger:
            patients_list = paginator.page(1)
        except EmptyPage:
            patients_list = paginator.page(paginator.num_pages)
    else:
        patients_list = []

    context.update({'patients': patients_list, "form_r": form_r, "form": form})
    return render(request, 'children.html', context)