コード例 #1
0
ファイル: reports.py プロジェクト: dcmul/rapidsms
def malnutrition_screening(request, object_id=None, per_page="0", \
                           rformat="pdf"):
    ''' Malnutrition Screening Form Originally for SN CC '''
    pdfrpt = []
    pdfrpt = PDFReport()

    #fourteen_days = timedelta(days=30)
    today = datetime.now()

    #duration_start = day_start(today - fourteen_days)
    #duration_end = today

    pdfrpt.setTitle("%(app_name)s: Formulaire de Depistage" % \
                   {'app_name': Cfg.get("app_name")})
    #pdfrpt.setRowsPerPage(66)
    pdfrpt.setNumOfColumns(1)
    pdfrpt.setLandscape(True)
    pdfrpt.setFontSize(10)
    if object_id is None and not request.POST:
        sites = Location.objects.filter(type__name="Site")
        for site in sites:
            queryset, fields = \
                ReportAllPatients.malnutrition_screening_info(site)
            subtitle = _("%(site_name)s: Registre des Enfants pour: " % \
                         {'site_name': site.name})
            pdfrpt.setTableData(queryset, fields, subtitle, \
                            [0.4 * inch, 1.5 * inch, 0.4 * inch, 0.5 * inch, \
                             0.5 * inch, 1.0 * inch, 0.9 * inch, 1.0 * inch, \
                             0.7 * inch, 0.7 * inch, 0.7 * inch, 0.7 * inch, \
                             0.8 * inch, 1.0 * inch])
            if (int(per_page) == 1) is True:
                pdfrpt.setPageBreak()
                pdfrpt.setFilename("/tmp/malnutrition_at_risk")
    else:
        if request.POST['zone']:
            site_id = request.POST['zone']
            site = Location.objects.get(id=site_id)
            queryset, fields = \
                ReportAllPatients.malnutrition_screening_info(site)

            subtitle = _("Registre des Enfants pour: %(site_name)s" % \
                         {'site_name': site.name})
        # no nom sex dob age mere sms numero pb poids oedems
        # ddepistage consulter
            pdfrpt.setTableData(queryset, fields, subtitle, \
                            [0.4 * inch, 1.5 * inch, 0.4 * inch, 0.5 * inch, \
                             0.5 * inch, 1.0 * inch, 0.9 * inch, 1.0 * inch, \
                             0.7 * inch, 0.7 * inch, 0.7 * inch, 0.7 * inch, \
                             0.8 * inch, 1.0 * inch])
            filename = "/tmp/formulaire_de_depistage" + \
                    datetime.today().strftime("%Y_%m_%d_%H_%M_%S")

            pdfrpt.setFilename(filename)

    return pdfrpt.render()
コード例 #2
0
ファイル: reports.py プロジェクト: dcmul/rapidsms
def patients_by_age(request, object_id=None, per_page="0", rformat="pdf"):
    ''' Children Screening per age for SN CC '''
    pdfrpt = PDFReport()

    #pdfrpt.setTitle(_("ChildCount Senegal: Listing Enfant par Age"))
    pdfrpt.setTitle(_(Cfg.get("app_name") + \
                ": Listing Enfant par Age" ))
    #pdfrpt.setRowsPerPage(66)
    pdfrpt.setNumOfColumns(1)
    pdfrpt.setLandscape(True)
    pdfrpt.setFontSize(10)
    if object_id is None and not request.POST:
        age_mois = 0
        cases = Case.objects.order_by("location").distinct()
        queryset, fields = ReportAllPatients.by_age(age_mois, cases)
        subtitle = _("Registre des Enfants pour: ") #%(site.name)
        pdfrpt.setTableData(queryset, fields, subtitle, \
                    [0.2 * inch, 1.5 * inch, 0.5 * inch, 0.7 * inch, \
                     0.5 * inch, 1.5 * inch,1.0 * inch, 0.5 * inch, 0.7 * inch, \
                     0.5 * inch, 0.5 * inch, 0.7 * inch, 1.5 * inch, \
                     1 * inch])
        if (int(per_page) == 1) is True:
            pdfrpt.setPageBreak()
        pdfrpt.setFilename("/tmp/Listing_Enfant")

    else:
        cases = Case.objects.order_by("location").distinct()

        if request.POST['age']:
            age_mois = int(request.POST['age'])
            str_age = request.POST['age']

            queryset, fields = ReportAllPatients.by_age(age_mois, cases)

            subtitle = _("Registre des Enfants de : %(age)s mois" % \
                         {'age': str_age})
        # no nom sex dob age mere sms numero pb poids oedems
        #depistage consulter
            pdfrpt.setTableData(queryset, fields, subtitle, \
                        [0.2 * inch, 1.5 * inch, 0.5 * inch, 0.7 * inch, \
                         0.5 * inch, 1.5 * inch,1.0 * inch, 0.5 * inch, 0.7 * inch, \
                         0.5 * inch, 0.5 * inch, 0.7 * inch, 1.5 * inch, \
                         1 * inch])
            filename = "/tmp/Listing_Enfant_" + \
                datetime.today().strftime("%Y_%m_%d_%H_%M_%S")

            pdfrpt.setFilename(filename)

    return pdfrpt.render()