# -*- 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 = 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 = vitals_pop_up_title.text.toUtf8().constData() test.compare(vitals_pop_up_title, VITALS_TITLE,"Vitals title text is displayed") bp_title = waitForObject(names.o_pop_up_bp_title) bp_title = bp_title.text.toUtf8().constData() test.compare(bp_title, BLOOD_PRESSURE_TITLE,"Blood pressure title text is displayed") bp_uom = waitForObject(names.o_bp_uom) bp_uom = bp_uom.text.toUtf8().constData() test.compare(bp_uom, BLOOD_PRESSURE_UNIT,"Blood pressure unit " + "should be {unit}".format(unit=BLOOD_PRESSURE_UNIT)) heart_rate_title = waitForObject(names.o_pop_up_heart_rate_title) heart_rate_title = heart_rate_title.text.toUtf8().constData() test.compare(heart_rate_title, HEART_RATE_TITLE,"Heart rate title text is displayed") hr_uom = waitForObject(names.o_hr_uom) hr_uom = hr_uom.text.toUtf8().constData() test.compare(hr_uom, HEART_RATE_UNIT,"Heart Rate unit " + "should be {unit}".format(unit=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: user user entered value @param vital_parameter - parameter name under which user is entering value (sys/dia/heart rate) @param input_field - object of input field """ test.startSection("Verify the color of {vital_parameter} value {entry}".format(\ vital_parameter=vital_parameter, entry=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 " + "{entry} is out of range, systolic value should be in range of ".format(entry=entry) + "{lower_limit} and {upper_limit}".format(lower_limit=SYSTOLIC_LOWER_LIMIT, upper_limit=SYSTOLIC_UPPER_LIMIT)) elif (entry >= SYSTOLIC_LOWER_LIMIT) and (entry <= SYSTOLIC_UPPER_LIMIT): test.compare(input_field_color, IN_RANGE_COLOR, "systolic value {entry}".format(entry=entry) + " is in range of {lower_limit} and {upper_limit}".format(\ lower_limit=SYSTOLIC_LOWER_LIMIT, upper_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 " + "{entry} is out of range, diastolic value should be in range of ".format(entry=entry) + "{lower_limit} and {upper_limit}".format(lower_limit=DIASTOLIC_LOWER_LIMIT, upper_limit=DIASTOLIC_UPPER_LIMIT)) elif (entry >= DIASTOLIC_LOWER_LIMIT) and (entry <= DIASTOLIC_UPPER_LIMIT): test.compare(input_field_color,IN_RANGE_COLOR, "diastolic value {entry}".format(entry=entry) + " is in range of {lower_limit} and {upper_limit}".format(\ lower_limit=DIASTOLIC_LOWER_LIMIT, upper_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 " + "{entry} is out of range, Heart Rate value should be in range of ".format(entry=entry) + "{lower_limit} and {upper_limit}".format(lower_limit=HEART_RATE_LOWER_LIMIT, upper_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 {entry}".format(entry=entry) + " is in range of {lower_limit} and {upper_limit}".format(\ lower_limit=HEART_RATE_LOWER_LIMIT, upper_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: 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: {saved_time}".format(saved_time=saved_time) last_read = waitForObject(names.vitals_reading_obj(reading=expected_last_read)) last_read = last_read.text.toUtf8().constData() test.compare(last_read, expected_last_read, "Last read time should be {last_read}".format(last_read=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: user user entered value @param vital - parameter name under which user is entering value (sys/dia/heart rate) @param input_field - object of input field """ test.startSection("Verify the user entered {vital} ".format(vital=vital) + "value {value} in main-treatment screen".format(value=value)) if save: input_field = waitForObject(names.vitals_reading_obj(reading=value)) entered_value = input_field.text.toUtf8().constData() value = str(value) test.compare(entered_value, value, "Expected {vital} value: {value} ".format(vital=vital, value=value) + "should be equal to Actual {vital} value: ".format(vital=vital) + "{actual_value}".format(actual_value=entered_value)) elif (save is False): if object.exists(names.vitals_reading_obj(reading=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: user user entered value @param value: user user entered value @param vital - parameter name under which user is entering value (sys/dia/heart rate) """ test.startSection("Verify the user entered {vital} ".format(vital=vital) + "value {value}".format(value=value)) input_field = waitForObject(input_field) entered_value = input_field.text.toUtf8().constData() test.compare(entered_value, value, "Expected {vital} value: {value} ".format(vital=vital, value=value) + "should be equal to Actual {vital} value: ".format(vital=vital) + "{actual_value}".format(actual_value=entered_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 - parameter name under which user is entering value (sys/dia/heart rate) """ test.startSection("Verify the range of {vital}".format(vital=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(entry=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(entry=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(input_field=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(entry=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(input_field=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 : parameter name (systolic, diastolic, heart rate) """ test.startSection("Verify the color out of range values of " + "{vital}".format(vital=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(entry=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(input_field=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(entry=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(input_field=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 """ 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(input_field=systolic) enter_keypad_value(entry=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(input_field=diastolic) enter_keypad_value(entry=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(input_field=hr) enter_keypad_value(entry=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 " + "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__) start_application(AUT_NAME) hd.cmd_send_power_on_self_test_version_request() hd.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(delay_s=3) 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(2) 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(2) 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(2) 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(2) 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()