Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -r108450c58851ff7c48c4607494b8cdae59952908 -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 108450c58851ff7c48c4607494b8cdae59952908) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-2024 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 VTreatmentCreate.cpp - * \author (last) Peter Lucia - * \date (last) 15-Oct-2020 - * \author (original) Peter Lucia - * \date (original) 03-Aug-2020 + * \file VTreatmentCreate.cpp + * \author (last) Behrouz NematiPour + * \date (last) 21-Nov-2023 + * \author (original) Peter Lucia + * \date (original) 22-Sep-2020 * */ @@ -20,96 +20,48 @@ #include "VTreatmentCreate.h" #include "FileHandler.h" #include "MsgDefs.h" +#include "TreatmentLog.h" using namespace Gui; using namespace View; using namespace Storage; VTreatmentCreate::VTreatmentCreate(QObject *parent) : QObject(parent) { - ADJUST_VIEW_CONNECTION(AdjustParametersValidationRequestData ) - ACTION_VIEW_CONNECTION(AdjustParametersValidationResponseData) - ADJUST_VIEW_CONNECTION( AdjustParametersConfirmRequestData) - - connect(&_ApplicationController , SIGNAL(didSettingsDone()), - this , SLOT( onSettingsDone())); - + ADJUST_VIEW_CONNECTION(AdjustParametersValidationRequestData ) + ACTION_VIEW_CONNECTION(AdjustParametersValidationResponseData ) + ADJUST_VIEW_CONNECTION(AdjustParametersConfirmRequestData ) + ACTION_VIEW_CONNECTION(AdjustSerialNumberHDResponseData ) } -/** - * \brief VCreateTreatment::onResetCreateTreatment - * Resets the create treatment page to the default values. - * Disables the continue button. - */ -void VTreatmentCreate::doResetCreateTreatment() -{ - reset_bloodFlowRate(); - reset_dialysateFlowRate(); - reset_duration(); - reset_heparinDispensingRate(); - reset_heparinBolusVolume(); - reset_heparinStopTime(); - reset_salineBolusVolume(); - reset_heparinType(); - reset_acidConcentrate(); - reset_bicarbonateConcentrate(); - reset_dialyzerType(); - reset_dialysateTemp(); - reset_arterialPressureLimitLow(); - reset_arterialPressureLimitHigh(); - reset_venousPressureLimitLow(); - reset_venousPressureLimitHigh(); - reset_bloodPressureMeasureInterval(); - reset_rinsebackFlowRate(); - continueEnabled(false); - - emit resetCreateTreatment(); -} - /** - * \brief VCreateTreatment::setTreatmentData - * Assigns treatment parameters to the treatment data structure. - */ -void VTreatmentCreate::setTreatmentData() { - - treatmentData.bloodFlowRate = _bloodFlowRate; - treatmentData.dialysateFlowRate = _dialysateFlowRate; - treatmentData.duration = _duration; - treatmentData.heparinDispensingRate = _heparinDispensingRate; - treatmentData.heparinBolusVolume = _heparinBolusVolume; - treatmentData.heparinStopTime = _heparinStopTime; - treatmentData.salineBolus = _salineBolusVolume; - - treatmentData.heparinType = _heparinType; - treatmentData.acidConcentrate = _acidConcentrate; - treatmentData.bicarbonateConcentrate = _bicarbonateConcentrate; - treatmentData.dialyzerType = _dialyzerType; - treatmentData.dialysateTemp = _dialysateTemp; - treatmentData.arterialPressureLimitLow = _arterialPressureLimitLow; - treatmentData.arterialPressureLimitHigh = _arterialPressureLimitHigh; - treatmentData.venousPressureLimitLow = _venousPressureLimitLow; - treatmentData.venousPressureLimitHigh = _venousPressureLimitHigh; - treatmentData.bloodPressureMeasureInterval = _bloodPressureMeasureInterval; - treatmentData.rinsebackFlowRate = _rinsebackFlowRate; -} - -/** * \brief VCreateTreatment::doValidation * Validates the treatment profile locally, then requests validation of it with FW */ void VTreatmentCreate::doValidation() { - setTreatmentData(); + AdjustParametersValidationRequestData data; - if (!validate(treatmentData)) - { - LOG_DEBUG("Local create treatment validation failed."); - return; - } + data.mBloodFlowRate = _bloodFlowRate ; + data.mDialysateFlowRate = _dialysateFlowRate ; + data.mTreatmentDuration = _treatmentDuration ; + data.mHeparinDispensingRate = _heparinDispensingRate ; + data.mHeparinBolusVolume = _heparinBolusVolume ; + data.mHeparinStopTime = _heparinStopTime ; + data.mSalineBolus = _salineBolusVolume ; + data.mHeparinType = _heparinType ; + data.mAcidConcentrate = _acidConcentrate ; + data.mBicarbonateConcentrate = _bicarbonateConcentrate ; + data.mDialyzerType = _dialyzerType ; + data.mDialysateTemp = _dialysateTemp ; + data.mArterialPressureLimitWindow = _arterialPressureLimitWindow ; + data.mVenousPressureLimitWindow = _venousPressureLimitWindow ; + data.mVenousPressureLimitAsymtrc = _venousPressureLimitAsymtrc ; + data.mBloodPressureMeasureInterval = _bloodPressureMeasureInterval ; + data.mRinsebackFlowRate = _rinsebackFlowRate ; - // Request that FW validates the selected parameters - emit didAdjustment(treatmentData); + emit didAdjustment(data); } /** @@ -154,266 +106,119 @@ * \param messageData The message data must contain the reject reason codes for all parameters * \returns True if FW OK's treatment parameters, false otherwise */ -bool VTreatmentCreate::onActionReceive(AdjustParametersValidationResponseData data) { - bool success = true; - if (data.bloodFlowRate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - emit scrollToParameter(GET_VARIABLE_NAME(data.bloodFlowRate)); - success = false; - emit bloodFlowRate_ValidationFailed(enumToString(static_cast(data.bloodFlowRate))); - } - if (data.dialysateFlowRate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.dialysateFlowRate)); - success = false; - emit dialysateFlowRate_ValidationFailed(enumToString(static_cast(data.dialysateFlowRate))); - } - if (data.duration != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.duration)); - success = false; - emit duration_ValidationFailed(enumToString(static_cast(data.duration))); - } - if (data.heparinDispensingRate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.heparinDispensingRate)); - success = false; - emit heparinDispensingRate_ValidationFailed(enumToString(static_cast(data.heparinDispensingRate))); - } - if (data.heparinBolusVolume != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.heparinBolusVolume)); - success = false; - emit heparinBolusVolume_ValidationFailed(enumToString(static_cast(data.heparinBolusVolume))); - } - if (data.heparinStopTime != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.heparinStopTime)); - success = false; - emit heparinStopTime_ValidationFailed(enumToString(static_cast(data.heparinStopTime))); - } - if (data.salineBolus != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.salineBolus)); - success = false; - emit salineBolusVolume_ValidationFailed(enumToString(static_cast(data.salineBolus))); - } - if (data.acidConcentrate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.acidConcentrate)); - success = false; - emit acidConcentrate_ValidationFailed(enumToString(static_cast(data.acidConcentrate))); - } - if (data.bicarbonateConcentrate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.bicarbonateConcentrate)); - success = false; - emit bicarbonateConcentrate_ValidationFailed(enumToString(static_cast(data.bicarbonateConcentrate))); - } - if (data.dialyzerType != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.dialyzerType)); - success = false; - emit dialyzerType_ValidationFailed(enumToString(static_cast(data.dialyzerType))); - } - if (data.heparinType != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.heparinType)); - success = false; - emit heparinType_ValidationFailed(enumToString(static_cast(data.heparinType))); - } - if (data.dialysateTemp != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.dialysateTemp)); - success = false; - emit dialysateTemp_ValidationFailed(enumToString(static_cast(data.dialysateTemp))); - } - if (data.arterialPressureLimitLow != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.arterialPressureLimitLow)); - success = false; - emit arterialPressureLimitLow_ValidationFailed(enumToString(static_cast(data.arterialPressureLimitLow))); - } - if (data.arterialPressureLimitHigh != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.arterialPressureLimitHigh)); - success = false; - emit arterialPressureLimitHigh_ValidationFailed(enumToString(static_cast(data.arterialPressureLimitHigh))); - } - if (data.venousPressureLimitLow != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.venousPressureLimitLow)); - success = false; - emit venousPressureLimitLow_ValidationFailed(enumToString(static_cast(data.venousPressureLimitLow))); - } - if (data.venousPressureLimitHigh != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.venousPressureLimitHigh)); - success = false; - emit venousPressureLimitHigh_ValidationFailed(enumToString(static_cast(data.venousPressureLimitHigh))); - } - if (data.bloodPressureMeasureInterval != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.bloodPressureMeasureInterval)); - success = false; - emit bloodPressureMeasureInterval_ValidationFailed(enumToString(static_cast(data.bloodPressureMeasureInterval))); - } - if (data.rinsebackFlowRate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { - if (success) emit scrollToParameter(GET_VARIABLE_NAME(data.rinsebackFlowRate)); - success = false; - emit rinsebackFlowRate_ValidationFailed(enumToString(static_cast(data.rinsebackFlowRate))); - } - +void VTreatmentCreate::onActionReceive(const AdjustParametersValidationResponseData &data) { if (! data.mAccepted) { - success = false; - emit fwValidationFailed(""); - } + bloodFlowRateRejectReason (data.mBloodFlowRate ); + dialysateFlowRateRejectReason (data.mDialysateFlowRate ); + treatmentDurationRejectReason (data.mDuration ); + heparinDispensingRateRejectReason (data.mHeparinDispensingRate ); + heparinBolusVolumeRejectReason (data.mHeparinBolusVolume ); + heparinStopTimeRejectReason (data.mHeparinStopTime ); + salineBolusVolumeRejectReason (data.mSalineBolus ); - qDebug() << "fw validation success = " << success; + heparinTypeRejectReason (data.mHeparinType ); + acidConcentrateRejectReason (data.mAcidConcentrate ); + bicarbonateConcentrateRejectReason (data.mBicarbonateConcentrate ); + dialyzerTypeRejectReason (data.mDialyzerType ); - if (success) - { - emit fwValidationSuccess(); - } + dialysateTempRejectReason (data.mDialysateTemp ); + arterialPressureLimitWindowRejectReason (data.mArterialPressureLimitWindow ); + venousPressureLimitWindowRejectReason (data.mVenousPressureLimitWindow ); + venousPressureLimitAsymtrcRejectReason (data.mVenousPressureLimitAsymtrc ); + bloodPressureMeasureIntervalRejectReason (data.mBloodPressureMeasureInterval); + rinsebackFlowRateRejectReason (data.mRinsebackFlowRate ); - return success; + emit didValidationFail(); + } + else { + generateTxCode(); + emit didValidationPass(); + } } -/** - * \brief VCreateTreatment::validate - * \details Validates the create new treatment input. - * \param vData - the selected TreatmentParametersData - * \return true on success, false otherwise. +/*! + * \brief VTreatmentCreate::onActionReceive + * \details This message is received from the HD in POST through the applicationController and GuiController. + * This class keeps the serial for any treatment Code (txCode) generation + * \param data - the message model data */ -bool VTreatmentCreate::validate(const AdjustParametersValidationRequestData &vData) -{ - Q_UNUSED(vData) - if (!isbloodFlowRateSet ) return false; - if (!isdialysateFlowRateSet ) return false; - if (!isdurationSet ) return false; - if (!isheparinDispensingRateSet ) return false; - if (!isheparinBolusVolumeSet ) return false; - if (!isheparinStopTimeSet ) return false; - if (!issalineBolusVolumeSet ) return false; - if (!isheparinTypeSet ) return false; - if (!isacidConcentrateSet ) return false; - if (!isbicarbonateConcentrateSet ) return false; - if (!isdialyzerTypeSet ) return false; - if (!isdialysateTempSet ) return false; - if (!isarterialPressureLimitLowSet ) return false; - if (!isarterialPressureLimitHighSet ) return false; - if (!isvenousPressureLimitLowSet ) return false; - if (!isvenousPressureLimitHighSet ) return false; - if (!isbloodPressureMeasureIntervalSet ) return false; - if (!isrinsebackFlowRateSet ) return false; - return true; +void VTreatmentCreate::onActionReceive(const AdjustSerialNumberHDResponseData &data) { + _HDSerialNumber = data.mSerialNumber; } -/** - * \brief VCreateTreatment::doUserModifiedParameters - * Manages enabling / disabling the continue button - */ -void VTreatmentCreate::doUserModifiedParameters() -{ - setTreatmentData(); - - continueEnabled(validate(treatmentData)); - emit continueEnabledChanged(continueEnabled()); -} - /*! - * \brief VCreateTreatment::doGetPrescriptionParameterNames - * \details Gets a list of the prescription parameter names. - * \return (QStringList) A list of the prescription parameter names + * \brief VTreatmentCreate::generateTxCode + * \details Generates the txCode by combination of the HD serial number and date and time in yyyyMMddHHmmss + * And updates the TreatmenLog class to be saved in the Tx Report. */ -QStringList VTreatmentCreate::doGetPrescriptionParameterNames() -{ - return QStringList() << "Blood Flow Rate" - << "Dialysate Flow Rate" - << "Duration" - << "Heparin Dispensing Rate" - << "Heparin Bolus Volume" - << "Heparin Stop Time" - << "Saline Bolus Volume"; - +void VTreatmentCreate::generateTxCode() { + QDateTime datetime = QDateTime::currentDateTime(); + QString today = datetime.toString("yyyyMMddHHmmss"); + txCode(_HDSerialNumber + today); + _TreatmentLog.gTxCode(_txCode); + LOG_APPED_UI(QString("Generated Treatment Code is %1").arg(_txCode)); } /*! * \brief VCreateTreatment::doGetPrescriptionParameterValues * \details Gets a list of the prescription parameter values * \return (QStringList) The list of parameter values with units */ -QStringList VTreatmentCreate::doGetPrescriptionParameterValues() -{ - return QStringList() << QString("%0 mL/min").arg(_bloodFlowRate) - << QString("%0 mL/min").arg(_dialysateFlowRate) - << QString("%0 min").arg(_duration) - << QString("%0 mL/hr").arg(_heparinDispensingRate) - << QString("%0 mL").arg(_heparinBolusVolume) - << QString("%0 min").arg(_heparinStopTime) - << QString("%0 mL").arg(_salineBolusVolume); +QStringList VTreatmentCreate::doGetPrescriptionParameterValues() { + return QStringList() << QString("%1 mL/min" ).arg(_bloodFlowRate ) + << QString("%1 mL/min" ).arg(_dialysateFlowRate ) + << QString("%1 min" ).arg(_treatmentDuration ) + << ( _heparinDispensingRate ? QString("%1 mL/hr" ).arg(_heparinDispensingRate) : tr("OFF") ) + << ( _heparinBolusVolume ? QString("%1 mL" ).arg(_heparinBolusVolume ) : tr("OFF") ) + << ( _heparinDispensingRate ? QString("%1 min" ).arg(_heparinStopTime ) : tr("OFF") ) + << QString("%1 mL" ).arg(_salineBolusVolume ) ; } /*! - * \brief VCreateTreatment::doGetOperatingParameterNames - * Gets a list of the operating parameter names - * \return (QStringList) The list of operating parameter names - */ -QStringList VTreatmentCreate::doGetOperatingParameterNames() -{ - return QStringList() << "Heparin Type" - << "Acid Concentrate" - << "Bicarbonate Concentrate" - << "Dialyzer Type" - << "Dialysate Temperature" - << "Arterial Pressure Limit Low" - << "Arterial Pressure Limit High" - << "Venous Pressure Limit Low" - << "Venous Pressure Limit High" - << "Blood Pressure Measure Interval" - << "Rinseback Rate"; -} - -/*! * \brief VCreateTreatment::doGetOperatingParameterValues * \details Gets the operating parameter values * \return (QStringList) The list of operating parameter values with units where applicable */ QStringList VTreatmentCreate::doGetOperatingParameterValues() { - QString heparinType; - QString acidConcentrate; - QString bicarbConcentrate; - QString dialyzerType; - if ((heparinTypeOptions().length() - 1 < (int)_heparinType)) - heparinType = "None"; - else - heparinType = heparinTypeOptions().at(_heparinType); + QString mHeparinType ; + QString mAcidConcentrate ; + QString mBicarbonateConcentrate ; + QString mDialyzerType ; - if ((acidConcentrateOptions().length() - 1 < (int)_acidConcentrate)) - acidConcentrate = "None"; - else - acidConcentrate = acidConcentrateOptions().at(_acidConcentrate); + QStringList mHeparinTypeOptions ; + QStringList mAcidConcentrateOptions ; + QStringList mBicarbonateConcentrateOptions ; + QStringList mDialyzerTypeOptions ; - if ((bicarbonateConcentrateOptions().length() - 1 < (int)_bicarbonateConcentrate)) - bicarbConcentrate = "None"; - else - bicarbConcentrate = bicarbonateConcentrateOptions().at(_bicarbonateConcentrate); + QString mCategory = Storage::Settings_Category_ConfigurationsDataList; - if ((dialyzerTypeOptions().length() - 1 < (int)_dialyzerType) || ((int)_dialyzerType < 0)) - dialyzerType = "None"; - else - dialyzerType = dialyzerTypeOptions().at(_dialyzerType); + if ( heparinTypeSet () ) { // this is managed on UI with heparinTypeSet() // && ( _heparinDispensingRate || _heparinBolusVolume ) + mHeparinTypeOptions = _Settings.keys(mCategory, "Heparin Type Options" ); + if ((int) _heparinType < mHeparinTypeOptions .length()) mHeparinType = mHeparinTypeOptions .at( _heparinType ); + } else { mHeparinType = tr("NONE"); } - return QStringList() << heparinType - << acidConcentrate - << bicarbConcentrate - << dialyzerType - << QString("%0 °C").arg(_dialysateTemp) - << QString("%0 mmHg").arg(_arterialPressureLimitLow) - << QString("%0 mmHg").arg(_arterialPressureLimitHigh) - << QString("%0 mmHg").arg(_venousPressureLimitLow) - << QString("%0 mmHg").arg(_venousPressureLimitHigh) - << QString("%0 min").arg(_bloodPressureMeasureInterval) - << QString("%0 mL/min").arg(_rinsebackFlowRate); -} + if ( acidConcentrateSet () ) { + mAcidConcentrateOptions = _Settings.keys(mCategory, "Acid Concentrate Options" ); + if ((int) _acidConcentrate < mAcidConcentrateOptions .length()) mAcidConcentrate = mAcidConcentrateOptions .at( _acidConcentrate ); + } else { mAcidConcentrate = tr("NONE"); } -/*! - * \brief VTreatmentCreate::onSettingsDone - * \details fills the items below, read from the settings file, when the reading is notified done by ApplicationController. - * acidConcentrateOptions - * bicarbonateConcentrateOptions - * dialyzerTypeOptions - * heparinTypeOptions - * - */ -void VTreatmentCreate::onSettingsDone() -{ - heparinTypeOptions ( _Settings.keys("Heparin Type" )); - acidConcentrateOptions ( _Settings.keys("Acid Concentrate" )); - bicarbonateConcentrateOptions ( _Settings.keys("Bicarbonate Concentrate" )); - dialyzerTypeOptions ( _Settings.keys("Dialyzer Type" )); + if ( bicarbonateConcentrateSet () ) { + mBicarbonateConcentrateOptions = _Settings.keys(mCategory, "Bicarbonate Concentrate Options" ); + if ((int) _bicarbonateConcentrate < mBicarbonateConcentrateOptions .length()) mBicarbonateConcentrate = mBicarbonateConcentrateOptions .at( _bicarbonateConcentrate ); + } else { mBicarbonateConcentrate = tr("NONE"); } + + if ( dialyzerTypeSet () ) { + mDialyzerTypeOptions = _Settings.keys(mCategory, "Dialyzer Type Options" ); + if ((int) _dialyzerType < mDialyzerTypeOptions .length()) mDialyzerType = mDialyzerTypeOptions .at( _dialyzerType ); + } else { mDialyzerType = tr("NONE"); } + + + return QStringList() << mHeparinType + << mAcidConcentrate + << mBicarbonateConcentrate + << mDialyzerType + << QString("%0 °C" ).arg(_dialysateTemp ) + << ( _bloodPressureMeasureInterval ? QString("%0 min").arg(_bloodPressureMeasureInterval) : tr("OFF") ) + ; }