# -*- coding: utf-8 -*- ## # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # copyright # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, # IN PART OR IN WHOLE, # WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # file tst_create_patient_ID # date 2020/01/27 # author Joseph varghese # # NOTE: # This test is intended to be used to verify custom treatment in application . import names import test from dialin.ui import utils from dialin.ui import unittests from builtins import str as pyStr from configuration import utility from configuration.assertion_helper import AssertionHelper from dialin.common.msg_defs import RequestRejectReasons from dialin.ui.hd_simulator import HDSimulator PATIENT_ID = "demopatientid" HEPARIN_TYPE = "UFH 1,000 IU/mL" ACID_CONCENTRATE = ["Fres. Naturalyte", "08-1251-1", "08-2251-0", "08-3251-9"] BICARBONATE_CONCENTRATE = "Fres. Centrisol" DIALYZER_TYPE = ["BB Diacap Pro 13H", "BB Diacap Pro 16H", "BB Diacap Pro 19H", "F Optiflux F160NRe", "F Optiflux F180NRe"] CREATE_TREATMENT_SLIDER_VALUES = { "bloodFlowRate": [200, 300, 400, 150, 250], "dialysateFlowRate": [150, 250, 300, 450, 500], "duration": [120, 150, 240, 300, 450], "heparinDispensingRate": [0.2, 0.3, 0.6, 0.8, 0.5], "heparinBolusVolume": [0.2, 0.5, 0.8, 1.0, 1.6], "heparinStopTime": [20, 60, 270, 320, 420, 440], "salineBolus": [200], "dialysateTemperature": [35.5, 36.0, 36.5, 37.0, 37.5], "bloodPressureMeasurementInterval": [5, 15, 20, 30, 45, 55], "rinsebackFlowRate": [75, 100, 125], } def treatment_create_flickable(x_axis =0, y_axis = 0): mouseWheel(waitForObject(names.treatment_create_flickable), 1184, 107, x_axis, y_axis, Qt.NoModifier) def set_parameter_type(text): if isinstance(text, pyStr): names.operating_parameters["text"] = text return names.operating_parameters else: test.log(f"Invalid \"text\": {text} for object.") names.keyboard_input["text"] = "UFH 1,000 IU/mL" slider_object = waitForObject(names.demo) child = object.children(slider_object)[0] child = object.children(child)[0] child = object.children(child)[1] child = object.children(child)[2] child1 = object.children(child)[5] move = object.children(child)[2] set_random_slider_weight(value = 400, slider_object = child) def set_operating_parameters(heparin_type, acid_concentrate, bicarbonate_concentrate, dialyzer_type): """ Tests that all possible non-slider options are shown. @return: None """ treatment_create_flickable(y_axis = -120) heparin_box_obj = set_heparin_type(text = heparin_type) tapObject(waitForObject(heparin_box_obj)) acid_concentrate_box_obj = set_acid_concentrate(text = acid_concentrate) tapObject(waitForObject(acid_concentrate_box_obj)) treatment_create_flickable(y_axis = -80) bicarbonate_concentrate_box_obj = set_bicarbonate_concentrate(text = bicarbonate_concentrate) tapObject(waitForObject(bicarbonate_concentrate_box_obj)) treatment_create_flickable(y_axis = -120) dialyzer_type_box_obj = set_dialyzer_type(text = dialyzer_type) tapObject(waitForObject(dialyzer_type_box_obj)) treatment_create_flickable(y_axis = -80) def verify_request_rejection_mode(hd_simulator): reject_reasons = [ RequestRejectReasons.REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE ] * hd_simulator.NUM_TREATMENT_PARAMETERS treatment_status = hd_simulator.cmd_send_treatment_parameter_validation_response(reject_reasons) test.compare(True, treatment_status) test.log("custom treatment should be rejected") def set_slider_value_for_parameter(index_value, item_text, slider_value, slider_obj): parameter = object.children(slider_obj)[index_value] slider_object = object.children(parameter)[2] status = utility.set_slider_value(slider_value, slider_object) if status is True: test.passes(f"{item_text} should set to value -> {slider_value}") else: test.fail(f"{item_text} could not set to value -> {slider_value}") def create_custom_treatment_record( blood_flow_rate, dialysate_flow_rate, duration, heparin_dispensing_rate, heparin_bolus_volume, heparin_stop_time, saline_bolus, dialysate_temperature, blood_pressure_measurement_interval, rinseback_flowrate, ): slider_object = waitForObject(names.create_treatment_screen) child = object.children(slider_object)[0] parameter_child = object.children(child)[0] slider_status = set_slider_value_for_parameter(index_value = 1, item_text = "blood flow rate", slider_value = blood_flow_rate, slider_obj = parameter_child) test.compare(Trueslider_status, ) set_slider_value_for_parameter(index_value = 2, item_text = "dialysate flow rate", slider_value = dialysate_flow_rate, slider_obj = parameter_child) set_slider_value_for_parameter(index_value = 3, item_text = "duration", slider_value = duration, slider_obj = parameter_child) parameter_object = set_parameter_type(text = "Heparin Stop Time") utility.scroll_to_zone(parameter_object, names.create_treatment_screen) set_slider_value_for_parameter(index_value = 4, item_text = "heparin dispensing rate", slider_value = heparin_dispensing_rate, slider_obj = parameter_child) set_slider_value_for_parameter(index_value = 5, item_text = "heparin bolus volume", slider_value = heparin_bolus_volume, slider_obj = parameter_child) parameter_object = set_parameter_type(text = "Saline Bolus") utility.scroll_to_zone(parameter_object, names.create_treatment_screen) set_slider_value_for_parameter(index_value = 6, item_text = "heparin stop time", slider_value = heparin_stop_time, slider_obj = parameter_child) set_slider_value_for_parameter(index_value = 7, item_text = "saline bolus", slider_value = saline_bolus, slider_obj = parameter_child) """ set_slider_value_for_parameter(index_value = 8, item_text = "dialysate temperature", slider_value = dialysate_temperature, slider_obj = parameter_child) set_slider_value_for_parameter(index_value = 9, item_text = "blood pressure measurement interval", slider_value = blood_pressure_measurement_interval, slider_obj = parameter_child) set_slider_value_for_parameter(index_value = 10, item_text = "rinseback_flowrate", slider_value = rinseback_flowrate, slider_obj = parameter_child) """ """ custom_treatment = waitForObject(names.custom_treatment) test.compare("Create a Custom Treatment", custom_treatment.text) test.log(f"user successfully authenticated.") """ """ mouseClick(waitForImage("blood",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("dialysate",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("duration",{ "tolerant": True, "threshold": 99.999 })) treatment_create_flickable(y_axis = -100) mouseClick(waitForImage("heparin_dispensing_rate",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("heparin_bolus_volume",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("heparin_stop_time",{ "tolerant": True, "threshold": 99.999 })) treatment_create_flickable(y_axis = -65) mouseClick(waitForImage("saline_bolus",{ "tolerant": True, "threshold": 99.999 })) set_operating_parameters(heparin_type = HEPARIN_TYPE, acid_concentrate = ACID_CONCENTRATE[0], bicarbonate_concentrate = BICARBONATE_CONCENTRATE, dialyzer_type = DIALYZER_TYPE[0]) treatment_create_flickable(y_axis = -65) mouseClick(waitForImage("dialysate_temperature",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("aterial_pressure_low_limit",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("aterial_pressure_high_limit",{ "tolerant": True, "threshold": 99.999 })) treatment_create_flickable(y_axis = -150) mouseClick(waitForImage("venous_pressure_low_limits",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("venous_pressure_high_limits",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("blood_pressure_measurement_interval",{ "tolerant": True, "threshold": 99.999 })) mouseClick(waitForImage("Rinseback_flow_rate",{ "tolerant": True, "threshold": 99.999 })) test.log("User successfully selected values for treatment items") """ def main(): utils.tstStart("tst_create_custom_treatment") utility.start_application("Create custom treatment for a patient") hd = HDSimulator() hd.cmd_send_power_on_self_test_version_request() hd._handler_ui_first_check_in(message = None) tapObject(waitForObject(names.input_patient_id)) type(waitForObject(names.input_patient_id), PATIENT_ID) tapObject(waitForObject(names.confirm_button)) create_custom_treatment_record( blood_flow_rate = CREATE_TREATMENT_SLIDER_VALUES["bloodFlowRate"][0], dialysate_flow_rate = CREATE_TREATMENT_SLIDER_VALUES["dialysateFlowRate"][0], duration = CREATE_TREATMENT_SLIDER_VALUES["duration"][0], heparin_dispensing_rate = CREATE_TREATMENT_SLIDER_VALUES["heparinDispensingRate"][0], heparin_bolus_volume = CREATE_TREATMENT_SLIDER_VALUES["heparinBolusVolume"][0], heparin_stop_time = CREATE_TREATMENT_SLIDER_VALUES["heparinStopTime"][0], saline_bolus = CREATE_TREATMENT_SLIDER_VALUES["salineBolus"][0], dialysate_temperature = CREATE_TREATMENT_SLIDER_VALUES["dialysateTemperature"][0], blood_pressure_measurement_interval = CREATE_TREATMENT_SLIDER_VALUES["bloodPressureMeasurementInterval"][0], rinseback_flowrate = CREATE_TREATMENT_SLIDER_VALUES["rinsebackFlowRate"][0], ) #verify_custom_treatment_record() """ create_custom_treatment_record( bloodFlowRate = CREATE_TREATMENT_SLIDER_VALUES["bloodFlowRate"][1], dialysateFlowRate = CREATE_TREATMENT_SLIDER_VALUES["dialysateFlowRate"][1], duration = CREATE_TREATMENT_SLIDER_VALUES["duration"][1], heparinDispensingRate = CREATE_TREATMENT_SLIDER_VALUES["heparinDispensingRate"][1], heparinBolusVolume = CREATE_TREATMENT_SLIDER_VALUES["heparinBolusVolume"][1], heparinStopTime = CREATE_TREATMENT_SLIDER_VALUES["heparinStopTime"][1], salineBolus = CREATE_TREATMENT_SLIDER_VALUES["salineBolus"][1], dialysateTemperature = CREATE_TREATMENT_SLIDER_VALUES["dialysateTemperature"][1], bloodPressureMeasurementInterval = CREATE_TREATMENT_SLIDER_VALUES["bloodPressureMeasurementInterval"][1], rinsebackFlowRate = CREATE_TREATMENT_SLIDER_VALUES["rinsebackFlowRate"][1], ) verify_request_rejection_mode(hd) create_custom_treatment_record( bloodFlowRate = CREATE_TREATMENT_SLIDER_VALUES["bloodFlowRate"][2], dialysateFlowRate = CREATE_TREATMENT_SLIDER_VALUES["dialysateFlowRate"][2], duration = CREATE_TREATMENT_SLIDER_VALUES["duration"][2], heparinDispensingRate = CREATE_TREATMENT_SLIDER_VALUES["heparinDispensingRate"][2], heparinBolusVolume = CREATE_TREATMENT_SLIDER_VALUES["heparinBolusVolume"][2], heparinStopTime = CREATE_TREATMENT_SLIDER_VALUES["heparinStopTime"][2], salineBolus = CREATE_TREATMENT_SLIDER_VALUES["salineBolus"][2], dialysateTemperature = CREATE_TREATMENT_SLIDER_VALUES["dialysateTemperature"][2], bloodPressureMeasurementInterval = CREATE_TREATMENT_SLIDER_VALUES["bloodPressureMeasurementInterval"][2], rinsebackFlowRate = CREATE_TREATMENT_SLIDER_VALUES["rinsebackFlowRate"][2], ) verify_request_continue_mode(hd) #verify_request_rejection_mode(hd) #set_operating_parameters(heparin_type = HEPARIN_TYPE, # acid_concentrate = ACID_CONCENTRATE[1], # bicarbonate_concentrate = BICARBONATE_CONCENTRATE, # dialyzer_type = DIALYZER_TYPE[1]) treatment_create_flickable(y_axis = -65) #hd.cmd_send_pre_treatment_patient_connection_confirm_response(accepted = 1, reason = 1) #hd.cmd_send_pre_treatment_prime_start_response(accepted = 1, reason = 1) #hd.cmd_send_pre_treatment_continue_to_treament_response( accepted=1, reason= 0) hd.cmd_send_treatment_parameter_manual_validation_response([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) hd.cmd_initiate_treatment_response(response= 1, reason=0) time.sleep(2) #hd.cmd_send_pre_treatment_patient_connection_confirm_response(accepted = 1, reason = 0) #hd.simulator.cmd_send_treatment_parameter_validation_response(19) #hd.cmd_initiate_treatment_response(response=1, reason=0) #hd.cmd_send_treatment_parameter_validation_response(self, rejections: List[RequestRejectReasons]) time.sleep(20) """ utils.tstDone()