def _newborn(case, days=None): # :( def af(action): if not days: return True now = dt.datetime.now() return now - dt.timedelta(days=days) <= action.date <= now def recently_delivered(case): return _get_form(case, action_filter=af, form_filter=lambda f: f.form.get('recently_delivered', "") == 'yes') return is_pregnant_mother(case) and\ (recently_delivered(case) or get_related_prop(case, 'birth_status') == "live_birth")
def _numerator(self, case): dtf = _get_prop_from_forms(case, 'date_time_feed') tob = get_related_prop(case, 'time_of_birth') if dtf and tob: return 1 if dtf - tob <= dt.timedelta(hours=1) else 0 return 0
def _denominator(self, case): if super(IDNBCalculator, self)._denominator(case) and get_related_prop(case, 'birth_status') == "live_birth": return 1 else: return 0
def _get_tob(case): # only guaranteed to be accurate within 24 hours tob = get_related_prop(case, "time_of_birth") or get_add(case) # use add if time_of_birth can't be found if isinstance(tob, dt.date): tob = dt.datetime.combine(tob, dt.datetime.time(dt.datetime.now())) #convert date to dt.datetime return tob