Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rf8a8914a4e42e08237ba0603096e67e4bd1576c5 -r17cecc45c8449e30977177ee28b9f29daf4c60ef --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision f8a8914a4e42e08237ba0603096e67e4bd1576c5) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 17cecc45c8449e30977177ee28b9f29daf4c60ef) @@ -6,7 +6,10 @@ from leahi_dialin.ui import utils from datetime import datetime from leahi_dialin.ui.td_messaging import TD_Messaging -from configuration import config, navigation +from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates +from configuration import config, navigation +from leahi_dialin.ui import utils +from builtins import int as pyInt td =TD_Messaging() @@ -62,8 +65,8 @@ """ return " ".join(('leahi', *args)) - -def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): + +def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 3000): """ To get an object with try..except catching to prevent script errors when the object is not found on the GUI @param names_dict - the dictionary element from the names.py file (ie: names.some_variable_name_of_element) @@ -73,7 +76,7 @@ return squish.waitForObject(names_dict, timeout_ms) except LookupError: test.fail("ERROR : " + error_message) - return None + return None def get_bullet_object(screen_obj, num): """ @@ -96,7 +99,7 @@ names.o_text_object["text"] = txt return names.o_text_object -def setObjectText(text,obj): +def setObjectText(obj,text): """ Method to set object property based on text @param text : (string) treatment parameter text @@ -126,7 +129,26 @@ found = findChildByText(child, target_text) if found: return found - + + return None + +def findAllObjectsById(parent, target_id): + """ + Recursively finds all child objects by their id property. + Returns a list of all matching objects found. + """ + results = [] + + # Use hasattr to safely check for 'id' property + if hasattr(parent, 'id') and str(parent.id) == target_id: + results.append(parent) + + # Recurse through all children to collect all instances + for child in object.children(parent): + results.extend(findAllObjectsById(child, target_id)) + + return results + def set_value_based_on_target(obj, target_value): """ obj: dictionary containing object paths @@ -164,7 +186,7 @@ test.log(f"Updated value: {current_value}") - test.log(f"✅ Target value reached: {current_value}") + test.log(f"✅ Target value reached: {current_value}") def select_different_dropdown(object,type,whichTypeIndex): """ @@ -185,91 +207,73 @@ test.startSection("Pre treatment parameters") navigation.navigation_pageIndicator_step(config.CREATERX) squish.mouseClick(squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry)) - squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry).text ="Patient ID" - parent_obj = squish.waitForObject(names.o_PreTreatmentCreate_leftColumn_Column) - blood_flow_rate = findObjectById(parent_obj, "_bloodFlowRate") - set_value_based_on_target(blood_flow_rate, 70) - dialysate_flow_rate = findObjectById(parent_obj, "_dialysateFlowRate") - set_value_based_on_target(dialysate_flow_rate, 50) - duration = findObjectById(parent_obj,"_duration") - set_value_based_on_target(duration, 60) - right_obj = squish.waitForObject(names.o_PreTreatmentCreate_rightColumn_Column) - ultrafiltration_volume = findObjectById(right_obj,"_ufVolume") - set_value_based_on_target(ultrafiltration_volume,0.20) - heparin_rx = findObjectById(right_obj,"_heparinRx") - heparin_right_arrow = findObjectById(heparin_rx, "_rightArrow") - squish.mouseClick(heparin_right_arrow) - heparin_obj = squish.waitForObject(names.o_LabelUnitValueAdjuster_LabelUnitValueAdjuster) - heparin_bolus = findObjectById(heparin_obj,"_heparinBolusVolume") - set_value_based_on_target(heparin_bolus, 0.2) - set_value_based_on_target(names.o_heparinDispensingRate_LabelUnitValueAdjuster,0.3) - set_value_based_on_target(names.o_heparinDeliveryDuration_LabelUnitValueAdjuster, 60) - squish.mouseClick(squish.waitForObject(names.o_confirmButton_ConfirmButton)) + squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry).text ="abcd" + set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 60) + set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 75) + set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 75) + heparinValue =navigation.get_ini_value("/home/denali/Public/luis/config/configurations/Settings/System.conf", section ="Feature Configurations", key ="HeparinSyringePump") + if heparinValue == "1": + set_value_based_on_target(names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, 0.4) + set_value_based_on_target(names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, 0.5) + set_value_based_on_target(names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 60) select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,config.ACID_CONCENTRATE,2) select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,config.DIALYZER_TYPE,2) + set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 200) + set_value_based_on_target(names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom,2.0) select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) - Nextbutton = setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) - squish.mouseClick(squish.waitForObject(Nextbutton)) - set_value_based_on_target(names.o_PreTreatmentCreate_sodium_LabelUnitValueAdjuster, 139) - set_value_based_on_target(names.o_PreTreatmentCreate_bicarbonate_LabelUnitValueAdjuster, 35) - set_value_based_on_target(names.o_PreTreatmentCreate_fluidBolusVolume_LabelUnitValueAdjuster,300) - set_value_based_on_target(names.o_PreTreatmentCreate_primeRinsebackVolume_LabelUnitValueAdjuster,310) - set_value_based_on_target(names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom,0) - confirm_button = squish.waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton) - squish.mouseClick(confirm_button) - td.td_Treatment_Parameters_Validation( vAccepted = 1, - vTreatmentModalityRejectReason = 1, - vHDFTreatmentModeRejectReason = 0, - vBloodFlowRateRejectReason = 0, - vDialysateFlowRateRejectReason = 0, - vTreatmentDurationRejectReason = 0, - vHeparinDeliveryDurationRejectReason = 0, - vHeparinTypeRejectReason = 0, - vDryBicarbCartSizeRejectReason = 0, - vSodiumRejectReason = 0, - vBicarbonateRejectReason = 0, - vDialyzerTypeRejectReason = 0, - vFluidBolusVolumeRejectReason = 0, - vBloodPressureMeasureIntervalRejecteason = 0, - vRinsebackVolumeRejectReason = 0, - vHepatitusBStatusRejectReason = 0, - vAcidConcentrateIndextRejectReason = 0, - vSubstitutionFluidVolumeRejecteason = 0, - vHeparinBolusVolumeRejectReason = 0, - vHeparinDispensingRateRejecteason = 0, - vDialysateTempRejectReason = 0, - vAcidConcentrateConversionFactorRejectReason = 0, - vUFPreWeightRejectReason = 0, - vUFEstimatedTargetWeightRejectReason = 0, - vUFVolumeRejectReason = 0 - ) + Validatebutton = setObjectText(obj = names.o_preTreatmentStack_Text, text =config.VALIDATE) + squish.mouseClick(squish.waitForObject(Validatebutton)) + 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, + vTransmembranePressureLimitWindowRejectReason = 0, + vDialysateTempRejectReason = 0, + vHeparinDispensingRateRejectReason = 0, + vHeparinBolusVolumeRejectReason = 0 + ) + confirm = squish.waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) + squish.mouseClick(confirm) test.endSection() def findAllObjectsById(parent, target_id): """ - Recursively finds all child objects by their id property. - Returns a list of all matching objects found. + Finds all child objects (excluding parent) by their id property. + Returns a list of all matching child objects found. """ results = [] - # Use hasattr to safely check for 'id' property - if hasattr(parent, 'id') and str(parent.id) == target_id: - results.append(parent) - - # Recurse through all children to collect all instances + # Recurse through all children to collect matching instances for child in object.children(parent): - results.extend(findAllObjectsById(child, target_id)) - + # Check child's id + if str(child.id) == target_id: + results.append(child) + + # Continue searching in grand children + results.extend(findAllChildrenById(child, target_id)) + return results - + def set_value_with_slider(value_field_obj, slider_obj,parameter): """ Opens the slider and moves it gradually to the target value (step of 10). Uses controlled arrow key input for fine adjustment. """ try: - value_field = waitForObject(value_field_obj,1000) + value_field = squish.waitForObject(value_field_obj,1000) test.log(f"Opening slider for {parameter}...") squish.mousePress(value_field, squish.Qt.LeftButton) value = value_field.value @@ -282,10 +286,10 @@ if not object.exists(slider_obj): test.fail(f"{parameter}: Slider did not appear.") - slider = waitForObject(slider_obj) + slider = squish.waitForObject(slider_obj) test.log(f"{parameter}: Slider appeared successfully.") squish.mousePress(slider,squish.Qt.LeftButton) - final_value = waitForObject(value_field_obj).value + final_value = squish.waitForObject(value_field_obj).value test.verify(final_value!= value, f"{parameter} slider adjusted correctly to {final_value}") squish.mouseRelease(slider, squish.Qt.LeftButton) if object.exists(slider_obj): @@ -312,6 +316,17 @@ utils.waitForGUI(0.2) # Small delay to allow UI to update return None + +def get_row_object(screen_obj, num): + """ + To obtain a row object based on occurrence provided. + @param screen_obj: provides the container on which the row must be present + @param num: provides the occurrence value (0-based index) + @returns a real name object + """ + names.o_Row_Object["container"] = screen_obj + names.o_Row_Object["occurrence"] = num + 1 + return names.o_Row_Object def get_object_color(names_dict, error_message = "Missing object color", timeout_ms = 2000): """ @@ -323,8 +338,8 @@ return squish.waitForObject(names_dict, timeout_ms).color.name except LookupError: test.fail("ERROR : " + error_message) - return None + def get_object_source_path(names_dict, error_message = "Missing object source path", timeout_ms = 2000): """ To get an object source path with try..except catching to prevent script errors when the object is not found on the GUI @@ -333,9 +348,9 @@ """ try: return squish.waitForObject(names_dict, timeout_ms).source.path - except LookupError: - return None + except LookupError: test.fail("ERROR : " + error_message) + return None def get_object_text(names_dict, error_message = "Missing object text", timeout_ms = 2000): """ @@ -348,3 +363,82 @@ except LookupError: test.fail("ERROR : " + error_message) return None + +def findAllObjectsByText(parent, target_text): + """ + Recursively finds all child objects that have a 'text' property + matching the target_text. Returns a list of matches. + """ + results = [] + # Use hasattr to safely check for 'text' property before comparing + if hasattr(parent, 'text') and str(parent.text) == target_text: + results.append(parent) + + # Recurse through all children + for child in object.children(parent): + results.extend(findAllObjectsByText(child, target_text)) + + return results + +def verify_create_treatment_parameters(): + test.startSection("Pre treatment parameters") + navigation.navigation_pageIndicator_step(config.CREATERX) + squish.mouseClick(squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry)) + squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry).text ="abcd" + set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 60) + set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 75) + set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 75) + heparinValue =navigation.get_ini_value("/home/denali/Public/luis/config/configurations/Settings/System.conf", section ="Feature Configurations", key ="HeparinSyringePump") + if heparinValue == "1": + set_value_based_on_target(names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, 0.4) + set_value_based_on_target(names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, 0.5) + set_value_based_on_target(names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 60) + select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,config.ACID_CONCENTRATE,2) + set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) + select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,config.DIALYZER_TYPE,2) + set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 200) + set_value_based_on_target(names.o_PreTreatmentCreate_bpMeasurementIntervalControl_ValueAdjusterCustom,5.0) + select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) + Validatebutton = setObjectText(obj = names.o_preTreatmentStack_Text, text =config.VALIDATE) + squish.mouseClick(squish.waitForObject(Validatebutton)) + 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, + vTransmembranePressureLimitWindowRejectReason = 0, + vDialysateTempRejectReason = 0, + vHeparinDispensingRateRejectReason = 0, + vHeparinBolusVolumeRejectReason = 0 + ) + confirm = squish.waitForObjectExists(names.o_preTreatmentStack_confirmButton_ConfirmButton, 3000) + squish.mouseClick(confirm) + test.endSection() + +def findAllObjectsById(parent, target_id): + """ + Recursively finds all child objects by their id property. + Returns a list of all matching objects found. + """ + results = [] + + # Use hasattr to safely check for 'id' property + if hasattr(parent, 'id') and str(parent.id) == target_id: + results.append(parent) + + # Recurse through all children to collect all instances + for child in object.children(parent): + results.extend(findAllObjectsById(child, target_id)) + + return results