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 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 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)