#ifndef VCREATETREATMENT_H #define VCREATETREATMENT_H // Qt #include #include #include #include #include #include // Project #include "MTreatmentParameters.h" #include "MTreatmentParametersResp.h" #include "guicontroller.h" #include "storageglobals.h" #include "filesaver.h" // forward diclations class tst_views; using namespace Storage; using namespace Gui; namespace View { /*! * \brief The VCreateTreatment class * * The Create Treatment View manages the treatment parameter selection entry and validation. * * 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 * */ class VCreateTreatment : public QObject { Q_OBJECT // friends friend class::tst_views; public: explicit VCreateTreatment(QObject *parent = nullptr); protected: TREATMENT_PARAMETER(quint32, bloodFlowRate, 100) // mL/min TREATMENT_PARAMETER(quint32, dialysateFlowRate, 100) // mL/min TREATMENT_PARAMETER(quint32, duration, 60) // minutes TREATMENT_PARAMETER(quint32, heparinDispensingRate, 0) // mL/hr TREATMENT_PARAMETER(quint32, heparinBolusVolume, 100) // mL TREATMENT_PARAMETER(quint32, heparinStopTime, 1000) // mL TREATMENT_PARAMETER(quint32, salineBolusVolume, 9999) // mL TREATMENT_PARAMETER(quint32, acidConcentrate, 9999) // lookup idx TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, 9999) // lookup idx TREATMENT_PARAMETER(quint32, dialyzerType, 9999) // lookup idx TREATMENT_PARAMETER(quint32, dialysateTemp, 35) // Celsius TREATMENT_PARAMETER(qint32, arterialPressureLimitLow, 0) // mmHg TREATMENT_PARAMETER(qint32, arterialPressureLimitHigh, 0) // mmHg TREATMENT_PARAMETER(qint32, venousPressureLimitLow, 0) // mmHg TREATMENT_PARAMETER(qint32, venousPressureLimitHigh, 0) // mmHg TREATMENT_PARAMETER(quint32, bloodPressureMeasureInterval, 0) // minutes TREATMENT_PARAMETER(quint32, rinsebackFlowRate, 50) // mL/min protected: // ranges PROPERTY(quint32, bloodFlowRateMin, 100) PROPERTY(quint32, bloodFlowRateMax, 500) PROPERTY(quint32, dialysateFlowRateMin, 100) PROPERTY(quint32, dialysateFlowRateMax, 600) PROPERTY(quint32, durationMin, 60) PROPERTY(quint32, durationMax, 480) PROPERTY(quint32, heparinDispensingRateMin, 0) PROPERTY(quint32, heparinDispensingRateMax, 1000) PROPERTY(quint32, heparinBolusVolumeMin, 100) PROPERTY(quint32, heparinBolusVolumeMax, 2000) PROPERTY(quint32, heparinStopTimeMin, 1000) PROPERTY(quint32, heparinStopTimeMax, 2000) PROPERTY(QStringList, salineBolusOptions, QStringList() << "100 mL" << "200 mL" << "300 mL") 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(quint32, dialysateTempMin, 35) PROPERTY(quint32, dialysateTempMax, 39) PROPERTY(qint32, arterialPressureLimitLowMin, -300) PROPERTY(qint32, arterialPressureLimitLowMax, 200) PROPERTY(qint32, arterialPressureLimitHighMin, -300) PROPERTY(qint32, arterialPressureLimitHighMax, 200) PROPERTY(qint32, venousPressureLimitLowMin, -100) PROPERTY(qint32, venousPressureLimitLowMax, 600) PROPERTY(qint32, venousPressureLimitHighMin, 0) PROPERTY(qint32, venousPressureLimitHighMax, 600) PROPERTY(quint32, bloodPressureMeasureIntervalMin, 0) PROPERTY(quint32, bloodPressureMeasureIntervalMax, 30) PROPERTY(quint32, rinsebackFlowRateMin, 50) PROPERTY(quint32, rinsebackFlowRateMax, 150) PROPERTY(bool, continueEnabled, false) PROPERTY(bool, saveTreatmentProfile, false) AdjustTreatmentParametersData treatmentData; bool validate(const AdjustTreatmentParametersData &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); QStringList jsonArrayToStringList(const QJsonArray &arr); bool indexInItems(quint32 idx, const QStringList &items); void setTreatmentData(); private: enum UIRejectReasons { OUT_OF_RANGE, LOW_HIGH_INCOMPATIBLE }; QHash uiRejections { { OUT_OF_RANGE, "The selected value is out of range." }, { LOW_HIGH_INCOMPATIBLE, "The low and high selections are incompatible." }, }; QString enumToString(GuiRequestReasons vEnum); private slots: void onFinishedSaveNewTreatment(bool result); signals: void didCreateTreatment(const AdjustTreatmentParametersData &data); void showConfirm(); void showPrime(); void showBegin(); void validateParamsWithFW(const GuiActionType &action, const QVariantList &data); void resetCreateTreatment(); void fwValidationFailed(QString reason); public slots: void onResetCreateTreatment(); void onFinishedCreate(); void onFinishedConfirm(); void onFinishedPrime(); void onStart(); bool onFWValidationResponse(const GuiActionType &actionType, const QVariantList &messageData); void onUserModifiedParameters(); }; } #endif // VCREATETREATMENT_H