def __fill_representatives_from_draft(self, default_representatives, draft):

        self.existing_representative = None
        self.alternate_representative = None
        if default_representatives and len(default_representatives) > 0:
            self.existing_representative = default_representatives[0]
        draft_participant = None
        if len(draft.participant_full_name) > 0:
            draft_participant = BereavedRepresentative({
                "fullName": draft.participant_full_name,
                "relationship": draft.participant_relationship,
                'phoneNumber': draft.participant_phone_number,
            })
        if draft_participant is None:
            if self.existing_representative is not None:
                self.discussion_representative_type = enums.people.BEREAVED_REP
            else:
                self.discussion_representative_type = enums.people.NOBODY
        else:
            if draft_participant.equals(self.existing_representative):
                self.discussion_representative_type = enums.people.BEREAVED_REP
            else:
                self.discussion_representative_type = enums.people.OTHER
                self.alternate_representative = draft_participant

        self.__set_use_existing_bereaved()
 def set_bereaved_info_values(self, form):
     self.representatives = []
     representative1 = {
         'bereaved_name': form.bereaved_name_1,
         'relationship': form.relationship_1,
         'phone_number': form.phone_number_1,
         'day_of_appointment': form.day_of_appointment_1,
         'month_of_appointment': form.month_of_appointment_1,
         'year_of_appointment': form.year_of_appointment_1,
         'time_of_appointment': form.time_of_appointment_1,
         'appointment_notes': form.appointment_additional_details_1,
     }
     representative2 = {
         'bereaved_name': form.bereaved_name_2,
         'relationship': form.relationship_2,
         'phone_number': form.phone_number_2,
         'day_of_appointment': form.day_of_appointment_2,
         'month_of_appointment': form.month_of_appointment_2,
         'year_of_appointment': form.year_of_appointment_2,
         'time_of_appointment': form.time_of_appointment_2,
         'appointment_notes': form.appointment_additional_details_2,
     }
     self.representatives.append(
         BereavedRepresentative().set_values_from_form(representative1))
     self.representatives.append(
         BereavedRepresentative().set_values_from_form(representative2))
     return self
Beispiel #3
0
 def test_initialising_with_the_valid_date_leads_appointment_details_being_set(self):
     bereaved_data = ExaminationMocks.get_patient_details_bereaved_form_data()
     bereaved_data['appointmentDate'] = '2019-03-26T13:29:50.473Z'
     bereaved = BereavedRepresentative(bereaved_data)
     self.assertEqual(bereaved.appointment_day, 26)
     self.assertEqual(bereaved.appointment_month, 3)
     self.assertEqual(bereaved.appointment_year, 2019)
 def __init_alternate_representative(self, form_data):
     alternate_bereaved_data = {
         'fullName': fallback_to(form_data.get('bereaved_alternate_rep_name'), ''),
         'relationship': fallback_to(form_data.get('bereaved_alternate_rep_relationship'), ''),
         'phoneNumber': fallback_to(form_data.get('bereaved_alternate_rep_phone_number'), '')
     }
     self.alternate_representative = BereavedRepresentative(obj_dict=alternate_bereaved_data)
Beispiel #5
0
 def test_initialising_with_the_no_date_leads_no_appointment_details_set(self):
     bereaved_data = ExaminationMocks.get_patient_details_bereaved_form_data()
     bereaved_data['appointmentDate'] = None
     bereaved = BereavedRepresentative(bereaved_data)
     self.assertIsNone(bereaved.appointment_date)
     self.assertIsNone(bereaved.appointment_day)
     self.assertIsNone(bereaved.appointment_month)
     self.assertIsNone(bereaved.appointment_year)
 def __init_existing_representative(self, form_data):
     self.existing_representative = None
     bereaved_existing_name = fallback_to(form_data.get('bereaved_existing_rep_name'), '')
     if len(bereaved_existing_name) > 0:
         existing_bereaved_data = {
             'fullName': bereaved_existing_name,
             'relationship': fallback_to(form_data.get('bereaved_existing_rep_relationship'), ''),
             'phoneNumber': fallback_to(form_data.get('bereaved_existing_rep_phone_number'), '')
         }
         self.existing_representative = BereavedRepresentative(obj_dict=existing_bereaved_data)
    def __init__(self, obj_dict={}, modes_of_disposal={}, examination_id=None):

        self.modes_of_disposal = modes_of_disposal

        self.id = examination_id if examination_id else obj_dict.get("id")
        self.case_header = PatientHeader(obj_dict.get("header"))

        self.completed = obj_dict.get("completed")
        self.coroner_status = obj_dict.get("coronerStatus")

        self.given_names = obj_dict.get("givenNames")
        self.surname = obj_dict.get("surname")
        self.gender = obj_dict.get("gender")
        self.gender_details = obj_dict.get("genderDetails")
        self.nhs_number = obj_dict.get("nhsNumber")
        self.hospital_number_1 = obj_dict.get("hospitalNumber_1")
        self.hospital_number_2 = obj_dict.get("hospitalNumber_2")
        self.hospital_number_3 = obj_dict.get("hospitalNumber_3")
        self.death_occurred_location_id = obj_dict.get("placeDeathOccured")
        self.medical_examiner_office_responsible = obj_dict.get(
            "medicalExaminerOfficeResponsible")
        self.out_of_hours = obj_dict.get("outOfHours")

        self.house_name_number = fallback_to(obj_dict.get("houseNameNumber"),
                                             '')
        self.street = fallback_to(obj_dict.get("street"), '')
        self.town = fallback_to(obj_dict.get("town"), '')
        self.county = fallback_to(obj_dict.get("county"), '')
        self.country = fallback_to(obj_dict.get("country"), '')
        self.postcode = fallback_to(obj_dict.get("postCode"), '')
        self.last_occupation = fallback_to(obj_dict.get("lastOccupation"), '')
        self.organisation_care_before_death_location_id = fallback_to(
            obj_dict.get("organisationCareBeforeDeathLocationId"), '')
        self.any_implants = 'true' if obj_dict.get("anyImplants") else 'false'
        self.implant_details = fallback_to(obj_dict.get("implantDetails"), '')
        self.funeral_directors = fallback_to(obj_dict.get("funeralDirectors"),
                                             '')
        self.any_personal_effects = 'true' if obj_dict.get(
            "anyPersonalEffects") else 'false'
        self.personal_affects_details = fallback_to(
            obj_dict.get("personalEffectDetails"), '')

        self.cultural_priority = bool_to_string(
            obj_dict.get("culturalPriority"))
        self.faith_priority = bool_to_string(obj_dict.get("faithPriority"))
        self.child_priority = bool_to_string(obj_dict.get("childPriority"))
        self.coroner_priority = bool_to_string(obj_dict.get("coronerPriority"))
        self.other_priority = bool_to_string(obj_dict.get("otherPriority"))
        self.priority_details = fallback_to(obj_dict.get("priorityDetails"),
                                            '')

        if is_empty_time(obj_dict.get("timeOfDeath")):
            self.time_of_death = None
        else:
            self.time_of_death = obj_dict.get("timeOfDeath")

        if not (is_empty_date(obj_dict.get("dateOfBirth"))
                or obj_dict.get("dateOfBirth") is None):
            self.date_of_birth = parse_datetime(obj_dict.get("dateOfBirth"))
            self.day_of_birth = self.date_of_birth.day
            self.month_of_birth = self.date_of_birth.month
            self.year_of_birth = self.date_of_birth.year
        else:
            self.date_of_birth = None
            self.day_of_birth = None
            self.month_of_birth = None
            self.year_of_birth = None

        if not (is_empty_date(obj_dict.get("dateOfDeath"))
                or obj_dict.get("dateOfDeath") is None):
            self.date_of_death = parse_datetime(obj_dict.get("dateOfDeath"))
            self.day_of_death = self.date_of_death.day
            self.month_of_death = self.date_of_death.month
            self.year_of_death = self.date_of_death.year
        else:
            self.date_of_death = None
            self.day_of_death = None
            self.month_of_death = None
            self.year_of_death = None

        self.mode_of_disposal = ''
        for key, value in self.modes_of_disposal.items():
            if key == obj_dict.get("modeOfDisposal"):
                self.mode_of_disposal = key

        self.representatives = []
        if obj_dict.get('representatives'):
            for representative in obj_dict.get("representatives"):
                self.representatives.append(
                    BereavedRepresentative(representative))