Example #1
0
    def measles_mini_summary(cls):
        ps = []
        fields = []
        tcounter = 0
        teligible_cases = 0
        tvaccinated_cases = 0
        tclinic_cases = 0
        clinics = Facility.objects.all()
        for clinic in clinics:
            providers = Provider.list_by_clinic(clinic)
            p = {}
            eligible_cases = 0
            vaccinated_cases = 0
            clinic_cases = 0
            counter = 0
            p["clinic"] = clinic
            p["num_cases"] = 0
            p["eligible_cases"] = 0
            p["vaccinated_cases"] = 0
            for provider in providers:
                counter = counter + 1
                # p['counter'] = "%d"%counter
                cases = Case.list_e_4_measles(provider)
                eligible_cases += cases.count()
                clinic_cases = clinic_cases + Case.count_by_provider(provider)
                mcases = ReportMeasles.get_vaccinated(provider)
                # slow count
                slowcount = 0
                for case in cases:
                    if ReportMeasles.is_vaccinated(case):
                        slowcount += 1
                # vaccinated_cases += mcases.count()
                vaccinated_cases += slowcount

            # Summary
            p = {}
            p["clinic"] = clinic
            p["counter"] = ""
            p["num_cases"] = clinic_cases
            p["eligible_cases"] = eligible_cases
            p["vaccinated_cases"] = vaccinated_cases
            ps.append(p)

            tcounter += counter
            teligible_cases += eligible_cases
            tvaccinated_cases += vaccinated_cases
            tclinic_cases += clinic_cases
            # caseid +|Y lastname firstname | sex | dob/age | guardian | provider  | date
        p = {}
        p["clinic"] = "Total:"
        p["counter"] = ""
        p["num_cases"] = tclinic_cases
        p["eligible_cases"] = teligible_cases
        p["vaccinated_cases"] = tvaccinated_cases
        ps.append(p)
        return ps
Example #2
0
    def measles_summary(cls, duration_start, duration_end, muac_duration_start, clinic_id=None):
        ps = []
        fields = []
        counter = 0
        eligible_cases = 0
        vaccinated_cases = 0
        clinic_cases = 0
        if clinic_id is not None:
            providers = Provider.list_by_clinic(clinic_id)
            for provider in providers:
                p = {}
                counter = counter + 1
                p["counter"] = "%d" % counter
                p["provider"] = provider
                p["num_cases"] = Case.count_by_provider(provider)
                cases = Case.list_e_4_measles(provider)
                p["eligible_cases"] = cases.count()
                eligible_cases += p["eligible_cases"]
                clinic_cases = clinic_cases + p["num_cases"]
                # slow count
                slowcount = 0
                for case in cases:
                    if ReportMeasles.is_vaccinated(case):
                        slowcount += 1
                mcases = ReportMeasles.get_vaccinated(provider)
                # p['vaccinated_cases'] = mcases.count()
                p["vaccinated_cases"] = slowcount
                p["not_vaccinated_cases"] = p["eligible_cases"] - p["vaccinated_cases"]
                vaccinated_cases += p["vaccinated_cases"]
                p["sms_sent"] = int(round(float(float(p["vaccinated_cases"]) / float(p["eligible_cases"])) * 100, 0))

                ps.append(p)

            # ps = sorted(ps)
            # Summary
            p = {}
            p["counter"] = ""
            p["provider"] = "Summary"
            p["num_cases"] = clinic_cases
            p["eligible_cases"] = eligible_cases
            p["vaccinated_cases"] = vaccinated_cases
            p["not_vaccinated_cases"] = eligible_cases - vaccinated_cases
            sms_sent = int(round(float(float(vaccinated_cases) / float(eligible_cases)) * 100, 0))
            p["sms_sent"] = sms_sent
            ps.append(p)
            # caseid +|Y lastname firstname | sex | dob/age | guardian | provider  | date
            fields.append({"name": "#", "column": None, "bit": "{{ object.counter }}"})
            fields.append({"name": "PROVIDER", "column": None, "bit": "{{ object.provider }}"})
            fields.append({"name": "TOTAL CASES", "column": None, "bit": "{{ object.num_cases}}"})
            fields.append({"name": "# ELIGIBLE CASES", "column": None, "bit": "{{ object.eligible_cases}}"})
            fields.append({"name": "# VACCINATED", "column": None, "bit": "{{ object.vaccinated_cases }}"})
            fields.append({"name": "# NOT VACCINATED", "column": None, "bit": "{{ object.not_vaccinated_cases }}"})
            fields.append({"name": "%", "column": None, "bit": "{{ object.sms_sent }}%"})
            return ps, fields