#ifndef VCREATETREATMENT_H #define VCREATETREATMENT_H // Qt #include #include #include #include #include #include // Project #include "MTreatmentParametersResp.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 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 VTreatmentCreate : public QObject { Q_OBJECT // friends friend class::tst_views; public: explicit VTreatmentCreate(QObject *parent = nullptr); protected: // Def Min Max Res TREATMENT_PARAMETER(quint32, bloodFlowRate, 100, 100, 500, 25 ) // mL/min TREATMENT_PARAMETER(quint32, dialysateFlowRate, 100, 100, 600, 50 ) // mL/min TREATMENT_PARAMETER(quint32, duration, 60, 60, 480, 15 ) // minutes TREATMENT_PARAMETER(qreal, heparinDispensingRate, 0, 0.1, 1.0, 0.1) // mL/hr (0 = off) TREATMENT_PARAMETER(qreal, heparinBolusVolume, 0, 0.1, 2.0, 0.1) // mL (0 = off) TREATMENT_PARAMETER(quint32, heparinStopTime, 0, 0, 480, 10 ) // min TREATMENT_PARAMETER(quint32, salineBolusVolume, 100, 100, 300, 100) // mL TREATMENT_PARAMETER(quint32, acidConcentrate, UNSET, 0, 3, 1) TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, UNSET, 0, 1, 1) TREATMENT_PARAMETER(quint32, dialyzerType, UNSET, 0, 3, 1) TREATMENT_PARAMETER(qreal, dialysateTemp, 37, 35, 38, 0.5) // Celsius TREATMENT_PARAMETER(qint32, arterialPressureLimitLow, -300, -300, 200, 10) // mmHg TREATMENT_PARAMETER(qint32, arterialPressureLimitHigh, 100, -300, 200, 10) // mmHg TREATMENT_PARAMETER(qint32, venousPressureLimitLow, -100, -100, 600, 10) // mmHg TREATMENT_PARAMETER(qint32, venousPressureLimitHigh, 400, 100, 600, 10) // mmHg TREATMENT_PARAMETER(quint32, bloodPressureMeasureInterval, 30, 15, 60, 5) // minutes TREATMENT_PARAMETER(quint32, rinsebackFlowRate, 75, 50, 150, 25) // mL/min 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) AdjustTreatmentParametersRequestData treatmentData; bool validate(const AdjustTreatmentParametersRequestData &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 }; 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); StartTreatmentRequestData startTreatmentRequest; ConfirmTreatmentRequestData 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 AdjustTreatmentParametersRequestData &data); void requestConfirm(const ConfirmTreatmentRequestData &data); void requestSelectParameters(const StartTreatmentRequestData &data); void resetCreateTreatment(); void fwValidationFailed(QString reason); void scrollToParameter(QString parameter); void requestConcurrentSave(QString, QString, bool); public slots: void onResetCreateTreatment(); void onFinishedCreate(); void onFinishedConfirm(); void onFinishedPrime(); void onStartTreatment(); bool onFWValidationResponse(AdjustTreatmentParametersResponseData data); void onStartTreatmentResponse(const StartTreatmentResponseData &messageData); void onUserModifiedParameters(); QStringList getPrescriptionParameterNames(); QStringList getPrescriptionParameterValues(); QStringList getOperatingParameterNames(); QStringList getOperatingParameterValues(); void onSelectingParameters(); void onCancelSelectingParameters(); void onRequestPop(); }; } #endif // VCREATETREATMENT_H