def childnutrition(self): ''' Try Get All nutritions details for the baby ''' if hasattr(self.record, 'child_weight'): self.DATA.append(('child_weight', self.record.child_weight)) if hasattr(self.record, 'child_height'): self.DATA.append(('child_height', self.record.child_height)) if hasattr(self.record, 'muac'): self.DATA.append(('muac', self.record.muac)) try: self.DATA.append(('premature', self.ourchild()['symptom_pm'])) except: pass if hasattr(self.record, 'breastfeeding'): self.DATA.append(('breastfeeding', self.record.breastfeeding)) if hasattr(self.record, 'birth_date'): if self.table == 'birmessage': self.DATA.append(('age_in_months', 0)) self.DATA.append(('bf1', self.record.breastfeeding)) else: self.DATA.append(('age_in_months', helpers.date_to_age_in_months( self.record.birth_date.date()))) return True
def childnutrition(self): ''' Try Get All nutritions details for the baby ''' if hasattr(self.record, 'child_weight'): self.DATA.append( ('child_weight', self.record.child_weight)) if hasattr(self.record, 'child_height'): self.DATA.append( ('child_height', self.record.child_height)) if hasattr(self.record, 'muac'): self.DATA.append( ('muac', self.record.muac)) try: self.DATA.append( ('premature', self.ourchild()['symptom_pm'])) except: pass if hasattr(self.record, 'breastfeeding'): self.DATA.append( ('breastfeeding', self.record.breastfeeding)) if hasattr(self.record, 'birth_date'): if self.table == 'birmessage': self.DATA.append( ('age_in_months', 0) ) self.DATA.append( ('bf1', self.record.breastfeeding)) else: self.DATA.append( ('age_in_months', helpers.date_to_age_in_months( self.record.birth_date.date() ) ) ) return True
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
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
return message.respond(_("invalid-gender") % (survey_entry.gender)) try: # find patient or create a new one self.debug(patient_kwargs) patient, created = self.__get_or_create_patient(message, **patient_kwargs) except Exception, e: self.exception('problem saving patient') try: # update age separately (should be the only volitile piece of info) self.debug(survey_entry.age_in_months) if survey_entry.age_in_months is not None: patient.age_in_months = int(survey_entry.age_in_months) else: patient.age_in_months = helpers.date_to_age_in_months(patient.date_of_birth) self.debug(patient.age_in_months) patient.save() except Exception, e: self.exception('problem saving age') return message.respond("On doit mettre le X pour les donnees manquantes par age") # calculate age based on reported date of birth # respond if calcualted age differs from reported age # by more than 3 months TODO make this configurable #self.debug("getting sloppy age...") #sloppy_age_in_months = helpers.date_to_age_in_months(patient.date_of_birth) #self.debug(sloppy_age_in_months) #if (abs(int(sloppy_age_in_months) - int(patient.age_in_months)) > 3): # message.respond("Date of birth indicates Child ID %s's age (in months) is %s, which does not match the reported age (in months) of %s" % (patient.code, sloppy_age_in_months, patient.age_in_months))