Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -r40c09957821fb3779fa06214a856c20cca110e56 -r5e03d3f26ea0c88562e430c4b8192dd745fa1011 --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 40c09957821fb3779fa06214a856c20cca110e56) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 5e03d3f26ea0c88562e430c4b8192dd745fa1011) @@ -27,89 +27,40 @@ 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 ) } -/** - * \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.bloodFlowRate = _bloodFlowRate; + data.dialysateFlowRate = _dialysateFlowRate; + data.treatmentDuration = _treatmentDuration; + data.heparinDispensingRate = _heparinDispensingRate; + data.heparinBolusVolume = _heparinBolusVolume; + data.heparinStopTime = _heparinStopTime; + data.salineBolus = _salineBolusVolume; + data.heparinType = _heparinType; + data.acidConcentrate = _acidConcentrate; + data.bicarbonateConcentrate = _bicarbonateConcentrate; + data.dialyzerType = _dialyzerType; + data.dialysateTemp = _dialysateTemp; + data.arterialPressureLimitLow = _arterialPressureLimitLow; + data.arterialPressureLimitHigh = _arterialPressureLimitHigh; + data.venousPressureLimitLow = _venousPressureLimitLow; + data.venousPressureLimitHigh = _venousPressureLimitHigh; + data.bloodPressureMeasureInterval = _bloodPressureMeasureInterval; + data.rinsebackFlowRate = _rinsebackFlowRate; - // Request that FW validates the selected parameters - emit didAdjustment(treatmentData); + emit didAdjustment(data); } /** @@ -154,174 +105,16 @@ * \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(""); } - - // DEBUG: qDebug() << "fw validation success = " << success; - - if (success) - { + else { emit fwValidationSuccess(); } - - return success; } -/** - * \brief VCreateTreatment::validate - * \details Validates the create new treatment input. - * \param vData - the selected TreatmentParametersData - * \return true on success, false otherwise. - */ -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; -} - -/** - * \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 - */ -QStringList VTreatmentCreate::doGetPrescriptionParameterNames() -{ - return QStringList() << "Blood Flow Rate" - << "Dialysate Flow Rate" - << "Duration" - << "Heparin Dispensing Rate" - << "Heparin Bolus Volume" - << "Heparin Stop Time" - << "Saline Bolus Volume"; - -} - -/*! * \brief VCreateTreatment::doGetPrescriptionParameterValues * \details Gets a list of the prescription parameter values * \return (QStringList) The list of parameter values with units @@ -330,91 +123,62 @@ { 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(_treatmentDuration) + << ( _heparinDispensingRate ? QString("%0 mL/hr").arg(_heparinDispensingRate) : tr("OFF") ) + << ( _heparinBolusVolume ? QString("%0 mL" ).arg(_heparinBolusVolume ) : tr("OFF") ) << QString("%0 min").arg(_heparinStopTime) << QString("%0 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 () ) { + 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() -{ - QString mCategory = Storage::Settings_Category_ConfigurationsDataList; - heparinTypeOptions ( _Settings.keys(mCategory, "Heparin Type" )); - acidConcentrateOptions ( _Settings.keys(mCategory, "Acid Concentrate" )); - bicarbonateConcentrateOptions ( _Settings.keys(mCategory, "Bicarbonate Concentrate" )); - dialyzerTypeOptions ( _Settings.keys(mCategory, "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 ) + << 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 ); }