Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 3
0
 def get_providers_by_clinic(cls, duration_start, duration_end, muac_duration_start, clinic_id=None):
     
 
     ps      = []
     fields  = []
     counter = 0
     clinic_cases = 0
     clinic_mrdt = 0
     clinic_muac = 0
     clinic_sent = 0
     clinic_processed = 0
     clinic_refused = 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)
             p_muac = ReportMalaria.count_by_provider(provider, duration_end, duration_start)
             p['num_malaria_reports'] = p_muac
             clinic_mrdt = clinic_mrdt + p_muac 
             num_cases = Case.count_by_provider(provider)
             clinic_cases = clinic_cases + num_cases
             num_muac = ReportMalnutrition.count_by_provider(provider, duration_end, muac_duration_start)
             clinic_muac = clinic_muac + num_muac
             if num_cases == 0:
                 muac_percentage = 0
             else:
                 muac_percentage  = round(float(float(num_muac)/float(num_cases))*100, 0)
             p['num_muac_reports'] = "%d %% (%s/%s)"%(muac_percentage, num_muac, num_cases)
             sms_sent = MessageLog.count_by_provider(provider, duration_end, duration_start)
             clinic_sent = clinic_sent + sms_sent
             p['sms_sent'] = sms_sent
             sms_processed = MessageLog.count_processed_by_provider(provider, duration_end, duration_start)
             clinic_processed = clinic_processed + sms_processed
             p['sms_processed'] = sms_processed
             sms_refused = MessageLog.count_refused_by_provider(provider, duration_end, duration_start)
             clinic_refused = clinic_refused + sms_refused
             p['sms_refused'] = sms_refused
             if p['sms_sent'] != 0:
                 p['sms_rate'] = int(float(float(p['sms_processed'])/float(p['sms_sent'])*100))
             else:
                 p['sms_rate'] = 0
             #p['sms_rate'] = "%s%%"%p['sms_rate']
             last_activity = MessageLog.days_since_last_activity(provider)
             if last_activity == "":
                 p['days_since_last_activity'] = "No Activity"
             else:
                 p['days_since_last_activity'] = "%s days ago"%last_activity
                                 
             ps.append(p)
         
         #ps = sorted(ps)
         # Summary    
         p = {}
         p['counter'] = ""
         p['provider'] = "Summary"
         p['num_cases'] = clinic_cases
         p['num_malaria_reports'] = clinic_mrdt
         num_cases = clinic_cases
         num_muac = clinic_muac
         if num_cases == 0:
             muac_percentage = 0
         else:
             muac_percentage  = round(float(float(num_muac)/float(num_cases))*100, 0)
         p['num_muac_reports'] = "%d %% (%s/%s)"%(muac_percentage, num_muac, num_cases)
         p['sms_sent'] = clinic_sent
         p['sms_processed'] = clinic_processed
         p['sms_refused'] = clinic_refused
         if p['sms_sent'] != 0:
             p['sms_rate'] = int(float(float(p['sms_processed'])/float(p['sms_sent'])*100))
         else:
             p['sms_rate'] = 0
         #p['sms_rate'] = "%s%%"%p['sms_rate']
         p['days_since_last_activity'] = "" 
                             
         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": 'NUMBER OF CASES', "column": None, "bit": "{{ object.num_cases}}" })
         fields.append({"name": 'MRDT', "column": None, "bit": "{{ object.num_malaria_reports }}" })
         fields.append({"name": 'MUAC', "column": None, "bit": "{{ object.num_muac_reports }}" })
         fields.append({"name": 'RATE', "column": None, "bit": "{{ object.sms_rate }}% ({{ object.sms_processed }}/{{ object.sms_sent }})" })
         fields.append({"name": 'LAST ACTVITY', "column": None, "bit": "{{ object.days_since_last_activity }}" })
         return ps, fields