Index: suite_leahi/shared/scripts/configuration/config.py =================================================================== diff -u -rf6d23e89ccf01b57313b0e920f013dc1027706d4 -r352eb7ec404fbbfd22541f9d12ec7ab458a3f057 --- suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision f6d23e89ccf01b57313b0e920f013dc1027706d4) +++ suite_leahi/shared/scripts/configuration/config.py (.../config.py) (revision 352eb7ec404fbbfd22541f9d12ec7ab458a3f057) @@ -45,3 +45,26 @@ WIFI_PARAMETERS_TEXTS = ["SSID", "IP Address", "Gateway", "Subnet Mask", "DNS"] WIFI_SCREEN_SCAN_BUTTON_TEXT = "SCAN" DISABLED = False + +# Settings Service +DEFAULT_SERVICE_PASSWORD_RAW = "Atal.Matal.22leh" # TODO need to update if we ever change the default +NEW_PASSWORD_RAW = "Test4.Ksah.sk43sa" +MANUFACTURING_SCREEN_TITLE_TEXT = "Manufacturing Setup" +SERVICE_SCREEN_TITLE_TEXT = "Service" +ADVANCED_MODES_SCREEN_TITLE_TEXT = "Advanced Mode" +DATE_AND_TIME_SCREEN_TITLE_TEXT = "Date and Time" +DATE_AND_TIME_PARAMETERS_TEXTS = ["NTP", "(Network Time Protocol)", "Time", "(HH:mm:ss)", "Date", "(MM/dd/yyyy)"] +ENABLE_ROOT_SSH_SCREEN_TITLE_TEXT = "Enable Root SSH" +ENABLE_ROOT_SSH_PARAMETERS_TEXTS = ["Enable SSH Login", "Enable Root Login"] +FACTORY_RESET_SCREEN_TITLE_TEXT = "Factory Reset" +FACTORY_RESET_SCREEN_TEXT = "Do you want to perform the factory reset?" + +# Service Institutional +INSTITUTIONAL_CONFIGURATIONS_SCREEN_TITLE_TEXT = "Institutional Configurations" +ADVANCED_INSTITUTIONAL_SETTINGS_SCREEN_TITLE_TEXT = "Advanced Institutional Settings" +ADVANCED_INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT = "Advanced Institutional records and preferences updated" +INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT = "Institutional records and preferences updated" +CREATERX = "Rx" +NEXT = "Next" + + Index: suite_leahi/shared/scripts/configuration/navigation.py =================================================================== diff -u -r4e2b2a08fb10fb528e782a505eaab19f63874cc4 -r352eb7ec404fbbfd22541f9d12ec7ab458a3f057 --- suite_leahi/shared/scripts/configuration/navigation.py (.../navigation.py) (revision 4e2b2a08fb10fb528e782a505eaab19f63874cc4) +++ suite_leahi/shared/scripts/configuration/navigation.py (.../navigation.py) (revision 352eb7ec404fbbfd22541f9d12ec7ab458a3f057) @@ -7,29 +7,80 @@ td_simulator = TD_Messaging() +# COMPLETE_COLOR = '#4696f7' +# CURRENT_COLOR = '#000000' + def navigate_to_device_settings_screen(): """ Method to navigate to "Service" screen """ td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value, 0) - settings_menu_object = utility.get_object_from_names( - names.o_Settings_Menu, - error_message="Settings menu object missing", - timeout_ms=1000, + headerbar_container = squish.waitForObject(names.o_mainMenu_MainMenu, 2000) + settings_menu_object = utility.findChildByText( + headerbar_container, "Settings" ) if settings_menu_object is not None: squish.mouseClick(settings_menu_object) - device_setting_screen_title_text = utility.get_object_from_names( - names.o_DeviceSettingsTitleText, - error_message="Device Settings Screen title text object missing", - timeout_ms=2000, + headerbar_container = squish.waitForObject(names.o_headerBar_HeaderBar, 2000) + device_setting_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Device Settings" ) - if device_setting_screen_title_text is not None: + if device_setting_screen_headerbar_title_text is not None: test.compare( - device_setting_screen_title_text.text, + device_setting_screen_headerbar_title_text.text, config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Device Settings Screen Title text".format( config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT ), - ) \ No newline at end of file + ) + +def navigate_to_device_settings_using_service_password(): + td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) + grid_container = squish.waitForObject(names.o_DeviceSettingsGrid) + service_option = utility.findChildByText(grid_container, "Service") + + if service_option is not None: + squish.mouseClick(service_option) + + headerbar_container = squish.waitForObject(names.o_headerBar_HeaderBar) + service_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Service" + ) + if service_screen_headerbar_title_text is not None: + test.compare( + service_screen_headerbar_title_text.text, + config.SERVICE_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Device Settings Screen Title text".format( + config.SERVICE_SCREEN_TITLE_TEXT + ), + ) + input_field = squish.waitForObject(names.o_userConfirmation_TextInput, 1000) + + squish.type(input_field, config.DEFAULT_SERVICE_PASSWORD_RAW) + confirm_button = squish.waitForObject(names.o_userConfirmation_ConfirmButton, 1000) + squish.mouseClick(confirm_button) + +def navigation_pageIndicator_step(vStep_name): + """ + Navigate to the specified page using the step indicator component. + + This method selects the given step from the page step indicator + Args: + vStep_name (str): The name of the step to navigate to as displayed + in the step indicator. + + """ + test.startSection("Method to navigation in the pretreatment page ") + stepId = squish.waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) + values = utility.findAllObjectsById(stepId, "_text") + for index, input_field in enumerate(values[1:]): + test.log(str(index)); + test.log(str(input_field.text)) + if str(input_field.text) == vStep_name: + test.log("Reached the target step") + break + else: + Nextbutton = utility.setObjectText(obj=names.o_preTreatmentStack_Text, text=config.NEXT) + squish.mouseClick(Nextbutton) + test.endSection() \ No newline at end of file Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rbddd2fe08aac52e286b53a811f0ab41919c7fea2 -r352eb7ec404fbbfd22541f9d12ec7ab458a3f057 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision bddd2fe08aac52e286b53a811f0ab41919c7fea2) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 352eb7ec404fbbfd22541f9d12ec7ab458a3f057) @@ -5,6 +5,13 @@ from squish import * from leahi_dialin.ui import utils from builtins import int as pyInt + +def aut(name, *args): + """ + Joins the executable name and argument + into a single command string + """ + return " ".join((name, *args)) def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -72,6 +79,23 @@ 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 @@ -170,4 +194,49 @@ while findObject(object_name).value != 0.0: squish.mouseClick(waitForObject(left_arrow)) utils.waitForGUI(0.2) # Small delay to allow UI to update - + +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_bullet_object(screen_obj, num): + """ + To obtain a bullet object based on occurrence provided. + @param screen_obj: provides the container on which the bullet must be present + @param num: provides the occurrence value + @returns a real name object + """ + names.o_bullet_object["container"] = screen_obj + names.o_bullet_object["occurrence"] = num + 1 + return names.o_bullet_object + +def navigation_pageIndicator_step(vStep_name): + """ + Navigate to the specified page using the step indicator component. + + This method selects the given step from the page step indicator + Args: + vStep_name (str): The name of the step to navigate to as displayed + in the step indicator. + + """ + test.startSection("Method to navigation in the pretreatment page ") + stepId = squish.waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) + values = utility.findAllObjectsById(stepId, "_text") + for index, input_field in enumerate(values[2:]): + test.log(str(index)); + test.log(str(input_field.text)) + if str(input_field.text) == vStep_name: + test.log("Reached the target step") + break + else: + Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) + squish.mouseClick(Nextbutton) + test.endSection() \ No newline at end of file Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -rbddd2fe08aac52e286b53a811f0ab41919c7fea2 -r352eb7ec404fbbfd22541f9d12ec7ab458a3f057 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision bddd2fe08aac52e286b53a811f0ab41919c7fea2) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 352eb7ec404fbbfd22541f9d12ec7ab458a3f057) @@ -39,6 +39,7 @@ o_treatmentTimeNotificationBarSmall = {"container": mainTreatmentScreen, "objectName": "notification", "type": "NotificationBarSmall" } # settings_service_export_logs +o_mainMenu_MainMenu = {"container": o_Gui_MainView, "id": "_mainMenu", "type": "MainMenu", "unnamed": 1 } o_listView_ListView = {"container": o_Gui_MainView, "id": "_listView", "type": "ListView", "unnamed": 1 } o_listView_delegateControl = {"container": o_listView_ListView, "index": 2, "objectName": "delegateControl", "type": "Item" } o_Settings_Menu = {"container": o_listView_delegateControl, "objectName": "_touchRect2", "type": "TouchRect" } @@ -54,6 +55,7 @@ o_ExportLogsProgressRect = {"container": o_SettingsExportLogs, "id": "_progressRect", "type": "ProgressRect", "unnamed": 1 } o_ExportLogsNotificationBar = {"container": o_SettingsExportLogs, "id": "_information", "type": "NotificationBarSmall" } o_DeviceSettingsGrid = {"container": o_SettingsHome, "id": "_grid", "type": "Grid", } +o_headerBar_HeaderBar = {"container": o_Gui_MainView, "id": "_headerBar", "type": "HeaderBar", "unnamed": 1 } #HeaderBar Information Pop up o_InformationIconButton = {"container": o_Gui_MainView, "id": "_informationButton", "type": "IconButton", "unnamed": 1 } @@ -154,4 +156,58 @@ o_PreTreatment_vitalsCombobox_BaseCombobox = {"container": o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_bpMeasurementIntervalControl", "type": "BaseComboBox", "unnamed": 1 } o_PreTreatmentCreate_Text = {"container": o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "type": "Text", "unnamed": 1 } +# Settings Service +o_SettingsStack_SettingsStack = {"container": o_Gui_MainView, "objectName": "_SettingsStack", "type": "SettingsStack", } +o_UserConfirmation_SettingsServicePassword = {"container": o_SettingsStack_SettingsStack, "objectName": "UserConfirmation", "type": "SettingsServicePassword" } +o_loginPage_Titletext = {"container": o_UserConfirmation_SettingsServicePassword, "id":"_titleText", "type": "Text", "unnamed": 1 } +o_userConfirmation_TextInput = {"container": o_UserConfirmation_SettingsServicePassword, "echoMode": 2, "id": "_input", "passwordCharacter": "•", "type": "TextInput", "unnamed": 1 } +o_headerBar_HeaderBar = {"container": o_Gui_MainView, "id": "_headerBar", "type": "HeaderBar", "unnamed": 1 } +o_userConfirmation_ConfirmButton = {"container": o_UserConfirmation_SettingsServicePassword, "objectName": "_confirmButton", "type": "ConfirmButton" } +o_SettingsHome_confirmButton = {"container": o_SettingsHome, "objectName": "_confirmButton", "type": "ConfirmButton" } +o_SettingsBase_SettingsAdvancedMode = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsAdvancedMode" } +o_settingsAdvancedMode_BaseSwitch = {"checkable": True, "container": o_SettingsBase_SettingsAdvancedMode, "id": "_settingsAdvancedMode", "type": "BaseSwitch", "unnamed": 1 } +o_SettingsBase_backButton_AdvancedMode = {"container": o_SettingsBase_SettingsAdvancedMode, "objectName": "_backButton", "type": "BackButton" } +o_SettingsBase_SettingsDateTime = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsDateTime" } +o_SettingsBase_ntpSwitch_BaseSwitch = {"checkable": True, "container": o_SettingsBase_SettingsDateTime, "id": "_ntpSwitch", "type": "BaseSwitch", "unnamed": 1 } +o_SettingsBase_backButton_NTP_Switch = {"container": o_SettingsBase_SettingsDateTime, "objectName": "_backButton", "type": "BackButton" } +o_timeContainer_LabelUnitContainer = {"container": o_SettingsBase_SettingsDateTime, "id": "_timeContainer", "type": "LabelUnitContainer", "unnamed": 1 } +o_SettingsBase_SettingsRootSSHAccess = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsRootSSHAccess" } +o_SettingsBase_SSH_LoginSwitch = {"checkable": True, "container": o_SettingsBase_SettingsRootSSHAccess, "id": "_settingsRootSSHAccess_SSHDSwitch", "type": "BaseSwitch", "unnamed": 1 } +o_SettingsBase_Root_LoginSwitch = {"checkable": True, "container": o_SettingsBase_SettingsRootSSHAccess, "id": "_settingsRootSSHAccess_RootSwitch", "type": "BaseSwitch", "unnamed": 1 } +o_SettingsBase_backButton_RootSSH = {"container": o_SettingsBase_SettingsRootSSHAccess, "objectName": "_backButton", "type": "BackButton" } +o_userConfirmation_SettingsFactoryReset = {"container": o_Gui_MainView, "objectName": "UserConfirmation", "type": "SettingsFactoryReset" } +o_userConfirmation_backButton_FactoryReset = {"container": o_userConfirmation_SettingsFactoryReset, "objectName": "_backButton", "type": "BackButton" } +o_factoryReset_ConfirmButton = {"container": o_userConfirmation_SettingsFactoryReset, "objectName": "_confirmButton", "type": "ConfirmButton" } +o_cancelTouch_TouchRect = {"container": o_Overlay, "id": "_cancelTouch", "type": "TouchRect", "unnamed": 1 } +o_confirmTouch_ConfirmButton = {"container": o_Overlay, "id": "_confirmTouch", "type": "ConfirmButton", "unnamed": 1 } + +# Service Institutional +o_standByScreen_MainHome = {"container": o_Gui_MainView, "type": "MainHome" } +o_createTreatmentRect_TouchRect = {"container": o_standByScreen_MainHome, "id": "_createTreatmentRect", "type": "TouchRect", "unnamed": 1 } +o_preTreatmentStack_PreTreatmentStack = {"container": o_Gui_MainView, "id": "_preTreatmentStack", "type": "PreTreatmentStack", "unnamed": 1 } +o_preTreatmentStack_Text = {"container": o_preTreatmentStack_PreTreatmentStack, "type": "Text", "unnamed": 1 } +o_preTreatmentStack_stepIndicator_StepIndicator = {"container": o_preTreatmentStack_PreTreatmentStack, "id": "_stepIndicator", "type": "StepIndicator", "unnamed": 1 } +o_preTreatmentStack_PreTreatmentStack = {"container": o_Gui_MainView, "id": "_preTreatmentStack", "type": "PreTreatmentStack", "unnamed": 1 } +o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate = {"container": o_preTreatmentStack_PreTreatmentStack, "objectName": "_PreTreatmentCreate", "type": "PreTreatmentCreate" } +o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry = {"container": o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_pretreatmentPatientIDEntry", "type": "TextEntry", "unnamed": 1 } +o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster = {"container": o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_bloodFlowRateControl", "type": "ValueAdjuster", "unnamed": 1 } +o_row_object = {"id": "_row", "type": "Row", "unnamed": 1 } +o_SettingsBase_SettingsInstitutionalRecord = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsInstitutionalRecord", } +o_SettingsInstitutionalRecord_BackButton = {"container": o_SettingsBase_SettingsInstitutionalRecord, "objectName": "_backButton", "type": "BackButton", } +o_SettingsBase_listView_ListView = {"container": o_SettingsBase_SettingsInstitutionalRecord, "id": "_listView", "type": "ListView", "unnamed": 1, } +o_SettingsInstitutionalRecord_NotificationBar = {"container": o_SettingsBase_SettingsInstitutionalRecord, "objectName": "NotificationBar", "type": "NotificationBarSmall", } +o_SettingsBase_min_ValueAdjuster_3 = {"container": o_SettingsBase_SettingsInstitutionalRecord, "id": "_min", "type": "ValueAdjuster", "unnamed": 1, } +o_SettingsBase_max_ValueAdjuster_3 = {"container": o_SettingsBase_SettingsInstitutionalRecord, "id": "_max", "type": "ValueAdjuster", "unnamed": 1, } +o_SettingsBase_def_ValueAdjuster_3 = {"container": o_SettingsBase_SettingsInstitutionalRecord, "id": "_def", "type": "ValueAdjuster", "unnamed": 1, } +o_SettingsBase_confirmButton_ConfirmButton_2 = {"container": o_SettingsBase_SettingsInstitutionalRecord, "objectName": "_confirmButton", "type": "ConfirmButton", } +o_SettingsBase_SettingsAdvancedInstitutional = {"container": o_Gui_MainView, "objectName": "_SettingsBase", "type": "SettingsAdvancedInstitutional", } +o_SettingsAdvancedInstitutional_Notification = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "objectName": "NotificationBar", "type": "NotificationBarSmall", } +o_SettingsAdvancedInstitutional_BackButton = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "objectName": "_backButton", "type": "BackButton", } +o_SettingsBase_confirmButton_ConfirmButton = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "objectName": "_confirmButton", "type": "ConfirmButton", } +o_SettingsBase_min_ValueAdjuster = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "id": "_min", "type": "ValueAdjuster", "unnamed": 1, } +o_SettingsBase_max_ValueAdjuster = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "id": "_max", "type": "ValueAdjuster", "unnamed": 1, } +o_SettingsBase_def_ValueAdjuster = {"container": o_SettingsBase_SettingsAdvancedInstitutional, "id": "_def", "type": "ValueAdjuster", "unnamed": 1, } +o_PreTreatmentCreate_leftArrow_IconButton = {"container": o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_leftArrow", "type": "IconButton", "unnamed": 1 } +o_PreTreatmentCreate_rightArrow_IconButton = {"container": o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_rightArrow", "type": "IconButton", "unnamed": 1} +o_PreTreatmentCreate_Text_2 = {"container": o_preTreatmentStack_PreTreatmentCreate_PreTreatmentCreate, "occurrence": 2, "text": "-- --", "type": "Text", "unnamed": 1, "visible": True} Index: suite_leahi/tst_service_institutional/test.py =================================================================== diff -u --- suite_leahi/tst_service_institutional/test.py (revision 0) +++ suite_leahi/tst_service_institutional/test.py (revision 352eb7ec404fbbfd22541f9d12ec7ab458a3f057) @@ -0,0 +1,789 @@ +# Subject/Title: Service - SW - 02 - Institutional - Q&R +# +# Functionalities: Testing items of Service Institutional feature +# +# Steps: +# 1 Start Leahi Application and simulate TD standby mode and navigate to the Device Settings screen +# Navigate to Institutional Configuration screen and compare Title bar text, Verifying the values sent +# over reflect on the UI and click Back button +# 2 Navigate to Service screen, Enter Password and Click confirm Then Navigate to +# Advanced Institutional Settings Screen and compare Title bar text, Verifying the values sent +# over reflect on the UI, compare rejection reason and click Back button, navigate back to +# Advanced Institutional Settings Screen, Adjust values compare rejection reason and and click confirm +# then Compare Advanced Institutional Settings records and preferences updated Notification Text +# 3 Navigate to Advanced Institutional Settings Screen and Adjust Values, compare rejection reason +# and click confirm then Compare Advanced Institutional Settings records and preferences updated Notification Text +# then Compare Advanced Institutional Settings records and preferences Notification Text and click Back button +# 4 Navigate to Institutional Configurations Screen and Adjust Values +# and click Confirm button then Compare Institutional Configurations records and preferences updated Notification Text +# then Compare Advanced Institutional Settings records and preferences Notification Text +# 5 Navigate to Institutional Configurations Screen and Adjust Blood Flow Values +# and click Confirm button then Compare Institutional Configurations records and preferences updated Notification Text +# then Compare Advanced Institutional Settings records and preferences Notification Text and compare rejection reason + + +import names +import re +from configuration import config, utility, navigation, application_init +from leahi_dialin.ui import utils +from leahi_dialin.ui.td_messaging import TD_Messaging +from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates + +td_simulator = TD_Messaging() +INSTITUTIONAL_CONFIGURATIONS = { + "vBloodFlowMin": 80, + "vBloodFlowMax": 210, + "vBloodFlowDef": 130, + "vDialysateFlowMin": 50, + "vDialysateFlowMax": 600, + "vDialysateFlowDef": 50, + "vTxDurationMin": 60, + "vTxDurationMax": 480, + "vTxDurationDef": 60, + "vHepBolVolumeMin": 0.2, + "vHepBolVolumeMax": 1.0, + "vHepBolVolumeDef": 0.1, + "vHepDispRateMin": 0.2, + "vHepDispRateMax": 3.0, + "vHepDispRateDef": 0.1, + "vHepStopTimeMin": 15, + "vHepStopTimeMax": 480, + "vDialysateTempMin": 35.00, + "vDialysateTempMax": 38.00, + "vDialysateTempDef": 37.00, + "vPotassiumMin": 0.00, + "vPotassiumMax": 4.00, + "vCalciumMin": 0.00, + "vCalciumMax": 3.50, + "DialysateBicarbMin": 130, + "DialysateBicarbMax": 155, + "DialysateBicarbDef": 137, + "SodiumBicarbMin": 20, + "SodiumBicarbMax": 40, + "SodiumBicarbDef": 33, + "vFluidBolusMin": 100, + "vFluidBolusMax": 300, + "vFluidBolusDef": 100, + "vArtPressLimitWindowMin": 120, + "vArtPressLimitWindowMax": 200, + "vArtPressLimitWindowDef": 120, + "vVenPressLimitWindowMin": 100, + "vVenPressLimitWindowMax": 200, + "vVenPressLimitWindowDef": 100, + "vVenAsymLimitWindowMin": 20, + "vVenAsymLimitWindowMax": 35, + "vVenAsymLimitWindowDef": 20, + "vTMPPressLimitWindowMin": 40, + "vTMPPressLimitWindowMax": 100, + "vTMPPressLimitWindowDef": 40, + "vUltrafiltrationVolumeMin": 0.00, + "vUltrafiltrationVolumeMax": 0.80, + "vUltrafiltrationVolumeDef": 0.00, + "vVitalsIntervalDef": 5, + "RinsebackVolumeMin": 200, + "RinsebackVolumeMax": 400, + "RinsebackVolumeDef": 300, + "RinsebackFlowRateMin": 100, + "RinsebackFlowRateMax": 500, + "RinsebackFlowRateDef": 200, + "vSubstitutionVolumeMin": 1.00, + "vSubstitutionVolumeMax": 30.00, + "vSubstitutionVolumeDef": 1.00, +} + +EXPECTED_VALUES_PER_ROW = [ + {"vBloodFlowMin": 80, "vBloodFlowMax": 210, "vBloodFlowDef": 130}, + {"vDialysateFlowMin": 50, "vDialysateFlowMax": 600, "vDialysateFlowDef": 50}, + {"vTxDurationMin": 60, "vTxDurationMax": 480, "vTxDurationDef": 60}, + {"vHepBolVolumeMin": 0.2, "vHepBolVolumeMax": 1.0, "vHepBolVolumeDef": 0.1}, + {"vHepDispRateMin": 0.2, "vHepDispRateMax": 3.0, "vHepDispRateDef": 0.1}, + {"vHepStopTimeMin": 15, "vHepStopTimeMax": 480}, + {"vDialysateTempMin": 35.0, "vDialysateTempMax": 38.0, "vDialysateTempDef": 37.0}, + {"vPotassiumMin": 0.0, "vPotassiumMax": 4.0}, + {"vCalciumMin": "0.00", "vCalciumMax": "3.50"}, + {"DialysateBicarbMin": 130, "DialysateBicarbMax": 155, "DialysateBicarbDef": 137}, + {"SodiumBicarbMin": 20, "SodiumBicarbMax": 40, "SodiumBicarbDef": 33}, + {"vFluidBolusMin": 100, "vFluidBolusMax": 300, "vFluidBolusDef": 100}, + {"vArtPressLimitWindowMin": 120, "vArtPressLimitWindowMax": 200, "vArtPressLimitWindowDef": 120}, + {"vVenPressLimitWindowMin": 100, "vVenPressLimitWindowMax": 200, "vVenPressLimitWindowDef": 100}, + {"vVenAsymLimitWindowMin": 20, "vVenAsymLimitWindowMax": 35, "vVenAsymLimitWindowDef": 20}, + {"vTMPPressLimitWindowMin": 40, "vTMPPressLimitWindowMax": 100, "vTMPPressLimitWindowDef": 40}, + {"vUltrafiltrationVolumeMin": 0.00, "vUltrafiltrationVolumeMax": 0.80, "vUltrafiltrationVolumeDef": 0.00}, + {"vVitalsIntervalDef": 5}, + {"RinsebackVolumeMin": 200, "RinsebackVolumeMax": 400, "RinsebackVolumeDef": 300}, + {"RinsebackFlowRateMin": 100, "RinsebackFlowRateMax": 500, "RinsebackFlowRateDef": 200}, + {"vSubstitutionVolumeMin": 1.00, "vSubstitutionVolumeMax": 30.00, "vSubstitutionVolumeDef": 1.00} +] + + +ADVANCED_INSTITUTIONAL_SETTINGS = { + 'vMinRORejectionRatioAlarmMin': 1, + 'vMinRORejectionRatioAlarmMax': 99, + 'vMinRORejectionRatioAlarmDef': 90, + 'vDisinfectionFrequencyMin': 1, + 'vDisinfectionFrequencyMax': 5, + 'vDisinfectionFrequencyDef': 3, + 'vDisinfectionParametersCycleTimeMin': 1, + 'vDisinfectionParametersCycleTimeMax': 60, + 'vDisinfectionParametersCycleTimeDef': 60, + 'vMaxBloodPumpStopTimeMin': 5, + 'vMaxBloodPumpStopTimeMax': 30, + 'vMaxBloodPumpStopTimeDef': 5, + 'vInletWaterCondLowThresholdMin': 20, + 'vInletWaterCondLowThresholdMax': 200, + 'vInletWaterCondLowThresholdDef': 200, + 'vInletWaterCondHighThresholdMin': 50, + 'vInletWaterCondHighThresholdMax': 200, + 'vInletWaterCondHighThresholdDef': 50, + 'vChlorineWaterSampleCheckMin': 15, + 'vChlorineWaterSampleCheckMax': 480, + 'vChlorineWaterSampleCheckDef': 140, + 'vWaterSampleTestResultRequiredDef': 0, +} + +ADVANCED_INSTITUTIONAL_SETTINGS_PER_ROW = [ + {'vMinRORejectionRatioAlarmMin': 1, 'vMinRORejectionRatioAlarmMax': 99, 'vMinRORejectionRatioAlarmDef': 90}, + {'vDisinfectionFrequencyMin': 1, 'vDisinfectionFrequencyMax': 5, 'vDisinfectionFrequencyDef': 3}, + {'vDisinfectionParametersCycleTimeMin': 1, 'vDisinfectionParametersCycleTimeMax': 60, 'vDisinfectionParametersCycleTimeDef': 60}, + {'vMaxBloodPumpStopTimeMin': 5, 'vMaxBloodPumpStopTimeMax': 30, 'vMaxBloodPumpStopTimeDef': 5}, + {'vInletWaterCondLowThresholdMin': 20, 'vInletWaterCondLowThresholdMax': 200, 'vInletWaterCondLowThresholdDef': 200}, + {'vInletWaterCondHighThresholdMin': 50, 'vInletWaterCondHighThresholdMax': 200, 'vInletWaterCondHighThresholdDef': 50}, + {'vChlorineWaterSampleCheckMin': 15, 'vChlorineWaterSampleCheckMax': 480, 'vChlorineWaterSampleCheckDef': 140}, + {'vWaterSampleTestResultRequiredDef': 0} +] + +ADJUST_INSTITUTIONAL_RECORDS_REJECTION_REASONS = { + "vAccepted": 1, + "vBloodFlowMinReason": 0, + "vBloodFlowMaxReason": 0, + "vBloodFlowDefReason": 0, + "vDialysateFlowMinReason": 0, + "vDialysateFlowMaxReason": 0, + "vDialysateFlowDefReason": 0, + "vTreatmentDurationMinReason": 0, + "vTreatmentDurationMaxReason": 0, + "vTreatmentDurationDefReason": 0, + "vHepBolusVolumeMinReason": 0, + "vHepBolusVolumeMaxReason": 0, + "vHepBolusVolumeDefReason": 0, + "vHepDispRateMinReason": 0, + "vHepDispRateMaxReason": 0, + "vHepDispRateDefReason": 0, + "vHepStopTimeMinReason": 0, + "vHepStopTimeMaxReason": 0, + "vDialysateTempMinReason": 0, + "vDialysateTempMaxReason": 0, + "vDialysateTempDefReason": 0, + "vPotassiumMinReason": 0, + "vPotassiumMaxReason": 0, + "vCalciumMinReason": 0, + "vCalciumMaxReason": 0, + "vDialysateBicarbMinReason": 0, + "vDialysateBicarbMaxReason": 0, + "vDialysateBicarbDefReason": 0, + "vSodiumBicarbMinReason": 0, + "vSodiumBicarbMaxReason": 0, + "vSodiumBicarbDefReason": 0, + "vFluidBolusVolumeMinReason": 0, + "vFluidBolusVolumeMaxReason": 0, + "vFluidBolusVolumeDefReason": 0, + "vArterialPressureMinReason": 0, + "vArterialPressureMaxReason": 0, + "vArterialPressureDefReason": 0, + "vVenousPressureMinReason": 0, + "vVenousPressureMaxReason": 0, + "vVenousPressureDefReason": 0, + "vVenousAsymmetricMinReason": 0, + "vVenousAsymmetricMaxReason": 0, + "vVenousAsymmetricDefReason": 0, + "vTmpPressureMinReason": 0, + "vTmpPressureMaxReason": 0, + "vTmpPressureDefReason": 0, + "vUfVolumeMinReason": 0, + "vUfVolumeMaxReason": 0, + "vUfVolumeDefReason": 0, + "vVitalsIntervalReason": 0, + "vRincebackVolumeMinReason": 0, + "vRincebackVolumeMaxReason": 0, + "vRincebackVolumeDefReason": 0, + "vRincebackFlowRateMinReason": 0, + "vRincebackFlowRateMaxReason": 0, + "vRincebackFlowRateDefReason": 0, + "vSubVolumeMinReason": 0, + "vSubVolumeMaxReason": 0, + "vSubVolumeDefReason": 0 +} + + +ADJUST_ADVANCED_INSTITUTIONAL_SETTINGS_REJECTION_REASONS = { + "vAccepted": 0, + "vMinRORejectionRatioAlarmMaxRejectionReason": 0, + "vMinRORejectionRatioAlarmMinRejectionReason": 0, + "vMinRORejectionRatioAlarmDefRejectionReason": 0, + "vDisinfectionFrequencyMinRejectionReason": 0, + "vDisinfectionFrequencyMaxRejectionReason": 0, + "vDisinfectionFrequencyDefRejectionReason": 0, + "vDisinfectionParametersCycleTimeMinRejectionReason": 0, + "vDisinfectionParametersCycleTimeMaxRejectionReason": 0, + "vDisinfectionParametersCycleTimeDefRejectionReason": 0, + "vMaxBloodPumpStopTimeMinRejectionReason": 0, + "vMaxBloodPumpStopTimeMaxRejectionReason": 0, + "vMaxBloodPumpStopTimeDefRejectionReason": 0, + "vInletWaterCondLowThresholdMinRejectionReason": 0, + "vInletWaterCondLowThresholdMaxRejectionReason": 0, + "vInletWaterCondLowThresholdDefRejectionReason": 0, + "vInletWaterCondHighThresholdMinRejectionReason": 0, + "vInletWaterCondHighThresholdMaxRejectionReason": 0, + "vInletWaterCondHighThresholdDefRejectionReason": 0, + "vChlorineWaterSampleCheckMinRejectionReason": 0, + "vChlorineWaterSampleCheckMaxRejectionReason": 0, + "vChlorineWaterSampleCheckDefRejectionReason": 0, + "vWaterSampleTestResultRequiredDefRejectionReason": 0 +} + + +ADVANCED_INSTITUTIONAL_SETTINGS_PARAMETER_RANGE = { + "vMinRORejectionRatioAlarmMin" : [0], + "vMinRORejectionRatioAlarmMax" : [0], + "vMinRORejectionRatioAlarmDef" : [0], + } +MINIMUM_RO_REJECTION_RATIO_ALARM_MIN = "vMinRORejectionRatioAlarmMin" +MINIMUM_RO_REJECTION_RATIO_ALARM_MAX = "vMinRORejectionRatioAlarmMax" +MINIMUM_RO_REJECTION_RATIO_ALARM_DEF = "vMinRORejectionRatioAlarmDef" + +INSTITUTIONAL_CONFIGURATIONS_PARAMETER_RANGE = { + "vBloodFlowMin": [60], + "vBloodFlowMax": [180], + "vBloodFlowDef": [160], + } + +INSTITUTIONAL_CONFIGURATIONS_BLOOD_FLOW_CUSTOM_RANGE = { + "vBloodFlowMin": [100], + "vBloodFlowMax": [200], + "vBloodFlowDef": [150], + } +BLOOD_FLOW_RATE_MIN = "vBloodFlowMin" +BLOOD_FLOW_RATE_MAX = "vBloodFlowMax" +BLOOD_FLOW_RATE_DEF = "vBloodFlowDef" + + +def scroll_to_next_rows(): + """ + Scroll down to view next set of rows using flick gesture + """ + try: + # Use flick gesture to scroll down + flick(waitForObject(names.o_SettingsBase_listView_ListView), 0, 943) + # Wait for scroll to complete and content to load + snooze(1) + return True + except Exception as e: + test.log(f"Scroll failed: {str(e)}") + return False + + +def institutional_configurations_screen(): + test.startSection("Navigating to 'Institutional Configurations' Screen") + + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + institutional_configurations_option = utility.findChildByText( + grid_container, "Institutional Configurations" + ) + + if institutional_configurations_option is not None: + mouseClick(institutional_configurations_option) + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + institutional_configurations_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Institutional Configurations" + ) + if institutional_configurations_screen_headerbar_title_text is not None: + test.compare( + institutional_configurations_screen_headerbar_title_text.text, + config.INSTITUTIONAL_CONFIGURATIONS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Institutional Configurations Screen Title text".format( + config.INSTITUTIONAL_CONFIGURATIONS_SCREEN_TITLE_TEXT + ), + ) + td_simulator.td_institutional_response( + vRejectionReason=1, **INSTITUTIONAL_CONFIGURATIONS + ) + total_rows = 12 + rows_per_scroll = 12 + verified_count = 0 + + for row_index in range(0, total_rows): + row_object = utility.get_row_object( + names.o_SettingsBase_SettingsInstitutionalRecord, row_index + ) + bullet_children = object.children(waitForObject(row_object)) + + if row_index < len(EXPECTED_VALUES_PER_ROW): + expected_values = EXPECTED_VALUES_PER_ROW[row_index] + else: + expected_values = INSTITUTIONAL_CONFIGURATIONS # fallback + + # Using zip() to iterate through children and the row's expected items + for bullet_child, (key, expected_value) in zip( + bullet_children, expected_values.items() + ): + value = utility.findObjectById(bullet_child, "_text") + if value: + # Format both values to handle decimal precision + actual_text = str(value.text) + expected_text = str(expected_value) + + # If both are numeric, format to same decimal places + try: + actual_float = float(actual_text) + expected_float = float(expected_text) + # Format to 2 decimal places for comparison + test.compare( + f"{actual_float:.2f}", + f"{expected_float:.2f}", + f"Comparison of Institutional Configurations '{key}' in Row {row_index + 1}", + ) + except ValueError: + # If not numeric, compare as strings + test.compare( + actual_text, + expected_text, + f"Comparison of Heparin Prescription '{key}' in Row {row_index + 1}", + ) + + verified_count += 1 + + # Scroll after every 12 rows (0-11, then scroll, then 12-23, etc.) + if (row_index + 1) % rows_per_scroll == 0 and (row_index + 1) < total_rows: + test.log(f"Scrolling after row {row_index + 1}") + if not scroll_to_next_rows(): + test.log("Failed to scroll, stopping verification") + break + else: + test.log("Scroll completed, continuing with next batch") + + test.log(f"Verified {verified_count} out of {total_rows} rows") + + back_button = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + + test.endSection() + + +def advanced_institutional_configurations_screen(): + test.startSection("Navigating to 'Advanced Institutional Settings' Screen") + navigation.navigate_to_device_settings_using_service_password() + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + advanced_modes_option = utility.findChildByText( + grid_container, "Advanced Institutional Settings" + ) + + if advanced_modes_option is not None: + mouseClick(advanced_modes_option) + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + advanced_institutional_settings_screen_headerbar_title_text = ( + utility.findChildByText(headerbar_container, "Advanced Institutional Settings") + ) + if advanced_institutional_settings_screen_headerbar_title_text is not None: + test.compare( + advanced_institutional_settings_screen_headerbar_title_text.text, + config.ADVANCED_INSTITUTIONAL_SETTINGS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Advanced Institutional Settings Screen Title text".format( + config.ADVANCED_INSTITUTIONAL_SETTINGS_SCREEN_TITLE_TEXT + ), + ) + td_simulator.td_advanced_institutional_response( + vRejectionReason=1, **ADVANCED_INSTITUTIONAL_SETTINGS + ) + + for row_index in range(0, 7): + + row_object = utility.get_row_object( + names.o_SettingsBase_SettingsAdvancedInstitutional, row_index + ) + bullet_children = object.children(waitForObject(row_object)) + + # Get expected values for this specific row + if row_index < len(ADVANCED_INSTITUTIONAL_SETTINGS_PER_ROW): + expected_values = ADVANCED_INSTITUTIONAL_SETTINGS_PER_ROW[row_index] + else: + expected_values = ADVANCED_INSTITUTIONAL_SETTINGS # fallback + + # Using zip() to iterate through children and the row's expected items + for bullet_child, (key, expected_value) in zip( + bullet_children, expected_values.items() + ): + value = utility.findObjectById(bullet_child, "_text") + if value: + test.compare( + str(value.text), + str(expected_value), + f"Comparison of Heparin Prescription '{key}' in Row {row_index}", + ) + + advanced_reject_notification = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_Notification, timeout_ms=3000 + ) + advanced_reject_notification_text = str(advanced_reject_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", advanced_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(1, digit_int, f"Rejection reason number comparison for reason {1}") + test.log(f"Rejection reason text is {advanced_reject_notification_text}") + + back_button = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + advanced_modes_option = utility.findChildByText( + grid_container, "Advanced Institutional Settings" + ) + + td_simulator.td_advanced_institutional_response( + vRejectionReason=2, **ADVANCED_INSTITUTIONAL_SETTINGS + ) + + if advanced_modes_option is not None: + mouseClick(advanced_modes_option) + + advanced_reject_notification = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_Notification, timeout_ms=3000 + ) + advanced_reject_notification_text = str(advanced_reject_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", advanced_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(2, digit_int, f"Rejection reason number comparison for reason {2}") + test.log(f"Rejection reason text is {advanced_reject_notification_text}") + + confirm_button = utility.get_object_from_names( + names.o_SettingsBase_confirmButton_ConfirmButton, + "Error Missing Confirm Button", + 2000, + ) + td_simulator.td_Adjust_Advanced_Institutional_Records( + **ADJUST_ADVANCED_INSTITUTIONAL_SETTINGS_REJECTION_REASONS + ) + if confirm_button is not None: + mouseClick(confirm_button) + + advanced_confirm_notification = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_Notification, timeout_ms=3000 + ) + test.compare( + advanced_confirm_notification.text, + config.ADVANCED_INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT, + f"Confirm Advanced Institutional Settings Notification Text", + ) + back_button = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + test.endSection() + + +def adjust_advanced_institutional_configurations_values(): + test.startSection("Navigating to 'Advanced Institutional Settings' Values Adjust") + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + advanced_modes_option = utility.findChildByText( + grid_container, "Advanced Institutional Settings" + ) + + if advanced_modes_option is not None: + mouseClick(advanced_modes_option) + + td_simulator.td_advanced_institutional_response( + vRejectionReason=2, **ADVANCED_INSTITUTIONAL_SETTINGS + ) + for ( + minimum_ro_rejection_ratio_alarm + ) in ADVANCED_INSTITUTIONAL_SETTINGS_PARAMETER_RANGE[ + MINIMUM_RO_REJECTION_RATIO_ALARM_DEF + ]: + utility.set_value_based_on_target( + names.o_SettingsBase_def_ValueAdjuster, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in ADVANCED_INSTITUTIONAL_SETTINGS_PARAMETER_RANGE[ + MINIMUM_RO_REJECTION_RATIO_ALARM_MAX + ]: + utility.set_value_based_on_target( + names.o_SettingsBase_max_ValueAdjuster, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in ADVANCED_INSTITUTIONAL_SETTINGS_PARAMETER_RANGE[ + MINIMUM_RO_REJECTION_RATIO_ALARM_MIN + ]: + utility.set_value_based_on_target( + names.o_SettingsBase_min_ValueAdjuster, minimum_ro_rejection_ratio_alarm + ) + + advanced_reject_notification = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_Notification, timeout_ms=3000 + ) + advanced_reject_notification_text = str(advanced_reject_notification.text) + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", advanced_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(2, digit_int, f"Rejection reason number comparison for reason {2}") + test.log(f"Rejection reason text is {advanced_reject_notification_text}") + + td_simulator.td_Adjust_Advanced_Institutional_Records( + **ADJUST_ADVANCED_INSTITUTIONAL_SETTINGS_REJECTION_REASONS + ) + + confirm_button = utility.get_object_from_names( + names.o_SettingsBase_confirmButton_ConfirmButton, + "Error Missing Confirm Button", + 2000, + ) + if confirm_button is not None: + mouseClick(confirm_button) + + advanced_confirm_notification = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_Notification, timeout_ms=3000 + ) + test.compare( + advanced_confirm_notification.text, + config.ADVANCED_INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT, + f"Confirm Advanced Institutional Settings Notification Text", + ) + back_button = utility.get_object_from_names( + names.o_SettingsAdvancedInstitutional_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + test.endSection() + + +def adjust_institutional_configurations_values(): + test.startSection("Navigating to 'Institutional Settings' And Adjust Values") + navigation.navigate_to_device_settings_using_service_password() + + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + institutional_configurations_option = utility.findChildByText( + grid_container, "Institutional Configurations" + ) + + if institutional_configurations_option is not None: + mouseClick(institutional_configurations_option) + + headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) + institutional_configurations_screen_headerbar_title_text = utility.findChildByText( + headerbar_container, "Institutional Configurations" + ) + if institutional_configurations_screen_headerbar_title_text is not None: + test.compare( + institutional_configurations_screen_headerbar_title_text.text, + config.INSTITUTIONAL_CONFIGURATIONS_SCREEN_TITLE_TEXT, + "{} screen is displayed and Comparison of Institutional Configurations Screen Title text".format( + config.INSTITUTIONAL_CONFIGURATIONS_SCREEN_TITLE_TEXT + ), + ) + td_simulator.td_institutional_response( + vRejectionReason=2, **INSTITUTIONAL_CONFIGURATIONS + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_PARAMETER_RANGE[BLOOD_FLOW_RATE_MIN]: + utility.set_value_based_on_target( + names.o_SettingsBase_min_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_PARAMETER_RANGE[BLOOD_FLOW_RATE_MAX]: + utility.set_value_based_on_target( + names.o_SettingsBase_max_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_PARAMETER_RANGE[BLOOD_FLOW_RATE_DEF]: + utility.set_value_based_on_target( + names.o_SettingsBase_def_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + td_simulator.td_Adjust_Institutional_Records( + **ADJUST_INSTITUTIONAL_RECORDS_REJECTION_REASONS + ) + + confirm_button = utility.get_object_from_names( + names.o_SettingsBase_confirmButton_ConfirmButton_2, + "Error Missing Confirm Button", + 2000, + ) + if confirm_button is not None: + mouseClick(confirm_button) + + institutional_confirm_notification = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_NotificationBar, timeout_ms=3000 + ) + test.compare( + institutional_confirm_notification.text, + config.INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT, + f"Confirm Institutional Configurations Notification Text", + ) + td_simulator.td_institutional_response( + vRejectionReason=2, **INSTITUTIONAL_CONFIGURATIONS + ) + institutional_reject_notification = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_NotificationBar, timeout_ms=3000 + ) + institutional_reject_notification_text = str(institutional_reject_notification.text) + + digit = re.sub(r"^.*?\[(\d+)\].*$", r"\1", institutional_reject_notification_text) + + if digit: + digit_int = int(float(digit)) + test.compare(2, digit_int, f"Rejection reason number comparison for reason {2}") + test.log(f"Rejection reason text is {institutional_reject_notification_text}") + + back_button = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + + test.endSection() + + +def adjust_blood_flow_of_institutional_configurations(): + test.startSection( + "Navigating to 'Institutional Settings' Adjust Values and Verify it Create Rx Screen" + ) + grid_container = waitForObject(names.o_DeviceSettingsGrid, 2000) + institutional_configurations_option = utility.findChildByText( + grid_container, "Institutional Configurations" + ) + + if institutional_configurations_option is not None: + mouseClick(institutional_configurations_option) + + td_simulator.td_institutional_response( + vRejectionReason=1, **INSTITUTIONAL_CONFIGURATIONS + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_BLOOD_FLOW_CUSTOM_RANGE[BLOOD_FLOW_RATE_MIN]: + utility.set_value_based_on_target( + names.o_SettingsBase_min_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_BLOOD_FLOW_CUSTOM_RANGE[BLOOD_FLOW_RATE_MAX]: + utility.set_value_based_on_target( + names.o_SettingsBase_max_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + for ( + minimum_ro_rejection_ratio_alarm + ) in INSTITUTIONAL_CONFIGURATIONS_BLOOD_FLOW_CUSTOM_RANGE[BLOOD_FLOW_RATE_DEF]: + utility.set_value_based_on_target( + names.o_SettingsBase_def_ValueAdjuster_3, minimum_ro_rejection_ratio_alarm + ) + + td_simulator.td_Adjust_Institutional_Records( + **ADJUST_INSTITUTIONAL_RECORDS_REJECTION_REASONS + ) + + confirm_button = utility.get_object_from_names( + names.o_SettingsBase_confirmButton_ConfirmButton_2, + "Error Missing Confirm Button", + 2000, + ) + if confirm_button is not None: + mouseClick(confirm_button) + + institutional_confirm_notification = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_NotificationBar, timeout_ms=3000 + ) + test.compare( + institutional_confirm_notification.text, + config.INSTITUTIONAL_SETTINGS_NOTIFICATION_TEXT, + f"Confirm Institutional Configurations Notification Text", + ) + + back_button = utility.get_object_from_names( + names.o_SettingsInstitutionalRecord_BackButton, + "Error Missing Back Button", + 2000, + ) + if back_button is not None: + mouseClick(back_button) + + td_simulator.td_operation_mode(TDOpModes.MODE_STAN.value) + mouseClick(waitForObject(names.o_createTreatmentRect_TouchRect)) + td_simulator.td_operation_mode(TDOpModes.MODE_PRET.value) + td_simulator.td_blood_set_auto_load_response(vRejectionReason = 0) + navigation.navigation_pageIndicator_step(config.CREATERX) + mouseClick(waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry)) + waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry).text ="abcd" + mouseClick(waitForObjectExists(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster)) + parent_obj = waitForObjectExists(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster) + default_value = utility.findObjectById(parent_obj, "_text") + test.compare( + str(default_value.text), + '150', + "Comparison of Default Blood Flow Value", + ) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 100) + left_arrow = waitForObject(names.o_PreTreatmentCreate_leftArrow_IconButton) + if left_arrow.enabled is not config.ENABLED: + parent_obj = waitForObjectExists(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster) + minimum_value = utility.findObjectById(parent_obj, "_text") + test.compare( + str(minimum_value.text), + '100', + "Comparison of Default Blood Flow Value", + ) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 200) + right_arrow = waitForObject(names.o_PreTreatmentCreate_rightArrow_IconButton) + if right_arrow.enabled is not config.ENABLED: + parent_obj = waitForObjectExists(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster) + maxmum_value = utility.findObjectById(parent_obj, "_text") + test.compare( + str(maxmum_value.text), + '200', + "Comparison of Default Blood Flow Value", + ) + test.endSection() + + +def main(): + utils.tstStart(__file__) + startApplication(utility.aut("leahi", "-q")) + navigation.navigate_to_device_settings_screen() + institutional_configurations_screen() + advanced_institutional_configurations_screen() + adjust_advanced_institutional_configurations_values() + adjust_institutional_configurations_values() + adjust_blood_flow_of_institutional_configurations()