def check_no_notifications(context):
    patient_name = context.patient_name
    page_confirm = PageConfirm(context.browser)
    task_page = ListPage(context.browser)
    task_page.go_to_task_list()
    assert (page_confirm.is_task_list_page())
    task_list = [
        task.find_element(*TASK).text for task in task_page.get_list_items()
        if task.find_element(*LIST_ITEM_PATIENT_NAME).text == patient_name
    ]
    assert (len(task_list) == 0)
 def test_can_go_to_stand_in_page(self):
     """
     Test that can navigate to the stand in page
     """
     self.task_list_page.go_to_standin()
     self.assertTrue(PageConfirm(self.driver).is_stand_in_page(),
                     'Did not get to stand in page correctly')
 def test_go_to_patient_list_page(self):
     """
     Test that can go to the patient list page
     """
     self.task_list_page.go_to_patient_list()
     self.assertTrue(PageConfirm(self.driver).is_patient_list_page(),
                     'Did not get to patient list page correctly')
 def test_can_logout(self):
     """
     Test that the title of the login page is Open-eObs
     """
     self.task_list_page.logout()
     self.assertTrue(PageConfirm(self.driver).is_login_page(),
                     'Did not get to the logout page correctly')
def check_next_ews(context, time, period):
    patient_name = context.patient_name
    page_confirm = PageConfirm(context.browser)
    task_page = ListPage(context.browser)
    task_page.go_to_patient_list()
    assert (page_confirm.is_patient_list_page())
    task_list = [
        task.find_element(*LIST_ITEM_DEADLINE).text
        for task in task_page.get_list_items()
        if task.find_element(*LIST_ITEM_PATIENT_NAME).text == patient_name
    ]
    assert (len(task_list) == 1)
    time_range = range(int(time) - 1, int(time) + 1)
    if period == 'minutes':
        assert (int(task_list[0][3:][:2]) in time_range)
    else:
        assert (int(task_list[0][:2]) in time_range)
 def test_click_list_item(self):
     """
     Test that clicking on a work item tasks user to carry out the task
     """
     tasks = self.task_list_page.get_list_items()
     task_to_test = tasks[0]
     task_url = task_to_test.get_attribute('href')
     task_to_test.click()
     self.assertTrue(PageConfirm(self.driver).is_task_page(),
                     'Did not get to task page correctly')
     self.assertEqual(self.driver.current_url, task_url,
                      'Incorrect url')
 def test_view_patient_details(self):
     """
     Test that clicking on a work item tasks user to carry out the task
     """
     patients = self.patient_list_page.get_list_items()
     patient_to_test = patients[0]
     patient_url = patient_to_test.get_attribute('href')
     patient_to_test.click()
     self.assertTrue(PageConfirm(self.driver).is_patient_page(),
                     'Did not get to patient page correctly')
     self.assertEqual(self.driver.current_url, patient_url,
                      'Incorrect url')
def submit_observation(context, clinical_risk):

    risk_dict = {
        'no': NO_RISK_EWS_DATA,
        'a low': LOW_RISK_SCORE_1_EWS_DATA,
        'a medium': MEDIUM_RISK_SCORE_5_EWS_DATA,
        'a high': HIGH_RISK_SCORE_7_EWS_DATA
    }
    risk_score = risk_dict.get(clinical_risk)
    if not risk_score:
        raise ValueError('No risk score available')

    page_confirm = PageConfirm(context.browser)
    patient_list_page = ListPage(context.browser)

    patient_list_page.go_to_patient_list()
    assert(page_confirm.is_patient_list_page())
    patients = patient_list_page.get_list_items()

    PatientPage(context.browser).select_patient(patients)
    PatientPage(context.browser).open_form(OPEN_OBS_MENU_NEWS_ITEM)
    ObservationFormPage(context.browser).enter_obs_data(risk_score)
def go_to_task_list(context):
    task_page = TaskPage(context.browser)
    page_confirm = PageConfirm(context.browser)
    task_page.go_to_task_list()
    assert (page_confirm.is_task_list_page())
def submit_extended_obs(context, risk, stay_duration):

    durations = {
        '1-2': 1,
        '3+': 5
    }
    risk_triggered_acts = {
        'no': [],
        'a low': [
            'nh.clinical.notification.assessment',
            'nh.clinical.notification.hca',
            'nh.clinical.notification.nurse'
        ],
        'a medium': [
            'nh.clinical.notification.hca',
            'nh.clinical.notification.nurse',
            'nh.clinical.notification.shift_coordinator',
            'nh.clinical.notification.medical_team',
            'nh.clinical.notification.ambulance'
        ],
        'a high': [
            'nh.clinical.notification.hca',
            'nh.clinical.notification.nurse',
            'nh.clinical.notification.shift_coordinator',
            'nh.clinical.notification.medical_team',
            'nh.clinical.notification.ambulance'
        ]
    }

    spell_model = context.odoo_client.model('nh.clinical.spell')
    page_confirm = PageConfirm(context.browser)
    patient_list_page = ListPage(context.browser)

    patient_list_page.go_to_patient_list()
    assert(page_confirm.is_patient_list_page())
    patients = patient_list_page.get_list_items()

    patient = patients[0]
    patient_id = patient.get_attribute('href').replace(
        PATIENT_PAGE, ''
    )
    patient_name = patient.find_element(*LIST_ITEM_PATIENT_NAME)
    context.patient_name = patient_name.text
    spell_id = spell_model.get_by_patient_id(int(patient_id))
    tasks_to_cancel = risk_triggered_acts.get(risk)
    if tasks_to_cancel:
        patient_list_page.remove_tasks_for_patient(
            patient_id, tasks_to_cancel, database=context.test_database_name)
    present = datetime.now()
    days_ago = timedelta(days=durations.get(stay_duration))
    new_date = present - days_ago
    new_date_str = new_date.strftime('%Y-%m-%d %H:%M:00')
    spell_model.write(spell_id, {
        'date_started': new_date_str,
        'start_date': new_date_str,
    })
    read_date = spell_model.read(spell_id, ['date_started', 'start_date'])
    assert(read_date['date_started'] == new_date_str)
    assert(read_date['start_date'] == new_date_str)
    time.sleep(1)
    submit_observation(context, risk)
 def test_login_page_title(self):
     """
     Test that the title of the login page is Open-eObs
     """
     self.assertTrue(
         PageConfirm(self.driver).is_login_page(), 'Incorrect page title')