/*!
 *
 * Copyright (c) 2020-2023 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    ConfirmTreatmentTable.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      18-Jul-2023
 * \author  (original)  Peter Lucia
 * \date    (original)  22-Sep-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

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

Item { id: _root
    objectName: "ConfirmTreatmentTable"
    width: Variables.createTreatmentTableWidth
    height: Variables.createTreatmentTableHeight

    Rectangle {
        id: _header
        width: parent.width
        height: Variables.createTreatmentHeaderHeight
        color: Colors.transparent
        radius: Variables.dialogRadius

        Rectangle {
            id: _treatment_profile_id
            objectName: _root.objectName + "_treatment_profile_id"
            height: 40
            width: height
            anchors.top: _header.top
            anchors.left: _header.left
            anchors.topMargin: Variables.createTreatmentMargin
            anchors.leftMargin: Variables.createTreatmentMargin
            color: Colors.createTrProfileID
            radius: Variables.dialogRadius

            Text {
                id: _treatment_profile_id_text
                objectName: _treatment_profile_id.objectName + "_treatment_profile_id_text"
                color: Colors.backgroundDialog
                text: "1"
                font.pixelSize: Fonts.fontPixelTextRectTitle
                anchors.centerIn: _treatment_profile_id
                font.bold: true
            }
        }

        Text {
            id: _treatment_profile_name
            objectName: _root.objectName + "_treatment_profile_name"
            anchors.bottom: _treatment_profile_id.bottom
            anchors.left: _treatment_profile_id.right
            anchors.topMargin: Variables.createTreatmentMargin
            anchors.leftMargin: 20
            text: qsTr("New Treatment")
            color: Colors.textMain
            font.pixelSize: Fonts.fontPixelCreateTreatment
        }
    }

    Text {
        id: _prescription
        objectName: _root.objectName + "_prescription"
        text: qsTr("PRESCRIPTION")
        font.pixelSize: Fonts.fontPixelCreateTreatmentTable
        color: Colors.textMain
        anchors.left: parent.left
        anchors.top: _header.bottom
        anchors.leftMargin: Variables.createTreatmentMargin
    }

    Text {
        id: _operating_parameters
        objectName: _root.objectName + "_operating_parameters"
        text: qsTr("OPERATING PARAMETERS")
        font.pixelSize: Fonts.fontPixelCreateTreatmentTable
        color: Colors.textMain
        anchors.top: _header.bottom
        anchors.left: _root.horizontalCenter
    }

    ConfirmTreatmentSubTable {
        id: _left_table
        anchors.top: _prescription.bottom
        anchors.left: _root.left
        anchors.leftMargin: Variables.createTreatmentMargin
        // Disabled for now since the rows changed for the A/V change and doesn't need scrolling
        // anchors.topMargin: Variables.createTreatmentTableMargin
        anchors.bottom: parent.bottom
        width: parent.width - 2*Variables.createTreatmentMargin
        height: _root.height - _header.height
        prescriptionKeys    : [ qsTr("Blood Flow Rate"                  ),
                                qsTr("Dialysate Flow Rate"              ),
                                qsTr("Duration"                         ),
                                qsTr("Heparin Dispensing Rate"          ),
                                qsTr("Heparin Bolus Volume"             ),
                                qsTr("Heparin Stop Time"                ),
                                qsTr("Saline Bolus Volume"              )]
        prescriptionValues  : vTreatmentCreate.doGetPrescriptionParameterValues()

        operatingKeys       : [ qsTr("Heparin Type"                     ),
                                qsTr("Acid Concentrate"                 ),
                                qsTr("Bicarbonate Concentrate"          ),
                                qsTr("Dialyzer Type"                    ),
                                qsTr("Dialysate Temperature"            ),
                                qsTr("Blood Pressure Measure Interval"  )]
        operatingValues     : vTreatmentCreate.doGetOperatingParameterValues()

        onVisibleChanged: {
            if (visible) {
                prescriptionValues  = vTreatmentCreate.doGetPrescriptionParameterValues()
                operatingValues     = vTreatmentCreate.doGetOperatingParameterValues()
            }
        }
    }
}
