Index: denali.pro.user =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- denali.pro.user (.../denali.pro.user) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ denali.pro.user (.../denali.pro.user) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/gui/qml/components/ConfirmTreatmentTable.qml =================================================================== diff -u -rdd2d4b50f32f74eccbc9592be5ef9da0bc0fbd25 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/components/ConfirmTreatmentTable.qml (.../ConfirmTreatmentTable.qml) (revision dd2d4b50f32f74eccbc9592be5ef9da0bc0fbd25) +++ sources/gui/qml/components/ConfirmTreatmentTable.qml (.../ConfirmTreatmentTable.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -101,16 +101,16 @@ anchors.bottom: parent.bottom width: parent.width - 2*Variables.createTreatmentMargin height: _root.height - _header.height - prescriptionKeys: vTreatmentCreate.doGetPrescriptionParameterNames() - prescriptionValues: vTreatmentCreate.doGetPrescriptionParameterValues() - operatingKeys: vTreatmentCreate.doGetOperatingParameterNames() - operatingValues: vTreatmentCreate.doGetOperatingParameterValues() + prescriptionKeys : vTreatmentCreate.doGetPrescriptionParameterNames() + prescriptionValues : vTreatmentCreate.doGetPrescriptionParameterValues() + operatingKeys : vTreatmentCreate.doGetOperatingParameterNames() + operatingValues : vTreatmentCreate.doGetOperatingParameterValues() onVisibleChanged: { if (visible) { - prescriptionKeys = vTreatmentCreate.doGetPrescriptionParameterNames() - prescriptionValues = vTreatmentCreate.doGetPrescriptionParameterValues() - operatingKeys = vTreatmentCreate.doGetOperatingParameterNames() - operatingValues = vTreatmentCreate.doGetOperatingParameterValues() + prescriptionKeys = vTreatmentCreate.doGetPrescriptionParameterNames() + prescriptionValues = vTreatmentCreate.doGetPrescriptionParameterValues() + operatingKeys = vTreatmentCreate.doGetOperatingParameterNames() + operatingValues = vTreatmentCreate.doGetOperatingParameterValues() } } } Index: sources/gui/qml/components/ConfirmTreatmentTableEntry.qml =================================================================== diff -u -rdd2d4b50f32f74eccbc9592be5ef9da0bc0fbd25 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/components/ConfirmTreatmentTableEntry.qml (.../ConfirmTreatmentTableEntry.qml) (revision dd2d4b50f32f74eccbc9592be5ef9da0bc0fbd25) +++ sources/gui/qml/components/ConfirmTreatmentTableEntry.qml (.../ConfirmTreatmentTableEntry.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -28,16 +28,17 @@ */ Rectangle { id: _root - property var key: "Key" - property var value: "Value" + property var key : "Key" + property var value : "Value" + height: Variables.createTreatmentSubTableHeight width: Variables.createTreatmentSubTableWidth color: "transparent" Line { id: _line width: _root.width + Variables.createTreatmentTableMargin - thickness: 3 + thickness: 2 color: Colors.backgroundMenu anchors.top: _root.bottom anchors.left: _root.left Index: sources/gui/qml/pages/MainHome.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/pages/MainHome.qml (.../MainHome.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/MainHome.qml (.../MainHome.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -29,9 +29,11 @@ ScreenItem { id: _root objectName: "_MainHome" - signal treatmentStarted() - signal treatmentCreated() + property alias reasonText : _notification.text + signal startTreatment() + signal createTreatment() + // 2 - Header ImageLogoD { id: _headerLogo } @@ -47,15 +49,20 @@ TouchRect { id : _startTreatmentRect anchors.horizontalCenter: parent.horizontalCenter text.text: qsTr("START TREATMENT") - onClicked: treatmentStarted() + onClicked: startTreatment() } TouchRect { id : _createTreatmentRect anchors.horizontalCenter: parent.horizontalCenter text.text: qsTr("CREATE TREATMENT") - onClicked: treatmentCreated() + onClicked: createTreatment() } } + NotificationBar { id: _notification + iconVisible: false + anchors.bottomMargin: Variables.mainMenuHeight + } + onVisibleChanged: { if (visible) { _mainMenu.hidden = false Index: sources/gui/qml/pages/MainStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/pages/MainStack.qml (.../MainStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/MainStack.qml (.../MainStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -66,8 +66,8 @@ } MainHome { id: _mainHome - onTreatmentStarted : { page( _treatmentStack )} - onTreatmentCreated : { vPreTreatmentAdjustmentInitTreatment.doInitiate() } + onStartTreatment : { page( _treatmentStack )} + onCreateTreatment : { vPreTreatmentAdjustmentInitTreatment.doInitiate() } } Connections { target: vHDOperationMode @@ -105,6 +105,14 @@ onTsRecirculateNoChanged : { page( null , vtsRecirculateNo )} } + Connections { target: vPreTreatmentAdjustmentInitTreatment + onAdjustmentTriggered: { + // this may be handled by alarm and in that case if it is shown, it would be duplicate or simply will be covered by alarm. + // if not it is not handled by alarm, removing the comment will make it work properly, since the MainHome modified to support this. + // _mainHome.reasonText = vPreTreatmentAdjustmentInitTreatment.text() + } + } + onVisibleChanged: { if (visible) { _mainMenu.hidden = false Index: sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml =================================================================== diff -u -r8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml (.../PreTreatmentCreateStack.qml) (revision 8d6f0d14c717e6f3eecb32b6acb4c4306d8eb608) +++ sources/gui/qml/pages/pretreatment/create/PreTreatmentCreateStack.qml (.../PreTreatmentCreateStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -44,9 +44,6 @@ header.backVisible : true header.confirmVisible : true title.text : qsTr("Confirm Treatment") - - onBackClicked : { vTreatmentCreate.doCancelConfirmParameters ()} - onConfirmClicked : { vTreatmentCreate.doFinishedConfirm ()} } Connections { target: vHDOperationMode @@ -58,14 +55,14 @@ } Connections { target: _pretreatmentCreate - onBackClicked : { vTreatmentCreate.doCancelSelectingParameters ()} - onConfirmClicked : { vTreatmentCreate.doFinishedCreate ()} + onBackClicked : { vPreTreatmentAdjustmentInitTreatment.doCancel ()} + onConfirmClicked : { vTreatmentCreate.doValidation ()} } Connections { target: _pretreatmentConfirm - onBackClicked : { vTreatmentCreate.doCancelConfirmParameters () - page( _pretreatmentCreate )} - onConfirmClicked : { vTreatmentCreate.doFinishedConfirm ()} + onBackClicked : { vTreatmentCreate.doCancel () + page( _pretreatmentCreate )} + onConfirmClicked : { vTreatmentCreate.doConfirm ()} } onVisibleChanged: { Index: sources/gui/qml/pages/treatment/TreatmentStack.qml =================================================================== diff -u -rbd01334f257c35b96b7b232beacbcd7fae60c852 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision bd01334f257c35b96b7b232beacbcd7fae60c852) +++ sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -160,7 +160,7 @@ } Connections { target: _mainHome - onTreatmentStarted : push( _treatmentStart ) + onStartTreatment : push( _treatmentStart ) onVisibleChanged : if (_mainHome.visible) _treatmentMenu.hidden = true } } Index: sources/view/VTreatmentCreate (legacy).cpp =================================================================== diff -u --- sources/view/VTreatmentCreate (legacy).cpp (revision 0) +++ sources/view/VTreatmentCreate (legacy).cpp (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -0,0 +1,577 @@ +/*! + * + * 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 VTreatmentCreate.cpp + * \author (last) Peter Lucia + * \date (last) 15-Oct-2020 + * \author (original) Peter Lucia + * \date (original) 03-Aug-2020 + * + */ + +// Qt + +// Project +#include "VTreatmentCreate.h" +#include "FileHandler.h" +#include "MsgDefs.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(this, SIGNAL(requestConcurrentSave(QString,QString,bool)), + &_FileSaver, SLOT(onConcurrentSave(QString,QString,bool))); + + loadTreatmentParameterRanges(); +} + +/** + * \brief VCreateTreatment::loadTreatmentParameterRanges + * Loads treatment parameters from a json file + * \return QJsonObject holding the treatment parameters + */ +QJsonObject VTreatmentCreate::loadTreatmentParameterRanges(const QString &path) +{ + QJsonObject obj; + if (!FileHandler::read(path, obj)) + { + // TODO: notify user + LOG_EVENT(tr("Could not load treatment parameter ranges from %1").arg(path)); + return QJsonObject(); + } + + foreach (const QString& key, obj.keys()) + { + QJsonValue value = obj.value(key); + + if (key == GET_VARIABLE_NAME(bloodFlowRateMin)) _bloodFlowRateMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(bloodFlowRateMax)) _bloodFlowRateMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(dialysateFlowRateMin)) _dialysateFlowRateMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(dialysateFlowRateMax)) _dialysateFlowRateMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(durationMin)) _durationMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(durationMax)) _durationMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinDispensingRateMin)) _heparinDispensingRateMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinDispensingRateMax)) _heparinDispensingRateMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinBolusVolumeMin)) _heparinBolusVolumeMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinBolusVolumeMax)) _heparinBolusVolumeMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinStopTimeMin)) _heparinStopTimeMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(heparinStopTimeMax)) _heparinStopTimeMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(salineBolusVolumeMin)) _salineBolusVolumeMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(salineBolusVolumeMax)) _salineBolusVolumeMax = value.toInt(); + // options + else if (key == GET_VARIABLE_NAME(acidConcentrateOptions)) _acidConcentrateOptions = jsonArrayToStringList(value.toArray()); + else if (key == GET_VARIABLE_NAME(bicarbonateConcentrateOptions)) _bicarbonateConcentrateOptions = jsonArrayToStringList(value.toArray()); + else if (key == GET_VARIABLE_NAME(dialyzerTypeOptions)) _dialyzerTypeOptions = jsonArrayToStringList(value.toArray()); + + else if (key == GET_VARIABLE_NAME(dialysateTempMin)) _dialysateTempMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(dialysateTempMax)) _dialysateTempMax = value.toInt(); + // arterial + else if (key == GET_VARIABLE_NAME(arterialPressureLimitLowMin)) _arterialPressureLimitLowMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(arterialPressureLimitLowMax)) _arterialPressureLimitLowMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(arterialPressureLimitHighMin)) _arterialPressureLimitHighMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(arterialPressureLimitHighMax)) _arterialPressureLimitHighMax = value.toInt(); + // venous + else if (key == GET_VARIABLE_NAME(venousPressureLimitLowMin)) _venousPressureLimitLowMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(venousPressureLimitLowMax)) _venousPressureLimitLowMax = value.toInt(); + else if (key == GET_VARIABLE_NAME(venousPressureLimitHighMin)) _venousPressureLimitHighMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(venousPressureLimitHighMax)) _venousPressureLimitHighMax = value.toInt(); + + else if (key == GET_VARIABLE_NAME(bloodPressureMeasureIntervalMin)) _bloodPressureMeasureIntervalMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(bloodPressureMeasureIntervalMax)) _bloodPressureMeasureIntervalMax = value.toInt(); + + else if (key == GET_VARIABLE_NAME(rinsebackFlowRateMin)) _rinsebackFlowRateMin = value.toInt(); + else if (key == GET_VARIABLE_NAME(rinsebackFlowRateMax)) _rinsebackFlowRateMax = value.toInt(); + else + { + qDebug() << "Invalid treatment parameter range: " << key; + LOG_EVENT(tr("Invalid treatment parameter found: %0").arg(key)); + } + } + + return obj; +} + +/** + * \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_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::jsonArrayToStringList + * Converts a jsonarray of strings to a QStringList + * \param arr (QJsonArray) to convert + * \return (QStringList) The list of strings in the array + */ +QStringList VTreatmentCreate::jsonArrayToStringList(const QJsonArray &arr) +{ + QStringList result; + foreach (const QJsonValue &val, arr) { + result.append(val.toString()); + } + return result; +} + +/** + * \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.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::onFinishedCreate + * Validates the treatment profile locally, then requests validation of it with FW + */ +void VTreatmentCreate::doFinishedCreate() { + + setTreatmentData(); + + if (!validate(treatmentData)) + { + qDebug() << "Local create treatment validation failed."; + LOG_EVENT("Local create treatment validation failed."); + return; + } + + // Request that FW validates the selected parameters + emit didAdjustment(treatmentData); + + LOG_DEBUG("Requesting FW validation of new treatment parameters"); + +} + +/** + * \brief VCreateTreatment::enumToString + * Convenience function to convert an enum to a string + * \param vEnum - the enum value + * \return QString - the enum name + */ +QString VTreatmentCreate::enumToString(GuiRequestReasons vEnum) +{ + const QMetaObject *mo = qt_getEnumMetaObject(vEnum); + int enumIdx = mo->indexOfEnumerator(qt_getEnumName(vEnum)); + QString mText = mo->enumerator(enumIdx).valueToKey(vEnum); + if ( ! mText.isEmpty() ) { + return mText; + } + return QString("[%1] Unknown Rejection Reason").arg(vEnum); +} + +/** + * \brief VCreateTreatment::onFWValidationResponse + * Slot to handle a validation response from FW + * \param actionType The action type must be a create treatment response + * \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.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))); + } + + if (! data.mAccepted) { + success = false; + emit fwValidationFailed(""); + } + + qDebug() << "fw validation success = " << success; + + if (success) + { + emit fwValidationSuccess(); + } + + return success; +} + +/** + * \brief VCreateTreatment::onFinishedConfirm + * \details Emits treatment data to gui controller, + * who emits to application controller and the + * application controller will save the data to disk. + * \note Finished create treatment confirm... + */ +void VTreatmentCreate::doFinishedConfirm() { + QJsonObject obj { + {"bloodFlowRate", QString::number(treatmentData.bloodFlowRate)}, + {"dialysateFlowRate", QString::number(treatmentData.dialysateFlowRate)}, + {"duration", QString::number(treatmentData.duration)}, + {"heparinDispensingRate", QString::number(treatmentData.heparinDispensingRate)}, + {"heparinBolusVolume", QString::number(treatmentData.heparinBolusVolume)}, + {"heparinStopTime", QString::number(treatmentData.heparinStopTime)}, + {"acidConcentrate", QString::number(treatmentData.acidConcentrate)}, + {"bicarbonateConcentrate", QString::number(treatmentData.bicarbonateConcentrate)}, + {"dialyzerType", QString::number(treatmentData.dialyzerType)}, + {"dialysateTemp", QString::number(treatmentData.dialysateTemp)}, + {"arterialPressureLimitLow", QString::number(treatmentData.arterialPressureLimitLow)}, + {"arterialPressureLimitHigh", QString::number(treatmentData.arterialPressureLimitHigh)}, + {"venousPressureLimitLow", QString::number(treatmentData.venousPressureLimitLow)}, + {"venousPressureLimitHigh", QString::number(treatmentData.venousPressureLimitHigh)}, + {"bloodPressureMeasureInterval",QString::number(treatmentData.bloodPressureMeasureInterval)}, + {"rinsebackFlowRate", QString::number(treatmentData.rinsebackFlowRate)} + }; + + QString treatmentParameters = QJsonDocument(obj).toJson(QJsonDocument::Indented); + LOG_EVENT(QString("Create Treatment Confirm: %1").arg(treatmentParameters)); + if (saveTreatmentProfile()) + saveNewTreatment(obj); + + // Tell FW we confirm + confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eConfirm; + emit didAdjustment(confirmTreatmentRequest); +} + +/** + * \brief ApplicationController::saveNewTreatment + * \details Saves a new treatment to the file system. + * \param doc - QJsonDocument containing the new treatment parameters. + * \returns QString - the file to be written to + * + */ +QString VTreatmentCreate::saveNewTreatment(const QJsonObject &obj, const QString &dir) +{ + QJsonDocument document(obj); + int i = 0; + while (QFile(QString("%0treatment%1.json").arg(dir).arg(i)).exists()) + { + i++; + } + QString filename = QString("%0treatment%1.json").arg(dir).arg(i); + emit requestConcurrentSave(filename, document.toJson(), false); + return filename; +} + +/** + * \brief VCreateTreatment::getParameterRangesDataCSV + * \details Gets the parameter ranges data prepared for CSV file format + * \return QString - the data to write to CSV + */ +QString VTreatmentCreate::getParameterRangesDataCSV() +{ + QString csvData; + QString sep = ","; + + csvData += QString("bloodFlowRateMin,%0\n").arg(bloodFlowRateMin()); + csvData += QString("bloodFlowRateMax,%0\n").arg(bloodFlowRateMax()); + csvData += QString("dialysateFlowRateMin,%0\n").arg(dialysateFlowRateMin()); + csvData += QString("dialysateFlowRateMax,%0\n").arg(dialysateFlowRateMax()); + csvData += QString("durationMin,%0\n").arg(durationMin()); + csvData += QString("durationMax,%0\n").arg(durationMax()); + csvData += QString("heparinDispensingRateMin,%0\n").arg(heparinDispensingRateMin()); + csvData += QString("heparinDispensingRateMax,%0\n").arg(heparinDispensingRateMax()); + csvData += QString("heparinBolusVolumeMin,%0\n").arg(heparinBolusVolumeMin()); + csvData += QString("heparinBolusVolumeMax,%0\n").arg(heparinBolusVolumeMax()); + csvData += QString("heparinStopTimeMin,%0\n").arg(heparinStopTimeMin()); + csvData += QString("heparinStopTimeMax,%0\n").arg(heparinStopTimeMax()); + csvData += QString("salineBolusVolumeMin,%0\n").arg(salineBolusVolumeMin()); + csvData += QString("salineBolusVolumeMax,%0\n").arg(salineBolusVolumeMax()); + csvData += QString("acidConcentrateOptions,%0\n").arg(acidConcentrateOptions().join(sep)); + csvData += QString("bicarbonateConcentrateOptions,%0\n").arg(bicarbonateConcentrateOptions().join(sep)); + csvData += QString("dialyzerTypeOptions,%0\n").arg(dialyzerTypeOptions().join(sep)); + csvData += QString("dialysateTempMin,%0\n").arg(dialysateTempMin()); + csvData += QString("dialysateTempMax,%0\n").arg(dialysateTempMax()); + csvData += QString("arterialPressureLimitLowMin,%0\n").arg(arterialPressureLimitLowMin()); + csvData += QString("arterialPressureLimitLowMax,%0\n").arg(arterialPressureLimitLowMax()); + csvData += QString("arterialPressureLimitHighMin,%0\n").arg(arterialPressureLimitHighMin()); + csvData += QString("arterialPressureLimitHighMax,%0\n").arg(arterialPressureLimitHighMax()); + csvData += QString("venousPressureLimitLowMin,%0\n").arg(venousPressureLimitLowMin()); + csvData += QString("venousPressureLimitLowMax,%0\n").arg(venousPressureLimitLowMax()); + csvData += QString("venousPressureLimitHighMin,%0\n").arg(venousPressureLimitHighMin()); + csvData += QString("venousPressureLimitHighMax,%0\n").arg(venousPressureLimitHighMax()); + csvData += QString("bloodPressureMeasureIntervalMin,%0\n").arg(bloodPressureMeasureIntervalMin()); + csvData += QString("bloodPressureMeasureIntervalMax,%0\n").arg(bloodPressureMeasureIntervalMax()); + csvData += QString("rinsebackFlowRateMin,%0\n").arg(rinsebackFlowRateMin()); + csvData += QString("rinsebackFlowRateMax,%0\n").arg(rinsebackFlowRateMax()); + + return csvData; +} + +/*! + * \brief VCreateTreatment::saveTreatmentRangesCSV + * \details Saves the treatment ranges to a CSV file + * \param filename - the csv file to save the ranges to + * \return bool - true if successful, false otherwise + */ +bool VTreatmentCreate::saveTreatmentRangesCSV(const QString &filename) +{ + QString csvData = getParameterRangesDataCSV(); + return FileHandler::write(filename, csvData); +} + +/** + * \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) +{ + 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 (!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 + */ +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); +} + +/*! + * \brief VCreateTreatment::doGetOperatingParameterNames + * Gets a list of the operating parameter names + * \return (QStringList) The list of operating parameter names + */ +QStringList VTreatmentCreate::doGetOperatingParameterNames() +{ + return QStringList() << "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 aConcentrate; + QString bCarbConcentrate; + QString dType; + if ((acidConcentrateOptions().length() - 1 < (int)_acidConcentrate)) + aConcentrate = "None"; + else + aConcentrate = acidConcentrateOptions().at(acidConcentrate()); + if ((bicarbonateConcentrateOptions().length() - 1 < (int)_bicarbonateConcentrate)) + bCarbConcentrate = "None"; + else + bCarbConcentrate = bicarbonateConcentrateOptions().at(bicarbonateConcentrate()); + if ((dialyzerTypeOptions().length() - 1 < (int)_dialyzerType) || ((int)_dialyzerType < 0)) + dType = "None"; + else + dType = dialyzerTypeOptions().at(dialyzerType()); + return QStringList() << aConcentrate + << bCarbConcentrate + << dType + << 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 min").arg(_rinsebackFlowRate); +} + +/** + * \brief VCreateTreatment::doCancelConfirmParameters + * \details Notifies FW the user has canceled confirming the treatment parameters + * \note Telling FW user is canceling confirm treatment parameters... + */ +void VTreatmentCreate::doCancelConfirmParameters() +{ + confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eCancel; + emit didAdjustment(confirmTreatmentRequest); +} Index: sources/view/VTreatmentCreate (legacy).h =================================================================== diff -u --- sources/view/VTreatmentCreate (legacy).h (revision 0) +++ sources/view/VTreatmentCreate (legacy).h (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -0,0 +1,258 @@ +#pragma once + +// Qt +#include +#include +#include +#include +#include +#include + +// Project +#include "MPreTreatmentAdjustParametersValidationResponse.h" +#include "GuiController.h" +#include "StorageGlobals.h" +#include "FileSaver.h" + +// forward diclations +class tst_views; + +using namespace Storage; +using namespace Gui; +using namespace Model; + +#define UNSET 9999 + +namespace View { + +/*! + * \brief The VCreateTreatment class + * + * The Create Treatment View manages the pre-treatment parameter selection entry and validation. + * + * \details The Create Treatment View manages data display and translation between the user interface + * and treatment parameter and treatment parameter response models. + * + * Upon HD messaging with confirmation of the current parameter selection, + * the Create Treatment View segues to the Create Treatment confirmation screen. + * + * Upon HD messaging with a list of one or more invalid parameters, the Create Treatment View + * will signal the invalid parameters to the GUI so the user can make adjustments. + * + * The Create Treatment View replicates the validation function used by FW to mitigate + * incompatible parameter selection situations. + * + * When a user modifies treatment parameters: + * - The treatment parameters model is populated with the data + * - The data is validated for correctness and compatibility + * - The continue button is enabled upon success so FW can validate the parameter selection + * + * \sa Model::MAdjustParametersValidationResponse + * \sa Model::MAdjustParametersConfirmReq + * \sa Model::MInitTreatmentReq + * \sa Model::MConfirmTreatmentReq + * \sa Model::MAdjustInitTreatmentResponse + */ +class VTreatmentCreate : public QObject +{ + Q_OBJECT + + // friends + friend class::tst_views; + +public: + explicit VTreatmentCreate(QObject *parent = nullptr); + +private: + + // mL/min + const quint32 bloodFlowRate_Def = 100 ; // PRS 30 + const quint32 bloodFlowRate_Min = 100 ; // PRS 30 + const quint32 bloodFlowRate_Max = 500 ; // PRS 30 + const quint32 bloodFlowRate_Res = 25 ; // PRS 30 + + // mL/min + const quint32 dialysateFlowRate_Def = 100 ; // PRS 345 + const quint32 dialysateFlowRate_Min = 100 ; // PRS 345 + const quint32 dialysateFlowRate_Max = 600 ; // PRS 345 + const quint32 dialysateFlowRate_Res = 50 ; // PRS 345 + + // minutes + const quint32 duration_Def = 60 ; // PRS 346 + const quint32 duration_Min = 60 ; // PRS 346 + const quint32 duration_Max = 480 ; // PRS 346 + const quint32 duration_Res = 15 ; // PRS 346 + + // mL/hr (0 = off) + const qreal heparinDispensingRate_Def = 0.0 ; // PRS 347 + const qreal heparinDispensingRate_Min = 0.0 ; // PRS 347 + const qreal heparinDispensingRate_Max = 1.0 ; // PRS 347 + const qreal heparinDispensingRate_Res = 0.1 ; // PRS 347 + + // mL + const qreal heparinBolusVolume_Def = 0.0 ; // PRS 348 + const qreal heparinBolusVolume_Min = 0.0 ; // PRS 348 + const qreal heparinBolusVolume_Max = 2.0 ; // PRS 348 + const qreal heparinBolusVolume_Res = 0.1 ; // PRS 348 + + // min + const quint32 heparinStopTime_Def = 0 ; // PRS 464 + const quint32 heparinStopTime_Min = 0 ; // PRS 464 + const quint32 heparinStopTime_Max = 480 ; // PRS 464 + const quint32 heparinStopTime_Res = 10 ; // PRS 464 + + // mL + const quint32 salineBolusVolume_Def = 100 ; // PRS 350 + const quint32 salineBolusVolume_Min = 100 ; // PRS 350 + const quint32 salineBolusVolume_Max = 300 ; // PRS 350 + const quint32 salineBolusVolume_Res = 100 ; // PRS 350 + + const quint32 acidConcentrate_Res = 1 ; // PRS 35 + + const quint32 bicarbonateConcentrate_Res = 1 ; // PRS 351 + + const quint32 dialyzerType_Res = 1 ; // PRS 352 + + // Celsius + const qreal dialysateTemp_Def = 37 ; // PRS 353 + const qreal dialysateTemp_Min = 35 ; // PRS 353 + const qreal dialysateTemp_Max = 38 ; // PRS 353 + const qreal dialysateTemp_Res = 0.5 ; // PRS 353 + + // mmHg + const qint32 arterialPressureLimitLow_Min = -300 ; // PRS 354 + const qint32 arterialPressureLimitLow_Max = 0 ; // PRS 354 + const qint32 arterialPressureLimitLow_Res = 10 ; // PRS 354 + const qint32 arterialPressureLimitLow_Def = -300 ; // PRS 354 + + // mmHg + const qint32 arterialPressureLimitHigh_Min = -300 ; // PRS 355 + const qint32 arterialPressureLimitHigh_Max = 0 ; // PRS 355 + const qint32 arterialPressureLimitHigh_Res = 10 ; // PRS 355 + const qint32 arterialPressureLimitHigh_Def = 0 ; // PRS 355 + + // mmHg + const qint32 venousPressureLimitLow_Min = 20 ; // PRS 356 + const qint32 venousPressureLimitLow_Max = 600 ; // PRS 356 + const qint32 venousPressureLimitLow_Res = 10 ; // PRS 356 + const qint32 venousPressureLimitLow_Def = 20 ; // PRS 356 + + // mmHg + const qint32 venousPressureLimitHigh_Min = 20 ; // PRS 357 + const qint32 venousPressureLimitHigh_Max = 600 ; // PRS 357 + const qint32 venousPressureLimitHigh_Res = 10 ; // PRS 357 + const qint32 venousPressureLimitHigh_Def = 400 ; // PRS 357 + + // min + const quint32 bloodPressureMeasureInterval_Def = 30 ; // PRS 358 + const quint32 bloodPressureMeasureInterval_Min = 15 ; // PRS 358 + const quint32 bloodPressureMeasureInterval_Max = 60 ; // PRS 358 + const quint32 bloodPressureMeasureInterval_Res = 5 ; // PRS 358 + + // mL/min + const quint32 rinsebackFlowRate_Def = 75 ; // PRS 359 + const quint32 rinsebackFlowRate_Min = 50 ; // PRS 359 + const quint32 rinsebackFlowRate_Max = 150 ; // PRS 359 + const quint32 rinsebackFlowRate_Res = 25 ; // PRS 359 + + enum ACID_ENUM { + eAcidUnset = -1, + eAcid01 = 0, + eAcid02 , + eAcid03 , + }; + + enum BICARBONATE_ENUM { + eBicarbUnset= -1, + eBicarb01 = 0, + + }; + + enum DIALYZER_ENUM { + eDialyzerUnset = -1, + eDialyzer01 = 0, + eDialyzer02 , + eDialyzer03 , + + }; + +protected: + TREATMENT_PARAMETER(quint32, bloodFlowRate, bloodFlowRate_Def, bloodFlowRate_Min, bloodFlowRate_Max, bloodFlowRate_Res) + TREATMENT_PARAMETER(quint32, dialysateFlowRate, dialysateFlowRate_Def, dialysateFlowRate_Min, dialysateFlowRate_Max, dialysateFlowRate_Res) + TREATMENT_PARAMETER(quint32, duration, duration_Def, duration_Min, duration_Max, duration_Res) + TREATMENT_PARAMETER(qreal, heparinDispensingRate, heparinDispensingRate_Def, heparinDispensingRate_Min, heparinDispensingRate_Max, heparinDispensingRate_Res) + TREATMENT_PARAMETER(qreal, heparinBolusVolume, heparinBolusVolume_Def, heparinBolusVolume_Min, heparinBolusVolume_Max, heparinBolusVolume_Res) + TREATMENT_PARAMETER(quint32, heparinStopTime, heparinStopTime_Def, heparinStopTime_Min, heparinStopTime_Max, heparinStopTime_Res) + TREATMENT_PARAMETER(quint32, salineBolusVolume, salineBolusVolume_Def, salineBolusVolume_Min, salineBolusVolume_Max, salineBolusVolume_Res) + + TREATMENT_PARAMETER(quint32, acidConcentrate, eAcidUnset, eAcid01, eAcid03, acidConcentrate_Res) + TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, eBicarbUnset, eBicarb01, eBicarb01, bicarbonateConcentrate_Res) + TREATMENT_PARAMETER(quint32, dialyzerType, eDialyzerUnset, eDialyzer01, eDialyzer03, dialyzerType_Res) + + TREATMENT_PARAMETER(qreal, dialysateTemp, dialysateTemp_Def, dialysateTemp_Min, dialysateTemp_Max, dialysateTemp_Res) + TREATMENT_PARAMETER(qint32, arterialPressureLimitLow, arterialPressureLimitLow_Def, arterialPressureLimitLow_Min, arterialPressureLimitLow_Max, arterialPressureLimitLow_Res) + TREATMENT_PARAMETER(qint32, arterialPressureLimitHigh, arterialPressureLimitHigh_Def, arterialPressureLimitHigh_Min, arterialPressureLimitHigh_Max, arterialPressureLimitHigh_Res) + TREATMENT_PARAMETER(qint32, venousPressureLimitLow, venousPressureLimitLow_Def, venousPressureLimitLow_Min, venousPressureLimitLow_Max, venousPressureLimitLow_Res) + TREATMENT_PARAMETER(qint32, venousPressureLimitHigh, venousPressureLimitHigh_Def, venousPressureLimitHigh_Min, venousPressureLimitHigh_Max, venousPressureLimitHigh_Res) + TREATMENT_PARAMETER(quint32, bloodPressureMeasureInterval, bloodPressureMeasureInterval_Def, bloodPressureMeasureInterval_Min, bloodPressureMeasureInterval_Max, bloodPressureMeasureInterval_Res) + TREATMENT_PARAMETER(quint32, rinsebackFlowRate, rinsebackFlowRate_Def, rinsebackFlowRate_Min, rinsebackFlowRate_Max, rinsebackFlowRate_Res) + +protected: + + PROPERTY(QStringList, acidConcentrateOptions, + QStringList() << "08-1251-1" + << "08-2251-0" + << "08-3251-9" + ) + PROPERTY(QStringList, bicarbonateConcentrateOptions, + QStringList() << "Dimesol - BC-201" + ) + PROPERTY(QStringList, dialyzerTypeOptions, + QStringList() << "Nipro Elisio-H 17" + << "Nipro Elisio-H 19" + << "Fresenius Optiflux F160NRe" + << "Fresenius Optiflux F180NRe" + ) + + PROPERTY(bool, continueEnabled, false) + PROPERTY(bool, saveTreatmentProfile, false) + + AdjustParametersValidationRequestData treatmentData; // OK + AdjustParametersConfirmRequestData confirmTreatmentRequest; + + bool validate(const AdjustParametersValidationRequestData &vData); + QString saveNewTreatment(const QJsonObject &obj, const QString &dir = Treatment_Profiles_Dir); + QString getParameterRangesDataCSV(); + bool saveTreatmentRangesCSV(const QString &filename); + QJsonObject loadTreatmentParameterRanges(const QString &path = Treatment_Parameter_Ranges_Path_JSON); + QStringList jsonArrayToStringList(const QJsonArray &arr); + void setTreatmentData(); + +private: + QString enumToString(GuiRequestReasons vEnum); + +signals: + void didAdjustment(const AdjustParametersValidationRequestData &data); + void didAdjustment(const AdjustParametersConfirmRequestData &data); + + void resetCreateTreatment(); + void fwValidationFailed(QString reason); + void fwValidationSuccess(); + void scrollToParameter(QString parameter); + void requestConcurrentSave(QString, QString, bool); + +private slots: + bool onActionReceive(AdjustParametersValidationResponseData data); + +public slots: + void doResetCreateTreatment(); + void doFinishedCreate(); + void doFinishedConfirm(); + void doUserModifiedParameters(); + QStringList doGetPrescriptionParameterNames(); + QStringList doGetPrescriptionParameterValues(); + QStringList doGetOperatingParameterNames(); + QStringList doGetOperatingParameterValues(); + void doCancelConfirmParameters(); +}; +} Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -rbd01334f257c35b96b7b232beacbcd7fae60c852 -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision bd01334f257c35b96b7b232beacbcd7fae60c852) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -24,100 +24,14 @@ using namespace View; using namespace Storage; - VTreatmentCreate::VTreatmentCreate(QObject *parent) : QObject(parent) { - connect(&_FileSaver, SIGNAL(fileSaved(bool)), - this, SLOT(onFinishedSaveNewTreatment(bool))); - - connect(this, SIGNAL(requestValidateParameters(AdjustParametersValidationRequestData)), - &_GuiController, SLOT(doAdjustment(AdjustParametersValidationRequestData))); - - connect(&_GuiController, SIGNAL(didActionReceive(AdjustParametersValidationResponseData)), - this, SLOT(doActionReceive(AdjustParametersValidationResponseData))); - - connect(this, SIGNAL(requestSelectParameters(AdjustInitTreatmentRequestData)), - &_GuiController, SLOT(doAdjustment(AdjustInitTreatmentRequestData))); - - connect(this, SIGNAL(requestConfirm(AdjustParametersConfirmRequestData)), - &_GuiController, SLOT(doAdjustment(AdjustParametersConfirmRequestData))); - - connect(&_GuiController, SIGNAL(didActionReceive(AdjustInitTreatmentResponseData)), - this, SLOT(doActionReceive(AdjustInitTreatmentResponseData))); - - connect(this, SIGNAL(requestConcurrentSave(QString,QString,bool)), - &_FileSaver, SLOT(onConcurrentSave(QString,QString,bool))); - - loadTreatmentParameterRanges(); + ADJUST_VIEW_CONNECTION(AdjustParametersValidationRequestData ) + ACTION_VIEW_CONNECTION(AdjustParametersValidationResponseData) + ADJUST_VIEW_CONNECTION( AdjustParametersConfirmRequestData) } /** - * \brief VCreateTreatment::loadTreatmentParameterRanges - * Loads treatment parameters from a json file - * \return QJsonObject holding the treatment parameters - */ -QJsonObject VTreatmentCreate::loadTreatmentParameterRanges(const QString &path) -{ - QJsonObject obj; - if (!FileHandler::read(path, obj)) - { - // TODO: notify user - LOG_EVENT(tr("Could not load treatment parameter ranges from %1").arg(path)); - return QJsonObject(); - } - - foreach (const QString& key, obj.keys()) - { - QJsonValue value = obj.value(key); - - if (key == GET_VARIABLE_NAME(bloodFlowRateMin)) _bloodFlowRateMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(bloodFlowRateMax)) _bloodFlowRateMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(dialysateFlowRateMin)) _dialysateFlowRateMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(dialysateFlowRateMax)) _dialysateFlowRateMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(durationMin)) _durationMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(durationMax)) _durationMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinDispensingRateMin)) _heparinDispensingRateMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinDispensingRateMax)) _heparinDispensingRateMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinBolusVolumeMin)) _heparinBolusVolumeMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinBolusVolumeMax)) _heparinBolusVolumeMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinStopTimeMin)) _heparinStopTimeMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(heparinStopTimeMax)) _heparinStopTimeMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(salineBolusVolumeMin)) _salineBolusVolumeMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(salineBolusVolumeMax)) _salineBolusVolumeMax = value.toInt(); - // options - else if (key == GET_VARIABLE_NAME(acidConcentrateOptions)) _acidConcentrateOptions = jsonArrayToStringList(value.toArray()); - else if (key == GET_VARIABLE_NAME(bicarbonateConcentrateOptions)) _bicarbonateConcentrateOptions = jsonArrayToStringList(value.toArray()); - else if (key == GET_VARIABLE_NAME(dialyzerTypeOptions)) _dialyzerTypeOptions = jsonArrayToStringList(value.toArray()); - - else if (key == GET_VARIABLE_NAME(dialysateTempMin)) _dialysateTempMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(dialysateTempMax)) _dialysateTempMax = value.toInt(); - // arterial - else if (key == GET_VARIABLE_NAME(arterialPressureLimitLowMin)) _arterialPressureLimitLowMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(arterialPressureLimitLowMax)) _arterialPressureLimitLowMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(arterialPressureLimitHighMin)) _arterialPressureLimitHighMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(arterialPressureLimitHighMax)) _arterialPressureLimitHighMax = value.toInt(); - // venous - else if (key == GET_VARIABLE_NAME(venousPressureLimitLowMin)) _venousPressureLimitLowMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(venousPressureLimitLowMax)) _venousPressureLimitLowMax = value.toInt(); - else if (key == GET_VARIABLE_NAME(venousPressureLimitHighMin)) _venousPressureLimitHighMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(venousPressureLimitHighMax)) _venousPressureLimitHighMax = value.toInt(); - - else if (key == GET_VARIABLE_NAME(bloodPressureMeasureIntervalMin)) _bloodPressureMeasureIntervalMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(bloodPressureMeasureIntervalMax)) _bloodPressureMeasureIntervalMax = value.toInt(); - - else if (key == GET_VARIABLE_NAME(rinsebackFlowRateMin)) _rinsebackFlowRateMin = value.toInt(); - else if (key == GET_VARIABLE_NAME(rinsebackFlowRateMax)) _rinsebackFlowRateMax = value.toInt(); - else - { - qDebug() << "Invalid treatment parameter range: " << key; - LOG_EVENT(tr("Invalid treatment parameter found: %0").arg(key)); - } - } - - return obj; -} - -/** * \brief VCreateTreatment::onResetCreateTreatment * Resets the create treatment page to the default values. * Disables the continue button. @@ -147,23 +61,7 @@ emit resetCreateTreatment(); } - /** - * \brief VCreateTreatment::jsonArrayToStringList - * Converts a jsonarray of strings to a QStringList - * \param arr (QJsonArray) to convert - * \return (QStringList) The list of strings in the array - */ -QStringList VTreatmentCreate::jsonArrayToStringList(const QJsonArray &arr) -{ - QStringList result; - foreach (const QJsonValue &val, arr) { - result.append(val.toString()); - } - return result; -} - -/** * \brief VCreateTreatment::setTreatmentData * Assigns treatment parameters to the treatment data structure. */ @@ -190,25 +88,43 @@ } /** - * \brief VCreateTreatment::onFinishedCreate + * \brief VCreateTreatment::doValidation * Validates the treatment profile locally, then requests validation of it with FW */ -void VTreatmentCreate::doFinishedCreate() { +void VTreatmentCreate::doValidation() { setTreatmentData(); if (!validate(treatmentData)) { - qDebug() << "Local create treatment validation failed."; LOG_EVENT("Local create treatment validation failed."); return; } // Request that FW validates the selected parameters - emit requestValidateParameters(treatmentData); + emit didAdjustment(treatmentData); +} - LOG_DEBUG("Requesting FW validation of new treatment parameters"); +/** + * \brief VCreateTreatment::doConfirm + * \details Emits treatment data to GUI controller, + * who emits to application controller + * \note Finished create treatment confirm... + */ +void VTreatmentCreate::doConfirm() { + confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eConfirm; + emit didAdjustment(confirmTreatmentRequest); +} +/** + * \brief VCreateTreatment::doCancel + * \details Notifies FW the user has canceled confirming the treatment parameters + * \note Telling FW user is canceling confirm treatment parameters... + */ +void VTreatmentCreate::doCancel() +{ + confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eCancel; + emit didAdjustment(confirmTreatmentRequest); } /** @@ -235,8 +151,7 @@ * \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::doActionReceive(AdjustParametersValidationResponseData data) { - +bool VTreatmentCreate::onActionReceive(AdjustParametersValidationResponseData data) { bool success = true; if (data.bloodFlowRate != Gui::GuiRequestReasons::REQUEST_REJECT_REASON_NONE) { emit scrollToParameter(GET_VARIABLE_NAME(data.bloodFlowRate)); @@ -334,436 +249,41 @@ if (success) { emit fwValidationSuccess(); - - // goToNextPage(true); } return success; } /** - * \brief VCreateTreatment::doActionReceive - * Called when we receive a response back from firmware after requesting - * to start selecting treatment parameters, cancel, or start the treatment - * @param messageData - */ -void VTreatmentCreate::doActionReceive(const AdjustInitTreatmentResponseData &messageData) -{ - if (messageData.mAccepted != 1) - return; - - if (initTreatmentRequest.requestedState == AdjustInitTreatmentRequestData::eCancel) { - //goToNextPage(false); - } - else { - //goToNextPage(true); - } -} - -/** - * \brief VCreateTreatment::getNextPage - * \details Updates the current page to the next page after - * moving forward or backward - * \param forward - (bool) true if moving forward, if false pop the page - */ -void VTreatmentCreate::goToNextPage(bool forward) -{ - qDebug() << __FUNCTION__ << pageToShow; - - switch (pageToShow) - { - case None: { - // coco begin validated: Has been manually validated - if (forward) { - pageToShow = CreateTreatment; - emit showCreate(); - } - break; - } -// coco end - case CreateTreatment: { - if (forward) { - pageToShow = ConfirmTreatment; - emit showConfirm(); - } - else { - pageToShow = None; - emit pop(); - } - break; - } - case ConfirmTreatment: { - if (forward) { - pageToShow = Priming; - emit showPrime(); - } else { - pageToShow = CreateTreatment; - emit pop(); - } - break; - } - case Priming: { - if (forward) { - pageToShow = BeginTreatment; - emit showBegin(); - } else { - pageToShow = ConfirmTreatment; // TODO: won't be able to go back eventually - emit pop(); - } - break; - } - case BeginTreatment: { - if (forward) { - // reset for next time a treatment is created - pageToShow = None; - emit showTreatmentStart(); - } else { - pageToShow = Priming; - emit pop(); - } - break; - } - // coco begin validated: This has been validated manually. - default: { - LOG_EVENT("Invalid current page."); - } - } -} -// coco end - -/** - * \brief VCreateTreatment::onFinishedConfirm - * \details Emits treatment data to gui controller, - * who emits to application controller and the - * application controller will save the data to disk. - * \note Finished create treatment confirm... - */ -void VTreatmentCreate::doFinishedConfirm() { - QJsonObject obj { - {"bloodFlowRate", QString::number(treatmentData.bloodFlowRate)}, - {"dialysateFlowRate", QString::number(treatmentData.dialysateFlowRate)}, - {"duration", QString::number(treatmentData.duration)}, - {"heparinDispensingRate", QString::number(treatmentData.heparinDispensingRate)}, - {"heparinBolusVolume", QString::number(treatmentData.heparinBolusVolume)}, - {"heparinStopTime", QString::number(treatmentData.heparinStopTime)}, - {"acidConcentrate", QString::number(treatmentData.acidConcentrate)}, - {"bicarbonateConcentrate", QString::number(treatmentData.bicarbonateConcentrate)}, - {"dialyzerType", QString::number(treatmentData.dialyzerType)}, - {"dialysateTemp", QString::number(treatmentData.dialysateTemp)}, - {"arterialPressureLimitLow", QString::number(treatmentData.arterialPressureLimitLow)}, - {"arterialPressureLimitHigh", QString::number(treatmentData.arterialPressureLimitHigh)}, - {"venousPressureLimitLow", QString::number(treatmentData.venousPressureLimitLow)}, - {"venousPressureLimitHigh", QString::number(treatmentData.venousPressureLimitHigh)}, - {"bloodPressureMeasureInterval",QString::number(treatmentData.bloodPressureMeasureInterval)}, - {"rinsebackFlowRate", QString::number(treatmentData.rinsebackFlowRate)} - }; - - QString treatmentParameters = QJsonDocument(obj).toJson(QJsonDocument::Indented); - LOG_EVENT(QString("Create Treatment Confirm: %1").arg(treatmentParameters)); - if (saveTreatmentProfile()) - saveNewTreatment(obj); - - // Tell FW we confirm - confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eConfirm; - emit requestConfirm(confirmTreatmentRequest); - - // no FW response required - // goToNextPage(true); -} - -/** - * \brief ApplicationController::saveNewTreatment - * \details Saves a new treatment to the file system. - * \param doc - QJsonDocument containing the new treatment parameters. - * \returns QString - the file to be written to - * - */ -QString VTreatmentCreate::saveNewTreatment(const QJsonObject &obj, const QString &dir) -{ - QJsonDocument document(obj); - int i = 0; - while (QFile(QString("%0treatment%1.json").arg(dir).arg(i)).exists()) - { - i++; - } - QString filename = QString("%0treatment%1.json").arg(dir).arg(i); - emit requestConcurrentSave(filename, document.toJson(), false); - return filename; -} - -/** - * \brief VCreateTreatment::getParameterRangesDataCSV - * \details Gets the parameter ranges data prepared for CSV file format - * \return QString - the data to write to CSV - */ -QString VTreatmentCreate::getParameterRangesDataCSV() -{ - QString csvData; - QString sep = ","; - - csvData += QString("bloodFlowRateMin,%0\n").arg(bloodFlowRateMin()); - csvData += QString("bloodFlowRateMax,%0\n").arg(bloodFlowRateMax()); - csvData += QString("dialysateFlowRateMin,%0\n").arg(dialysateFlowRateMin()); - csvData += QString("dialysateFlowRateMax,%0\n").arg(dialysateFlowRateMax()); - csvData += QString("durationMin,%0\n").arg(durationMin()); - csvData += QString("durationMax,%0\n").arg(durationMax()); - csvData += QString("heparinDispensingRateMin,%0\n").arg(heparinDispensingRateMin()); - csvData += QString("heparinDispensingRateMax,%0\n").arg(heparinDispensingRateMax()); - csvData += QString("heparinBolusVolumeMin,%0\n").arg(heparinBolusVolumeMin()); - csvData += QString("heparinBolusVolumeMax,%0\n").arg(heparinBolusVolumeMax()); - csvData += QString("heparinStopTimeMin,%0\n").arg(heparinStopTimeMin()); - csvData += QString("heparinStopTimeMax,%0\n").arg(heparinStopTimeMax()); - csvData += QString("salineBolusVolumeMin,%0\n").arg(salineBolusVolumeMin()); - csvData += QString("salineBolusVolumeMax,%0\n").arg(salineBolusVolumeMax()); - csvData += QString("acidConcentrateOptions,%0\n").arg(acidConcentrateOptions().join(sep)); - csvData += QString("bicarbonateConcentrateOptions,%0\n").arg(bicarbonateConcentrateOptions().join(sep)); - csvData += QString("dialyzerTypeOptions,%0\n").arg(dialyzerTypeOptions().join(sep)); - csvData += QString("dialysateTempMin,%0\n").arg(dialysateTempMin()); - csvData += QString("dialysateTempMax,%0\n").arg(dialysateTempMax()); - csvData += QString("arterialPressureLimitLowMin,%0\n").arg(arterialPressureLimitLowMin()); - csvData += QString("arterialPressureLimitLowMax,%0\n").arg(arterialPressureLimitLowMax()); - csvData += QString("arterialPressureLimitHighMin,%0\n").arg(arterialPressureLimitHighMin()); - csvData += QString("arterialPressureLimitHighMax,%0\n").arg(arterialPressureLimitHighMax()); - csvData += QString("venousPressureLimitLowMin,%0\n").arg(venousPressureLimitLowMin()); - csvData += QString("venousPressureLimitLowMax,%0\n").arg(venousPressureLimitLowMax()); - csvData += QString("venousPressureLimitHighMin,%0\n").arg(venousPressureLimitHighMin()); - csvData += QString("venousPressureLimitHighMax,%0\n").arg(venousPressureLimitHighMax()); - csvData += QString("bloodPressureMeasureIntervalMin,%0\n").arg(bloodPressureMeasureIntervalMin()); - csvData += QString("bloodPressureMeasureIntervalMax,%0\n").arg(bloodPressureMeasureIntervalMax()); - csvData += QString("rinsebackFlowRateMin,%0\n").arg(rinsebackFlowRateMin()); - csvData += QString("rinsebackFlowRateMax,%0\n").arg(rinsebackFlowRateMax()); - - return csvData; -} - -/*! - * \brief VCreateTreatment::saveTreatmentRangesCSV - * \details Saves the treatment ranges to a CSV file - * \param filename - the csv file to save the ranges to - * \return bool - true if successful, false otherwise - */ -bool VTreatmentCreate::saveTreatmentRangesCSV(const QString &filename) -{ - QString csvData = getParameterRangesDataCSV(); - return FileHandler::write(filename, csvData); -} - -void VTreatmentCreate::onFinishedSaveNewTreatment(bool success) -{ - if (success) { - qDebug() << "------------------> Saved a new treatment."; - } else { - qDebug() << "------------------> Failed to save new treatment."; - } -} - -/** - * \brief VCreateTreatment::onFnishedPrime - * \details Called when priming qml selections are complete. - * \note Finished create treatment prime... - * \todo Placed here for now. Likely will be moved eventually. - */ -void VTreatmentCreate::doFinishedPrime() { - // goToNextPage(true); -} - -/** - * \brief VCreateTreatment::start - * \details Called when user is ready to begin a new treatment. - */ -void VTreatmentCreate::doStartTreatment() { - qDebug() << "Requesting to start a treatment..."; - initTreatmentRequest.requestedState = AdjustInitTreatmentRequestData::eInitiate; - emit requestSelectParameters(initTreatmentRequest); -} - -/** * \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) { - bool success = true; - - if (!isbloodFlowRateSet) - success = false; - - if (!isdialysateFlowRateSet) - success = false; - - if (!isdurationSet) - success = false; - - if (!isheparinDispensingRateSet) - success = false; - - if (!isheparinBolusVolumeSet) - success = false; - - if (!isheparinStopTimeSet) - success = false; - - if (!issalineBolusVolumeSet) - success = false; - - if (!isacidConcentrateSet) - success = false; - - if (!isbicarbonateConcentrateSet) - success = false; - - if (!isdialyzerTypeSet) - success = false; - - if (!isdialysateTempSet) - success = false; - - if (!isarterialPressureLimitLowSet) - success = false; - - if (!isarterialPressureLimitHighSet) - success = false; - - if (!isvenousPressureLimitLowSet) - success = false; - - if (!isvenousPressureLimitHighSet) - success = false; - - if (!isbloodPressureMeasureIntervalSet) - success = false; - - if (!isrinsebackFlowRateSet) - success = false; - - if (!success) { - return false; - } - if (vData.bloodFlowRate < _bloodFlowRateMin || - vData.bloodFlowRate > _bloodFlowRateMax) - { - emit bloodFlowRate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.dialysateFlowRate < _dialysateFlowRateMin || - vData.dialysateFlowRate > _dialysateFlowRateMax ) - { - emit dialysateFlowRate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.duration < _durationMin || vData.duration > _durationMax) - { - emit duration_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.heparinDispensingRate < _heparinDispensingRateMin || - vData.heparinDispensingRate > _heparinDispensingRateMax) - { - emit heparinDispensingRate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.heparinBolusVolume < _heparinBolusVolumeMin || - vData.heparinBolusVolume > _heparinBolusVolumeMax) - { - emit heparinBolusVolume_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - - if (vData.heparinStopTime < _heparinStopTimeMin || - vData.heparinStopTime > _heparinStopTimeMax) - { - emit heparinStopTime_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - - if (vData.salineBolus < _salineBolusVolumeMin || - vData.salineBolus > _salineBolusVolumeMax) - { - emit salineBolusVolume_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (!indexInItems(vData.acidConcentrate, _acidConcentrateOptions)) - { - emit acidConcentrate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (!indexInItems(vData.bicarbonateConcentrate, _bicarbonateConcentrateOptions)) - { - emit bicarbonateConcentrate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (!indexInItems(vData.dialyzerType, _dialyzerTypeOptions)) - { - emit dialyzerType_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.dialysateTemp < _dialysateTempMin || - vData.dialysateTemp > _dialysateTempMax) - { - emit dialysateTemp_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.arterialPressureLimitLow < _arterialPressureLimitLowMin || - vData.arterialPressureLimitLow > _arterialPressureLimitLowMax || - vData.arterialPressureLimitLow >= vData.arterialPressureLimitHigh) - { - emit arterialPressureLimitLow_ValidationFailed(uiRejections.value(LOW_HIGH_INCOMPATIBLE)); - success = false; - } - if (vData.arterialPressureLimitHigh < _arterialPressureLimitHighMin || - vData.arterialPressureLimitHigh > _arterialPressureLimitHighMax || - vData.arterialPressureLimitHigh <= vData.arterialPressureLimitLow) - { - emit arterialPressureLimitHigh_ValidationFailed(uiRejections.value(LOW_HIGH_INCOMPATIBLE)); - success = false; - } - if (vData.venousPressureLimitLow < _venousPressureLimitLowMin || - vData.venousPressureLimitLow > _venousPressureLimitLowMax || - vData.venousPressureLimitLow >= vData.venousPressureLimitHigh) - { - emit venousPressureLimitLow_ValidationFailed(uiRejections.value(LOW_HIGH_INCOMPATIBLE)); - success = false; - } - if (vData.venousPressureLimitHigh < _venousPressureLimitHighMin || - vData.venousPressureLimitHigh > _venousPressureLimitHighMax || - vData.venousPressureLimitHigh <= vData.venousPressureLimitLow) - { - emit venousPressureLimitHigh_ValidationFailed(uiRejections.value(LOW_HIGH_INCOMPATIBLE)); - success = false; - } - if (vData.bloodPressureMeasureInterval < _bloodPressureMeasureIntervalMin || - vData.bloodPressureMeasureInterval > _bloodPressureMeasureIntervalMax) - { - emit bloodPressureMeasureInterval_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - if (vData.rinsebackFlowRate < _rinsebackFlowRateMin || - vData.rinsebackFlowRate > _rinsebackFlowRateMax) - { - emit rinsebackFlowRate_ValidationFailed(uiRejections.value(OUT_OF_RANGE)); - success = false; - } - return success; + 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 (!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::indexInItems - * \details Checks if the index is in the QStringList - * \param idx (int) the index - * \param items (QStringList) The list of strings to check - * \return True if it is in the list, false otherwise - */ -bool VTreatmentCreate::indexInItems(quint32 idx, const QStringList &items) -{ - if (idx > (quint32)items.size() - 1) - return false; - else - return true; -} - -/** * \brief VCreateTreatment::doUserModifiedParameters * Manages enabling / disabling the continue button */ @@ -837,6 +357,7 @@ QString aConcentrate; QString bCarbConcentrate; QString dType; + qDebug() << acidConcentrateOptions().length(); if ((acidConcentrateOptions().length() - 1 < (int)_acidConcentrate)) aConcentrate = "None"; else @@ -860,46 +381,3 @@ << QString("%0 min").arg(_bloodPressureMeasureInterval) << QString("%0 min").arg(_rinsebackFlowRate); } - -/** - * \brief VCreateTreatment::doSelectParameters - * \details Sends a request to FW to start selecting treatment parameters - * \note Sending request to FW to select parameters... - */ -void VTreatmentCreate::doSelectParameters() -{ - initTreatmentRequest.requestedState = AdjustInitTreatmentRequestData::eInitiate; - emit requestSelectParameters(initTreatmentRequest); -} - -/** - * \brief VCreateTreatment::doCancelSelectingParameters - * \details Sends a request to FW to cancel selecting parameters - * \note Sending request to FW to cancel selecting parameters... - */ -void VTreatmentCreate::doCancelSelectingParameters() -{ - initTreatmentRequest.requestedState = AdjustInitTreatmentRequestData::eCancel; - emit requestSelectParameters(initTreatmentRequest); -} - -/** - * \brief VCreateTreatment::doCancelConfirmParameters - * \details Notifies FW the user has canceled confirming the treatment parameters - * \note Telling FW user is canceling confirm treatment parameters... - */ -void VTreatmentCreate::doCancelConfirmParameters() -{ - confirmTreatmentRequest.requestedState = AdjustParametersConfirmRequestData::eCancel; - emit requestConfirm(confirmTreatmentRequest); - // goToNextPage(false); -} - -/** - * \brief VCreateTreatment::doRequestPop - * \details Navigates backward in the create treatment process. - */ -void VTreatmentCreate::doRequestPop() -{ - // goToNextPage(false); -} Index: sources/view/VTreatmentCreate.h =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- sources/view/VTreatmentCreate.h (.../VTreatmentCreate.h) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ sources/view/VTreatmentCreate.h (.../VTreatmentCreate.h) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -1,5 +1,4 @@ -#ifndef VCREATETREATMENT_H -#define VCREATETREATMENT_H +#pragma once // Qt #include @@ -157,29 +156,27 @@ const quint32 rinsebackFlowRate_Res = 25 ; // PRS 359 enum ACID_ENUM { - eAcid01 = 0, - eAcid02, - eAcid03, - - eAcidUnset = 9999, + eAcidUnset = 9999, + eAcid01 = 0, + eAcid02 , + eAcid03 , }; enum BICARBONATE_ENUM { - eBicarb01 = 0, + eBicarbUnset= 9999, + eBicarb01 = 0, - eBicarbUnset = 9999, }; enum DIALYZER_ENUM { - eDialyzer01 = 0, - eDialyzer02, - eDialyzer03, - eDialyzerUnset = 9999, + eDialyzer01 = 0, + eDialyzer02 , + eDialyzer03 , + }; protected: - TREATMENT_PARAMETER(quint32, bloodFlowRate, bloodFlowRate_Def, bloodFlowRate_Min, bloodFlowRate_Max, bloodFlowRate_Res) TREATMENT_PARAMETER(quint32, dialysateFlowRate, dialysateFlowRate_Def, dialysateFlowRate_Min, dialysateFlowRate_Max, dialysateFlowRate_Res) TREATMENT_PARAMETER(quint32, duration, duration_Def, duration_Min, duration_Max, duration_Res) @@ -202,92 +199,47 @@ protected: - PROPERTY(QStringList, acidConcentrateOptions, QStringList() << "08-1251-1" << "08-2251-0" << "08-3251-9") - PROPERTY(QStringList, bicarbonateConcentrateOptions, QStringList() << "Dimesol - BC-201") - PROPERTY(QStringList, dialyzerTypeOptions, QStringList() << "Nipro Elisio-H 17" - << "Nipro Elisio-H 19" - << "Fresenius Optiflux F160NRe" - << "Fresenius Optiflux F180NRe") + PROPERTY(QStringList, acidConcentrateOptions , QStringList() << "08-1251-1" + << "08-2251-0" + << "08-3251-9") + PROPERTY(QStringList, bicarbonateConcentrateOptions , QStringList() << "Dimesol - BC-201") + PROPERTY(QStringList, dialyzerTypeOptions , QStringList() << "Nipro Elisio-H 17" + << "Nipro Elisio-H 19" + << "Fresenius Optiflux F160NRe" + << "Fresenius Optiflux F180NRe") PROPERTY(bool, continueEnabled, false) - PROPERTY(bool, saveTreatmentProfile, false) - AdjustParametersValidationRequestData treatmentData; + AdjustParametersValidationRequestData treatmentData; // OK + AdjustParametersConfirmRequestData confirmTreatmentRequest; + bool validate(const AdjustParametersValidationRequestData &vData); - QString saveNewTreatment(const QJsonObject &obj, const QString &dir = Treatment_Profiles_Dir); - QString getParameterRangesDataCSV(); - bool saveTreatmentRangesCSV(const QString &filename); - QJsonObject loadTreatmentParameterRanges(const QString &path = Treatment_Parameter_Ranges_Path_JSON); - QStringList jsonArrayToStringList(const QJsonArray &arr); - bool indexInItems(quint32 idx, const QStringList &items); void setTreatmentData(); private: - - enum UIRejectReasons { - OUT_OF_RANGE, - LOW_HIGH_INCOMPATIBLE - }; - - enum Page { - None, - CreateTreatment, - ConfirmTreatment, - Priming, - BeginTreatment - }; - - QHash uiRejections { - { OUT_OF_RANGE, "The selected value is out of range." }, - { LOW_HIGH_INCOMPATIBLE, "The low and high selections are incompatible." }, - - }; - - Page pageToShow = None; - QString enumToString(GuiRequestReasons vEnum); - AdjustInitTreatmentRequestData initTreatmentRequest; - AdjustParametersConfirmRequestData confirmTreatmentRequest; - void goToNextPage(bool forward); - -private slots: - void onFinishedSaveNewTreatment(bool result); - signals: - void showCreate(); - void showConfirm(); - void showPrime(); - void showBegin(); - void pop(); - void showTreatmentStart(); - void requestValidateParameters(const AdjustParametersValidationRequestData &data); - void requestConfirm(const AdjustParametersConfirmRequestData &data); - void requestSelectParameters(const AdjustInitTreatmentRequestData &data); + void didAdjustment(const AdjustParametersValidationRequestData &data); + void didAdjustment(const AdjustParametersConfirmRequestData &data); + void resetCreateTreatment(); void fwValidationFailed(QString reason); void fwValidationSuccess(); void scrollToParameter(QString parameter); - void requestConcurrentSave(QString, QString, bool); +private slots: + bool onActionReceive(AdjustParametersValidationResponseData data); + public slots: void doResetCreateTreatment(); - void doFinishedCreate(); - void doFinishedConfirm(); - void doFinishedPrime(); - void doStartTreatment(); - bool doActionReceive(AdjustParametersValidationResponseData data); - void doActionReceive(const AdjustInitTreatmentResponseData &messageData); + void doValidation(); + void doConfirm(); + void doCancel(); void doUserModifiedParameters(); QStringList doGetPrescriptionParameterNames(); QStringList doGetPrescriptionParameterValues(); QStringList doGetOperatingParameterNames(); QStringList doGetOperatingParameterValues(); - void doSelectParameters(); - void doCancelConfirmParameters(); - void doCancelSelectingParameters(); - void doRequestPop(); }; } - -#endif // VCREATETREATMENT_H Index: unittests/tst_views.cpp =================================================================== diff -u -rc8de9dc4cb679628ac9c0c9551bc43ad3c415d4a -r7cc15ae5968205b241a08ca4646f283b8bf97b03 --- unittests/tst_views.cpp (.../tst_views.cpp) (revision c8de9dc4cb679628ac9c0c9551bc43ad3c415d4a) +++ unittests/tst_views.cpp (.../tst_views.cpp) (revision 7cc15ae5968205b241a08ca4646f283b8bf97b03) @@ -136,7 +136,7 @@ QCOMPARE(view.bloodPressureMeasureInterval(), view.bloodPressureMeasureIntervalMax()); QCOMPARE(view.rinsebackFlowRate(), view.rinsebackFlowRateMax()); - view.doFinishedCreate(); + view.doValidation(); } else { QCOMPARE(view.validate(view.treatmentData), false); @@ -395,7 +395,7 @@ } QCOMPARE(view.validate(view.treatmentData), false); - view.doFinishedCreate(); + view.doValidation(); } view.dialyzerType(-1); QVERIFY(!(view.dialyzerTypeOptions().length() - 1 < (int)view.dialyzerType())); @@ -733,32 +733,23 @@ if (i == 15) respData.heparinDispensingRate = 1; else respData.heparinDispensingRate = 0; if (i == 16) respData.heparinBolusVolume = 1; else respData.heparinBolusVolume = 0; if (i == 17) respData.dialysateTemp = 1; else respData.dialysateTemp = 0; - QVERIFY(!view.doActionReceive(respData)); + QVERIFY(!view.onActionReceive(respData)); } AdjustParametersValidationRequestData dataBackup = view.treatmentData; AdjustParametersValidationResponseData respData; - AdjustInitTreatmentResponseData startResponse; + QVERIFY(view.onActionReceive(respData)); - startResponse.startTreatmentResponse = 0; // REJECT - view.doActionReceive(startResponse); - QCOMPARE(view.pageToShow, View::VTreatmentCreate::Page::None); - - QVERIFY(view.doActionReceive(respData)); - view.saveTreatmentProfile(false); QVERIFY(!view._saveTreatmentProfile); - view.doFinishedConfirm(); + view.doConfirm(); view.saveTreatmentProfile(true); QVERIFY(view._saveTreatmentProfile); - view.doFinishedConfirm(); + view.doConfirm(); - view.onFinishedSaveNewTreatment(true); - view.onFinishedSaveNewTreatment(false); - view.doFinishedPrime(); view.doStartTreatment(); QCOMPARE(view.treatmentData.bloodFlowRate, dataBackup.bloodFlowRate);