def to_object(self): date_from = build_date(self.year_from, self.month_from, self.day_from).strftime(API_DATE_FORMAT) date_to = build_date(self.year_to, self.month_to, self.day_to).strftime(API_DATE_FORMAT) return { "me_office": self.me_office, "date_from": date_from, "date_to": date_to, }
def __calculate_full_date_of_conversation(self): if self.day_of_conversation != '' and self.month_of_conversation != '' and self.year_of_conversation != '': hr, minute = self.__calculate_hour_and_minute_of_conversation() return build_date(self.year_of_conversation, self.month_of_conversation, self.day_of_conversation, hr, minute) else: return None
def for_request(self): representatives = [] if self.bereaved_name_1: appointment_1_date = None if self.day_of_appointment_1 and self.month_of_appointment_1 and self.year_of_appointment_1: appointment_1_date = build_date( self.year_of_appointment_1, self.month_of_appointment_1, self.day_of_appointment_1).strftime(API_DATE_FORMAT) representatives.append({ "fullName": self.bereaved_name_1, "relationship": self.relationship_1, "phoneNumber": self.phone_number_1, "appointmentDate": appointment_1_date, "appointmentTime": self.time_of_appointment_1, "notes": self.appointment_additional_details_1 }) if self.bereaved_name_2: appointment_2_date = None if self.day_of_appointment_2 and self.month_of_appointment_2 and self.year_of_appointment_2: appointment_2_date = build_date( self.year_of_appointment_2, self.month_of_appointment_2, self.day_of_appointment_2).strftime(API_DATE_FORMAT) representatives.append({ "fullName": self.bereaved_name_2, "relationship": self.relationship_2, "phoneNumber": self.phone_number_2, "appointmentDate": appointment_2_date, "appointmentTime": self.time_of_appointment_2, "notes": self.appointment_additional_details_2 }) return { 'representatives': representatives, }
def dates_are_blank_or_death_is_after_birth_date(self): valid_date_of_death = validate_date(self.year_of_death, self.month_of_death, self.day_of_death) valid_date_of_birth = validate_date(self.year_of_birth, self.month_of_birth, self.day_of_birth) if valid_date_of_death and valid_date_of_birth: date_of_death = build_date(self.year_of_death, self.month_of_death, self.day_of_death) date_of_birth = build_date(self.year_of_birth, self.month_of_birth, self.day_of_birth) if date_of_death >= date_of_birth: return True else: return False else: return True
def date_of_death_in_future(self): valid_date_of_death = validate_date(self.year_of_death, self.month_of_death, self.day_of_death) if valid_date_of_death: date_of_death = build_date(self.year_of_death, self.month_of_death, self.day_of_death) current_date = datetime.today() if date_of_death > current_date: return True else: return False
def to_object(self): dob = NONE_DATE dod = NONE_DATE if not self.date_of_birth_not_known: dob = build_date(self.year_of_birth, self.month_of_birth, self.day_of_birth).strftime(API_DATE_FORMAT) if not self.date_of_death_not_known: dod = build_date(self.year_of_death, self.month_of_death, self.day_of_death).strftime(API_DATE_FORMAT) return { "givenNames": self.first_name, "surname": self.last_name, "gender": self.gender, "genderDetails": self.gender_details, "placeDeathOccured": self.place_of_death, "medicalExaminerOfficeResponsible": self.me_office, "nhsNumber": self.nhs_number, "hospitalNumber_1": self.hospital_number_1, "hospitalNumber_2": self.hospital_number_2, "hospitalNumber_3": self.hospital_number_3, "dateOfBirth": dob, "dateOfDeath": dod, "timeOfDeath": '00:00' if self.time_of_death_not_known else self.time_of_death, }
def admission_date(self): if self.admission_date_unknown: return None else: return build_date(self.admission_year, self.admission_month, self.admission_day).strftime(self.date_format)