Index: shared/scripts/configuration/config.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r8242123c781d022e2c7d9e1d36436ddfde01ffe4 --- shared/scripts/configuration/config.py (.../config.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/config.py (.../config.py) (revision 8242123c781d022e2c7d9e1d36436ddfde01ffe4) @@ -32,3 +32,60 @@ BLOOD_PRIMING_TEXT = "Blood Priming" SALINE_UNIT = "mL" BLOOD_PRIMING_DEFAULT_VALUE = "0 mL" + +#main-treatment heparin +HEPARIN_UNIT = "mL" +HEPARIN_DELIVERY_TEXT = "HEPARIN DELIVERY" +HEPARIN_DELIVERY_OFF_TEXT = "Heparin Delivery Off" +HEPARIN_STOP_TEXT = "Heparin Delivery Stopped" +HEPARIN_RESUME_DELIVERY_TEXT = "RESUME DELIVERY" +HEPARIN_BOLUS_ACTIVE_TEXT = "Heparin Bolus Active" +HEPARIN_PAUSE_DELIVERY_TEXT = "PAUSE DELIVERY" +HEPARIN_MAXIMUM_VOLUME_DELIVERED_TEXT = "Maximum Cumulative Heparin Volume Delivered" +HEPARIN_SYRINGE_EMPTY_TEXT = "Heparin Syringe Empty" + + +REJECTION_REASON = { + 0: "No Active Alarm List", + 1: "REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE", + 2: "REQUEST_REJECT_REASON_TIMEOUT_WAITING_FOR_USER_CONFIRM", + 3: "REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE", + 4: "REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE", + 5: "REQUEST_REJECT_REASON_TREATMENT_TOO_CLOSE_TO_FINISHED", + 6: "REQUEST_REJECT_REASON_TREATMENT_TIME_OUT_OF_RANGE", + 7: "REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_CURRENT", + 8: "REQUEST_REJECT_REASON_BLOOD_FLOW_OUT_OF_RANGE", + 9: "REQUEST_REJECT_REASON_DIAL_FLOW_OUT_OF_RANGE", + 10: "REQUEST_REJECT_REASON_DIAL_VOLUME_OUT_OF_RANGE", + 11: "REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE", + 12: "REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE", + 13: "REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM", + 14: "REQUEST_REJECT_REASON_UF_NOT_IN_PROGESS", + 15: "REQUEST_REJECT_REASON_UF_NOT_PAUSED", + 16: "REQUEST_REJECT_REASON_SALINE_BOLUS_IN_PROGRESS", + 17: "REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE", + 18: "REQUEST_REJECT_REASON_HEPARIN_PRESTOP_EXCEEDS_DURATION", + 19: "REQUEST_REJECT_REASON_ARTERIAL_PRESSURE_LOW_VS_HIGH", + 20: "REQUEST_REJECT_REASON_VENOUS_PRESSURE_LOW_VS_HIGH", + 21: "REQUEST_REJECT_REASON_SALINE_MAX_VOLUME_REACHED", + 22: "REQUEST_REJECT_REASON_SALINE_BOLUS_NOT_IN_PROGRESS", + 23: "REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE", + 24: "REQUEST_REJECT_REASON_ALARM_IS_ACTIVE", + 25: "REQUEST_REJECT_REASON_INVALID_COMMAND", + 26: "REQUEST_REJECT_REASON_TREATMENT_IS_COMPLETED", + 27: "REQUEST_REJECT_REASON_ADDL_RINSEBACK_MAX_VOLUME_REACHED", + 28: "REQUEST_REJECT_REASON_UF_VOLUME_NOT_SET", + 29: "REQUEST_REJECT_REASON_NO_PATIENT_CONNECTION_CONFIRM", + 30: "REQUEST_REJECT_REASON_HEPARIN_PAUSE_INVALID_IN_THIS_STATE", + 31: "REQUEST_REJECT_REASON_HEPARIN_NOT_PAUSED", + 32: "REQUEST_REJECT_REASON_DG_COMM_LOST", + 33: "REQUEST_REJECT_REASON_DRAIN_NOT_COMPLETE", + 34: "REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE", + 35: "REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT", + 36: "REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME", + 37: "REQUEST_REJECT_REASON_NO_NEW_TREATMENT_ALARM_TRIGGERED", + 38: "REQUEST_REJECT_REASON_BATTERY_IS_NOT_CHARGED", + 39: "REQUEST_REJECT_REASON_RINSEBACK_NOT_COMPLETED", + } + +NUM_OF_REJECTION_MSG = 39 Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r8242123c781d022e2c7d9e1d36436ddfde01ffe4 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 8242123c781d022e2c7d9e1d36436ddfde01ffe4) @@ -12,7 +12,7 @@ # ############################################################################ - +import names import sys import test import squish @@ -81,6 +81,10 @@ return False + +def rejection_msg(text): + names.rejection_msg["text"] = text + return names.rejection_msg def scroll_to_zone(zone=None, screen_object=None): """ Index: shared/scripts/names.py =================================================================== diff -u -r0cc92d3b75bfb96dc4ecafd760a9ce15e455033b -r8242123c781d022e2c7d9e1d36436ddfde01ffe4 --- shared/scripts/names.py (.../names.py) (revision 0cc92d3b75bfb96dc4ecafd760a9ce15e455033b) +++ shared/scripts/names.py (.../names.py) (revision 8242123c781d022e2c7d9e1d36436ddfde01ffe4) @@ -47,7 +47,23 @@ o_fluid_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Volume Delivered", "type": "Text", "unnamed": 1, "visible": True} o_cumulative_fluid_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Cumulative Delivered", "type": "Text", "unnamed": 1, "visible": True} +#Heparin +cumulative_fluid = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Cumulative Delivered", "type": "Text", "unnamed": 1, "visible": True} +heparin_value = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "occurrence": 2, "text": "Volume Delivered", "type": "Text", "unnamed": 1, "visible": True} +o_QQuickView = {"type": "QQuickView"} +o_treatmentStart_TreatmentStart = {"container": o_QQuickView, "id": "_treatmentStart", "type": "TreatmentStart", "unnamed": 1, "visible": True} +o_treatmentStart_HeparinSection = {"container": o_treatmentStart_TreatmentStart , "id": "_heparinTouchArea", "type": "TreatmentFluid" } +#Heparin_Messages_on_Button +state0_heparin_delivery_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "HEPARIN DELIVERY", "type": "Text", "unnamed": 1, "visible": True} +state2_heparin_state_paused_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "RESUME DELIVERY", "type": "Text", "unnamed": 1, "visible": True} +state4_heparin_state_dispensing_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "PAUSE DELIVERY", "type": "Text", "unnamed": 1, "visible": True} +#Heparin_Statewise_Messages +state0_heparin_delivery_Off_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Heparin Delivery Off", "type": "Text", "unnamed": 1, "visible": True} +state_one_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Heparin Delivery Stopped", "type": "Text", "unnamed": 1, "visible": True} +state3_heparin_state_initial_bolus_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Heparin Bolus Active", "type": "Text", "unnamed": 1, "visible": True} +state5_heparin_state_completed_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Maximum Cumulative Heparin Volume Delivered", "type": "Text", "unnamed": 1, "visible": True} +state6_heparin_state_empty_text = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "text": "Heparin Syringe Empty", "type": "Text", "unnamed": 1, "visible": True} +#Heparin Rejection Message +rejection_msg = {"container": o_treatmentStack_treatmentHome_TreatmentHome, "type": "Text", "unnamed": 1, "visible": True} - - Index: tst_main_treatment_heparin/test.py =================================================================== diff -u --- tst_main_treatment_heparin/test.py (revision 0) +++ tst_main_treatment_heparin/test.py (revision 8242123c781d022e2c7d9e1d36436ddfde01ffe4) @@ -0,0 +1,168 @@ +# -*- coding: utf-8 -*-" + +# +# file tst__main_treatment_heparin +# date 2022/03/03 +# author Akshay Rajaram Dhawan +# author Shweta Policepatil +# NOTE: +# This test contradicts verification of Heparin Delivery data and Heparin States from Main Treatment + +import names +from configuration import config, utility +from dialin.ui import utils +from dialin.ui.hd_simulator import HDSimulator +import numpy as np + + +HIGHER_RANGE = 20.1 +STEP_VALUE = 0.1 +LOWER_RANGE = 0 + +hd_simulator = HDSimulator() + +def verification_of_cumulative_value(expected_cumulative_value): + """ + Verifying cumulative values from heparin delivery section. + @param expected_cumulative_value - (str) expected cumulative value. + """ + heparin_text = waitForObject(names.cumulative_fluid) + heparin_value = waitForObject(names.heparin_value) + heparin_unit = object.children(heparin_text)[0] + + if heparin_unit.text == config.HEPARIN_UNIT: + heparin_cumulative = object.children(heparin_value)[2] + expected_cumulative_value = str(expected_cumulative_value).replace(".0","") + + test.compare(heparin_cumulative.text, expected_cumulative_value, "Actual heparin cumulative value: {} should be equal to expected heparin cumulative value: {}".format(heparin_cumulative.text, expected_cumulative_value)) + else: + test.fail("The heparin value should not be more than 20ml") + + +def constants_for_cumulative_value(): + """ + Method is used to verify the constants for cumulative value. + """ + test.startSection("Verifying Heparin State 3 HEPARIN_INITIAL_BOLUS values") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 0, heparin_state= 3, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state= 0, treatment_stop_state=0) + test.compare(str(waitForObjectExists(names.state0_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, "Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT)) + test.compare((waitForObjectExists(names.state0_heparin_delivery_text)).enabled, False, "Heparin Delivery should be disabled") + initial_bolus_text = waitForObjectExists(names.state3_heparin_state_initial_bolus_text).text + test.compare(str(initial_bolus_text), config.HEPARIN_BOLUS_ACTIVE_TEXT, "Notification Message should be {}".format(config.HEPARIN_BOLUS_ACTIVE_TEXT)) + + + + for heparin_cumulative in np.arange(LOWER_RANGE, HIGHER_RANGE, STEP_VALUE): + heparin_cumulative = format(heparin_cumulative, ".1f") + heparin_cumulative = float(heparin_cumulative) + hd_simulator.cmd_set_treatment_heparin_data(cumulative = heparin_cumulative) + verification_of_cumulative_value(expected_cumulative_value = heparin_cumulative) + utils.waitForGUI(1) + test.endSection() + +def heparin_stop_states_in_main_treatment(): + """ + Verifying the heparin states when heparin cumulative is '0' at + HEPARIN STATE 0 -> HEPARIN_STATE_OFF + HEPARIN STATE 1 -> HEPARIN_STATE_STOPPED + HEPARIN STATE 5 -> HEPARIN_STATE_COMPLETED + HEPARIN STATE 6 -> HEPARIN_STATE_EMPTY + """ + test.log("Verifying Heparin State 0 - HEPARIN_STATE_OFF") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state= 0, heparin_state= 0, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state= 0, treatment_stop_state=0) + test.compare(str(waitForObjectExists(names.state0_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, "Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT)) + test.compare((waitForObjectExists(names.state0_heparin_delivery_text)).enabled, False, "Heparin Delivery should be disabled") + test.log("Verifying Notification Message") + test.compare(str(findObject(names.state0_heparin_delivery_Off_text).text ), config.HEPARIN_DELIVERY_OFF_TEXT,"Notification Message should be {}".format(config.HEPARIN_DELIVERY_OFF_TEXT)) + utils.waitForGUI(1) + + test.log("Verifying Heparin State 1 - HEPARIN_STATE_STOPPED") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 1, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + test.compare(str(waitForObjectExists(names.state0_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, "Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT)) + test.compare((waitForObjectExists(names.state0_heparin_delivery_text)).enabled, False, "Heparin Delivery should be disabled") + test.log("Verifying Notification Message") + test.compare(str(waitForObjectExists(names.state_one_text).text), config.HEPARIN_STOP_TEXT,"Notification Message should be {}".format(config.HEPARIN_STOP_TEXT)) + utils.waitForGUI(1) + + constants_for_cumulative_value() + heparin_pause_resume_states() + + test.log("Verifying Heparin State 5 - HEPARIN_STATE_COMPLETED") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 5, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + + test.compare(str(waitForObjectExists(names.state0_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, "Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT)) + test.compare((waitForObjectExists(names.state0_heparin_delivery_text)).enabled, False, "Heparin Delivery should be disabled") + test.log("Verifying Notification Message") + test.compare(str(waitForObjectExists(names.state5_heparin_state_completed_text).text), config.HEPARIN_MAXIMUM_VOLUME_DELIVERED_TEXT,"Notification Message should be {}".format(config.HEPARIN_MAXIMUM_VOLUME_DELIVERED_TEXT)) + utils.waitForGUI(1) + + test.log("Verifying Heparin State 6 - HEPARIN_STATE_EMPTY") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 6, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + + test.compare(str(waitForObjectExists(names.state0_heparin_delivery_text).text), config.HEPARIN_DELIVERY_TEXT, "Heparin Delivery Text should be {}".format(config.HEPARIN_DELIVERY_TEXT)) + test.compare((waitForObjectExists(names.state0_heparin_delivery_text)).enabled, False, "Heparin Delivery should be disabled") + test.log("Verifying Notification Message") + test.compare(str(waitForObjectExists(names.state6_heparin_state_empty_text).text), config.HEPARIN_SYRINGE_EMPTY_TEXT,"Notification Message should be {}".format(config.HEPARIN_SYRINGE_EMPTY_TEXT)) + utils.waitForGUI(1) + + +def heparin_pause_resume_states(): + """ + Verifying pause/resume delivery when HEPARIN DELIVERY button is active or deactive using heparin states + HEPARIN STATE 2 -> HEPARIN_STATE_PAUSED + HEPARIN STATE 4 -> HEPARIN_STATE_DISPENSING + """ + hd_simulator.cmd_set_heparin_pause_resume_response(accepted = 1, reason = 1, state = 2) + hd_simulator.cmd_set_treatment_heparin_data(cumulative = 10) + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 2, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + test.compare(str(waitForObjectExists(names.state2_heparin_state_paused_text).text),config.HEPARIN_RESUME_DELIVERY_TEXT,"Heparin Resume Delivery Text should be {}".format(config.HEPARIN_RESUME_DELIVERY_TEXT)) + test.compare( waitForObjectExists(names.state2_heparin_state_paused_text).enabled, True, "Resume Delivery Button is enabled") + + test.log("Heparin delivery is paused, resume delivery to start") + utils.waitForGUI(1) + hd_simulator.cmd_set_treatment_heparin_data(cumulative = 10.1) + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + test.compare(str(waitForObjectExists(names.state4_heparin_state_dispensing_text).text), config.HEPARIN_PAUSE_DELIVERY_TEXT,"Heparin Pause Delivery Text should be {}".format(config.HEPARIN_PAUSE_DELIVERY_TEXT)) + test.compare( waitForObjectExists(names.state4_heparin_state_dispensing_text).enabled , True, "Pause Delivery Button is enabled") + test.log("Heparin delivery is in dispensing state") + utils.waitForGUI(1) + + +def verify_the_rejection_msg(): + """ + Method to verify rejection messages + + """ + test.startSection("Verifying Rejection Messages") + hd_simulator.cmd_set_treatment_states_data(sub_mode= 2, uf_state= 0, saline_state=0, heparin_state= 4, + rinseback_state= 0, recirculate_state= 0, blood_prime_state= 0, + treatment_end_state=0, treatment_stop_state= 0) + for reason_id in range(1, config.NUM_OF_REJECTION_MSG+1): + hd_simulator.cmd_set_heparin_pause_resume_response(accepted=0, reason=reason_id, state=2) + rejection_msg = waitForObjectExists(utility.rejection_msg(text=config.REJECTION_REASON[reason_id])) + test.compare(rejection_msg.text, config.REJECTION_REASON[reason_id], "The rejection message should be {}".format(config.REJECTION_REASON[reason_id])) + test.endSection() + +def main(): + + utils.tstStart(__file__) + startApplication(config.AUT_NAME) + heparin_stop_states_in_main_treatment() + verify_the_rejection_msg() + + utils.tstDone() + \ No newline at end of file