/*!
 *
 * Copyright (c) 2021-2024 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    PreTreatmentPrime.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      31-Aug-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  01-Mar-2021
 *
 */

// Qt
import QtQuick 2.12

// Project
//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"
import "qrc:/pages/pretreatment"

/*!
 * \brief   The Pre Tretreatment Prime Screen
 */
PreTreatmentBase { id: _root
    objectName: "_PreTreatmentPrime"

    enum Prime {
        BloodTubeCircuit    = 0,
        DialysateCircuit    = 1,
        DialysatePurge      = 2,
        PrimingFluidDiscard = 3,
        Complete            = 4
    }

    isComplete              : vPreTreatmentDisposablesPrime.primeComplete // PRIME_COMPLETE_STATE
    completeText            : qsTr("Priming Complete!")

    // time circle
    hasTimeCircle           : true
    timeCircleMinimum       : 0
    timeCircleMaximum       : vPreTreatmentDisposablesPrime.total
    timeCircleProgressValue : vPreTreatmentDisposablesPrime.elapsed
    timeCircleTimeTextValue : vPreTreatmentDisposablesPrime.countDown * 60

    // chcek list
    hasCheckList            : true
    checkListStepNames      : [
        qsTr("Blood Tubing Circuit Priming" ),
        qsTr("Dialysate Circuit Priming"    ),
        qsTr("Dialysate Purge"              ),
        qsTr("Priming Fluid Discard"        ),
    ]

    onVisibleChanged: if (visible) checkList.resetItems()

    Item {
        anchors.top: parent.top
        anchors.left: parent.left
        width: 40
        height: 40
        Text {
            color: Colors.offWhite
            text: vPreTreatmentDisposablesPrime.state
            anchors.centerIn: parent
        }
    }

    Connections { target: vPreTreatmentDisposablesPrime
        function onPrimeBloodCircuitChanged                 ( vValue ) { print("onPrimeBloodCircuitChanged " + vValue)
                            checkList.setItemExt(PreTreatmentPrime.BloodTubeCircuit    , vValue        )
        }

        function onPrimeBloodCircuitStartChanged            ( vValue ) { checkList.setItemExt(PreTreatmentPrime.BloodTubeCircuit    , true          )}
        function onPrimeBloodCircuitEndChanged              ( vValue ) { checkList.setItemExt(PreTreatmentPrime.BloodTubeCircuit    , vValue        )}
        function onPrimeDialysateCircuitStartChanged        ( vValue ) { checkList.setItemExt(PreTreatmentPrime.DialysateCircuit    , true          )}
        function onPrimeDialysateCircuitEndChanged          ( vValue ) { checkList.setItemExt(PreTreatmentPrime.DialysateCircuit    , vValue        )}
        function onPrimeDialysatePurgeStartChanged          ( vValue ) { checkList.setItemExt(PreTreatmentPrime.DialysatePurge      , true          )}
        function onPrimeDialysatePurgeEndChanged            ( vValue ) { checkList.setItemExt(PreTreatmentPrime.DialysatePurge      , vValue        )}
        function onPrimePrimingFluidDiscardStartChanged     ( vValue ) { checkList.setItemExt(PreTreatmentPrime.PrimingFluidDiscard , vValue        )}
        function onPrimePrimingFluidDiscardEndChanged       ( vValue ) { checkList.setItemExt(PreTreatmentPrime.Complete            , vValue        )}
    }
}
