def _denominator(self, case): def afn(a): return self._action_within_timeframe(a, 30) and a.updated_known_properties.get('mother_alive', None) == "no" if is_pregnant_mother(case): action = _get_action(case, action_filter=afn) return 1 if action else 0 return 0
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 _mother_delivered_in_window(case, days): get_visitduedate = lambda case: case.add + dt.timedelta(days=days) + GRACE_PERIOD return is_pregnant_mother(case) and get_add(case) and _in_last_month(get_visitduedate(case))
def _denominator(self, case): return 1 if is_pregnant_mother(case) else 0
def _expecting_soon(case): return is_pregnant_mother(case) and get_edd(case) and _in_timeframe(case.edd, -30)
def delivered_in_timeframe(case, days): return is_pregnant_mother(case) and get_add(case) and _in_timeframe(case.add, days)