Beispiel #1
0
    def test_get_forms_for_role_with_items_published_returns_form_with_enabled_false(self):
        user = User()
        user.auth_token = SessionMocks.ACCESS_TOKEN
        user.id_token = SessionMocks.ID_TOKEN_NAME
        user.check_logged_in()

        data = ExaminationMocks.get_case_breakdown_response_content()
        data['caseBreakdown']['admissionNotes']['usersDraft'] = None
        available_forms = user.get_forms_for_role(
            CaseBreakdown(obj_dict=data, medical_team=None))

        self.assertEquals(available_forms[0]['id'], 'admin-notes')
        self.assertEquals(available_forms[0]['enabled'], 'false')
Beispiel #2
0
    def test_get_forms_for_role_returns_the_correct_list_of_forms_for_an_meo(self):
        user = User()
        user.auth_token = SessionMocks.ACCESS_TOKEN
        user.id_token = SessionMocks.ID_TOKEN_NAME
        user.check_logged_in()

        available_forms = user.get_forms_for_role(
            CaseBreakdown(obj_dict=ExaminationMocks.get_case_breakdown_response_content(), medical_team=None))

        self.assertEquals(type(available_forms), list)
        self.assertEquals(available_forms[0]['id'], 'admin-notes')
        self.assertEquals(available_forms[1]['id'], 'medical-history')
        self.assertEquals(available_forms[2]['id'], 'meo-summary')
        self.assertEquals(available_forms[3]['id'], 'other')
Beispiel #3
0
    def test_examination_event_list_parse_events_does_not_blow_up_if_it_recieves_an_unknown_event_type(
            self):
        patient_name = 'Joe Bloggs'
        event_list = ExaminationEventList({}, "0001-01-01T00:00:00",
                                          patient_name)
        self.assertEquals(len(event_list.events), 0)

        event_data = ExaminationMocks.get_case_breakdown_response_content(
        ).get('caseBreakdown')
        event_data['randomKey'] = event_data.get('otherEvents')

        try:
            event_list.parse_events(event_data, patient_name)
            # if the test reaches here the function completed without blowing up
            self.assertIsTrue(True)
        except:  # noqa: E722
            # function should not have thrown an error
            self.assertIsTrue(False)
Beispiel #4
0
    def test_get_forms_for_role_returns_the_correct_list_of_forms_for_an_me(self):
        user = User()
        user.auth_token = SessionMocks.ACCESS_TOKEN
        user.id_token = SessionMocks.ID_TOKEN_NAME
        user.permitted_actions = PermittedActions({"BereavedDiscussionEvent": True,
                                                   "QapDiscussionEvent": True,
                                                   "OtherEvent": True,
                                                   "PreScrutinyEvent": True
                                                   })

        available_forms = user.get_forms_for_role(
            CaseBreakdown(obj_dict=ExaminationMocks.get_case_breakdown_response_content(), medical_team=None))

        self.assertEquals(type(available_forms), list)
        self.assertEquals(available_forms[0]['id'], 'pre-scrutiny')
        self.assertEquals(available_forms[1]['id'], 'qap-discussion')
        self.assertEquals(available_forms[2]['id'], 'bereaved-discussion')
        self.assertEquals(available_forms[3]['id'], 'other')
Beispiel #5
0
    def test_examination_event_list_sort_events_oldest_to_newest_correctly_orders_events_with_oldest_first(
            self):
        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

        patient_name = 'Joe Bloggs'
        event_data = ExaminationMocks.get_case_breakdown_response_content(
        ).get('caseBreakdown')
        event_list = ExaminationEventList(event_data, "0001-01-01T00:00:00",
                                          patient_name)

        is_correctly_ordered = check_events_correctly_ordered(
            event_list.events)

        if is_correctly_ordered:
            holder = event_list.events[0]
            event_list.events[0] = event_list.events[1]
            event_list.events[1] = holder
            is_correctly_ordered = check_events_correctly_ordered(
                event_list.events)

        self.assertIsFalse(is_correctly_ordered)

        event_list.sort_events_oldest_to_newest()

        is_correctly_ordered = check_events_correctly_ordered(
            event_list.events)

        self.assertIsTrue(is_correctly_ordered)
Beispiel #6
0
    def test_examination_event_list_parse_events_creates_a_list_including_all_events_in_the_data(
            self):
        patient_name = 'Joe Bloggs'
        event_list = ExaminationEventList({}, "0001-01-01T00:00:00",
                                          patient_name)
        self.assertEquals(len(event_list.events), 0)

        event_data = ExaminationMocks.get_case_breakdown_response_content(
        ).get('caseBreakdown')
        event_list.parse_events(event_data, patient_name)

        count_of_initial_events_in_data = 1
        count_of_closed_events_in_data = 1 if key_not_empty(
            'caseClosed', event_data) else 0
        count_of_other_events_in_data = len(event_data.get('otherEvents').get('history')) if \
            key_not_empty('otherEvents', event_data) else 0
        count_of_scrutiny_events_in_data = len(event_data.get('preScrutiny').get('history')) if \
            key_not_empty('preScrutiny', event_data) else 0
        count_of_qap_events_in_data = len(event_data.get('qapDiscussion').get('history')) if \
            key_not_empty('qapDiscussion', event_data) else 0
        count_of_summary_events_in_data = len(event_data.get('meoSummary').get('history')) if \
            key_not_empty('meoSummary', event_data) else 0
        count_of_admission_events_in_data = len(event_data.get('admissionNotes').get('history')) if \
            key_not_empty('admissionNotes', event_data) else 0
        count_of_bereaved_events_in_data = len(event_data.get('bereavedDiscussion').get('history')) if \
            key_not_empty('bereavedDiscussion', event_data) else 0
        count_of_medical_events_in_data = len(event_data.get('medicalHistory').get('history')) if \
            key_not_empty('medicalHistory', event_data) else 0

        count_of_initial_events_in_list = 0
        count_of_closed_events_in_list = 0
        count_of_other_events_in_list = 0
        count_of_scrutiny_events_in_list = 0
        count_of_qap_events_in_list = 0
        count_of_summary_events_in_list = 0
        count_of_admission_events_in_list = 0
        count_of_bereaved_events_in_list = 0
        count_of_medical_events_in_list = 0

        for event in event_list.events:
            if type(event) == CaseInitialEvent:
                count_of_initial_events_in_list = count_of_initial_events_in_list + 1
            elif type(event) == CaseClosedEvent:
                count_of_closed_events_in_list = count_of_closed_events_in_list + 1
            elif type(event) == CaseOtherEvent:
                count_of_other_events_in_list = count_of_other_events_in_list + 1
            elif type(event) == CasePreScrutinyEvent:
                count_of_scrutiny_events_in_list = count_of_scrutiny_events_in_list + 1
            elif type(event) == CaseQapDiscussionEvent:
                count_of_qap_events_in_list = count_of_qap_events_in_list + 1
            elif type(event) == CaseMeoSummaryEvent:
                count_of_summary_events_in_list = count_of_summary_events_in_list + 1
            elif type(event) == CaseAdmissionNotesEvent:
                count_of_admission_events_in_list = count_of_admission_events_in_list + 1
            elif type(event) == CaseBereavedDiscussionEvent:
                count_of_bereaved_events_in_list = count_of_bereaved_events_in_list + 1
            elif type(event) == CaseMedicalHistoryEvent:
                count_of_medical_events_in_list = count_of_medical_events_in_list + 1

        self.assertEquals(count_of_initial_events_in_list,
                          count_of_initial_events_in_data)
        self.assertEquals(count_of_closed_events_in_list,
                          count_of_closed_events_in_data)
        self.assertEquals(count_of_other_events_in_list,
                          count_of_other_events_in_data)
        self.assertEquals(count_of_scrutiny_events_in_list,
                          count_of_scrutiny_events_in_data)
        self.assertEquals(count_of_qap_events_in_list,
                          count_of_qap_events_in_data)
        self.assertEquals(count_of_summary_events_in_list,
                          count_of_summary_events_in_data)
        self.assertEquals(count_of_admission_events_in_list,
                          count_of_admission_events_in_data)
        self.assertEquals(count_of_bereaved_events_in_list,
                          count_of_bereaved_events_in_data)
        self.assertEquals(count_of_medical_events_in_list,
                          count_of_medical_events_in_data)