# -*- 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 05/31/2022 # author Papiya Mandal import names import time from configuration import config, utility from configuration import application_init as application_init from dialin.ui import utils from dialin.ui.hd_simulator import HDSimulator from dialin.common.hd_defs import PreTreatmentSubModes, HDOpModes, HDStandbyStates, PreTreatmentSampleWaterStates, PreTreatmentConsumableSelfTestStates, PreTreatmentNoCartSelfTestStates, PreTreatmentCartridgeInstallStates, PreTreatmentDrySelfTestsStates, PreTreatmentPrimeStates, PreTreatmentRecircStates, PreTreatmentPatientConnectionStates, TreatmentStates, UFStates, SalineBolusStates, HeparinStates,PreTreatmentWetSelfTestStates,HDPreTreatmentReservoirMgmtStates, BloodLeakZeroingStates from time import strftime # from dialin.ui.utils import waitForGUI 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" 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]} SYSTOLIC_VALUES = [60, 122, 250] DIASTOLIC_VALUES = [40, 109, 200] HEART_RATE_VALUES = [40, 107, 180] time_interval = "25min" BP_HR_PRE_TREATMENT_STEPS = 6 ven_low = -100 ven_high = 600 art_low = -300 art_high = 200 def keyboard_object_map_helper(text): """ Method for setting custom object property's for keyboard keys @return: required object property's for keys """ if text is not None: names.o_keboard_input["text"] = text return names.o_keboard_input else: test.log("Invalid ",text," for object.") names.o_keyboard_input["text"] = "Q" def keyboard_switching_section(text): """ Tests to automate keyboard based on user input @return: key text (text displayed on keyboard) """ keyboard_value = keyboard_object_map_helper(text) object_status = object.exists(keyboard_value) if object_status is True: return text else: #Tests to get status of keys in keyboard layout object_status = object.exists(keyboard_object_map_helper(config.KEYBOARD_SWITCH[1])) if object_status is True: keyboard_value = keyboard_object_map_helper(config.KEYBOARD_SWITCH[1]) utils.waitForGUI(.3) mouseClick(waitForObject(keyboard_value)) keyboard_value = keyboard_object_map_helper(text) object_status = object.exists(keyboard_value) if object_status is True: return text object_status = object.exists(keyboard_object_map_helper(config.KEYBOARD_SWITCH[0])) if object_status is True: keyboard_value = keyboard_object_map_helper(config.KEYBOARD_SWITCH[0]) mouseClick(waitForObject(keyboard_value)) keyboard_value = keyboard_object_map_helper(text) object_status = object.exists(keyboard_value) if object_status is True: return text object_status = object.exists(names.o_keyboard_switch2) if object_status is True: keyboard_value = waitForObject(names.o_keyboard_switch2) mouseClick(keyboard_value) text = text.lower() keyboard_value = keyboard_object_map_helper(text) object_status = object.exists(keyboard_value) if object_status is True: return text object_status = object.exists(names.o_keyboard_switch) if object_status is True: keyboard_value = waitForObject(names.o_keyboard_switch) mouseClick(keyboard_value) text = text.lower() keyboard_value = keyboard_object_map_helper(text) object_status = object.exists(keyboard_value) if object_status is True: return text 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_toucharea)) start_time = time.time() 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, config.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, config.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, config.BLOOD_PRESSURE_UNIT,"Blood pressure unit should be {}".format(config.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, config.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, config.HEART_RATE_UNIT,"Heart Rate unit should be {}".format(config.HEART_RATE_UNIT)) test.endSection() return start_time def verify_last_read_time(saved_time): """ Method to verify the last read of blood pressure and heart rate @param saved_time: (str) time of saving blood pressure and heart rate """ test.startSection("Verify the last read of blood pressure and heart rate") test.log("Expected last read logs on current date and time") expected_last_read = "Interval: OFF , Last Read: {}".format(saved_time) expected_interval_status = (str(expected_last_read)).split(",") expected_interval_data = expected_interval_status[0] expected_last_read_data = expected_interval_status[1].split(":") expected_last_read_text = expected_last_read_data[0] expected_last_read_only_date = expected_last_read_data[1][1:11] expected_last_read_date = expected_interval_status[1].split(" ") expected_last_read_time = expected_last_read_date[4:] expected_last_read_time_without_sec = expected_last_read_time[0][0:5] test.log("Last read logs from UI screen") last_read = (waitForObject(names.o_time_interval)).text interval_status = (str(last_read)).split(",") interval_data = interval_status[0] last_read_data = interval_status[1].split(":") last_read_text = last_read_data[0] last_read_only_date = last_read_data[1][1:11] last_read_date = interval_status[1].split(" ") last_read_time = last_read_date[4:] last_read_time_without_sec = last_read_time[0][0:5] test.compare(interval_data, expected_interval_data, "Interval data should be {}".format(expected_interval_data)) test.compare(last_read_text, expected_last_read_text, "Last read text should be {}".format(expected_last_read_text)) test.compare(last_read_only_date, expected_last_read_only_date, "Last read date should be {}".format(expected_last_read_only_date)) test.compare(last_read_time_without_sec, expected_last_read_time_without_sec, "Last read time should be {}".format(expected_last_read_time_without_sec)) 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(utility.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)) else: if object.exists(utility.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) utils.waitForGUI(1) 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, set_single_systolic_value = False, systolic_value_to_set = 0, systolic_value_set = SYSTOLIC_VALUES, set_single_diastolic_value = False, diastolic_value_to_set = 0, diastolic_value_set = DIASTOLIC_VALUES, set_single_hr_value = False, hr_value_to_set = 0, hr_value_set = HEART_RATE_VALUES): """ 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) @param set_single_*_value - indicate whether only setting a single value without traversing list of values @param *_value_to_set - the single value to set if the set_single_*_value is True, ignored otherwise """ test.startSection("Verify the range of {}".format(vital_parameter)) systolic = waitForObject(names.o_pop_up_systolic_input_field) diastolic = waitForObject(names.o_pop_up_diastolic_input_field) hr = waitForObject(names.o_pop_up_heart_rate_input_field) is_completed = (str(systolic.text) != "") and (str(diastolic.text) != "") test.log(str(is_completed)) # HANDLE FOR SYSTOLIC FIELD if set_single_systolic_value: mouseClick(systolic) utility.enter_keypad_value(str(systolic_value_to_set)) verify_entered_value_in_pop_up(value=str(systolic_value_to_set), input_field=systolic, vital=config.SYSTOLIC_TEXT) if (vital_parameter is config.SYSTOLIC_TEXT) and (set_single_systolic_value is not True): mouseClick(systolic) for value in systolic_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=systolic, vital=vital_parameter) is_BP_valid = systolic.text.toInt() >= diastolic.text.toInt() #DEBUG test.log(("bp is valid {} comparing {} >= {}").format(is_BP_valid,systolic.text.toInt(),diastolic.text.toInt())) is_completed = is_completed and is_BP_valid utility.verify_color_of_entry(entry=value, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic, is_complete= is_completed) utility.erase_entered_value(input_field=systolic) # HANDLE FOR DIASTOLIC FIELD: if set_single_diastolic_value: mouseClick(diastolic) utility.enter_keypad_value(str(diastolic_value_to_set)) verify_entered_value_in_pop_up(value=str(diastolic_value_to_set), input_field=diastolic, vital=config.DIASTOLIC_TEXT) if (vital_parameter is config.DIASTOLIC_TEXT) and (set_single_diastolic_value is not True): mouseClick(diastolic) for value in diastolic_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=diastolic, vital=vital_parameter) is_BP_valid = systolic.text.toInt() >= diastolic.text.toInt() test.log(("bp is valid {} comparing {} >= {}").format(is_BP_valid,systolic.text.toInt(),diastolic.text.toInt())) is_completed = is_completed and is_BP_valid utility.verify_color_of_entry(entry=value, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic, is_complete= is_completed) utility.erase_entered_value(diastolic) # HANDLE FOR HR FIELD if set_single_hr_value: mouseClick(hr) utility.enter_keypad_value(str(hr_value_to_set)) verify_entered_value_in_pop_up(value=str(hr_value_to_set), input_field=hr, vital=config.HEART_RATE_TITLE) if (vital_parameter is config.HEART_RATE_TITLE) and (set_single_hr_value is not True): mouseClick(hr) for value in hr_value_set: utility.enter_keypad_value(str(value)) verify_entered_value_in_pop_up(value=str(value), input_field=hr, vital=vital_parameter) utility.verify_color_of_entry(entry=value, vital_parameter=config.HEART_RATE_TITLE, input_field=hr, is_complete= is_completed) utility.erase_entered_value(hr) test.endSection() def clear_BP_and_HR_settings(): #clearing systolic field systolic = waitForObject(names.o_PreTreatmentBase_input_TextInput_2) mouseClick(systolic) utility.erase_entered_value(input_field=systolic) #clear diastolic field diastolic = waitForObject(names.o_PreTreatmentBase_input_TextInput_3) mouseClick(diastolic) utility.erase_entered_value(diastolic) #Clearing HR field hr = waitForObject(names.o_PreTreatmentBase_input_TextInput_4) mouseClick(hr) utility.erase_entered_value(hr) 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 = utility.get_object_from_names(names.o_pop_up_systolic_input_field, "Systolic Input Object missing") diastolic = utility.get_object_from_names(names.o_pop_up_diastolic_input_field, "Diastolic Input Object missing") if systolic is not None: mouseClick(systolic) utils.waitForGUI(1) utility.erase_entered_value(systolic) mouseClick(systolic) utils.waitForGUI(1) utility.enter_keypad_value(str(sys_val)) verify_entered_value_in_pop_up(value=str(sys_val), input_field=systolic, vital=config.SYSTOLIC_TEXT) # the color of the input field text is affected by whether the systolic and diastolic are both filled in or not isDiastolic_complete = (diastolic is not None) and (diastolic.text != "") isSystolic_complete = (systolic is not None) and (systolic.text != "") isBothFields_complete = isDiastolic_complete and isSystolic_complete utility.verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=systolic, is_complete = isBothFields_complete) if diastolic is not None: mouseClick(diastolic) utils.waitForGUI(0.5) utility.erase_entered_value(diastolic) utils.waitForGUI(1) utility.enter_keypad_value(str(dia_val)) verify_entered_value_in_pop_up(value=str(dia_val), input_field=diastolic, vital=config.DIASTOLIC_TEXT) # the color of the input field text is affected by whether the systolic and diastolic are both filled in or not isDiastolic_complete = (diastolic is not None) and (diastolic.text != "") isSystolic_complete = (systolic is not None) and (systolic.text != "") isBothFields_complete = isDiastolic_complete and isSystolic_complete utility.verify_color_of_entry(entry=dia_val, vital_parameter=config.DIASTOLIC_TEXT, input_field=diastolic, is_complete=isBothFields_complete) utils.waitForGUI(0.5) hr = waitForObject(names.o_pop_up_heart_rate_input_field) mouseClick(hr) utility.erase_entered_value(hr) utility.enter_keypad_value(str(heart_rate)) verify_entered_value_in_pop_up(value=str(heart_rate), input_field=hr, vital=config.HEART_RATE_TITLE) utility.verify_color_of_entry(entry=heart_rate, vital_parameter=config.HEART_RATE_TITLE, input_field=hr) if save: test.log("Clicking confirm button") confirm_button = waitForObjectExists(names.o_treatmentStack_vitals_confirmButton_TouchRect) test.compare(confirm_button.enabled, True, "Valid Blood Pressure and Heart is entered therefore confirm button is enabled") saved_time = utility.get_current_date_and_time(date_format='%m/%d/%Y %H:%M:%S') 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=config.BLOOD_PRESSURE_TITLE, save=save) verify_entered_value_in_main_treatment_screen(value=heart_rate, vital=config.HEART_RATE_TITLE, save=save) test.endSection() def verify_request_continue_mode(): """ Method to accept treatment response. """ treatment_status = hd_simulator.cmd_send_treatment_parameter_manual_validation_response([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) test.compare(treatment_status, True, "custom treatment should be accepted") def verify_create_custom_treatment_parameter(): """ Method to set create custom treatment slider value based on slider buffer """ test.startSection("Set create custom treatment slider based on positive slider buffer") test.compare(waitForObject(names.o_PreTreatmentCreate_Create_a_Custom_Treatment_Text).text, config.TREATMENT_TITLE, "Title text should be -> "+str(config.TREATMENT_TITLE)) test.compare(waitForObject(names.o_PreTreatmentCreate_PRESCRIPTION_Text).text, config.PRESCRIPTION_TITLE, "Title text should be -> "+str(config.PRESCRIPTION_TITLE)) #set custom values for parameters test.startSection("verification of blood flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_bloodFlowRate_SliderCreateTreatment).label, config.BLOOD_FLOW_RATE, "Parameter should be -> "+str(config.BLOOD_FLOW_RATE)) test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodFlowRateSlider_Slider, 100, config.CREATE_TREATMENT_SLIDER_VALUES["blood_flow_rate"], config.BLOOD_FLOW_RATE) test.endSection() test.startSection("verification of dialysate flow values") test.compare(waitForObject(names.o_PreTreatmentCreate_dialysateFlowRate_SliderCreateTreatment).label, config.DIALYSATE_FLOW_RATE, "Parameter should be -> "+str(config.DIALYSATE_FLOW_RATE)) test_custom_treatment_slider(names.o_PreTreatmentCreate_dialysateFlowRateSlider_Slider, 250, config.CREATE_TREATMENT_SLIDER_VALUES["dialysate_flow_rate"], config.DIALYSATE_FLOW_RATE) test.endSection() test.startSection("verification of duration values") test.compare(waitForObject(names.o_PreTreatmentCreate_duration_SliderCreateTreatment).label, config.DURATION, "Parameter should be -> "+str(config.DURATION)) test_custom_treatment_slider(names.o_PreTreatmentCreate_durationSlider_Slider, 60, config.CREATE_TREATMENT_SLIDER_VALUES["duration"], config.DURATION) test.endSection() #scroll the screen to the title heparin bolus volume parameter_object = set_parameter_type(text=config.HEPARIN_BOLUS_VOLUME) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of heparin dispensing rate values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinDispensingRate_SliderCreateTreatment).label, config.HEPARIN_DISPENSING_RATE, "Parameter should be -> "+str(config.HEPARIN_DISPENSING_RATE)) utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_OFF_Text).text,"OFF", "Text should be -> "+"OFF") mouseClick(names.o_PreTreatmentCreate_heparinDispensingRateSwitch_Switch) mouseClick(names.o_PreTreatmentCreate_heparinDispensingRateSwitch_Switch) utils.waitForGUI(1) test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinDispensingRateSlider_Slider, 0.2, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_dispensing_rate"], config.HEPARIN_DISPENSING_RATE) test.endSection() test.startSection("verification of heparin bolus volume values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinBolusVolume_SliderCreateTreatment).label, config.HEPARIN_BOLUS_VOLUME, "Parameter should be -> "+str(config.HEPARIN_BOLUS_VOLUME)) utils.waitForGUI(1) # if (waitForObject(names.o_PreTreatmentCreate_Rectangle)).visible == true: test.compare(waitForObject(names.o_PreTreatmentCreate_OFF_Text).text,"OFF", "Text should be -> "+"OFF") mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) mouseClick(names.o_PreTreatmentCreate_heparinBolusVolumeSwitch_Switch) utils.waitForGUI(1) test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinBolusVolumeSlider_Slider, 0.2, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_bolus_volume"], config.HEPARIN_BOLUS_VOLUME) test.endSection() #scroll the screen to the title acid concentrate type parameter_object = set_parameter_type(text=config.HEPARIN_TYPE_TITLE) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of heparin stop time values") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinStopTime_SliderCreateTreatment).label, config.HEPARIN_STOP_TIME, "Parameter should be -> "+str(config.HEPARIN_STOP_TIME)) test_custom_treatment_slider(names.o_PreTreatmentCreate_heparinStopTimeSlider_Slider, 0, config.CREATE_TREATMENT_SLIDER_VALUES["heparin_stop_time"], config.HEPARIN_STOP_TIME) test.endSection() test.startSection("verification of saline bolus values") test.compare(waitForObject(names.o_PreTreatmentCreate_salineBolus_SliderCreateTreatment).label, config.SALINE_BOLUS_TITLE, "Parameter should be -> "+str(config.SALINE_BOLUS_TITLE)) test_custom_treatment_slider(names.o_PreTreatmentCreate_salineBolusSlider_Slider, 100, config.CREATE_TREATMENT_SLIDER_VALUES["saline_bolus"], config.SALINE_BOLUS_TITLE) test.endSection() #scroll the screen to the title acid concentrate type parameter_object = set_parameter_type(text=config.ACID_CONCENTRATE_TITLE) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of heparin type") test.compare(waitForObject(names.o_PreTreatmentCreate_heparinTypeRect_GridSelection).labels, config.HEPARIN_TYPE, "Parameter should be -> "+str(config.HEPARIN_TYPE)) mouseClick(waitForObject(names.o_PreTreatmentCreate_heparinTypeRect0_TouchRect)) test.compare(waitForObject(names.o_PreTreatmentCreate_heparinTypeRect0_TouchRect).text.text, config.HEPARIN_TYPE, "heparin text should be :"+ str(config.HEPARIN_TYPE)) test.compare(waitForObject(names.o_PreTreatmentCreate_heparinTypeRect0_TouchRect).color.name, config.TREATMENT_HIGHLIGHTED_COLOR, str(config.HEPARIN_TYPE)+" checkbox should be highlighted") test.endSection() #scroll the screen to the title dialyste rectangle parameter_object = set_parameter_type(text=config.DIALYZER_TYPE_TITLE) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of acid concentrate type") test.compare(waitForObject(names.o_PreTreatmentCreate_acidConcentrateRect_GridSelection).title, config.ACID_CONCENTRATE_TITLE, "Parameter should be -> "+str(config.ACID_CONCENTRATE_TITLE)) mouseClick(names.o_PreTreatmentCreate_acidConcentrateRect0_TouchRect) test.compare(waitForObject(names.o_PreTreatmentCreate_acidConcentrateRect0_TouchRect).color.name, config.TREATMENT_HIGHLIGHTED_COLOR, str(config.HEPARIN_TYPE)+" checkbox should be highlighted") test.compare(waitForObject(names.o_PreTreatmentCreate_acidConcentrateRect0_TouchRect).text.text, config.ACID_CONCENTRATE[0], "Acid concentrate value should be :"+str(config.ACID_CONCENTRATE[0])) test.endSection() #scroll the screen to the title dialyste rectangle parameter_object = set_parameter_type(text=config.DIALYZER_TYPE_TITLE) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of bicarbonate concentrate rectangle") test.compare(waitForObject(names.o_PreTreatmentCreate_bicarbonateConcentrateRect_GridSelection).title, config.BICARBONATE_CONCENTRATE_TITLE, "Parameter should be -> "+str(config.BICARBONATE_CONCENTRATE_TITLE)) mouseClick(names.o_PreTreatmentCreate_bicarbonateConcentrateRect0_TouchRect) test.compare(waitForObject(names.o_PreTreatmentCreate_bicarbonateConcentrateRect0_TouchRect).color.name, config.TREATMENT_HIGHLIGHTED_COLOR, str(config.HEPARIN_TYPE)+" checkbox should be highlighted") test.compare(waitForObject(names.o_PreTreatmentCreate_bicarbonateConcentrateRect0_TouchRect).text.text, config.BICARBONATE_CONCENTRATE, "Bicarbonate concentrate value should be :"+str(config.ACID_CONCENTRATE[0])) test.endSection() #scroll the screen to the title dialyste temperature value parameter_object = set_parameter_type(text=config.DIALYSATE_TEMPERATURE) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of dialysate rectangle") test.compare(waitForObject(names.o_PreTreatmentCreate_dialyzerTypeRect_GridSelection).title, config.DIALYZER_TYPE_TITLE, "Parameter should be -> "+str(config.DIALYZER_TYPE_TITLE)) mouseClick(names.o_PreTreatmentCreate_dialyzerTypeRect0_TouchRect) test.compare(waitForObject(names.o_PreTreatmentCreate_dialyzerTypeRect0_TouchRect).color.name, config.TREATMENT_HIGHLIGHTED_COLOR, str(config.HEPARIN_TYPE)+" checkbox should be highlighted") test.compare(waitForObject(names.o_PreTreatmentCreate_dialyzerTypeRect0_TouchRect).text.text, config.DIALYZER_TYPE[0], "Dialyzer type value should be :"+str(config.DIALYZER_TYPE[0])) test.endSection() #scroll the screen to the title blood pressure measurement interval parameter_object = set_parameter_type(text=config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) utility.scroll_to_zone(parameter_object, names.o_treatment_create_flickable) test.startSection("verification of dialysate temperature values") test.compare(waitForObject(names.o_PreTreatmentCreate_dialysateTemperature_SliderCreateTreatment).label, config.DIALYSATE_TEMPERATURE, "Parameter should be -> "+str(config.DIALYSATE_TEMPERATURE)) test_custom_treatment_slider(names.o_PreTreatmentCreate_dialysateTemperatureSlider_Slider, 35, config.CREATE_TREATMENT_SLIDER_VALUES["dialysate_temperature"], config.DIALYSATE_TEMPERATURE) test.endSection() test.startSection("verification of blood pressure measurement interval values") test.compare(waitForObject(names.o_PreTreatmentCreate_BPInterval_OFF_Text).text,"OFF", "Text should be -> "+"OFF") mouseClick(waitForObject(names.o_PreTreatmentCreate_BPInterval_Switch)) mouseClick(names.o_PreTreatmentCreate_BPInterval_Switch) utils.waitForGUI(1) test.compare(waitForObject(names.o_PreTreatmentCreate_bloodPressureMeasurementInterval_SliderCreateTreatment).label, config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL, "Parameter should be -> "+str(config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL)) test_custom_treatment_slider(names.o_PreTreatmentCreate_bloodPressureMeasurementIntervalSlider_Slider, 5, config.CREATE_TREATMENT_SLIDER_VALUES["blood_pressure_measurement_interval"], config.BLOOD_PRESSURE_MEASUREMENT_INTERVAL) test.endSection() test.endSection() def set_venous_low_and_high(): """ Method to set the venous low and high limits using slider """ test.startSection("Set the venous low and high limits using slider") utility.set_venous_ranges_min_val(ven_low) utility.set_venous_ranges_max_val(ven_high) test.endSection() def set_arterial_low_and_high(): """ Method to set the arterial low and high limits using slider """ test.startSection("Set the arterial low and high limits using slider") utility.set_arterial_ranges_max_val(art_high) utility.set_arterial_ranges_min_val(art_low) test.endSection() def verify_vital_entries_in_main_treatment_screen(sys_val, dia_val, heart_rate): """ Method to enter systolic, diastolic and heart rate value and save or unsave it and verify same is updated in pre-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") mouseClick(waitForObject(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_2) utility.enter_keypad_value(sys_val) test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).enabled, "systolic combo box should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureSystolic_TextEntry).text, str(sys_val), "systolic value should be : " + str(sys_val)) utility.verify_color_of_entry(entry=sys_val, vital_parameter=config.SYSTOLIC_TEXT, input_field=waitForObject(names.o_PreTreatmentBase_input_TextInput_2)) mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_3)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_3) utility.enter_keypad_value(dia_val) test.verify(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_bloodPressureDiastolic_TextEntry).text, str(dia_val), "diastolic value should be : "+str(dia_val)) utility.verify_color_of_entry(entry = dia_val, vital_parameter = config.DIASTOLIC_TEXT, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_3), is_complete = True) mouseClick(waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) utility.erase_entered_value(names.o_PreTreatmentBase_input_TextInput_4) utility.enter_keypad_value(heart_rate) test.verify(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).enabled, "diastolic value should be enabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_heartRate_TextEntry).text, str(heart_rate), "diastolic value should be : "+str(dia_val)) utility.verify_color_of_entry(entry = heart_rate, vital_parameter = config.HEART_RATE_TITLE, input_field = waitForObject(names.o_PreTreatmentBase_input_TextInput_4)) test.endSection() def verify_entered_vitals_in_patient_connection_screen(): """ Method to verify BP/HR section from patient connection. """ test.startSection("verification of BP/HR section from patient connection") test.log("Clearing all fields") clear_BP_and_HR_settings() test.compare(waitForObjectExists(names.o_PreTreatmentBase_BP_HR_Text).text, config.BP_HR_TEXT, "BP/HR title text should be :" + str(config.BP_HR_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).text, config.CONFIRM_TEXT, "BP/HR button text should be " + str(config.CONFIRM_TEXT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).enabled, False, "BP/HR button should disabled.") test.compare(waitForObjectExists(names.o_PreTreatmentBase_Blood_Pressure_Text).text, config.BLOOD_PRESSURE_TITLE, "BP title text should be :" + str(config.BLOOD_PRESSURE_TITLE)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_mmHg_Label).text, config.BLOOD_PRESSURE_UNIT, "BP unit should be " + str(config.BLOOD_PRESSURE_UNIT)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_Heart_Rate_Text).text, config.HEART_RATE_TITLE, "HR text should be :" + str(config.HEART_RATE_TITLE)) test.compare(waitForObjectExists(names.o_PreTreatmentBase_BPM_Label).text, config.HEART_RATE_UNIT, "BP unit should be " + str(config.HEART_RATE_UNIT)) verify_vital_entries_in_main_treatment_screen(sys_val=config.SYSTOLIC_PRESSSURE_175, dia_val=config.DIASTOLIC_PRESSSURE_74, heart_rate=config.HEART_RATE_VAL_85) test.verify(waitForObjectExists(names.o_PreTreatmentBase_CONFIRM_Text_2).enabled, "Confirm button is enabled.") mouseClick(waitForObject(names.o_PreTreatmentBase_CONFIRM_Text_2)) reset_bp_hr_in_main_treatment() test.endSection() def set_venous_high_and_low_limits_using_slider(): """ Method to set the venous low and high limits using slider """ test.startSection("Set the venous low and high limits using slider") utils.waitForGUI(1) for venous_value in range(config.VENOUS_VALUE_50, config.VENOUS_VALUE_600, config.POSITIVE_BUFFER): utility.set_venous_ranges_max_val(venous_value) for venous_value in range(config.VENOUS_VALUE_20, config.VENOUS_VALUE_570, config.POSITIVE_BUFFER): utility.set_venous_ranges_min_val(venous_value) test.endSection() def set_arterial_high_and_low_limits_using_slider(): """ Method to set the arterial low and high limits using slider """ test.startSection("Set the arterial low and high limits using slider") utils.waitForGUI(1) for arterial_value in range(config.ARTERIAL_VALUE_NEGATIVE_20, config.ARTERIAL_VALUE_NEGATIVE_300, config.NEGATIVE_BUFFER): utility.set_arterial_ranges_min_val(arterial_value) for arterial_value in range(config.ARTERIAL_VALUE_0, config.ARTERIAL_VALUE_NEGATIVE_270, config.NEGATIVE_BUFFER): utility.set_arterial_ranges_max_val(arterial_value) test.endSection() def drag_and_drop_ultrafiltration_slider(slider_value=0, maximum_ultrafiltration=0): """ Tests to verify ultrafiltration slider range @param slider_value: (int) value of the slider to set. """ slider_buffer = (config.UF_MAXIMUM_SLIDER_WIDTH/(maximum_ultrafiltration/100)) * slider_value slider_width = slider_buffer + config.UF_MINIMUM_SLIDER_WIDTH mouseClick(waitForObject(names.o_PreTreatmentUltrafiltration_volumeSlider_Slider), slider_width , 3, Qt.LeftButton) utils.waitForGUI(0.1) def verify_interval_for_bpm(): """ Method to set all parameters in create custom treatment and navigate to patient connection screen and set bp/hr navigate to main treatment screen to reset vital """ test.startSection("Verify last read and interval of blood pressure and heart rate") hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TPAR.value, sub_mode=HDStandbyStates.STANDBY_START_STATE.value) mouseClick(waitForObject(names.o_input_patient_id)) type(waitForObject(names.o_input_patient_id), "abcd") mouseClick(waitForObject(names.o_continue_button)) verify_create_custom_treatment_parameter() verify_request_continue_mode() utils.waitForGUI(1) hd_simulator.cmd_initiate_treatment_response(response=1, reason=0) hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_PRET.value , sub_mode=HDStandbyStates.STANDBY_START_STATE.value) hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=PreTreatmentSubModes.HD_PRE_TREATMENT_PATIENT_CONNECTION_STATE.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value,consumables_self_test_state=PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value, no_cartridge_self_test_state=PreTreatmentNoCartSelfTestStates.NO_CART_SELF_TESTS_HOME_IDLE_STATE.value,installation_state=PreTreatmentCartridgeInstallStates.CARTRIDGE_INSTALL_STATE.value, dry_self_test_state=PreTreatmentDrySelfTestsStates.DRY_SELF_TESTS_START_STATE.value, prime_state=PreTreatmentPrimeStates.HD_PRIME_WAIT_FOR_USER_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PRE_TREATMENT_PAT_CONN_WAIT_FOR_USER_CONFIRM_STATE.value, wet_selftests_state=PreTreatmentWetSelfTestStates.WET_SELF_TESTS_START_STATE.value, pretreatment_rsrvr_state=HDPreTreatmentReservoirMgmtStates.PRE_TREATMENT_RESERVOIR_MGMT_START_STATE.value) verify_entered_vitals_in_patient_connection_screen() utils.waitForGUI(1) hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TREA.value, sub_mode=TreatmentStates.TREATMENT_DIALYSIS_STATE.value) utils.waitForGUI(1) verify_vitals_pop_up_is_opened_automatically_after_an_interval(interval=5) test.endSection() def reset_bp_hr_in_main_treatment(): """ Method to verify the blood pressure and heart from navigating from main treatment to patient connection verifying the same by navigating from patient connection to main treatment to reset """ hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_TREA.value, sub_mode=TreatmentStates.TREATMENT_DIALYSIS_STATE.value) utils.waitForGUI(1) hd_simulator.cmd_set_treatment_states_data(sub_mode = TreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, uf_state= UFStates.UF_PAUSED_STATE.value, saline_state= SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state= HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state= TreatmentStates.TREATMENT_RINSEBACK_STATE.value, recirculate_state= TreatmentStates.TREATMENT_RECIRC_STATE.value, blood_prime_state= TreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, treatment_end_state= TreatmentStates.TREATMENT_END_STATE.value, treatment_stop_state= TreatmentStates.TREATMENT_STOP_STATE.value, dialysis_state= TreatmentStates.TREATMENT_DIALYSIS_STATE.value, bloodLeakZeoringState = BloodLeakZeroingStates.BLD_ZEROING_IDLE_STATE.value) hd_simulator.cmd_set_treatment_states_data(sub_mode = TreatmentStates.TREATMENT_DIALYSIS_STATE.value, uf_state= UFStates.UF_PAUSED_STATE.value, saline_state= SalineBolusStates.SALINE_BOLUS_STATE_IDLE.value, heparin_state= HeparinStates.HEPARIN_STATE_OFF.value, rinseback_state= TreatmentStates.TREATMENT_RINSEBACK_STATE.value, recirculate_state= TreatmentStates.TREATMENT_RECIRC_STATE.value, blood_prime_state= TreatmentStates.TREATMENT_BLOOD_PRIME_STATE.value, treatment_end_state= TreatmentStates.TREATMENT_END_STATE.value, treatment_stop_state= TreatmentStates.TREATMENT_STOP_STATE.value, dialysis_state= TreatmentStates.TREATMENT_DIALYSIS_STATE.value, bloodLeakZeoringState = BloodLeakZeroingStates.BLD_ZEROING_IDLE_STATE.value) def set_parameter_type(text): """ Method to set object property based on text @param text : (string) treatment parameter text """ if isinstance(text, str): names.o_operating_parameters["text"] = text return names.o_operating_parameters else: test.log("Invalid \"text\": " +text+" for object.") names.o_operating_parameters["text"] = None def test_custom_treatment_slider(slider_object, value, slider_parameter, parameter): """ Method to set slider handle based on custom values @param slider_object : (dictionary) object of treatment parameters @param vale : (int)value to be set on slider @param slider_parameter : (list) consist combination of slider minimum value, slider buffer and width buffer @param parameter : (str) parameter name """ minimum_slider_value = slider_parameter[0] slider_buffer = slider_parameter[1] width_buffer = slider_parameter[2] slider_width = ((value - minimum_slider_value)/slider_buffer) * width_buffer utils.waitForGUI(0.3) mouseClick(findObject(slider_object), float(slider_width) , 3, Qt.LeftButton) test.compare(waitForObjectExists(slider_object).value, value, str(parameter)+" slider value should set to"+str(value)) def verify_vitals_pop_up_automatic_close_functionality(): """ Method to verify the vitals pop up is closed automatically after 1 min """ test.startSection("Verify the vitals pop up closed automatically after 1 min") sec = 70 start_time = open_vitals_pop_up() time.sleep(sec) bp_uom = waitForObject(names.o_bp_uom) end_time = time.time() total_elapsed_time = end_time - start_time test.log("Total elapsed time : {}".format(total_elapsed_time)) test.compare(bp_uom.text, config.BLOOD_PRESSURE_UNIT, "{} should displayed when pop up is closed".format(config.BLOOD_PRESSURE_UNIT)) test.endSection() def verify_vitals_pop_up_is_opened_automatically_after_an_interval(interval): """ Method to verify the vitals pop up is opened automatically once the BPM interval time is elapsed @param interval - (int) interval in min """ test.startSection("Verify the vitals pop up opened automatically after interval time is elapsed") sec = interval*60 start_time = time.time() sec_count = 0 while not(object.exists(names.o_vitals_close_btn)): utils.waitForGUI(1) sec_count += 1 end_time = time.time() if sec_count in range(295, 301): test.log("Dialog close button be visible after {}".format(sec)) close_btn = waitForObject(names.o_vitals_close_btn) total_elapsed_time = end_time - start_time test.log("Total elapsed time : {}".format(total_elapsed_time)) test.compare(close_btn.visible, config.VISIBLE, "Dialog close button should be visible after the vitals pop up is opened automatically") test.endSection() def verify_ranges_of_vitals_fields_complete(vSystolic_value_set, vDiastolic_value_set, vHr_value_set): """ This is for the cases that the fields are complete and we are changing one single value """ # complete the fields with valid values: verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, systolic_value_set = vSystolic_value_set) # runs the multiple value test # complete the fields with valid values: verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) verify_ranges_of_vital(vital_parameter=config.DIASTOLIC_TEXT, diastolic_value_set=vDiastolic_value_set)# runs the multiple value test # complete the fields with valid values: verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, set_single_systolic_value=True, systolic_value_to_set=config.SYSTOLIC_LOWER_LIMIT, set_single_diastolic_value=True, diastolic_value_to_set=config.DIASTOLIC_LOWER_LIMIT, set_single_hr_value=True, hr_value_to_set=config.HEART_RATE_LOWER_LIMIT) verify_ranges_of_vital(vital_parameter=config.HEART_RATE_TITLE, hr_value_set = vHr_value_set)# runs the multiple value test def verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set, vDiastolic_value_set, vHr_value_set): verify_ranges_of_vital(vital_parameter=config.SYSTOLIC_TEXT, systolic_value_set = vSystolic_value_set) verify_ranges_of_vital(vital_parameter=config.DIASTOLIC_TEXT, diastolic_value_set=vDiastolic_value_set) verify_ranges_of_vital(vital_parameter=config.HEART_RATE_TITLE, hr_value_set = vHr_value_set) def main(): utils.tstStart(__file__) application_init.setup_post_log_successful_start() startApplication(config.AUT_NAME) hd_simulator.cmd_send_power_on_self_test_version_request() hd_simulator.cmd_set_treatment_states_data(sub_mode=TreatmentStates.TREATMENT_DIALYSIS_STATE.value, uf_state=TreatmentStates.TREATMENT_START_STATE.value, saline_state=TreatmentStates.TREATMENT_START_STATE.value, heparin_state=TreatmentStates.TREATMENT_START_STATE.value, rinseback_state=TreatmentStates.TREATMENT_START_STATE.value, recirculate_state=TreatmentStates.TREATMENT_START_STATE.value, blood_prime_state=TreatmentStates.TREATMENT_START_STATE.value, treatment_end_state=TreatmentStates.TREATMENT_START_STATE.value, treatment_stop_state=TreatmentStates.TREATMENT_START_STATE.value, dialysis_state=TreatmentStates.TREATMENT_START_STATE.value, bloodLeakZeoringState = BloodLeakZeroingStates.BLD_ZEROING_IDLE_STATE.value) hd_simulator.cmd_set_treatment_parameter_ranges(min_treatment_duration=0, max_treatment_duration=480, min_uf_volume=0.01, max_uf_volume=8.00, min_dialysate_flow_rate=100, max_dialysate_flow_rate=500) # verify_vitals_pop_up_automatic_close_functionality() 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() utils.waitForGUI(1) # verify the field colors for valid values verify_ranges_of_vitals_fields_complete(vSystolic_value_set = SYSTOLIC_VALUES, vDiastolic_value_set = DIASTOLIC_VALUES, vHr_value_set = HEART_RATE_VALUES) utils.waitForGUI(1) verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set = SYSTOLIC_VALUES, vDiastolic_value_set = DIASTOLIC_VALUES, vHr_value_set = HEART_RATE_VALUES) utils.waitForGUI(1) # verify the field colors for invalid values verify_ranges_of_vitals_fields_complete(vSystolic_value_set = INVALID_VALS["systolic"], vDiastolic_value_set = INVALID_VALS["diastolic"], vHr_value_set = INVALID_VALS["Heart Rate"]) utils.waitForGUI(1) verify_ranges_of_vitals_fields_incomplete(vSystolic_value_set = INVALID_VALS["systolic"], vDiastolic_value_set = INVALID_VALS["diastolic"], vHr_value_set = INVALID_VALS["Heart Rate"]) verify_interval_for_bpm() utils.tstDone()