/*!
 *
 * 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 TreatmentHeparin.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      17-Nov-2020
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  17-Nov-2020
 *
 */

// Qt
import QtQuick 2.12

// Project
import VTreatmentHeparin 0.1;

//  Qml imports
import "qrc:/globals"
import "qrc:/components"

/*!
 * \brief   Treatment Screen Heparin Management section
 */
TreatmentFluid { id: _root
    readonly property bool isOff            : vHDTreatmentStates.hpOff
    readonly property bool isPaused         : vHDTreatmentStates.hpPaused
    readonly property bool isBolus          : vHDTreatmentStates.hpInitial_bolus
    readonly property bool isDispensing     : vHDTreatmentStates.hpDispensing
    readonly property bool isCompleted      : vHDTreatmentStates.hpCompleted
    readonly property bool isEmpty          : vHDTreatmentStates.hpEmpty

    readonly property bool isTxRunning      : vHDTreatmentStates.txDialysis

    QtObject { id: _private
        readonly property string textHeparin        : qsTr("HEPARIN DELIVERY")
        readonly property string textPause          : qsTr("PAUSE DELIVERY")
        readonly property string textResume         : qsTr("RESUME DELIVERY")
        readonly property string textVolumeTarget   : "(" + valueTarget + unit + ")"
        readonly property string mesgBolus          : qsTr("Heparin bolus is active")
        readonly property string mesgCompleted      : qsTr("Maximum cumulative heparin volume delivered")
        readonly property string mesgEmpty          : qsTr("Heparin syringe empty")
        readonly property string mesgOff            : qsTr("Heparin delivery Off")
        readonly property string mesgRejectReason   : vTreatmentAdjustmentHeparin.adjustment_ReasonText
    }

    title   : qsTr("HEPARIN")
    cumulativeVisible: false

    hasArrow    : false
    targetVisible: false
    progressBarVisible: false

    isTouchable : ! (isOff || isBolus || isEmpty) && ! isSBInProgress && isTxRunning
    buttonText  : ! isTxRunning   ? _private.textHeparin  :
                    isDispensing  ? _private.textPause    :
                    isPaused      ? _private.textResume   :
                    isCompleted   ? _private.textResume   :
                                    _private.textHeparin
    unit        : Variables.unitTextSaline

    valueDelivered: vTreatmentHeparin.cumulative.toFixed(1) // this is the cumulative volume of the Heparin bolus and despensing.

    VTreatmentHeparin  { id: vTreatmentHeparin }

    onClicked: {
        vTreatmentAdjustmentHeparin.doAdjustment()
    }

    notification {
        visible : true
        text    : isBolus       ? _private.mesgBolus        :
                  isOff         ? _private.mesgOff          :
                  isCompleted   ? _private.mesgCompleted    :
                  isEmpty       ? _private.mesgEmpty        :
                                  _private.mesgRejectReason
    }
}
