示例#1
0
def _get_tob(case):  # only guaranteed to be accurate within 24 hours
    import couchdbkit
    tob = get_related_prop(case, "time_of_birth") or '00:00:00'

    tob = couchdbkit.schema.TimeProperty().to_python(tob)
    tob = datetime.datetime.combine(get_add(case), tob)  # convert date to dt.datetime
    return tob
示例#2
0
 def numerator(self, case):
     visit_time = _get_time_of_visit_after_birth(case)
     time_birth = _get_tob(case)
     if visit_time and time_birth:
         if time_birth < visit_time < time_birth + self.visited_window:
             # matches total, so you know this will be a subset of those
             yield get_add(case)
示例#3
0
    def _calculate_both(self, case):
        complication_date = None
        complication_shortly_after_birth_date = None
        if case.type == 'cc_bihar_pregnancy':
            for form, date in self.get_forms_with_complications(case):
                complication_date = date
                if form.xmlns == 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:
                    complication_shortly_after_birth_date = date

        return complication_shortly_after_birth_date, complication_date
示例#4
0
 def total(self, case):
     yield get_add(case)
示例#5
0
 def has_add(self, case):
     return is_pregnant_mother(case) and get_add(case)
示例#6
0
 def numerator(self, case):
     if less_than_two_kilos(case):
         yield get_add(case)
示例#7
0
 def numerator(self, case):
     if is_preterm(case):
         yield get_add(case)
示例#8
0
 def numerator(self, case):
     if adopted_fp(case):
         yield get_add(case)
示例#9
0
 def numerator(self, case):
     if couple_interested_in_fp(case):
         yield get_add(case)
示例#10
0
 def sortkey(self, case, context):
     # hacky way to sort by reverse add
     return datetime.datetime.today().date() - (get_add(case) or datetime.datetime.max.date())
示例#11
0
 def filter(self, case):
     return is_pregnant_mother(case) and get_add(case)