Esempio n. 1
0
 def test_examination_overview_urgent_returns_false_if_urgency_score_is_0_and_case_closed(
         self):
     case_overview_data = ExaminationMocks.get_case_overview_content()
     case_overview_data['urgencyScore'] = 0
     case_overview_data['open'] = False
     case_overview = ExaminationOverview(case_overview_data)
     self.assertIsFalse(case_overview.urgent())
Esempio n. 2
0
 def test_examination_overview_urgent_returns_true_if_urgency_score_gt_than_0_and_case_open(
         self):
     case_overview_data = ExaminationMocks.get_case_overview_content()
     case_overview_data['urgencyScore'] = 1000
     case_overview_data['open'] = True
     case_overview = ExaminationOverview(case_overview_data)
     self.assertIsTrue(case_overview.urgent())
Esempio n. 3
0
    def test_calc_age_returns_none_if__both_dates_missing(self):
        examination_overview = ExaminationOverview(
            ExaminationMocks.get_case_index_response_content()['examinations']
            [0])
        examination_overview.date_of_birth = None
        examination_overview.date_of_death = None
        result = examination_overview.calc_age()

        self.assertIsNone(result)
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_created_days_ago_returns_correct_number_of_days_if_case_created_date_present(
         self):
     examination_overview = ExaminationOverview(
         ExaminationMocks.get_case_index_response_content()['examinations']
         [0])
     case_created_date = datetime.today() - timedelta(days=1)
     examination_overview.case_created_date = case_created_date
     result = examination_overview.calc_created_days_ago()
     expected_days = 1
     self.assertEqual(result, expected_days)
Esempio n. 6
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. 7
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. 8
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. 9
0
    def load_closed_examinations(self, page_size, page_number, location,
                                 person):
        query_params = {
            "LocationId": location,
            "UserId": person,
            "CaseStatus": '',
            "OrderBy": "CaseCreated",
            "OpenCases": False,
            "PageSize": page_size,
            "PageNumber": page_number
        }

        response = examination_request_handler.load_examinations_index(
            query_params, self.auth_token)

        success = response.status_code == status.HTTP_200_OK

        if success:
            self.index_overview = IndexOverview(location, response.json(),
                                                page_size, page_number)
            for examination in response.json()['examinations']:
                examination['open'] = False
                self.examinations.append(ExaminationOverview(examination))
        else:
            log_api_error('case load', response.text)
Esempio n. 10
0
    def load_examinations(self,
                          page_size,
                          page_number,
                          location,
                          person,
                          case_status,
                          sorting_order=None):
        query_params = {
            "LocationId":
            location,
            "UserId":
            person,
            "CaseStatus":
            case_status,
            "OrderBy":
            sorting_order
            or enums.results_sorting.SORTING_ORDERS_DEFAULT_FIRST[0][1],
            "OpenCases":
            enums.open_closed.OPEN,
            "PageSize":
            page_size,
            "PageNumber":
            page_number
        }

        response = examination_request_handler.load_examinations_index(
            query_params, self.auth_token)

        success = response.status_code == status.HTTP_200_OK

        if success:
            self.index_overview = IndexOverview(location, response.json(),
                                                page_size, page_number)
            for examination in response.json().get('examinations'):
                examination['open'] = True
                self.examinations.append(ExaminationOverview(examination))
        else:
            log_api_error('permissions load', response.text)