# -*- 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 2022/feb/11 # author Papiya Mandal import names from configuration.config import * from configuration.utility import * from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from names import o_pop_up_bp_title hd = HDSimulator() SYSTOLIC_PRESSSURE_120 = "120" SYSTOLIC_PRESSSURE_249 = "249" SYSTOLIC_PRESSSURE_60 = "60" SYSTOLIC_PRESSSURE_200 = "200" SYSTOLIC_PRESSSURE_175 = "175" SYSTOLIC_PRESSSURE_80 = "80" DIASTOLIC_PRESSSURE_50 = "50" DIASTOLIC_PRESSSURE_249 = "249" DIASTOLIC_PRESSSURE_60 = "60" DIASTOLIC_PRESSSURE_200 = "200" DIASTOLIC_PRESSSURE_175 = "175" DIASTOLIC_PRESSSURE_80 = "80" DIASTOLIC_TEXT = "diastolic" SYSTOLIC_TEXT = "systolic" HEART_RATE_TITLE = "Heart Rate" BLOOD_PRESSURE_TITLE = "Blood Pressure" BLOOD_PRESSURE_UNIT = "mmHg" HEART_RATE_UNIT = "BPM" 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 """ test.startSection("Verify the color of {vital_parameter} value {entry}".format(\ vital_parameter=vital_parameter, entry=entry)) input_field_color = input_field.color.name 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_systolic_value_in_pop_up(value): # """ # method to verify the entered systolic value # @param value: user entered systolic value # """ # test.startSection("Verify the user entered systolic value " + # "{value}".format(value=value)) # systolic = waitForObject(names.o_pop_up_systolic_input_field) # systolic_value = systolic.text.toUtf8().constData() # test.compare(systolic_value, value, # "Expected systolic value: {value} ".format(value=value) + # "should be equal to Actual systolic value: " + # "{actual_value}".format(actual_value=systolic_value)) # test.endSection() # # # def verify_diastolic_value_in_pop_up(value): # """ # method to verify the entered diastolic value # @param value: user entered diastolic value # """ # test.startSection("Verify the user entered diastolic value " + # "{value}".format(value=value)) # diastolic = waitForObject(names.o_pop_up_diastolic_input_field) # diastolic_value = diastolic.text.toUtf8().constData() # test.compare(diastolic_value, value, # "Expected diastolic value: {value} ".format(value=value) + # "should be equal to Actual diastolic value: " + # "{actual_value}".format(actual_value=diastolic_value)) # 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 """ 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 """ 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): 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): 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): 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 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_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) current_date_time = get_current_date_and_time() test.log(current_date_time)