예제 #1
0
    def _calculate_both(self, case):
        has_complication = False
        has_recent_complication = False
        if case.type == 'cc_bihar_pregnancy':
            for form in self.get_forms_with_complications(case):
                has_complication = True
                if form.xmlns == self.DELIVERY:
                    add = form.xpath('form/add')
                else:
                    add = get_add(case)
                add = string_to_datetime(add).date()
                if form.metadata.timeStart.date() - add <= self.days:
                    has_recent_complication = True
                    break

        return has_recent_complication, has_complication
예제 #2
0
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))
예제 #3
0
def delivered_in_timeframe(case, days):
    return is_pregnant_mother(case) and get_add(case) and _in_timeframe(case.add, days)
예제 #4
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
예제 #5
0
 def sortkey(self):
     # hacky way to sort by reverse add
     return lambda case: dt.datetime.today().date() - (get_add(case) or dt.datetime.max.date())