# Subject/Title: LDT -2280 Patient Vitals - SW - 02 - Q&R - 15: SIT - Software Integration Tests - Squish Qt # # Functionalities: Testing all functionalities of Patient Vitals in the main treatment screen # # Steps: # 1 Patient Vitals: # - Verify the Systolic minimum,mid and maximum values in Vital Popup # - Verify the Diastolic minimum ,mid and maximum values in Vital Popup # - Verify the Heart Rate minimum,mid and maximum values in Vital Popup # - Verify the time intervals in the vital interval Popup # - Verify the vitals popup is opened automatically once the BPM interval time is elapsed when the rejection reason is 1 # - Verify the confirm button is disabled when user enters out of range values in the systolic, diastolic and heart rate parameters # - Verify the vitals interval time with current system time import names import time import builtins from leahi_dialin.ui import utils from configuration import utility from configuration import config from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from datetime import datetime import squish td =TD_Messaging() ACID_CONCENTRATE = ["1.0 K, 2.50 Ca, 1 Mg","2.0 K, 2.50 Ca, 1 Mg","3.0 K, 2.50 Ca, 1 Mg"] DIALYZER_TYPE = ["Diacap Pro 13H","Diacap Pro 16H", "Diacap Pro 19H", "Optiflux F160NRe", "Optiflux F180NRe", "Optiflux F200NRe","Optiflux F250NRe"] VITALS = ["OFF","5","10","15","20","30","60"] BICARBONATE = ["Sodium Bicarbonate"] SYSTOLIC = "Systolic" DIASTOLIC = "Diastolic" HEARTRATE = "Heart Rate" MIN_SYSTOLIC = "60" MIN_DIASTOLIC = "40" MIN_HEARTRATE = "40" MAX_SYSTOLIC = "250" MAX_DIASTOLIC = "200" MAX_HEARTRATE = "180" SYSTOLIC_251 = "251" DIASTOLIC_201 = "201" HEARTRATE_181 = "181" VISIBLE = True def verify_create_treatment_parameters(): test.startSection("Pre treatment parameters") mouseClick(waitForObject(names.o_PatientIDEntry_TextEntry)) waitForObject(names.o_PatientIDEntry_TextEntry).text ="abcd" utility.set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 90) utility.set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 100) utility.set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 105) utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, 0.4) utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, 0.5) utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 105) utility.select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,ACID_CONCENTRATE,2) utility.set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) utility.select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,DIALYZER_TYPE,2) utility.set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 100) utility.select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,VITALS,2) utility.select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,BICARBONATE,0) mouseClick(waitForObject(names.o_PreTreatmentButtom)) td.td_Treatment_Parameters_Validation( vAccepted = 1, vBloodFlowRateRejectReason = 0, vDialysateFlowRateRejectReason = 0, vTreatmentDurationRejectReason = 0, vSalineBolusVolumeRejectReason = 0, vHeparinStopTimeRejectReason = 0, vHeparinTypeRejectReason = 0, vAcidConcentrateRejectReason = 0, vBicarbonateConcentrateRejectReason = 0, vDialyzerTypeRejectReason = 0, vBloodPressureMeasureIntervalRejectReason = 0, vRinsebackFlowRateRejectReason = 0, vRinsebackVolumeRejectReason = 0, vArterialPressureLimitWindowRejectReason = 0, vVenousPressureLimitWindowRejectReason = 0, vVenousPressureLimitAsymtrcRejectReason = 0, vTrancembrncPressureLimitWindowRejectReason = 0, vDialysateTempRejectReason = 0, vHeparinDispensingRateRejectReason = 0, vHeparinBolusVolumeRejectReason = 0 ) confirmButton = waitForObject(names.o_PreTreatmentButtom) mouseClick(waitForObject(confirmButton)) td.td_operation_mode(TDOpModes.MODE_PRET.value, 0) test.endSection() 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.keyboard_input["text"] = text return names.keyboard_input else: test.log("Invalid ",text," for object.") names.o_keyboard_input["text"] = "Q" def verify_valid_vitals_through_keypad(title_name,input_field_obj,expected_value, actual_value): """ Tests verifies valid patient id set through application keyboard setup . @return: N/A """ input_field = waitForObject(input_field_obj) mouseClick(input_field) #check the title title = waitForObjectExists(utility.set_Object_Text(text = title_name,obj =names.o_title_Text)) test.compare(title_name, title.text, "Title text should be -> "+ str(title_name)) for text in expected_value: keyboard_value = keyboard_object_map_helper(text) utils.waitForGUI(0.2) mouseClick(waitForObjectExists(keyboard_value)) utils.waitForGUI(0.2) test.compare(actual_value, (input_field.text), "Value should be -> "+ str(actual_value)) test.log("User successfully authenticated through patient id -> " + expected_value + "using keypad.") 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)): 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, VISIBLE, "Popup close option is visible after the vitals pop up is opened automatically") mouseClick(waitForObject(names.o_vitals_close_btn)) test.endSection() def verify_last_read_time(interval): test.startSection("Verify the last read time") sec = interval*60 start_time = time.time() sec_count = 0 while not(object.exists(names.o_vitals_close_btn)): sec_count += 1 end_time = time.time() if sec_count in range(295, 301): test.log("Dialog close button be visible after {}".format(sec)) total_elapsed_time = end_time - start_time def erase_entered_value(input_field): """ Method to erase the entered value @param input_field - (obj) object of input field """ test.startSection("Erasing value") input_field= squish.waitForObject(input_field) entered_value = str(input_field.text) if len(entered_value) != 0: for value in range(len(entered_value)+1): squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.compare(str(input_field.text), "", "Input field should be empty") test.endSection() def clear_BP_and_HR_settings(): #clearing systolic field #Add start section and end section mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) systolic = waitForObject(names.o_bloodPressureSystolic_TextEntry) mouseClick(systolic) erase_entered_value(input_field=systolic) #clear diastolic field diastolic = waitForObject(names.o_bloodPressureDiastolic_TextEntry) mouseClick(diastolic) erase_entered_value(diastolic) #Clearing HR field hr = waitForObject(names.o_heartRate_TextEntry) mouseClick(hr) erase_entered_value(hr) def verify_entered_patient_vitals_in_maintreatment_screen(): """ Method to verify BP/HR section from patient vitals. """ test.startSection("verification of BP/HR section from patient vitals") test.log("Clearing all fields") clear_BP_and_HR_settings() mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,"185","185") #Mid values verify_valid_vitals_through_keypad(DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,"140","140") verify_valid_vitals_through_keypad(HEARTRATE, names.o_heartRate_TextEntry, "130", "130") mouseClick(waitForObject(names.o_confirm_button)) test.endSection() def verify_interval_for_bpm(): """ Method to check the popup is opened automatically after time interval """ test.startSection("Verify popup is opened automatically after time interval") verify_entered_patient_vitals_in_maintreatment_screen() td.td_vitals_adjustment_response(vRejectionReason=1) verify_vitals_pop_up_is_opened_automatically_after_an_interval(interval=10) test.endSection() def validate_time_interval(vital_interval_obj, int_min): """ vm_time_obj: Object name/path that displays VM time (HH:MM) vitals interval_obj: Object name/path that displays remaining time (MM:SS) interval_minutes: Integer (ex: 5, 10, 15 ...) """ vm_time_str = str(utility.get_current_date_and_time(date_format='%H:%M:%S')).strip() try: hh, mm, ss = vm_time_str.split(":") print(f"current time: {vm_time_str}") except Exception as e: test.fail(f"Invalid VM time format: {vm_time_str}, error={e}") # Compute interval start time # Example: interval=5, vm=09:01 -> start = 09:05 - 5 = 09:00 interval_seconds =int_min *60 # Expected remaining seconds elapsed =(builtins.int(mm) * 60)% interval_seconds + builtins.int(ss) remaining_seconds = interval_seconds - elapsed # If negative, clamp to zero if remaining_seconds < 0: remaining_seconds = 0 # Convert to MM:SS expected_mm = remaining_seconds // 60 expected_ss = remaining_seconds % 60 expected_str = f"{expected_mm:02d}:{expected_ss:02d}" #Read UI displayed remaining time (MM:SS) ui_str = str(waitForObject(vital_interval_obj).text).strip() fmt = "%M:%S" expected_time = datetime.strptime(expected_str, fmt) actual_time = datetime.strptime(ui_str, fmt) diff = abs((actual_time - expected_time).total_seconds()) if diff <= 1: test.log(f"Remaining time is correct: {ui_str}") else: test.fail(f"Remaining time incorrect. Expected {expected_str}, got {ui_str}") def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) td.td_operation_mode(TDOpModes.MODE_STAN.value) # verify Standby screen test.verify(waitForObjectExists(names.o_standByScreen_MainHome), "In Standby") mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect)) td.td_operation_mode(TDOpModes.MODE_TPAR.value, 0) test.startSection("Create the pretreatment values") verify_create_treatment_parameters() test.endSection() test.startSection("Check the vitals in main treatment screen") td.td_operation_mode(TDOpModes.MODE_TREA.value, 0) td.td_tx_state(TDTreatmentStates.TREATMENT_DIALYSIS_STATE.value , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0) utils.waitForGUI(1) validate_time_interval(names.o_vitalCountdown_Text,10) test.endSection() test.startSection("Verify the minimum values in the vitals popup") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,MIN_SYSTOLIC,MIN_SYSTOLIC) verify_valid_vitals_through_keypad(DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,MIN_DIASTOLIC,MIN_DIASTOLIC) verify_valid_vitals_through_keypad(HEARTRATE, names.o_heartRate_TextEntry, MIN_HEARTRATE, MIN_HEARTRATE) mouseClick(waitForObject(names.o_confirm_button)) blood_pressure = waitForObjectExists(names.o_treatmentHome_bloodPressure_LabelValue).topText test.compare(MIN_SYSTOLIC+"/"+MIN_DIASTOLIC, blood_pressure,"Blood pressure value should be ->"+str(MIN_SYSTOLIC+"/"+MIN_DIASTOLIC)) heart_rate = waitForObjectExists(names.o_treatmentHome_heartBeat_LabelValue).topText test.compare(MIN_HEARTRATE, heart_rate,"Heart Rate value should be ->"+str(MIN_HEARTRATE)) test.endSection() test.startSection("Verify the maximum values in the vitals popup") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,MAX_SYSTOLIC,MAX_SYSTOLIC) verify_valid_vitals_through_keypad(DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,MAX_DIASTOLIC,MAX_DIASTOLIC) verify_valid_vitals_through_keypad(HEARTRATE, names.o_heartRate_TextEntry, MAX_HEARTRATE, MAX_HEARTRATE) mouseClick(waitForObject(names.o_confirm_button)) blood_pressure = waitForObjectExists(names.o_treatmentHome_bloodPressure_LabelValue).topText test.compare(MAX_SYSTOLIC+"/"+MAX_DIASTOLIC, blood_pressure,"Blood pressure value should be ->"+str(MAX_SYSTOLIC+"/"+MAX_DIASTOLIC)) heart_rate = waitForObjectExists(names.o_treatmentHome_heartBeat_LabelValue).topText test.compare(MAX_HEARTRATE, heart_rate,"Heart Rate value should be ->"+str(MAX_HEARTRATE)) test.endSection() test.startSection("Verify the confirm button is disabled when user enter invalid values") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,SYSTOLIC_251,SYSTOLIC_251) verify_valid_vitals_through_keypad(DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,DIASTOLIC_201,DIASTOLIC_201) verify_valid_vitals_through_keypad(HEARTRATE, names.o_heartRate_TextEntry, HEARTRATE_181, HEARTRATE_181) confirm_button =waitForObjectExists(names.o_confirm_button) test.verify(not confirm_button.enabled, "Confirm button is not enabled") mouseClick(waitForObject(names.o_vitals_close_btn)) test.endSection() test.startSection("Verify the vitals interval popup") mouseClick(waitForObject(names.o_treatmentHome_editButton_IconButton)) #check the title text in the popup vitals_titleText = waitForObjectExists(names.o_vitals_Interval_TitleText).text test.compare("Vitals Interval", vitals_titleText, "Vitals Interval popup text should be ->"+str("Vitals Interval")) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,0) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,1) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[1], "Vitals interval value should be :"+str(VITALS[1])) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,2) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[2], "Vitals interval value should be :"+str(VITALS[2])) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,3) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[3], "Vitals interval value should be :"+str(VITALS[3])) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,4) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[4], "Vitals interval value should be :"+str(VITALS[4])) utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,5) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[5], "Vitals interval value should be :"+str(VITALS[5])) mouseClick(waitForObject(names.o_vitals_close_btn)) test.endSection() test.startSection("Verify the vitals data send automatically populate on popup") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) mouseClick(names.o_measureVitalsButton_TouchRect) td.td_vitals( systolic = 70 , diastolic = 50 , heartRate = 120 ) td.td_vitals_adjustment_response(vRejectionReason=0) blood_pressure = waitForObjectExists(names.o_treatmentHome_bloodPressure_LabelValue).topText test.compare(70+"/"+50, blood_pressure,"Blood pressure value should be ->"+str(70+"/"+50)) heart_rate = waitForObjectExists(names.o_treatmentHome_heartBeat_LabelValue).topText test.compare(120, heart_rate,"Heart Rate value should be ->"+str(120)) #With rejection reasom verify_interval_for_bpm() test.endSection() test.startSection("Verify the last read time in the UI") mouseClick(waitForObject(names.o_vitalsButton_VitalsButton)) verify_valid_vitals_through_keypad(SYSTOLIC,names.o_bloodPressureSystolic_TextEntry,MIN_SYSTOLIC,MIN_SYSTOLIC) verify_valid_vitals_through_keypad(DIASTOLIC,names.o_bloodPressureDiastolic_TextEntry,MIN_DIASTOLIC,MIN_DIASTOLIC) verify_valid_vitals_through_keypad(HEARTRATE, names.o_heartRate_TextEntry, MIN_HEARTRATE, MIN_HEARTRATE) mouseClick(waitForObject(names.o_confirm_button)) sys_time = utility.get_current_date_and_time(date_format="%Y/%b/%d - %H:%M:%S") last_read = waitForObjectExists(names.o_last_read).text lastdatetime = str(last_read).split(" ")[3] systime = sys_time.split("-")[1].strip() test.compare(lastdatetime, systime, "Last read time is updated properly") test.endSection() utils.tstDone()