Exemplo n.º 1
0
 def _validate_sex(self, potential_sex):
     self.debug("validate sex...")
     self.debug(potential_sex)
     try:
         gender = helpers.get_good_sex(potential_sex)
         if gender is not None:
             return gender
         else:
             return None
     except Exception, e:
         self.exception('problem validating sex')
Exemplo n.º 2
0
 def _get_valid_gender(self):
     try:
         sex = ""
         if self.gender.lower() == 'gi' :
             sex = 'Female'
         elif  self.gender.lower() == 'bo':
             sex = "Male"            
         valid_gender = helpers.get_good_sex( sex )
         return valid_gender
     except:
         return None
Exemplo n.º 3
0
    def child_nutrition_status(self):
        try:
            
            data = dict(self.DATA)
            valid_gender = helpers.get_good_sex( data.get('gender') )
            valid_age = helpers.date_to_age_in_months(data.get('birth_date').date())
            cg = Calculator(adjust_height_data=False, adjust_weight_scores=False)

            try:
                            
                new_value = float(self.record.child_weight)
                old_value = float(self.ourchild()['child_weight'])
                if self.table != 'birmessage':
                    if new_value < old_value:
                        self.DATA.append(('lostweight', True))
                        self.DATA.append( ('gainedweight', False))
                    if new_value > old_value:
                        self.DATA.append(('lostweight', False))
                        self.DATA.append( ('gainedweight', True))
                    if new_value == old_value:
                        self.DATA.append( ('falteringweight', True))
                        self.DATA.append(('lostweight', False))
                        self.DATA.append( ('gainedweight', False))

                wfa = cg.zscore_for_measurement('wfa', data.get('child_weight'), valid_age, valid_gender)
                self.DATA.append( ('weight_for_age', float(wfa)))
            except Exception, e: pass
            try: 
                hfa = cg.zscore_for_measurement('lhfa', data.get('child_height') , valid_age, valid_gender)
                self.DATA.append( ('height_for_age', float(hfa) ))
            except Exception, e: pass
            try:
                
                wfh = cg.zscore_for_measurement('wfh', data.get('child_weight'), valid_age, valid_gender, data.get('child_height'))
                self.DATA.append( ('weight_for_height', float(wfh) ))
            except Exception, e: pass
        except: return False 

        return True
Exemplo n.º 4
0
    def child_nutrition_status(self):
        try:

            data = dict(self.DATA)
            valid_gender = helpers.get_good_sex(data.get('gender'))
            valid_age = helpers.date_to_age_in_months(
                data.get('birth_date').date())
            cg = Calculator(adjust_height_data=False,
                            adjust_weight_scores=False)

            try:

                new_value = float(self.record.child_weight)
                old_value = float(self.ourchild()['child_weight'])
                if self.table != 'birmessage':
                    if new_value < old_value:
                        self.DATA.append(('lostweight', True))
                        self.DATA.append(('gainedweight', False))
                    if new_value > old_value:
                        self.DATA.append(('lostweight', False))
                        self.DATA.append(('gainedweight', True))
                    if new_value == old_value:
                        self.DATA.append(('falteringweight', True))
                        self.DATA.append(('lostweight', False))
                        self.DATA.append(('gainedweight', False))

                wfa = cg.zscore_for_measurement('wfa',
                                                data.get('child_weight'),
                                                valid_age, valid_gender)
                self.DATA.append(('weight_for_age', float(wfa)))
            except Exception, e:
                pass
            try:
                hfa = cg.zscore_for_measurement('lhfa',
                                                data.get('child_height'),
                                                valid_age, valid_gender)
                self.DATA.append(('height_for_age', float(hfa)))
            except Exception, e:
                pass