def hba1c(self): """ The HbA1c is calculated using the average blood glucose from the last 90 days. Less than 7 = Excellent Between 7 and 8 = Average Greater than 8 = Bad """ now = datetime.now(tz=self.user.settings.time_zone).date() subset = self.by_date(now - timedelta(days=90), now) average = core_utils.round_value( subset.aggregate(Avg('value'))['value__avg']) hba1c = core_utils.round_value(core_utils.calc_hba1c(average)) css_class = 'text-default' if hba1c: if hba1c < 7: css_class = 'text-success' elif hba1c > 8: css_class = 'text-danger' else: css_class = 'text-primary' value_html = '%s%%<br><small>(%s %s)</small>' % \ (hba1c, self.glucose_by_unit_setting(average), self.glucose_unit_name) \ if hba1c else 'None<br><small>(None)</small>' return {'value': value_html, 'css_class': css_class}
def hba1c(self): """ The HbA1c is calculated using the average blood glucose from the last 90 days. Less than 7 = Excellent Between 7 and 8 = Average Greater than 8 = Bad """ now = datetime.now(tz=self.user.settings.time_zone).date() subset = self.by_date(now - timedelta(days=90), now) average = core_utils.round_value( subset.aggregate(Avg('value'))['value__avg']) hba1c = core_utils.round_value(core_utils.calc_hba1c(average)) css_class = 'text-default' if hba1c: if hba1c < 7: css_class = 'text-success' elif hba1c > 8: css_class = 'text-danger' else: css_class = 'text-primary' value_html = '%s%%<br><small>(%s %s)</small>' % \ (hba1c, self.glucose_by_unit_setting(average), self.glucose_unit_name) \ if hba1c else 'None<br><small>(None)</small>' return { 'value': value_html, 'css_class': css_class }