コード例 #1
0
ファイル: reports.py プロジェクト: eliane/rapidsms
    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
コード例 #2
0
ファイル: reports.py プロジェクト: eliane/rapidsms
    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
コード例 #3
0
ファイル: app.py プロジェクト: dcmul/rapidsms
    def measles(self, message, text):
        '''Record vaccinated cases

        format: measles [+PID] [+PID] [+PID]
        '''
        reporter = message.persistant_connection.reporter
        cases, notcases = self.str_to_cases(text)
        result = ''
        for case in cases:
            result = result + "+%s " % case.ref_id
            report = ReportMeasles(case=case, reporter=reporter, taken=True)
            report.save()
        if result != '':
            msg = _("%(result)s received measles shot." % {'result': result})
            message.respond(_("%s") % msg)
        if notcases:
            nresult = ''
            for nc in notcases:
                nresult = nresult + "%s " % nc
            msg = _("%(nresult)s not found!!" % {'nresult': nresult})
            message.respond(_("%s") % msg)
        return True
コード例 #4
0
ファイル: reports.py プロジェクト: eliane/rapidsms
    def measles_by_provider(cls, provider_id=None):
        qs = []
        fields = []
        counter = 0
        if provider_id is not None:
            provider = Provider.objects.get(id=provider_id)
            cases = Case.list_e_4_measles(provider)

            for case in cases:
                q = {}
                q["case"] = case
                counter = counter + 1
                q["counter"] = "%d" % counter
                try:
                    muacc = ReportMalnutrition.objects.filter(case=case).latest()
                    # q['malnut'] = u"%(diag)s on %(date)s" % {'diag': muacc.diagnosis_msg(), 'date': muacc.entered_at.strftime("%Y-%m-%d")}
                    q["malnut_muac"] = "%s (%smm)" % (muacc.get_status_display(), muacc.muac)
                    q["malnut_symptoms"] = muacc.symptoms()
                    q["malnut_days_since_last_update"] = muacc.days_since_last_activity()
                except ObjectDoesNotExist:
                    q["malnut_muac"] = ""
                    q["malnut_symptoms"] = ""
                    q["malnut_days_since_last_update"] = ""
                try:
                    orsc = ReportDiarrhea.objects.filter(case=case).latest()
                    q["diarrhea"] = u"%(diag)s on %(date)s" % {
                        "diag": orsc.diagnosis_msg(),
                        "date": orsc.entered_at.strftime("%Y-%m-%d"),
                    }
                except ObjectDoesNotExist:
                    q["diarrhea"] = None

                try:
                    twoweeksago = date.today() - timedelta(14)
                    mrdtc = ReportMalaria.objects.filter(case=case, entered_at__gte=twoweeksago).latest()
                    mrdtcd = mrdtc.get_dictionary()
                    # q['malaria'] = u"result:%(res)s bednet:%(bed)s obs:%(obs)s on %(date)s" % {'res': mrdtcd['result_text'], 'bed': mrdtcd['bednet_text'], 'obs': mrdtcd['observed'], 'date': mrdtc.entered_at.strftime("%Y-%m-%d")}
                    q["malaria_result"] = mrdtc.results_for_malaria_result()
                    q["malaria_bednet"] = mrdtc.results_for_malaria_bednet()
                except ObjectDoesNotExist:
                    q["malaria_result"] = ""
                    q["malaria_bednet"] = ""

                num_of_malaria_cases = ReportMalaria.num_reports_by_case(case)
                if num_of_malaria_cases is not None and num_of_malaria_cases > 1:
                    q["malaria_result"] = q["malaria_result"] + "(%sX)" % num_of_malaria_cases
                    last_mrdt = ReportMalaria.days_since_last_mrdt(case)
                    if last_mrdt is not "" and last_mrdt < 15:
                        q["malaria_result"] = q["malaria_result"] + " %s days ago" % last_mrdt

                try:
                    dc = ReportDiagnosis.objects.filter(case=case).latest("entered_at")
                    dcd = dc.get_dictionary()
                    q["diagnosis"] = u"diag:%(diag)s labs:%(lab)s on %(date)s" % {
                        "diag": dcd["diagnosis"],
                        "lab": dcd["labs_text"],
                        "date": dc.entered_at.strftime("%Y-%m-%d"),
                    }
                except ObjectDoesNotExist:
                    q["diagnosis"] = None

                q["vaccinated"] = ReportMeasles.is_vaccinated(case)
                if q["vaccinated"]:
                    q["sent"] = u"Yes"
                    q["vaccinated"] = u"Yes"
                else:
                    q["vaccinated"] = u"No"
                    q["sent"] = u"No"
                    qs.append(q)

            # caseid +|Y lastname firstname | sex | dob/age | guardian | provider  | date
            fields.append({"name": "#", "column": None, "bit": "{{ object.case.zone }}"})
            fields.append({"name": "PID#", "column": None, "bit": "{{ object.case.ref_id }}"})
            fields.append(
                {"name": "NAME", "column": None, "bit": "{{ object.case.last_name }} {{ object.case.first_name }}"}
            )
            fields.append({"name": "SEX", "column": None, "bit": "{{ object.case.gender }}"})
            fields.append({"name": "AGE", "column": None, "bit": "{{ object.case.age }}"})
            fields.append({"name": "VACCINATED?", "column": None, "bit": "{{ object.vaccinated }}"})
            fields.append({"name": "SENT?", "column": None, "bit": "{{ object.sent }}"})

            return qs, fields