# -*- coding: utf-8 -*- ## # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_main_treatment_vitals # date 02/16/2022 # author Papiya Mandal import builtins import names from configuration.config import * from configuration.utility import * from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator hd_simulator = HDSimulator() SYSTOLIC_PRESSSURE_120 = "120" SYSTOLIC_PRESSSURE_113 = "113" SYSTOLIC_PRESSSURE_200 = "200" SYSTOLIC_PRESSSURE_175 = "175" DIASTOLIC_PRESSSURE_74 = "74" DIASTOLIC_PRESSSURE_150 = "150" DIASTOLIC_PRESSSURE_80 = "80" DIASTOLIC_PRESSSURE_60 = "60" HEART_RATE_VAL_101 = "101" HEART_RATE_VAL_60 = "60" HEART_RATE_VAL_70 = "70" HEART_RATE_VAL_85 = "85" DIASTOLIC_TEXT = "diastolic" SYSTOLIC_TEXT = "systolic" BLOOD_PRESSURE_DEFAULT_VAL = "__ / __" HEART_RATE_DEFAULT_VAL = "__" INVALID_VALS = {"systolic" : [260, 59, 300, 23], "diastolic": [39, 1, 210, 201], "Heart Rate": [181, 200, 39, 20]} def open_vitals_pop_up(): """ Method to open the vitals pop up and verify 'Vitals' pop is opened """ test.startSection("Opening 'Vitals' pop up") vitals_touch_area = object.parent(waitForObject(names.o_vitals_title)) mouseClick(vitals_touch_area) test.log("Verifying the 'Vitals' pop up is displayed") if object.exists(names.o_vitals_pop_up_title): vitals_pop_up_title = waitForObject(names.o_vitals_pop_up_title) vitals_pop_up_title = str(vitals_pop_up_title.text) test.compare(vitals_pop_up_title, VITALS_TITLE,"Vitals title text is displayed") bp_title = waitForObject(names.o_pop_up_bp_title) bp_title = str(bp_title.text) test.compare(bp_title, BLOOD_PRESSURE_TITLE,"Blood pressure title text is displayed") bp_uom = waitForObject(names.o_bp_uom) bp_uom = str(bp_uom.text) test.compare(bp_uom, BLOOD_PRESSURE_UNIT,"Blood pressure unit should be {}".format(BLOOD_PRESSURE_UNIT)) heart_rate_title = waitForObject(names.o_pop_up_heart_rate_title) heart_rate_title = str(heart_rate_title.text) test.compare(heart_rate_title, HEART_RATE_TITLE,"Heart rate title text is displayed") hr_uom = waitForObject(names.o_hr_uom) hr_uom = str(hr_uom.text) test.compare(hr_uom, HEART_RATE_UNIT,"Heart Rate unit should be {}".format(HEART_RATE_UNIT)) test.endSection() def verify_color_of_entry(entry, vital_parameter, input_field): """ Method to verify the color of entry of systolic, diastolic and heart rate @param entry: (int) user user entered value @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) @param input_field - (obj) object of input field """ test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) input_field_color = input_field.color.name entry = builtins.int(entry) if vital_parameter is SYSTOLIC_TEXT: if (entry < SYSTOLIC_LOWER_LIMIT) or (entry > SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif (entry >= SYSTOLIC_LOWER_LIMIT) and (entry <= SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, IN_RANGE_COLOR, "systolic value {} is in range of {} and {}".format(entry, SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT)) elif vital_parameter is DIASTOLIC_TEXT: if (entry < DIASTOLIC_LOWER_LIMIT) or (entry > DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif (entry >= DIASTOLIC_LOWER_LIMIT) and (entry <= DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color, IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT)) elif vital_parameter is HEART_RATE_TITLE: if (entry < HEART_RATE_LOWER_LIMIT) or (entry > HEART_RATE_UPPER_LIMIT): test.compare(input_field_color, OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) elif (entry >= HEART_RATE_LOWER_LIMIT) and (entry <= HEART_RATE_UPPER_LIMIT): test.compare(input_field_color,IN_RANGE_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT)) test.endSection() def verify_last_read_time(saved_time): """ method to verify the last read of blood pressure and heart rate @param last_read: (str) time of saving blood pressure and heart rate """ test.startSection("Verify the last read of blood pressure and heart rate") expected_last_read = "Interval: 30min , Last Read: {}".format(saved_time) last_read = waitForObject(vitals_reading_obj(expected_last_read)) last_read = str(last_read.text) test.compare(last_read, expected_last_read, "Last read time should be {}".format(last_read)) test.endSection() def verify_entered_value_in_main_treatment_screen(value, vital, save): """ method to verify the user entered value in main-treatment screen @param value: (int) user user entered value @param vital - (str) parameter name under which user is entering value (sys/dia/heart rate) @param input_field - (obj) object of input field """ test.startSection("Verify the user entered {} value {} in main-treatment screen".format(vital, value)) if save: input_field = waitForObject(vitals_reading_obj(value)) entered_value = input_field.text value = str(value) test.compare(str(entered_value), value, "Expected {} value: {} should be equal to Actual {} value: {}".format(vital, value, vital, entered_value)) elif (save is False): if object.exists(vitals_reading_obj(value)) is False: test.log("Entered is not saved and is not updated in main-treatment screen") test.endSection() def verify_entered_value_in_pop_up(value, input_field, vital): """ Method to verify the user entered value @param value - (int) user entered value @param vital - (str) parameter name under which user is entering value (sys/dia/heart rate) @param input_field - (obj) object of input field """ test.startSection("Verify the user entered {} value {}".format(vital, value)) input_field = waitForObject(input_field) entered_value = str(input_field.text) test.compare(entered_value, value, "Actual {} value: {} should be equal to Expected {} value: {}".format(vital, entered_value, vital, value)) test.endSection() def verify_ranges_of_vital(vital_parameter): """ Method to verify the in range value for Blood Pressure Systolic and diastolic and heart rate @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) """ test.startSection("Verify the range of {}".format(vital_parameter)) if vital_parameter is SYSTOLIC_TEXT: systolic = waitForObject(names.o_pop_up_systolic_input_field) mouseClick(systolic) for value in range(SYSTOLIC_LOWER_LIMIT, SYSTOLIC_UPPER_LIMIT+1): enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=systolic, vital=vital_parameter) verify_color_of_entry(entry=value, vital_parameter=SYSTOLIC_TEXT, input_field=systolic) erase_entered_value(input_field=systolic) elif vital_parameter is DIASTOLIC_TEXT: diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) for value in range(DIASTOLIC_LOWER_LIMIT, DIASTOLIC_UPPER_LIMIT+1): enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=diastolic, vital=vital_parameter) verify_color_of_entry(entry=value, vital_parameter=DIASTOLIC_TEXT, input_field=diastolic) erase_entered_value(diastolic) elif vital_parameter is HEART_RATE_TITLE: hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) for value in range(HEART_RATE_LOWER_LIMIT, HEART_RATE_UPPER_LIMIT+1): enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=hr, vital=vital_parameter) verify_color_of_entry(entry=value, vital_parameter=HEART_RATE_TITLE, input_field=hr) erase_entered_value(hr) test.endSection() def verify_the_color_of_out_of_range(vital_parameter): """ Method to verify the color of out of range values @param vital_parameter - (str) parameter name (systolic, diastolic, heart rate) """ test.startSection("Verify the color out of range values of {}".format(vital_parameter)) out_range_val_list = INVALID_VALS[vital_parameter] if vital_parameter is SYSTOLIC_TEXT: systolic = waitForObject(names.o_pop_up_systolic_input_field) mouseClick(systolic) for entry in out_range_val_list: enter_keypad_value(entry=str(entry)) verify_entered_value_in_pop_up(value=str(entry), input_field=systolic, vital=vital_parameter) verify_color_of_entry(entry=entry, vital_parameter=SYSTOLIC_TEXT, input_field=systolic) erase_entered_value(input_field=systolic) elif vital_parameter is DIASTOLIC_TEXT: diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) for entry in out_range_val_list: enter_keypad_value(str(entry)) verify_entered_value_in_pop_up(value=str(entry), input_field=diastolic, vital=vital_parameter) verify_color_of_entry(entry=entry, vital_parameter=DIASTOLIC_TEXT, input_field=diastolic) erase_entered_value(diastolic) elif vital_parameter is HEART_RATE_TITLE: hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) for entry in out_range_val_list: enter_keypad_value(str(entry)) verify_entered_value_in_pop_up(value=str(entry), input_field=hr, vital=vital_parameter) verify_color_of_entry(entry=entry, vital_parameter=HEART_RATE_TITLE, input_field=hr) erase_entered_value(hr) test.endSection() def verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val, dia_val, heart_rate, save): """ method to enter systolic, diastolic and heart rate value and save or unsave it and verify same is updated in main-treatment screen @param sys_val - (int) user expected systolic pressure @param dia_val - (int) user expected diastolic pressure @param heart_rate - (int) user expected heart rate @param save - (bool) True/False """ test.startSection("Verify the entered systolic, diastolic and heart rate value updated in main-treatement screen") systolic = waitForObject(names.o_pop_up_systolic_input_field) mouseClick(systolic) erase_entered_value(systolic) enter_keypad_value(str(sys_val)) verify_entered_value_in_pop_up(value=str(sys_val), input_field=systolic, vital=SYSTOLIC_TEXT) verify_color_of_entry(entry=sys_val, vital_parameter=SYSTOLIC_TEXT, input_field=systolic) diastolic = waitForObject(names.o_pop_up_diastolic_input_field) mouseClick(diastolic) erase_entered_value(diastolic) enter_keypad_value(str(dia_val)) verify_entered_value_in_pop_up(value=str(dia_val), input_field=diastolic, vital=DIASTOLIC_TEXT) verify_color_of_entry(entry=dia_val, vital_parameter=DIASTOLIC_TEXT, input_field=diastolic) hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) erase_entered_value(hr) enter_keypad_value(str(heart_rate)) verify_entered_value_in_pop_up(value=str(heart_rate), input_field=hr, vital=HEART_RATE_TITLE) verify_color_of_entry(entry=heart_rate, vital_parameter=HEART_RATE_TITLE, input_field=hr) if save: test.log("Clicking confirm button") confirm_button = waitForObjectExists(names.o_vitals_confrim_btn) test.compare(confirm_button.enabled, True, "Valid Blood Pressure and Heart is entered therefore confirm button is enabled") saved_time = get_current_date_and_time() mouseClick(confirm_button) verify_last_read_time(saved_time) elif save is False: mouseClick(waitForObject(names.o_vitals_close_btn)) test.log("'Vitals pop is closed") expected_blood_pressure = "{sys} / {dia}".format(sys=sys_val, dia=dia_val) verify_entered_value_in_main_treatment_screen(value=expected_blood_pressure, vital=BLOOD_PRESSURE_TITLE, save=save) verify_entered_value_in_main_treatment_screen(value=heart_rate, vital=HEART_RATE_TITLE, save=save) test.endSection() def main(): utils.tstStart(__file__) startApplication(AUT_NAME) hd_simulator.cmd_send_power_on_self_test_version_request() hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 0, rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, treatment_end_state=0, treatment_stop_state= 0) utils.waitForGUI(1) open_vitals_pop_up() verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_120, dia_val=DIASTOLIC_PRESSSURE_80, heart_rate=HEART_RATE_VAL_101, save=True) utils.waitForGUI(1) open_vitals_pop_up() verify_entered_value_in_pop_up(value=SYSTOLIC_PRESSSURE_120, input_field=names.o_pop_up_systolic_input_field, vital=SYSTOLIC_TEXT) verify_entered_value_in_pop_up(value=DIASTOLIC_PRESSSURE_80, input_field=names.o_pop_up_diastolic_input_field, vital=DIASTOLIC_TEXT) verify_entered_value_in_pop_up(value=HEART_RATE_VAL_101, input_field=names.o_pop_up_heart_rate_input_field, vital=HEART_RATE_TITLE) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_175, dia_val=DIASTOLIC_PRESSSURE_60, heart_rate=HEART_RATE_VAL_85, save=False) utils.waitForGUI(1) open_vitals_pop_up() verify_entered_value_in_pop_up(value=SYSTOLIC_PRESSSURE_175, input_field=names.o_pop_up_systolic_input_field, vital=SYSTOLIC_TEXT) verify_entered_value_in_pop_up(value=DIASTOLIC_PRESSSURE_60, input_field=names.o_pop_up_diastolic_input_field, vital=DIASTOLIC_TEXT) verify_entered_value_in_pop_up(value=HEART_RATE_VAL_85, input_field=names.o_pop_up_heart_rate_input_field, vital=HEART_RATE_TITLE) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_113, dia_val=DIASTOLIC_PRESSSURE_74, heart_rate=HEART_RATE_VAL_70, save=True) utils.waitForGUI(1) open_vitals_pop_up() verify_entered_value_in_pop_up(value=SYSTOLIC_PRESSSURE_113, input_field=names.o_pop_up_systolic_input_field, vital=SYSTOLIC_TEXT) verify_entered_value_in_pop_up(value=DIASTOLIC_PRESSSURE_74, input_field=names.o_pop_up_diastolic_input_field, vital=DIASTOLIC_TEXT) verify_entered_value_in_pop_up(value=HEART_RATE_VAL_70, input_field=names.o_pop_up_heart_rate_input_field, vital=HEART_RATE_TITLE) verify_entered_valid_vital_entries_in_main_treatment_screen(sys_val=SYSTOLIC_PRESSSURE_200, dia_val=DIASTOLIC_PRESSSURE_150, heart_rate=HEART_RATE_VAL_60, save=False) utils.waitForGUI(1) open_vitals_pop_up() verify_ranges_of_vital(vital_parameter=SYSTOLIC_TEXT) verify_ranges_of_vital(vital_parameter=DIASTOLIC_TEXT) verify_ranges_of_vital(vital_parameter=HEART_RATE_TITLE) verify_the_color_of_out_of_range(vital_parameter=SYSTOLIC_TEXT) verify_the_color_of_out_of_range(vital_parameter=DIASTOLIC_TEXT) verify_the_color_of_out_of_range(vital_parameter=HEART_RATE_TITLE) utils.tstDone()