Пример #1
0
    def __init__(self, case, report, child_index=1, **kwargs):
        super(LongitudinalConditionsMet, self).__init__(case, report,
                                                        child_index=child_index,
                                                        **kwargs)
        awc_data = user_sql_data().data_by_doc_id.get(self.owner_id, None)
        self.gp = awc_data[1] if awc_data else EMPTY_FIELD
        self.brank_branch_code = self.case_property('brank_branch_code', EMPTY_FIELD)
        self.caste_tribe_status = self.get_value_from_form(PREG_REG_XMLNS, 'form/caste_tribe_status')
        self.prev_pregnancies = self.get_value_from_form(PREG_REG_XMLNS, 'form/prev_pregnancies')
        self.prev_live_births = self.get_value_from_form(PREG_REG_XMLNS, 'form/prev_live_births')
        self.sons_alive = self.get_value_from_form(PREG_REG_XMLNS, 'form/sons_alive')
        self.daughters_alive = self.get_value_from_form(PREG_REG_XMLNS, 'form/daughters_alive')
        self.sum_children = self.get_value_from_form(PREG_REG_XMLNS, 'form/sum_children')
        self.contact_phone_number = self.get_value_from_form(PREG_REG_XMLNS, 'form/contact_phone_number')
        forms = self.filtered_forms(CHILDREN_FORMS, 3)
        for idx in range(1, 4):
            child_name = self.case_property('child%s_name' % str(idx), None)
            child_age = self.child_age
            if not child_name:
                child_age = EMPTY_FIELD
                child_name = EMPTY_FIELD
            setattr(self, 'child%s_name' % str(idx), child_name)
            setattr(self, 'child%s_age' % str(idx), child_age)
            setattr(self, 'child%s_sex' % str(idx),
                    self.case_property('child%s_sex' % str(idx), EMPTY_FIELD))

            if idx == 1:
                form_prop = 'interpret_grade'
            else:
                form_prop = 'interpret_grade_{}'.format(idx)
            if len(forms) == 0:
                setattr(self, form_prop, EMPTY_FIELD)
                setattr(self, "weight_this_month_%s" % str(idx), EMPTY_FIELD)
            else:
                form = sorted(forms, key=lambda form: form.received_on)[-1]
                setattr(self, form_prop, form.form.get(form_prop, EMPTY_FIELD))
                weight = EMPTY_FIELD
                if "child_%s" % str(idx) in form.form:
                    weight = form.form["child_%s" % str(idx)].get('child%s_weight' % str(idx), EMPTY_FIELD)
                setattr(self, "weight_this_month_%s" % str(idx), weight)
        self.one = format_bool(self.preg_attended_vhnd)
        self.two = format_bool(self.preg_weighed_trimestered(6))
        self.two_two = format_bool(self.preg_weighed_trimestered(9))
        self.three = format_bool(self.preg_received_ifa)
        self.four = format_bool(self.child_attended_vhnd)
        self.five = format_bool(self.child_age == 6)
        self.six = format_bool(self.child_growth_calculated)
        self.seven = format_bool(self.child_breastfed)
        self.eight = format_bool(self.child_age == 3)
        self.nine = format_bool(self.child_received_ors if self.status == 'mother' else False)
        self.ten = format_bool(self.child_age == 12)
        self.opened_on = self.case_property('opened_on', EMPTY_FIELD)
        self.closed_on = self.case_property('closed_on', False)
        self.close_mother_dup = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_dup')
        self.close_mother_mo = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_mo')
        self.leave_program = self.get_value_from_form(CLOSE_FORM, 'form/leave_program')
        self.close_mother_dead = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_dead')
        # set year 1900 and day 1 because we want only month name.
        self.disp_month = datetime.date(year=1900, month=self.month, day=1).strftime("%B")
Пример #2
0
    def __init__(self, case, report, child_index=1, **kwargs):
        super(ConditionsMet, self).__init__(case, report, child_index=child_index, **kwargs)
        self.serial_number = child_index
        self.payment_last_month = "Rs.%d" % (self.last_month_row.cash_amt if self.last_month_row else 0)
        self.cash_received_last_month = self.last_month_row.vhnd_available_display if self.last_month_row else 'no'
        awc_data = user_sql_data().data_by_doc_id.get(self.owner_id, None)
        self.awc_code = numeric_fn(awc_data[0] if awc_data else EMPTY_FIELD)
        self.issue = ''
        if self.status == 'mother':
            self.child_name = self.case_property(self.child_xpath("child{num}_name"), EMPTY_FIELD)
            self.one = self.condition_image(C_ATTENDANCE_Y, C_ATTENDANCE_N, "पोषण दिवस में उपस्थित",
                                            "पोषण दिवस में उपस्थित नही", self.child_attended_vhnd)
            self.two = self.condition_image(C_WEIGHT_Y, C_WEIGHT_N, "बच्चे का वज़न लिया गया",
                                            "बच्चे का वज़न लिया गया", self.child_growth_calculated)
            if self.child_has_diarhea and self.child_received_ors:
                self.three = self.img_elem % (ORSZNTREAT_Y, "दस्त होने पर ओ.आर.एस एवं जिंक लिया")
            elif self.child_has_diarhea and not self.child_received_ors:
                self.three = self.img_elem % (ORSZNTREAT_N, "दस्त होने पर ओ.आर.एस एवं जिंक नहीं लिया")
            elif not self.child_has_diarhea:
                self.three = self.img_elem % (ORSZNTREAT_Y, "बच्चे को दस्त नहीं हुआ")
            else:
                self.three = ""
            if self.child_condition_four is not None:
                self.four = self.condition_image(self.child_image_four[0], self.child_image_four[1],
                                                 self.child_image_four[2], self.child_image_four[3],
                                                 self.child_condition_four)
            else:
                self.four = ''
            self.five = self.condition_image(EXCBREASTFED_Y, EXCBREASTFED_N, "केवल माँ का दूध खिलाया गया",
                                             "केवल माँ का दूध नहीं खिलाया गया", self.child_breastfed)
        elif self.status == 'pregnant':
            self.child_name = EMPTY_FIELD
            self.one = self.condition_image(C_ATTENDANCE_Y, C_ATTENDANCE_N, "पोषण दिवस में उपस्थित",
                                            "पोषण दिवस में उपस्थित नही", self.preg_attended_vhnd)
            self.two = self.condition_image(M_WEIGHT_Y, M_WEIGHT_N, "गर्भवती का वज़न हुआ",
                                            "गर्भवती का वज़न नही हुआा", self.preg_weighed)
            self.three = self.condition_image(IFA_Y, IFA_N, "तीस आयरन की गोलियां लेना",
                                              "तीस आयरन की गोलियां नही लिया", self.preg_received_ifa)
            self.four = ''
            self.five = ''
        if self.child_age in (24, 36):
            if self.block == 'atri':
                met, pos, neg = self.weight_grade_normal, GRADE_NORMAL_Y, GRADE_NORMAL_N
            else:
                met, pos, neg = self.birth_spacing_years, SPACING_PROMPT_Y, SPACING_PROMPT_N

            if met:
                self.five = self.img_elem % (pos, "")
            elif met is False:
                self.five = self.img_elem % (neg, "")
            else:
                self.five = ''

        if not self.vhnd_available:
            self.one = self.img_elem % (VHND_NO, "पोषण दिवस का आयोजन नहीं हुआ")
Пример #3
0
class LongitudinalConditionsMet(ConditionsMet):
    method_map = [
        ('serial_number', ugettext_lazy("Serial number"), True, DTSortType.NUMERIC),
        ('name', ugettext_lazy("List of Beneficiaries"), True, None),
        ('case_id', ugettext_lazy('Case ID'), True, None),
        ('awc_name', ugettext_lazy("AWC Name"), True, None),
        ('awc_code', ugettext_lazy("AWC Code"), True, DTSortType.NUMERIC),
        ('block_name', ugettext_lazy("Block Name"), True, None),
        ('gp', ugettext_lazy("Gram Panchayat name"), True, None),
        ('village', ugettext_lazy("Village name"), True, None),
        ('dob_known', ugettext_lazy("Dob Known"), True, None),
        ('mother_age', ugettext_lazy("Mother's Age"), True, None),
        ('caste_tribe_status', ugettext_lazy("Caste tribe status"), True, None),
        ('husband_name', ugettext_lazy("Husband Name"), True, None),
        ('prev_pregnancies', ugettext_lazy("Prev pregnancies"), True, None),
        ('prev_live_births', ugettext_lazy("Prev live births"), True, None),
        ('sons_alive', ugettext_lazy("Sons alive"), True, None),
        ('daughters_alive', ugettext_lazy("Daughters alive"), True, None),
        ('sum_children', ugettext_lazy("Sum children"), True, None),
        ('contact_phone_number', ugettext_lazy("Contact phone number"), True, None),
        ('bank_name', ugettext_lazy("Bank Name"), True, None),
        ('account_number', ugettext_lazy("Bank Account Number"), True, None),
        ('bank_branch_name', ugettext_lazy("Bank Branch Name"), True, None),
        ('brank_branch_code', ugettext_lazy("Brank Branch Code"), True, None),
        ('ifs_code', ugettext_lazy("IFS Code"), True, None),
        ('readable_status', ugettext_lazy("Current status"), True, None),
        ('lmp', ugettext_lazy("Lmp Date"), True, None),
        ('edd', ugettext_lazy("EDD"), True, None),
        ('preg_month_display', ugettext_lazy("Pregnancy month"), True, None),
        ('window', ugettext_lazy("Window"), True, None),
        ('child1_age', ugettext_lazy("Child 1 Age"), True, None),
        ('child1_name', ugettext_lazy("Child 1 Name"), True, None),
        ('child1_sex', ugettext_lazy("Child 1 Sex"), True, None),
        ('dod', ugettext_lazy("Child DOB"), True, None),
        ('child2_age', ugettext_lazy("Child 2 Age"), True, None),
        ('child2_name', ugettext_lazy("Child 2 Name"), True, None),
        ('child2_sex', ugettext_lazy("Child 2 Sex"), True, None),
        ('child3_age', ugettext_lazy("Child 3 Age"), True, None),
        ('child3_name', ugettext_lazy("Child 3 Name"), True, None),
        ('child3_sex', ugettext_lazy("Child 3 Sex"), True, None),
        ('one', ugettext_lazy("Condition 1 / pregnant woman attended VHND"), True, None),
        ('two', ugettext_lazy("Condition 2 /pregnant woman's weight taken in first trimester"), True, None),
        ('three', ugettext_lazy("Condition 3/ Received 30 IFA pills"), True, None),
        ('two_two', ugettext_lazy("Condition 2 /pregnant woman's weight taken in second trimester"), True, None),
        ('four', ugettext_lazy("Condition 4/mother attended VHND with child"), True, None),
        ('five', ugettext_lazy("Condition 5/child birth registered"), True, None),
        ('six', ugettext_lazy("Condition 6/ child birth weight taken"), True, None),
        ('seven', ugettext_lazy("Condition 7 /exclusively breastfed for first 6 months"), True, None),
        ('eight', ugettext_lazy("Condition 8 /child weight monitored this month"), True, None),
        ('nine', ugettext_lazy("Condition 9 /ORS administered if child had diarrhea"), True, None),
        ('ten', ugettext_lazy("Condition 10/ Measles vaccine given before child turns 1"), True, None),
        ('incidence_of_diarrhea', ugettext_lazy("Incidence Of Diarrhea"), True, None),
        ('birth_spacing_bonus', ugettext_lazy("Birth Spacing Bonus"), True, None),
        ('weight_this_month_1', ugettext_lazy("Weight This Month - Child 1"), True, None),
        ('weight_this_month_2', ugettext_lazy("Weight This Month - Child 2"), True, None),
        ('weight_this_month_3', ugettext_lazy("Weight This Month - Child 3"), True, None),
        ('interpret_grade', ugettext_lazy("Nutritional Status This Month - Child 1"), True, None),
        ('interpret_grade_2', ugettext_lazy("Nutritional Status This Month - Child 2"), True, None),
        ('interpret_grade_3', ugettext_lazy("Nutritional Status This Month - Child 3"), True, None),
        ('nutritional_status_bonus', ugettext_lazy("Nutritional Status Bonus"), True, None),
        ('payment_last_month', ugettext_lazy("Payment amount for the month"), True, None),
        ('cash_received_last_month', ugettext_lazy("Cash received last month"), True, None),
        ('issue', ugettext_lazy('Issues'), True, None),
        ('vhnd_available_display', ugettext_lazy("VHND held this month?"), True, None),
        ('opened_on', ugettext_lazy("Opened on"), True, None),
        ('closed_on', ugettext_lazy("Closed on"), True, None),
        ('close_mother_dup', ugettext_lazy("Close mother dup"), True, None),
        ('close_mother_mo', ugettext_lazy("Close mother mo"), True, None),
        ('leave_program', ugettext_lazy("Leave program"), True, None),
        ('close_mother_dead', ugettext_lazy("Close mother dead"), True, None),
        ('year', ugettext_lazy("Calendar year"), True, None),
        ('disp_month', ugettext_lazy("Calendar month"), True, None)
    ]

    def __init__(self, case, report, child_index=1, **kwargs):
        super(LongitudinalConditionsMet, self).__init__(case, report,
                                                        child_index=child_index,
                                                        **kwargs)
        awc_data = user_sql_data().data_by_doc_id.get(self.owner_id, None)
        self.gp = awc_data[1] if awc_data else EMPTY_FIELD
        self.brank_branch_code = self.case_property('brank_branch_code', EMPTY_FIELD)
        self.caste_tribe_status = self.get_value_from_form(PREG_REG_XMLNS, 'form/caste_tribe_status')
        self.prev_pregnancies = self.get_value_from_form(PREG_REG_XMLNS, 'form/prev_pregnancies')
        self.prev_live_births = self.get_value_from_form(PREG_REG_XMLNS, 'form/prev_live_births')
        self.sons_alive = self.get_value_from_form(PREG_REG_XMLNS, 'form/sons_alive')
        self.daughters_alive = self.get_value_from_form(PREG_REG_XMLNS, 'form/daughters_alive')
        self.sum_children = self.get_value_from_form(PREG_REG_XMLNS, 'form/sum_children')
        self.contact_phone_number = self.get_value_from_form(PREG_REG_XMLNS, 'form/contact_phone_number')
        forms = self.filtered_forms(CHILDREN_FORMS, 3)
        for idx in range(1, 4):
            child_name = self.case_property('child%s_name' % str(idx), None)
            child_age = self.child_age
            if not child_name:
                child_age = EMPTY_FIELD
                child_name = EMPTY_FIELD
            setattr(self, 'child%s_name' % str(idx), child_name)
            setattr(self, 'child%s_age' % str(idx), child_age)
            setattr(self, 'child%s_sex' % str(idx),
                    self.case_property('child%s_sex' % str(idx), EMPTY_FIELD))

            if idx == 1:
                form_prop = 'interpret_grade'
            else:
                form_prop = 'interpret_grade_{}'.format(idx)
            if len(forms) == 0:
                setattr(self, form_prop, EMPTY_FIELD)
                setattr(self, "weight_this_month_%s" % str(idx), EMPTY_FIELD)
            else:
                form = sorted(forms, key=lambda form: form.received_on)[-1]
                setattr(self, form_prop, form.form.get(form_prop, EMPTY_FIELD))
                weight = EMPTY_FIELD
                if "child_%s" % str(idx) in form.form:
                    weight = form.form["child_%s" % str(idx)].get('child%s_weight' % str(idx), EMPTY_FIELD)
                setattr(self, "weight_this_month_%s" % str(idx), weight)
        self.one = format_bool(self.preg_attended_vhnd)
        self.two = format_bool(self.preg_weighed_trimestered(6))
        self.two_two = format_bool(self.preg_weighed_trimestered(9))
        self.three = format_bool(self.preg_received_ifa)
        self.four = format_bool(self.child_attended_vhnd)
        self.five = format_bool(self.child_birth_registered)
        self.six = format_bool(self.child_growth_calculated)
        self.seven = format_bool(self.child_breastfed)
        self.eight = format_bool(self.child_age == 3)
        self.nine = format_bool(self.child_received_ors_in_this_window if self.status == 'mother' else False)
        self.ten = format_bool(self.child_age == 12)
        self.opened_on = self.case_property('opened_on', EMPTY_FIELD)
        self.closed_on = self.case_property('closed_on', False)
        self.close_mother_dup = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_dup')
        self.close_mother_mo = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_mo')
        self.leave_program = self.get_value_from_form(CLOSE_FORM, 'form/leave_program')
        self.close_mother_dead = self.get_value_from_form(CLOSE_FORM, 'form/close_mother_dead')
        # set year 1900 and day 1 because we want only month name.
        self.disp_month = datetime.date(year=1900, month=self.month, day=1).strftime("%B")
Пример #4
0
class ConditionsMet(OPMCaseRow):
    method_map = [
        ('serial_number', ugettext_lazy("Serial number"), True, DTSortType.NUMERIC),
        ('name', ugettext_lazy("List of Beneficiaries"), True, None),
        ('awc_name', ugettext_lazy("AWC Name"), True, None),
        ('awc_code', ugettext_lazy("AWC Code"), True, DTSortType.NUMERIC),
        ('block_name', ugettext_lazy("Block Name"), True, None),
        ('husband_name', ugettext_lazy("Husband Name"), True, None),
        ('readable_status', ugettext_lazy("Current status"), True, None),
        ('preg_month_display', ugettext_lazy('Pregnancy Month'), True, DTSortType.NUMERIC),
        ('child_name', ugettext_lazy("Child Name"), True, None),
        ('child_age_display', ugettext_lazy("Child Age"), True, DTSortType.NUMERIC),
        ('window', ugettext_lazy("Window"), True, None),
        ('one', ugettext_lazy("Condition 1"), True, None),
        ('two', ugettext_lazy("Condition 2"), True, None),
        ('three', ugettext_lazy("Condition 3"), True, None),
        ('four', ugettext_lazy("Condition 4"), True, None),
        ('five', ugettext_lazy("Condition 5"), True, None),
        ('cash', ugettext_lazy("Payment amount this month (Rs.)"), True, None),
        ('payment_last_month', ugettext_lazy("Payment amount last month (Rs.)"), True, None),
        ('cash_received_last_month', ugettext_lazy("Cash received last month"), True, None),
        ('case_id', ugettext_lazy('Case ID'), True, None),
        ('closed_date', ugettext_lazy("Closed On"), True, None),
        ('issue', ugettext_lazy('Issues'), True, None)
    ]

    def __init__(self, case, report, child_index=1, **kwargs):
        super(ConditionsMet, self).__init__(case, report, child_index=child_index, **kwargs)
        self.serial_number = child_index
        self.payment_last_month = "Rs.%d" % (self.last_month_row.cash_amt if self.last_month_row else 0)
        self.cash_received_last_month = self.last_month_row.vhnd_available_display if self.last_month_row else 'no'
        awc_data = user_sql_data().data_by_doc_id.get(self.owner_id, None)
        self.awc_code = numeric_fn(awc_data[0] if awc_data else EMPTY_FIELD)
        self.issue = ''
        if self.status == 'mother':
            self.child_name = self.case_property(self.child_xpath("child{num}_name"), EMPTY_FIELD)
            self.one = self.condition_image(C_ATTENDANCE_Y, C_ATTENDANCE_N, "पोषण दिवस में उपस्थित",
                                            "पोषण दिवस में उपस्थित नही", self.child_attended_vhnd)
            self.two = self.condition_image(C_WEIGHT_Y, C_WEIGHT_N, "बच्चे का वज़न लिया गया",
                                            "बच्चे का वज़न लिया गया", self.child_growth_calculated)
            if self.child_has_diarhea and self.child_received_ors_in_this_window:
                self.three = self.img_elem % (ORSZNTREAT_Y, "दस्त होने पर ओ.आर.एस एवं जिंक लिया")
            elif self.child_has_diarhea and not self.child_received_ors_in_this_window:
                self.three = self.img_elem % (ORSZNTREAT_N, "दस्त होने पर ओ.आर.एस एवं जिंक नहीं लिया")
            elif not self.child_has_diarhea:
                self.three = self.img_elem % (ORSZNTREAT_Y, "बच्चे को दस्त नहीं हुआ")
            else:
                self.three = ""
            if self.child_condition_four is not None:
                self.four = self.condition_image(self.child_image_four[0], self.child_image_four[1],
                                                 self.child_image_four[2], self.child_image_four[3],
                                                 self.child_condition_four)
            else:
                self.four = ''
            self.five = self.condition_image(EXCBREASTFED_Y, EXCBREASTFED_N, "केवल माँ का दूध खिलाया गया",
                                             "केवल माँ का दूध नहीं खिलाया गया", self.child_breastfed)
        elif self.status == 'pregnant':
            self.child_name = EMPTY_FIELD
            self.one = self.condition_image(C_ATTENDANCE_Y, C_ATTENDANCE_N, "पोषण दिवस में उपस्थित",
                                            "पोषण दिवस में उपस्थित नही", self.preg_attended_vhnd)
            self.two = self.condition_image(M_WEIGHT_Y, M_WEIGHT_N, "गर्भवती का वज़न हुआ",
                                            "गर्भवती का वज़न नही हुआा", self.preg_weighed)
            self.three = self.condition_image(IFA_Y, IFA_N, "तीस आयरन की गोलियां लेना",
                                              "तीस आयरन की गोलियां नही लिया", self.preg_received_ifa)
            self.four = ''
            self.five = ''
        if self.child_age in (24, 36):
            if self.block == 'atri':
                met, pos, neg = self.weight_grade_normal, GRADE_NORMAL_Y, GRADE_NORMAL_N
            else:
                met, pos, neg = self.birth_spacing_years, SPACING_PROMPT_Y, SPACING_PROMPT_N

            if met:
                self.five = self.img_elem % (pos, "")
            elif met is False:
                self.five = self.img_elem % (neg, "")
            else:
                self.five = ''

        if not self.vhnd_available:
            self.one = self.img_elem % (VHND_NO, "पोषण दिवस का आयोजन नहीं हुआ")