Source code for liveobs_ui.page_object_models.mobile.patient_page

"""
Page Object Model for Patient Page
The Patient Page shows the observation data for the patient as well as allows
them to conduct an ad-hoc observation
"""
from liveobs_ui.page_object_models.mobile.mobile_common import BaseMobilePage
from liveobs_ui.selectors.mobile.patient_page_selectors import \
    ADHOC_OBS_MENU_BUTTON, OPEN_OBS_MENU, OPEN_OBS_MENU_LIST_ITEMS, \
    OPEN_OBS_MENU_CLOSE_BUTTON


[docs]class PatientPage(BaseMobilePage): """ Class that handles interacting with patient graphs and ad-hoc observation menu """
[docs] def open_adhoc_menu(self): """ Press the 'Take Observation' button to open the ad-hoc observation list """ menu_button = self.driver.find_element(*ADHOC_OBS_MENU_BUTTON) self.click_and_verify_change(menu_button, OPEN_OBS_MENU)
[docs] def get_observation_menu_items(self): """ Get a list of the ad-hoc observations in the 'Take Observation' menu :return: list of WebElements """ return self.driver.find_elements(*OPEN_OBS_MENU_LIST_ITEMS)
[docs] def get_observation_in_menu(self, observation_name): """ Select the specified observation from the ad-hoc observation menu :param observation_name: Name of the observation to select :type observation_name: str :return: WebElement for that observation """ observations = self.get_observation_menu_items() observation = \ [el for el in observations if observation_name in el.text] if observation: return observation[0] return None
[docs] def open_observation_form(self, observation_name): """ Open the ad-hoc observation menu, find the specified observation and open the observation form :param observation_name: Name of the observation to open :return: Boolean. Returns if the page is the intended observation """ self.open_adhoc_menu() return self.get_observation_in_list(observation_name)
[docs] def close_adhoc_menu(self): """ Close the ad-hoc observation menu """ close_button = self.driver.find_element(*OPEN_OBS_MENU_CLOSE_BUTTON) self.click_and_verify_change(close_button, OPEN_OBS_MENU, hidden=True)
[docs] def get_observation_in_list(self, observation_name): """ Find the specified observation and open the observation form :param observation_name: Name of the observation to open :return: Boolean. Returns if the page is the intended observation """ observation = self.get_observation_in_menu(observation_name) if observation: observation_url = observation.get_attribute('href') self.click_and_verify_change( observation, ADHOC_OBS_MENU_BUTTON, hidden=True) return observation_url in self.driver.current_url return False