Esempio n. 1
0
 def fill_from_api(self, obj_dict):
     self.urgency_score = obj_dict.get("urgencyScore")
     self.given_names = obj_dict.get("givenNames")
     self.surname = obj_dict.get("surname")
     self.nhs_number = obj_dict.get("nhsNumber")
     self.id = obj_dict.get("examinationId")
     self.time_of_death = obj_dict.get("timeOfDeath")
     self.date_of_birth = parse_datetime(obj_dict.get("dateOfBirth"))
     self.date_of_death = parse_datetime(obj_dict.get("dateOfDeath"))
     self.appointment_date = parse_datetime(obj_dict.get("appointmentDate"))
     self.appointment_time = obj_dict.get("appointmentTime")
     self.last_admission = parse_datetime(obj_dict.get("lastAdmission"))
     self.case_created_date = parse_datetime(
         obj_dict.get("caseCreatedDate"))
     self.admission_notes_added = obj_dict.get(
         "admissionNotesHaveBeenAdded")
     self.ready_for_me_scrutiny = obj_dict.get("readyForMEScrutiny")
     self.unassigned = obj_dict.get("unassigned")
     self.have_been_scrutinised = obj_dict.get("haveBeenScrutinisedByME")
     self.pending_admission_notes = obj_dict.get("pendingAdmissionNotes")
     self.pending_discussion_with_qap = obj_dict.get(
         "pendingDiscussionWithQAP")
     self.pending_discussion_with_representative = obj_dict.get(
         "pendingDiscussionWithRepresentative")
     self.pending_scrutiny_notes = obj_dict.get("pendingScrutinyNotes")
     self.have_final_case_outstanding_outcomes = obj_dict.get(
         "haveFinalCaseOutstandingOutcomes")
     self.is_cremation = obj_dict.get("isCremation", False)
     self.is_void = obj_dict.get("IsVoid", False)
Esempio n. 2
0
 def test_calc_age_correctly_calculates_the_age_if_dates_present(self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     birth_date = '2018-02-02T02:02:02.000Z'
     death_date = '2019-02-02T02:02:02.000Z'
     examination_overview.date_of_birth = parse_datetime(birth_date)
     examination_overview.date_of_death = parse_datetime(death_date)
     result = examination_overview.calc_age()
     expected_age = 1
     self.assertEqual(result, expected_age)
Esempio n. 3
0
        def check_events_correctly_ordered(events_list):
            correctly_ordered = True
            previous_loop_date = None

            for event in events_list:
                if previous_loop_date:
                    next_date = parse_datetime(event.created_date)
                    if next_date and previous_loop_date > next_date:
                        correctly_ordered = False

                previous_loop_date = parse_datetime(event.created_date)

            return correctly_ordered
Esempio n. 4
0
 def test_calc_age_returns_none_if_date_of_death_missing(self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     birth_date = '2019-02-02T02:02:02.000Z'
     examination_overview.date_of_birth = parse_datetime(birth_date)
     examination_overview.date_of_death = None
     result = examination_overview.calc_age()
     self.assertIsNone(result)
Esempio n. 5
0
 def test_calc_last_admission_days_ago_returns_0_if_date_of_admission_missing(
         self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     admission_date = None
     examination_overview.last_admission = parse_datetime(admission_date)
     result = examination_overview.calc_last_admission_days_ago()
     expected_days = 0
     self.assertEqual(result, expected_days)
Esempio n. 6
0
 def __init__(self, obj_dict, latest_id, dod):
     super().__init__(obj_dict)
     self.body = obj_dict.get('notes')
     self.admitted_date = parse_datetime(obj_dict.get('admittedDate'))
     self.admitted_date_unknown = obj_dict.get('admittedDateUnknown')
     self.admitted_time = obj_dict.get('admittedTime')
     self.admitted_time_unknown = obj_dict.get('admittedTimeUnknown')
     self.immediate_coroner_referral = obj_dict.get(
         'immediateCoronerReferral')
     self.route_of_admission = obj_dict.get('routeOfAdmission')
     self.published = obj_dict.get('isFinal')
     self.dod = dod
     self.is_latest = self.event_id == latest_id
Esempio n. 7
0
    def test_card_presenter_returns_a_correctly_formatted_appointment_date_if_date_present(
            self):
        examination_overview = ExaminationOverview(
            ExaminationMocks.get_case_index_response_content()['examinations']
            [0])
        given_date = '2019-02-02T02:02:02.000Z'
        examination_overview.appointment_date = parse_datetime(given_date)

        presenter = case_card_presenter(examination_overview)
        result = presenter['appointment_date']

        expected_date = '02.02.2019'
        self.assertEqual(result, expected_date)
Esempio n. 8
0
    def __init__(self, obj_dict={}):
        self.full_name = fallback_to(obj_dict.get("fullName"), '')
        self.relationship = fallback_to(obj_dict.get("relationship"), '')
        self.phone_number = fallback_to(obj_dict.get("phoneNumber"), '')
        self.appointment_time = obj_dict.get("appointmentTime")
        self.appointment_notes = fallback_to(obj_dict.get("notes"), '')

        if not is_empty_date(obj_dict.get("appointmentDate")) and obj_dict.get("appointmentDate") is not None:
            self.appointment_date = parse_datetime(obj_dict.get("appointmentDate"))
            self.appointment_day = self.appointment_date.day
            self.appointment_month = self.appointment_date.month
            self.appointment_year = self.appointment_date.year
        else:
            self.appointment_date = None
            self.appointment_day = None
            self.appointment_month = None
            self.appointment_year = None
Esempio n. 9
0
 def display_date(self):
     if self.created_date:
         date = parse_datetime(self.created_date)
         if date:
             if date.date() == datetime.today().date():
                 return 'Today at %s' % date.strftime(self.time_format)
             elif date.date() == datetime.today().date() - timedelta(
                     days=1):
                 return 'Yesterday at %s' % date.strftime(self.time_format)
             else:
                 time = date.strftime(self.time_format)
                 date = date.strftime(self.date_format)
                 return "%s at %s" % (date, time)
         else:
             return None
     else:
         return None
Esempio n. 10
0
 def __init__(self, obj_dict, latest_id):
     super().__init__(obj_dict)
     self.participant_full_name = obj_dict.get('participantName')
     self.participant_role = obj_dict.get('participantRole')
     self.participant_organisation = obj_dict.get('participantOrganisation')
     self.participant_phone_number = obj_dict.get('participantPhoneNumber')
     self.date_of_conversation = parse_datetime(
         obj_dict.get('dateOfConversation'))
     self.discussion_unable_happen = obj_dict.get('discussionUnableHappen')
     self.discussion_details = obj_dict.get('discussionDetails')
     self.qap_discussion_outcome = obj_dict.get('qapDiscussionOutcome')
     self.participant_name = obj_dict.get("participantName")
     self.cause_of_death_1a = obj_dict.get("causeOfDeath1a")
     self.cause_of_death_1b = obj_dict.get("causeOfDeath1b")
     self.cause_of_death_1c = obj_dict.get("causeOfDeath1c")
     self.cause_of_death_2 = obj_dict.get("causeOfDeath2")
     self.published = obj_dict.get('isFinal')
     self.is_latest = self.event_id == latest_id
Esempio n. 11
0
 def __init__(self, obj_dict, latest_id):
     super().__init__(obj_dict)
     self.participant_full_name = fallback_to(
         obj_dict.get('participantFullName'), '')
     self.participant_relationship = fallback_to(
         obj_dict.get('participantRelationship'), '')
     self.participant_phone_number = fallback_to(
         obj_dict.get('participantPhoneNumber'), '')
     self.date_of_conversation = parse_datetime(
         obj_dict.get('dateOfConversation'))
     self.discussion_unable_happen = enums.true_false.TRUE if obj_dict.get(
         'discussionUnableHappen') else enums.true_false.FALSE
     self.discussion_details = fallback_to(
         obj_dict.get('discussionDetails'), '')
     self.bereaved_discussion_outcome = obj_dict.get(
         'bereavedDiscussionOutcome')
     self.published = obj_dict.get('isFinal')
     self.is_latest = self.event_id == latest_id
Esempio n. 12
0
 def __init__(self, obj_dict, examination_id):
     self.examination_id = examination_id
     self.case_header = PatientHeader(obj_dict.get("header"))
     self.case_outcome_summary = obj_dict.get("caseOutcomeSummary")
     self.case_representative_outcome = obj_dict.get(
         "outcomeOfRepresentativeDiscussion")
     self.case_pre_scrutiny_outcome = obj_dict.get("outcomeOfPrescrutiny")
     self.case_qap_outcome = obj_dict.get("outcomeQapDiscussion")
     self.case_open = True if not obj_dict.get("caseCompleted") else False
     self.scrutiny_confirmed = parse_datetime(
         obj_dict.get("scrutinyConfirmedOn"))
     self.coroner_referral = obj_dict.get("coronerReferralSent")
     self.me_full_name = obj_dict.get("caseMedicalExaminerFullName")
     self.me_id = obj_dict.get('caseMedicalExaminerId')
     self.me_gmc_number = fallback_to(
         obj_dict.get('caseMedicalExaminerGmcNumber'), '')
     self.mccd_issued = obj_dict.get("mccdIssued")
     self.cremation_form_status = obj_dict.get("cremationFormStatus")
     self.gp_notified_status = obj_dict.get("gpNotifiedStatus")
     self.waive_fee = obj_dict.get('waiveFee')
Esempio n. 13
0
 def __init__(self, obj_dict):
     self.urgency_score = obj_dict.get("urgencyScore")
     self.given_names = obj_dict.get("givenNames")
     self.surname = obj_dict.get("surname")
     self.nhs_number = obj_dict.get("nhsNumber")
     self.id = obj_dict.get("examinationId")
     self.time_of_death = obj_dict.get("timeOfDeath")
     self.date_of_birth = parse_datetime(obj_dict.get("dateOfBirth"))
     self.date_of_death = parse_datetime(obj_dict.get("dateOfDeath"))
     self.appointment_date = parse_datetime(obj_dict.get("appointmentDate"))
     self.appointment_time = obj_dict.get("appointmentTime")
     self.last_admission = parse_datetime(obj_dict.get("lastAdmission"))
     self.case_created_date = parse_datetime(
         obj_dict.get("caseCreatedDate"))
     self.case_closed_date = parse_datetime(obj_dict.get("dateCaseClosed"))
     self.case_outcome = obj_dict.get("caseOutcome")
     self.open = obj_dict.get('open')
     self.void = obj_dict.get('isVoid')
Esempio n. 14
0
 def display_date_case_closed(self):
     if self.date_case_closed == NONE_DATE:
         return self.UNKNOWN
     else:
         date = parse_datetime(self.date_case_closed)
         return date.strftime(self.date_format)
Esempio n. 15
0
    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))