예제 #1
0
 def anc_completed(self):
     lmp = self.lmp
     anc_date_1 = self.anc_date_1
     if lmp != EMPTY_FIELD and anc_date_1 != EMPTY_FIELD:
         try:
             return _("yes") if CaseDisplay.parse_date(self, self.anc_date_1) < (CaseDisplay.parse_date(self, self.lmp) + timedelta(days=12*7)) else _("no")
         except AttributeError:
             return _("Bad date format!")
     else:
         return EMPTY_FIELD
예제 #2
0
 def anc_completed(self):
     lmp = self.lmp
     anc_date_1 = self.anc_date_1
     if lmp != EMPTY_FIELD and anc_date_1 != EMPTY_FIELD:
         try:
             return _("yes") if CaseDisplay.parse_date(self, self.anc_date_1) < (CaseDisplay.parse_date(self, self.lmp) + timedelta(days=12*7)) else _("no")
         except AttributeError:
             return _("Bad date format!")
     else:
         return EMPTY_FIELD
예제 #3
0
 def parse_date(self, date_string):
     if date_string != EMPTY_FIELD and date_string != '' and date_string is not None:
         try:
             return self.report.date_to_json(CaseDisplay.parse_date(self, date_string))
         except AttributeError:
             return _("Bad date format!")
     else:
         return EMPTY_FIELD
예제 #4
0
 def parse_date(self, date_string):
     if date_string != EMPTY_FIELD and date_string != '' and date_string is not None:
         try:
             return str(self.report.date_to_json(CaseDisplay.parse_date(self, date_string)))
         except AttributeError:
             return _("Bad date format!")
         except TypeError:
             return _("Bad date format!")
     else:
         return EMPTY_FIELD
예제 #5
0
 def rows(self):
     checkbox = mark_safe('<input type="checkbox" class="selected-commcare-case" data-caseid="%(case_id)s" data-owner="%(owner)s" data-ownertype="%(owner_type)s" />')
     for row in self.es_results['hits'].get('hits', []):
         case = self.get_case(row)
         display = CaseDisplay(self, case)
         yield [
             checkbox % dict(case_id=case['_id'], owner=display.owner_id, owner_type=display.owner_type),
             display.case_link,
             display.case_type,
             display.owner_display,
             naturaltime(display.parse_date(display.case['modified_on'])),
         ]
예제 #6
0
 def rows(self):
     checkbox = mark_safe('<input type="checkbox" class="selected-commcare-case" data-bind="event: {change: updateCaseSelection}" data-caseid="%(case_id)s" data-owner="%(owner)s" data-ownertype="%(owner_type)s" />')
     for row in self.es_results['hits'].get('hits', []):
         case = self.get_case(row)
         display = CaseDisplay(self, case)
         yield [
             checkbox % dict(case_id=case['_id'], owner=display.owner_id, owner_type=display.owner_type),
             display.case_link,
             display.case_type,
             display.owner_display,
             util.format_relative_date(display.parse_date(display.case['modified_on']))['html'],
         ]
예제 #7
0
    def dob_age(self):
        if "dob" in self.case and self.case["dob"]:
            try:
                dob = self.case["dob"]

                if type(dob) is dict:
                    dob = dob["#value"]
                days = (date.today() - CaseDisplay.parse_date(self, dob).date()).days
                dob = self.parse_date(dob)
                return "%s, %s" % (dob, int(days/365.25))
            except AttributeError:
                return _("Bad date format!")
        else:
            return EMPTY_FIELD
예제 #8
0
    def dob_age(self):
        if "mother_dob" in self.case and self.case["mother_dob"]:
            try:
                mother_dob = self.case["mother_dob"]

                if type(mother_dob) is dict:
                    mother_dob = mother_dob["#value"]
                days = (date.today() - CaseDisplay.parse_date(self, mother_dob).date()).days
                mother_dob = self.parse_date(mother_dob)
                return "%s, %s" % (mother_dob, days/365)
            except AttributeError:
                return _("Bad date format!")
        else:
            return EMPTY_FIELD
예제 #9
0
    def dob_age(self):
        if "dob" in self.case and self.case["dob"]:
            try:
                dob = self.case["dob"]

                if type(dob) is dict:
                    dob = dob["#value"]
                days = (date.today() - CaseDisplay.parse_date(self, dob).date()).days
                dob = self.parse_date(dob)
                return "%s, %s" % (dob, int(days/365.25))
            except AttributeError:
                return _("Bad date format!")
        else:
            return EMPTY_FIELD
예제 #10
0
    def dob_age(self):
        if "mother_dob" in self.case and self.case["mother_dob"]:
            try:
                mother_dob = self.case["mother_dob"]

                if type(mother_dob) is dict:
                    mother_dob = mother_dob["#value"]
                days = (date.today() - CaseDisplay.parse_date(self, mother_dob).date()).days
                mother_dob = self.parse_date(mother_dob)
                return "%s, %s" % (mother_dob, days/365)
            except AttributeError:
                return _("Bad date format!")
        else:
            return EMPTY_FIELD