ui file:

/*----------------------------------------------------
 |   This file was generated by Sense Composer 2.0   |
 |  Do not modify the Sense Composer Generated Code  |
 ----------------------------------------------------*/
#pragma once

#include <Sense.h>
#include <ExperienceIdentity.h>
#include "CustomControls.h"

namespace Sense {
    namespace Composer
    {

        using namespace Sense;
        using namespace Sense::ExperienceIdentity;
        using namespace MVSUI::CustomControls;

        class ResolvePatientMixup : public Dialog
        {
        public:

            ResolvePatientMixup(Control &parent)
                :
                Dialog(parent)
		#pragma region Sense Composer (do not modify)
	,	labelText        (*this)
	,	tabPatientData   (*this)
	,	tabPageScheduleExams(tabPatientData)
	,	tabPageReviewExams(tabPatientData)
	,	labelInfoText    (*this)
	,	buttonCancel     (*this)
	,	buttonConfirm    (*this)
	,	imageBoxInfoIcon (*this)
		#pragma endregion
            {
		#pragma region Sense Composer (do not modify)
		layoutUpdateBegin();
		name                             = L"ResolvePatientMixup";
		size                             = Size(1591.2, 828.96);
		font                             = Font(L"Philips Healthcare Font", 15.36, false, false, false, false, Font::Antialias::High, 0);
		text                             = L"Resolve Patient Mix - Select Destination Exam";
		labelText.name                   = L"labelText";
		labelText.position               = Point(34.08, 43.12);
		labelText.size                   = Size(1112, 20);
		labelText.font                   = Font(L"Philips Healthcare Font", 15.36, false, false, false, false, Font::Antialias::High, 0);
		labelText.text                   = L"Make sure the destination exam is in the schedule or review list. If not, click \'Cancel,\' add it to the scheduled list, and re-initiate this process.";
		tabPatientData.name              = L"tabPatientData";
		tabPatientData.position          = Point(34.56, 101.76);
		tabPatientData.size              = Size(1522.28, 570.24);
		tabPatientData.font              = Font(L"Philips Healthcare Font", 15.36, false, false, false, false, Font::Antialias::High, 0);
		tabPatientData.headerFont        = Font(L"Philips Healthcare Font", 14.4, false, false, false, false, Font::Antialias::High, 0);
		tabPatientData.headerHeight      = 39.84;
		tabPageScheduleExams.name        = L"tabPageScheduleExams";
		tabPageScheduleExams.font        = Font(L"Philips Healthcare Font", 32, false, false, false, false, Font::Antialias::High, 0);
		tabPageScheduleExams.text        = L"Schedule exams";
		tabPageScheduleExams.minimumWidth = 240.96;
		tabPageScheduleExams.maximumWidth = 240.96;
		tabPageReviewExams.name          = L"tabPageReviewExams";
		tabPageReviewExams.font          = Font(L"Philips Healthcare Font", 32, false, false, false, false, Font::Antialias::High, 0);
		tabPageReviewExams.text          = L"Review exams";
		tabPageReviewExams.minimumWidth  = 240.96;
		tabPageReviewExams.maximumWidth  = 240.96;
		labelInfoText.name               = L"labelInfoText";
		labelInfoText.position           = Point(56.16, 714.24);
		labelInfoText.size               = Size(1020, 19);
		labelInfoText.font               = Font(L"Philips Healthcare Font", 14.4, false, false, false, false, Font::Antialias::High, 0);
		labelInfoText.text               = L"Please note that the dose value of the source and destination exams may not be accurate since \u2018Resolve Patient Mix\u2019 does not change the dose value.";
		//buttonCancel.composerClass     = Button;
		buttonCancel.name                = L"buttonCancel";
		buttonCancel.position            = Point(1372.32, 696.96);
		buttonCancel.size                = Size(184.32, 54.24);
		buttonCancel.font                = Font(L"Philips Healthcare Font", 15.36, false, false, false, false, Font::Antialias::High, 0);
		buttonCancel.text                = L"Cancel";
		buttonCancel.radius              = Corners(0, 0, 0, 0);
		buttonCancel.border              = Margin(1.01, 1.01, 1.01, 1.01);
		//buttonConfirm.composerClass    = Button;
		buttonConfirm.name               = L"buttonConfirm";
		buttonConfirm.position           = Point(1176.48, 696.96);
		buttonConfirm.size               = Size(184.32, 54.24);
		buttonConfirm.font               = Font(L"Philips Healthcare Font", 15.36, false, false, false, false, Font::Antialias::High, 0);
		buttonConfirm.text               = L"Confirm";
		buttonConfirm.radius             = Corners(0, 0, 0, 0);
		buttonConfirm.border             = Margin(2.02, 2.02, 2.02, 2.02);
		buttonConfirm.glow               = true;
		imageBoxInfoIcon.name            = L"imageBoxInfoIcon";
		imageBoxInfoIcon.position        = Point(34.56, 717.12);
		imageBoxInfoIcon.size            = Size(13.92, 13.92);
		layoutUpdateEnd();
		#pragma endregion
            }

	#pragma region Sense Composer (do not modify)
	public:    Label             labelText;
	public:    Tab               tabPatientData;
	public:    TabPage           tabPageScheduleExams;
	public:    TabPage           tabPageReviewExams;
	public:    Label             labelInfoText;
	public:    FlatButtonEx      buttonCancel;
	public:    FlatButtonEx      buttonConfirm;
	public:    ImageBox          imageBoxInfoIcon;
	#pragma endregion

        private:

            ResolvePatientMixup(const ResolvePatientMixup&) = delete;
            ResolvePatientMixup& operator=(const ResolvePatientMixup&) = delete;
        };
    }
}

view header file
/*************************************************************************************\
*                                                                                   *
*   Filename   : ResolvePatientMixUpView.h                                          *
*                                                                                   *
*  Description : Handles display of the Resolve Patient MixUp View                  *
*                                                                                   *
*  Copyright   : Koninklijke Philips N.V., 2024.                                    *
*                                                                                   *
\*************************************************************************************/
#ifndef RESOLVEPATIENTMIXUPVIEW_h
#define RESOLVEPATIENTMIXUPVIEW_h

#include "Sense.h"
#include "IGuiViewComponent.h"
#include "ModelViewInterface.h"
#include "gui_exp.h"
#include "ui\ResolvePatMixupExamList.ui.h"
#include "IViewEventHandler.h"
#include "CustomControls.h"
#include "ListViewEx.h"

namespace Sense { namespace Composer { class ResolvePatientMixup; } }

namespace MVSUI
{
    struct GuiDataModel;

    class ResolvePatientMixUpView :public IGuiViewComponent , public IEventHandler
    {
    public:
        ResolvePatientMixUpView();
        virtual ~ResolvePatientMixUpView() = default;

        virtual void Destroy()          override;
        virtual int Init()              override;
        virtual int HandleEvent(const GUI_SENSE_EVENT& eventData) override;
        int OnModelUpdated()            override;
        void OnLocaleChanged()          override;
        void BindModel()                override;
        int SetControlIDs()             override;
        int                             InitPatMixupScheduleExamsTab();
        int                             InitPatMixupReviewExamsTab();
        int                             InitPatMixupScheduleExamsListView();
        int                             InitPatMixupReviewExamsListView();

        void OnExamUpdated(const GUI_ADMI_ROW_STRUCT& patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table);
        void UpdateReviewExam(const GUI_ADMI_ROW_STRUCT& patExamData);
        void PopulateReviewExamsListView();

    private:
        void SubscribeToCancel();
        void OnReviewLocaleChanged();
        void OnListHeaderClicked(const ADMI_DATA_LAYER_TABLE_ENUM table, const int columnIndex);

    private:
        std::shared_ptr<GuiDataModel>                            GuiDataModelPtr                   = nullptr;
        std::shared_ptr<Composer::ResolvePatientMixup>           ResolvePatMixUpUIPtr              = nullptr;
        std::shared_ptr<Sense::ExperienceIdentity::TabPage>      ScheduleExamsTabPagePtr           = nullptr;
        std::shared_ptr<ListViewEx>                              ScheduleExamsListViewExPtr        = nullptr;
        std::shared_ptr<Sense::ExperienceIdentity::TabPage>      ReviewExamsTabPagePtr             = nullptr;
        std::shared_ptr<ListViewEx>                              ReviewExamsListViewExPtr          = nullptr;
        std::shared_ptr<Sense::Timer>                            ListSelectionTimerPtr             = nullptr;
    };
}
#endif // RESOLVEPATIENTMIXUPVIEW_h


view cpp file.

//****************************************************************************//
//                                                                            //
//   Filename   : ResolvePatientMixUpView.cpp                                //
//                                                                            //
//   Description: Handles display of the Resolve Patient MixUp View          //
//                                                                            //
//   Copyright  : Koninklijke Philips N.V. 2024.                              //
//                                                                            //
//****************************************************************************//

#include "MainView.h"
#include "ResolvePatientMixUpView.h"
#include "ResolvePatientMixUp.h"
#include "ui\ResolvePatMixupExamList.ui.h"
#include "GuiUtilities.h"
#include "ControlIDs.h"
#include "StringIDs.h"
#include "Resources.h"
#include "ViewLogger.h"
#include "SenseDisplayer.h"
#include "PopupDisplay.h"
#include "UserMouseKeyboardEx.h"
#include "ViewLogger.h"
#include "gui_util.h"
#include "StringConverter.h"
#include "DateUtility.h"
#include "gui_all.h"


namespace MVSUI
{

    constexpr int            SCHEDULELIST_COLUMNCOUNT = 7;
    constexpr int            REVIEWLIST_COLUMNCOUNT = 9;
    constexpr double         IMAGE_SPACING = 30.0;
    const     Sense::Point   SCHED_REVIEW_LEFTPANELPOS = Sense::Point(0.0, 0.0);
    const     Sense::Size    SCHED_REVIEW_LEFTPANELSIZE = Sense::Size(587.0, 1940.0);
    const     Sense::Point   EXAMINFO_BTN_POS_WO_CLOSE = Sense::Point(0.0, 966.0);
    const     Sense::Point   EXAMINFO_BTN_POS_W_CLOSE = Sense::Point(0.0, 1126.0);
    const     Sense::Point   BACKTOACQ_BTN_POS_WO_CLOSE = Sense::Point(0.0, 1126.0);
    const     Sense::Point   BACKTOACQ_BTN_POS_W_CLOSE = Sense::Point(0.0, 1286.0);
    const     Sense::Margin  TEXT_MARGIN = Margin(80.0, 0.0, 0.0, 0.0);
    const     Sense::HAlign  HORIZONTAL_ALIGNMENT = Sense::Composer::HAlign::Left;
    const     Sense::Size    IMAGE_SIZE = Size(52.0, 64.0);                    //left panel button images
    const     Sense::Corners BUTTON_CORNER_RADIUS = Corners(8, 8, 8, 8);
    const     Sense::Font    TEXT_FONT = Font(L"Philips Healthcare Font", 32.0, false, false, false, false, Font::Antialias::High);
    const     Sense::Point   SYSBTN_POS = Sense::Point(745.0, 0.0);
    const     Sense::Point   LOGGEDINUSERBTN_POS = Sense::Point(1.0, 0.0);
    const     Sense::Point   ADDPROFILE_POS = Sense::Point(422.0, 0.0);
    constexpr int            INDEX_NOT_FOUND = -1;
   // extern std::array<bool, static_cast<int>(AdmiSystemMenu::SYS_MENU_NUMBEROFITEMS)> SysMenuItemAvailability;
    const     Sense::Point   ADMIDATAHANDLER_POS = Sense::Point(0.0, 80.0);
    const     Sense::Point   ADMIHEADER_POS = Sense::Point(2535.0, 0.0);
    constexpr int            MULTIPLE_ROW_SELECTED = -2;

    //Controls Positions and Sizes
    const Sense::Point       SCHED_REVIEW_LISTPOS = Sense::Point(587.0, 0.0);
    const Sense::Size        SCHED_REVIEW_LISTSIZE = Sense::Size(3253.0, 1940.0);

    constexpr int            LISTVIEW_SCROLLBAR_SIZE = 28;
    constexpr double         ICON_SIZE = 48.0;
    constexpr double         SCHED_REVIEW_LIST_HEADERHEIGHT = 110.0;
    constexpr double         SCHED_REVIEW_LIST_ITEMHEIGHT = 110.0;
    constexpr bool           CHECKBOX_VISIBILITY = true;
    const     Sense::HAlign  LISTVIEW_ICON_ALIGNMENT = Sense::Composer::HAlign::Center;
    const  Margin            LIST_BORDER_MARGIN = Margin(2, 1, 0, 0);

    const std::wstring       EMPTYSTRING = L"";

    enum class REVIEWLIST_COLUMNINDEX
    {
        REVIEWLIST_COLIDX_ICON = 0,
        REVIEWLIST_COLIDX_NAME,
        REVIEWLIST_COLIDX_SEX,
        REVIEWLIST_COLIDX_DOB,
        REVIEWLIST_COLIDX_PATID,
        REVIEWLIST_COLIDX_EXAMDT,
        REVIEWLIST_COLIDX_EXAMTYPE,
        REVIEWLIST_COLIDX_PHYSICIAN,
        REVIEWLIST_COLIDX_IMAGE,
        REVIEWLIST_COLUMNCOUNT                  // This should be the last item in this enumeration.
    };

    constexpr int REVIEWLIST_COLWIDTH_ICON = 150;
    constexpr int REVIEWLIST_COLWIDTH_NAME = 541;
    constexpr int REVIEWLIST_COLWIDTH_SEX = 170;
    constexpr int REVIEWLIST_COLWIDTH_DOB = 280;
    constexpr int REVIEWLIST_COLWIDTH_PATID = 581;
    constexpr int REVIEWLIST_COLWIDTH_EXAMDT = 294;
    constexpr int REVIEWLIST_COLWIDTH_EXAMTYPE = 423;
    constexpr int REVIEWLIST_COLWIDTH_PHYSICIAN = 581;
    constexpr int REVIEWLIST_COLWIDTH_IMAGE = 200;

    enum class SCHEDULELIST_COLUMNINDEX
    {
        SCHEDULELIST_COLIDX_ICON = 0,
        SCHEDULELIST_COLIDX_NAME,
        SCHEDULELIST_COLIDX_SEX,
        SCHEDULELIST_COLIDX_DOB,
        SCHEDULELIST_COLIDX_PATID,
        SCHEDULELIST_COLIDX_EXAMTYPE,
        SCHEDULELIST_COLIDX_PHYSICIAN,
        SCHEDULELIST_COLUMNCOUNT                // This should be the last item in this enumeration.
    };

    constexpr int SCHEDULELIST_COLWIDTH_ICON = 150;
    constexpr int SCHEDULELIST_COLWIDTH_NAME = 707;
    constexpr int SCHEDULELIST_COLWIDTH_SEX = 181;
    constexpr int SCHEDULELIST_COLWIDTH_DOB = 429;
    constexpr int SCHEDULELIST_COLWIDTH_PATID = 576;
    constexpr int SCHEDULELIST_COLWIDTH_EXAMTYPE = 509;
    constexpr int SCHEDULELIST_COLWIDTH_PHYSICIAN = 668;

    //ResolvePatientMixUpView::ResolvePatientMixUpView() : ListSelectionTimerPtr(nullptr),
    //    ButtonHelpAdmi(nullptr),
    //    PopupUpdatedSubscription(0u)
    //{
    //    SysMenuItemAvailability.fill(false);
    //}

    ResolvePatientMixUpView::ResolvePatientMixUpView():
        GuiDataModelPtr(nullptr) 
    {}

    void ResolvePatientMixUpView::Destroy()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::Destroy");
        ResolvePatMixUpUIPtr.reset();
    }

    int ResolvePatientMixUpView::Init()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::Init");
        if (OK == PopupDisplay::CreatePopupDialog<Composer::ResolvePatientMixup>(ResolvePatMixUpUIPtr))
        {
            BindModel();
            SetControlIDs();
            SubscribeToCancel();
            // Bind existing UI tab page (owned by UI)
            ReviewExamsTabPagePtr = std::shared_ptr<Sense::ExperienceIdentity::TabPage>( &ResolvePatMixUpUIPtr->tabPageReviewExams, [](Sense::ExperienceIdentity::TabPage*) { /* do not delete, owned by UI */ });

            // Create ListViewEx as child of Review tab page, with number of columns equal to your enum
            ReviewExamsListViewExPtr = std::make_shared<ListViewEx>(*ReviewExamsTabPagePtr, REVIEWLIST_COLUMNCOUNT);

            // Initialize appearance and columns
            InitPatMixupReviewExamsListView();

            // Bind selection changed event
            ReviewExamsListViewExPtr->eventSelectionChanged = [this](){OnReviewListSelectionChanged(); };
            
        }
        return OK;
    }

    int ResolvePatientMixUpView::HandleEvent(const GUI_SENSE_EVENT & /*eventData*/)
    {
        ViewLogger::Trace("ResolvePatientMixUpView::HandleEvent");

        return OK;
    }
    
    void ResolvePatientMixUpView::BindModel()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::BindModel");
        GuiDataModelPtr = MainView::Instance().GetGuiDataModel();
        if (!GuiDataModelPtr)
        {
            ViewLogger::Error("BindModel: GuiDataModelPtr is nullptr");
            return;
        }

        GuiDataModelPtr->Admi.ResolvePatMixUp.ModelUpdated = [this] { OnModelUpdated(); };
        GuiDataModelPtr->Admi.ExamUpdated = [this](const GUI_ADMI_ROW_STRUCT& patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table)
        {
            if (table == ADMI_DATA_LAYER_TABLE_ENUM::ADMI_PATMIXUP_REVIEW)
            {
                OnExamUpdated(patExamData, table);
            }
        };
        GuiDataModelPtr->Admi.ResolvePatMixUp.LocaleChanged = [this] { OnLocaleChanged(); };
        ViewLogger::Trace("ResolvePatientMixUpView::BindModel completed");
        
    }

    int ResolvePatientMixUpView::SetControlIDs()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::SetControlIDs");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {
            /*ScheduleExamsTabPagePtr->name = MVSUI::PATMIXUP_SCHEDULE_PAGE;
            ScheduleExamsListViewExPtr->name = MVSUI::PATMIXUP_SCHEDULELIST;
            ReviewExamsTabPagePtr->name = MVSUI::PATMIXUP_REVIEW_PAGE;
            ReviewExamsList->name = MVSUI::PATMIXUP_REVIEWLIST;*/
            /*if (ReviewExamsListViewExPtr)
            {
                ReviewExamsListViewExPtr->name = MVSUI::PATMIXUP_REVIEWLIST;
            }
            else
            {
                OutputDebugStringA("ReviewExamsListViewExPtr is null!\n");
            }*/
            ReviewExamsListViewExPtr->name = MVSUI::PATMIXUP_REVIEWLIST;

        });
        return OK;
    }

    void ResolvePatientMixUpView::SubscribeToCancel()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::SubscribeToCancel");
        ResolvePatMixUpUIPtr->buttonCancel.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.ResolvePatMixUp.Action(ResolvePatMixUpEventTypes::Cancel);
        };
    }

    void ResolvePatientMixUpView::OnReviewLocaleChanged()
    {
    }

    void ResolvePatientMixUpView::OnListHeaderClicked(const ADMI_DATA_LAYER_TABLE_ENUM table, const int columnIndex)
    {
        ViewLogger::Trace("AdmiView::OnListHeaderClicked");

        // Backup current selected Patient ID.
        int currentSelectedPatID = NO_ROW_SELECTED;
        int currentSelectedPatRowIndex = GetSelectedRow(table);
        if (NO_ROW_SELECTED < currentSelectedPatRowIndex)
        {
            currentSelectedPatID = GetPatientIDfromRow(table, currentSelectedPatRowIndex);
        }

        // Sort the list based on Column.
        if (ADMI_TABLE_SCHEDULE == table)
        {
            if (static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_DOB) == columnIndex)
            {
                ScheduleExamsListViewExPtr->Sort(columnIndex, &ResolvePatientMixUpView::SortByDate);
            }
            else
            {
                ScheduleExamsListViewExPtr->Sort(columnIndex);
            }
        }
        else
        {
            if ((static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB) == columnIndex) ||
                (static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT) == columnIndex))
            {
                ReviewExamsListViewExPtr->Sort(columnIndex, &ResolvePatientMixUpView::SortByDate);
            }
            else if (static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE) == columnIndex)
            {
                ReviewExamsListViewExPtr->Sort(columnIndex, &ResolvePatientMixUpView::SortByNoOfImage);
            }
            else
            {
                ReviewExamsListViewExPtr->Sort(columnIndex);
            }
        }
        // Put selection back on previously selected patient.
        if (NO_ROW_SELECTED < currentSelectedPatRowIndex)
        {
            int newRowIndex = FindPatRowIndex(table, currentSelectedPatID);
            SetSelectedRow(table, newRowIndex);
        }
        // Put selection back on previously selected patient.
        if (NO_ROW_SELECTED < currentSelectedPatRowIndex)
        {
            int newRowIndex = FindPatRowIndex(table, currentSelectedPatID);
            SetSelectedRow(table, newRowIndex);
        }
    }

    bool ResolvePatientMixUpView::SortByDate(const ListViewCell& cellLHS, const ListViewCell& cellRHS)
    {
        ViewLogger::Trace("AdmiView::SortByDate");

        int lhs = 0;
        int rhs = 0;

        GUI_BOUNDARY_STRUCT dobYear;
        dobYear.lowerLimit = GUI_DOB_LOWER_LIMIT;
        dobYear.upperLimit = GUI_DOB_UPPER_LIMIT;

        ResolvePatientMixUpView *thisPtr = dynamic_cast<ResolvePatientMixUpView*>(MainView::Instance().GetComponentByID(GUI_SC_WINDOW_ADMI).get());
        OsaTime lhsDate;
        memset(&lhsDate, 0, sizeof(lhsDate));
        if (Utilities::DateUtility::ConvertDateStringToOsaTime(cellLHS.cellText,
            thisPtr->GuiDataModelPtr->Admi.Setup.DateFormat,
            thisPtr->GuiDataModelPtr->LocalePtr,
            lhsDate, 1900))
        {
            lhs = ViewUtilities::GuiUtils::OsaTimeToSortableDate(&lhsDate);
        }

        OsaTime rhsDate;
        memset(&rhsDate, 0, sizeof(rhsDate));
        if (Utilities::DateUtility::ConvertDateStringToOsaTime(cellRHS.cellText,
            thisPtr->GuiDataModelPtr->Admi.Setup.DateFormat,
            thisPtr->GuiDataModelPtr->LocalePtr,
            rhsDate, 1900))
        {
            rhs = ViewUtilities::GuiUtils::OsaTimeToSortableDate(&rhsDate);
        }
        return (lhs < rhs);
    }

    bool ResolvePatientMixUpView::SortByNoOfImage(const ListViewCell& cellLHS, const ListViewCell& cellRHS)
    {
        ViewLogger::Trace("AdmiView::SortByNoOfImage");

        int lhs = std::stoi(cellLHS.cellText);
        int rhs = std::stoi(cellRHS.cellText);

        return (lhs < rhs);
    }

    /*void ResolvePatientMixUpView::SubscribeToListSelectionChanged()
    {
        ViewLogger::Trace("AdmiView::SubscribeToListSelectionChanged");

        ScheduleListViewExPtr->eventSelectionChanged = [this] { OnListSelectionChanged(); };
        ReviewListViewExPtr->eventSelectionChanged = [this] { OnListSelectionChanged(); };
    }*/

    void ResolvePatientMixUpView::OnLocaleChanged()
    {
        MVSUI::ViewLogger::Trace("ResolvePatientMixUpView::OnLocaleChanged");
    }

    int ResolvePatientMixUpView::OnModelUpdated()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::OnModelUpdated");
       
        SenseDisplayer::SyncInvoke(*ResolvePatMixUpUIPtr.get(), [this]
        {
            if (GuiDataModelPtr->Admi.ResolvePatMixUp.Visible)
            {
                UserMouseKeyboardEx::SetActiveEventHandler(this);
                PopupDisplay::ShowDialog(PopupDisplayID::RESOLVE_PATIENT_MIXUP_WINDOW, ResolvePatMixUpUIPtr.get());
            }
            else
            {
                PopupDisplay::HideDialog(PopupDisplayID::RESOLVE_PATIENT_MIXUP_WINDOW);
                UserMouseKeyboardEx::RemoveEventHandler(this);
            }
        });
        PopulateReviewExamsListView();
        return OK;
    }

    void ResolvePatientMixUpView::OnExamUpdated(const GUI_ADMI_ROW_STRUCT & patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table)
    {
        if (table == ADMI_DATA_LAYER_TABLE_ENUM::ADMI_PATMIXUP_SCHEDULE)
        {
           // UpdateScheduleExam(patExamData);
        }
        else if (table == ADMI_DATA_LAYER_TABLE_ENUM::ADMI_PATMIXUP_REVIEW)
        {
            UpdateReviewExam(patExamData);
        }
    }

    void ResolvePatientMixUpView::UpdateReviewExam(const GUI_ADMI_ROW_STRUCT & patExamData)
    {
        SenseDisplayer::SyncInvoke(*ResolvePatMixUpUIPtr, [this, patExamData]
        {
            Row reviewRow;
            Image cellIcon = ExamStateToIcon(patExamData.status,
                patExamData.exportStatus,
                patExamData.worklistStatus);
            reviewRow.AddCell(L" ", cellIcon);

            reviewRow.AddCell(std::wstring(patExamData.patientName));

            char genderChar[2] = { 0 };
            ViewUtilities::GuiUtils::SexEnumToSexString(patExamData.sex, genderChar, static_cast<int>(sizeof(genderChar)), BOOLEAN_TRUE);
            reviewRow.AddCell(Utilities::StringConverter::StringToWstring(genderChar));

            std::wstring dateOfBirth;
            Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.birthDate,
                this->GuiDataModelPtr->Admi.Setup.DateFormat,
                this->GuiDataModelPtr->LocalePtr,
                dateOfBirth);
            reviewRow.AddCell(dateOfBirth);

            if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
            {
                reviewRow.AddCell(patExamData.accNr);
            }
            else
            {
                reviewRow.AddCell(patExamData.regNr);
            }

            std::wstring dateOfExam;
            Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.examDate,
                this->GuiDataModelPtr->Admi.Setup.DateFormat,
                this->GuiDataModelPtr->LocalePtr,
                dateOfExam);
            reviewRow.AddCell(dateOfExam);

            std::wstring examType = L"";
            examType = std::wstring(patExamData.examType);
            if (0 != wcslen(patExamData.detProcType))
            {
                examType = examType + L" - ";
                examType = examType + patExamData.detProcType;
            }
            reviewRow.AddCell(examType);

            reviewRow.AddCell(patExamData.physician);
            reviewRow.AddCell(std::to_wstring(patExamData.nrOfImages));
            reviewRow.SetExtendedData(std::to_wstring(patExamData.patientId));

            int rowIndex = FindPatRowIndex(ADMI_TABLE_REVIEW, patExamData.patientId);
            int currentSelection = GetSelectedRow(ADMI_TABLE_REVIEW);
            if (NO_ROW_SELECTED == rowIndex)
            {
                ReviewExamsListViewExPtr->AddItem(reviewRow);
            }
            else
            {
                ReviewExamsListViewExPtr->UpdateRow(rowIndex, reviewRow);
            }
            // Maintain current selection.
            SetSelectedRow(ADMI_TABLE_REVIEW, currentSelection);

        });
    }


    void ResolvePatientMixUpView::SetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex)
    {
        ViewLogger::Trace("AdmiView::SetSelectedRow");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, rowIndex]
        {
            std::set<int> selectedItems;
            selectedItems.insert(rowIndex);

            if (ADMI_TABLE_SCHEDULE == table)
            {
                ScheduleExamsListViewExPtr->setSelection(selectedItems);
                ScheduleExamsListViewExPtr->setSelectedItem(rowIndex);
                ScheduleExamsListViewExPtr->ensureVisible(rowIndex);
            }
            else if (ADMI_TABLE_REVIEW == table)
            {
                ReviewExamsListViewExPtr->setSelection(selectedItems);
                ReviewExamsListViewExPtr->setSelectedItem(rowIndex);
                ReviewExamsListViewExPtr->ensureVisible(rowIndex);
            }
            else
            {
                // Do nothing.
            }
        });
    }

    // GetSelectedRow
    // Returns -1                    : No row selected
    //         -2                    : Multiple rows selected
    //          Current selected row : One row selected

    int ResolvePatientMixUpView::GetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table)
    {
        ViewLogger::Trace("AdmiView::GetSelectedRow");

        int selectedIndex = NO_ROW_SELECTED;
        SenseDisplayer::AsyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, &selectedIndex]
        {
            std::set<int> selectedItems;
            if (ADMI_TABLE_SCHEDULE == table)
            {
                selectedItems = ScheduleExamsListViewExPtr->getSelection();
            }
            else if (ADMI_TABLE_REVIEW == table)
            {
                selectedItems = ReviewExamsListViewExPtr->getSelection();
            }
            else
            {
                // Do nothing.
            }

            if (static_cast<size_t>(1) < selectedItems.size())
            {
                // Multiple rows selected
                selectedIndex = MULTIPLE_ROW_SELECTED;
            }
            else if (static_cast<size_t>(1) == selectedItems.size())
            {
                // Single row selected
                selectedIndex = *(selectedItems.begin());
            }
            else
            {
                // Do nothing
            }
        });
        return selectedIndex;
    }

    int ResolvePatientMixUpView::InitPatMixupReviewExamsTab()
    {
        ViewLogger::Trace("ResolvePatientMixUpView::InitPatMixupReviewExamsTab");

        //// Wraps UI-owned tab page with shared_ptr for API compatibility; DO NOT delete!
        //ReviewExamsTabPagePtr = std::shared_ptr<TabPage>(&ResolvePatMixUpUIPtr->tabPageReviewExams, [](TabPage*) {});

        //// Create the ListViewEx on the ReviewExamsTabPage
        //ReviewExamsListViewExPtr = std::make_shared<ListViewEx>(*ReviewExamsTabPagePtr, REVIEWLIST_COLUMNCOUNT);

        //// Configure it using SenseDisplayer::SyncInvoke
        //SenseDisplayer::SyncInvoke(*ReviewExamsListViewExPtr, [this]
        //{
        //    ReviewExamsListViewExPtr->color = Palette::Black;
        //    ReviewExamsListViewExPtr->colorBorder = Palette::Black;
        //    ReviewExamsListViewExPtr->border = LIST_BORDER_MARGIN;
        //    ReviewExamsListViewExPtr->headerHeight = SCHED_REVIEW_LIST_HEADERHEIGHT;
        //    ReviewExamsListViewExPtr->position = SCHED_REVIEW_LISTPOS;
        //    ReviewExamsListViewExPtr->size = SCHED_REVIEW_LISTSIZE;
        //    ReviewExamsListViewExPtr->scrollbarSize = LISTVIEW_SCROLLBAR_SIZE;
        //    ReviewExamsListViewExPtr->itemHeight = SCHED_REVIEW_LIST_ITEMHEIGHT;
        //    ReviewExamsListViewExPtr->font = TEXT_FONT;

        //    ReviewExamsListViewExPtr->eventScrollBarVisibilityChanged = [this](Orientation sbType, bool sbVisibility)
        //    {
        //        if (Orientation::Vertical == sbType)
        //        {
        //            int columnWidth = sbVisibility
        //                ? (REVIEWLIST_COLWIDTH_IMAGE - LISTVIEW_SCROLLBAR_SIZE)
        //                : REVIEWLIST_COLWIDTH_IMAGE;

        //            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), columnWidth);
        //        }
        //    };

        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), REVIEWLIST_COLWIDTH_ICON);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_NAME), REVIEWLIST_COLWIDTH_NAME);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_SEX), REVIEWLIST_COLWIDTH_SEX);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB), REVIEWLIST_COLWIDTH_DOB);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), REVIEWLIST_COLWIDTH_PATID);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT), REVIEWLIST_COLWIDTH_EXAMDT);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMTYPE), REVIEWLIST_COLWIDTH_EXAMTYPE);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PHYSICIAN), REVIEWLIST_COLWIDTH_PHYSICIAN);
        //    ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), REVIEWLIST_COLWIDTH_IMAGE);

        //    ReviewExamsListViewExPtr->showCheckbox = CHECKBOX_VISIBILITY;
        //    ReviewExamsListViewExPtr->SetIconSize(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), ICON_SIZE);

        //    ListViewHeader& columnHeaderIcon = ReviewExamsListViewExPtr->GetHeader(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON));
        //    columnHeaderIcon.cellHorizontalAlign = LISTVIEW_ICON_ALIGNMENT;

        //    for (int columnIndex = 0; columnIndex < static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLUMNCOUNT); columnIndex++)
        //    {
        //        ListViewHeader& columnHeader = ReviewExamsListViewExPtr->GetHeader(columnIndex);
        //        columnHeader.colorSeparator1 = Palette::Black;
        //        columnHeader.colorSeparator2 = Palette::Black;
        //        columnHeader.eventClicked = [this, columnIndex] {
        //        OnListHeaderClicked(ADMI_TABLE_REVIEW, columnIndex);
        //        };
        //    }

        //    ReviewExamsListViewExPtr->multiselect = true;
        //});

        
        return OK;
    }

    int ResolvePatientMixUpView::InitPatMixupReviewExamsListView()
    {
        if (!ReviewExamsListViewExPtr)
            return -1;

        SenseDisplayer::SyncInvoke(*ReviewExamsListViewExPtr, [this]()
        {
            ReviewExamsListViewExPtr->color = Palette::Black;
            ReviewExamsListViewExPtr->colorBorder = Palette::Black;
            ReviewExamsListViewExPtr->border = LIST_BORDER_MARGIN;
            ReviewExamsListViewExPtr->headerHeight = SCHED_REVIEW_LIST_HEADERHEIGHT;
            ReviewExamsListViewExPtr->position = SCHED_REVIEW_LISTPOS;
            ReviewExamsListViewExPtr->size = SCHED_REVIEW_LISTSIZE;
            ReviewExamsListViewExPtr->scrollbarSize = LISTVIEW_SCROLLBAR_SIZE;
            ReviewExamsListViewExPtr->itemHeight = SCHED_REVIEW_LIST_ITEMHEIGHT;
            ReviewExamsListViewExPtr->font = TEXT_FONT;
            ReviewExamsListViewExPtr->showCheckbox = CHECKBOX_VISIBILITY;
            ReviewExamsListViewExPtr->multiselect = true;

            ReviewExamsListViewExPtr->SetIconSize(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), ICON_SIZE);

            // Setup columns widths and headers - replace with localization if needed
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), L"");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_NAME), L"Name");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_SEX), L"Sex");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB), L"DOB");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), L"Patient ID");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT), L"Exam Date");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMTYPE), L"Exam Type");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PHYSICIAN), L"Physician");
            ReviewExamsListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), L"Images");

            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), REVIEWLIST_COLWIDTH_ICON);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_NAME), REVIEWLIST_COLWIDTH_NAME);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_SEX), REVIEWLIST_COLWIDTH_SEX);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB), REVIEWLIST_COLWIDTH_DOB);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), REVIEWLIST_COLWIDTH_PATID);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT), REVIEWLIST_COLWIDTH_EXAMDT);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMTYPE), REVIEWLIST_COLWIDTH_EXAMTYPE);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PHYSICIAN), REVIEWLIST_COLWIDTH_PHYSICIAN);
            ReviewExamsListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), REVIEWLIST_COLWIDTH_IMAGE);

            // Align the icon column to center
            ListViewHeader& iconHeader = ReviewExamsListViewExPtr->GetHeader(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON));
            iconHeader.cellHorizontalAlign = LISTVIEW_ICON_ALIGNMENT;

            // Optionally add sorting callback on header click if you want - reuse your OnListHeaderClicked
            for (int i = 0; i < static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLUMNCOUNT); i++)
            {
                ListViewHeader& header = ReviewExamsListViewExPtr->GetHeader(i);
                header.eventClicked = [this, i]() { OnListHeaderClicked(ADMI_PATMIXUP_REVIEW, i); };
            }
        });

        return OK;
    }

    void ResolvePatientMixUpView::PopulateReviewExamsListView()
    {
        if (!ReviewExamsListViewExPtr || !GuiDataModelPtr || !ResolvePatMixUpUIPtr)
            return;

        const auto& reviewStudies = GuiDataModelPtr->Admi.ResolvePatMixUp.StudyList;

        SenseDisplayer::SyncInvoke(*ResolvePatMixUpUIPtr, [this, &reviewStudies]()
        {
            ReviewExamsListViewExPtr->DeleteList();

            for (const auto& patExamData : reviewStudies)
            {
                Row reviewRow;

                Sense::Image icon = MVSUI::ResolvePatientMixUpView::ExamStateToIcon(patExamData.status,
                    patExamData.exportStatus,
                    patExamData.worklistStatus);
                reviewRow.AddCell(L" ", icon);
                reviewRow.AddCell(std::wstring(patExamData.patientName));

                char genderChar[2] = { 0 };
                ViewUtilities::GuiUtils::SexEnumToSexString(patExamData.sex, genderChar, sizeof(genderChar), BOOLEAN_TRUE);
                reviewRow.AddCell(Utilities::StringConverter::StringToWstring(genderChar));

                std::wstring dobStr;
                Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.birthDate,
                    GuiDataModelPtr->Admi.Setup.DateFormat,
                    GuiDataModelPtr->LocalePtr,
                    dobStr);
                reviewRow.AddCell(dobStr);

                if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
                    reviewRow.AddCell(patExamData.accNr);
                else
                    reviewRow.AddCell(patExamData.regNr);

                std::wstring examDateStr;
                Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.examDate,
                    GuiDataModelPtr->Admi.Setup.DateFormat,
                    GuiDataModelPtr->LocalePtr,
                    examDateStr);
                reviewRow.AddCell(examDateStr);

                std::wstring examTypeStr = std::wstring(patExamData.examType);
                if (0 != wcslen(patExamData.detProcType))
                    examTypeStr += L" - " + std::wstring(patExamData.detProcType);
                reviewRow.AddCell(examTypeStr);

                reviewRow.AddCell(patExamData.physician);
                reviewRow.AddCell(std::to_wstring(patExamData.nrOfImages));

                reviewRow.SetExtendedData(std::to_wstring(patExamData.patientId));

                ReviewExamsListViewExPtr->AddItem(reviewRow);
            }
        });
    }
    void ResolvePatientMixUpView::OnReviewListSelectionChanged()
    {
    }

    Sense::Image ResolvePatientMixUpView::ExamStateToIcon(EXAM_STATUS_ENUM examStatus, EXAM_EXPORT_STATUS_ENUM exportStatus, EXAM_WORKLIST_STATUS_ENUM worklistStatus)
    {
        ViewLogger::Trace("AdmiView::ExamStateToIcon");

        Sense::Image cellIcon;

        if (EST_CURRENT_ACQ == examStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_PATIENT_ACQUISITION);
        }
        else if (EST_CURRENT_REV == examStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_APPLICATION_VIEWING);
        }
        else if (EEST_ARCHIVED_AND_MPPS == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_ARCHIVED_AND_MPPS);
        }
        else if (EEST_MPPS_ONLY == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_MPPS_ONLY);
        }
        else if (EEST_ARCHIVED_ONLY == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_ARCHIVE_ONLY);
        }
        else if (EWST_NEVER_RECEIVED != worklistStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_SCHEDULER_NOW);
        }
        else if (EST_SCHEDULED == examStatus)
        {
            cellIcon = Image();
        }
        else
        {
            cellIcon = Image();
        }
        return cellIcon;
    }

    int ResolvePatientMixUpView::FindPatRowIndex(const ADMI_DATA_LAYER_TABLE_ENUM table, int patId)
    {
        ViewLogger::Trace("AdmiView::FindPatRowIndex");

        int rowFound = NO_ROW_SELECTED;
        long patientID = NO_ROW_SELECTED;

        ViewLogger::Debug("ID=%d", patId);

        int numberOfRows = GetNumberOfRows(table);
        for (int rowIndex = 0; (rowIndex< numberOfRows) && (NO_ROW_SELECTED == rowFound); rowIndex++)
        {
            patientID = GetPatientIDfromRow(table, rowIndex);

            if (patientID == patId)
            {
                rowFound = rowIndex;
                break;
            }
        }

        ViewLogger::Debug("Row Found = %d", rowFound);
        return rowFound;
    }

    int ResolvePatientMixUpView::GetNumberOfRows(const ADMI_DATA_LAYER_TABLE_ENUM table) const
    {
        ViewLogger::Trace("AdmiView::GetNumberOfRows");

        int numberOfRows = 0;

        if (ADMI_PATMIXUP_SCHEDULE == table)
        {
            numberOfRows = ScheduleExamsListViewExPtr->GetItemCount();
        }
        else if (ADMI_PATMIXUP_REVIEW == table)
        {
            numberOfRows = ReviewExamsListViewExPtr->GetItemCount();
        }
        else
        {
            // Do nothing.
        }

        return numberOfRows;
    }

    int ResolvePatientMixUpView::GetPatientIDfromRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex)
    {
        ViewLogger::Trace("AdmiView::GetPatientIDfromRow");

        int patientID;
        if (ADMI_PATMIXUP_SCHEDULE == table)
        {
            if (ScheduleExamsListViewExPtr->GetRowExtendedData(rowIndex).empty())
            {
                patientID = NO_ROW_SELECTED;
            }
            else
            {
                patientID = static_cast<int>(std::stol(ScheduleExamsListViewExPtr->GetRowExtendedData(rowIndex)));
            }
        }
        else
        {
            if (ReviewExamsListViewExPtr->GetRowExtendedData(rowIndex).empty())
            {
                patientID = NO_ROW_SELECTED;
            }
            else
            {
                patientID = static_cast<int>(std::stol(ReviewExamsListViewExPtr->GetRowExtendedData(rowIndex)));
            }
        }
        return patientID;
    }
}





model header== this is the model file for resolve patient mixup.
//****************************************************************************//
//                                                                            //
//   Filename   :ResolvePatientMixUp.h                                        //
//                                                                            //
//   Description: Handles display of the GUI_SC_PAT_MIX_UP                    //
//                                                                            //
//   Copyright  : Koninklijke Philips N.V. 2025                               //
//                                                                            //
//****************************************************************************//

#ifndef RESOLVEPATIENTMIXUP_H
#define RESOLVEPATIENTMIXUP_H

#include <mutex>
#include <atomic>
#include "IGuiComponent.h"
#include "gui_exp.h"
#include "GuiCommon.h"
#include "IObserver.h"
#include "ISuspendable.h"
#include "AVO\AVO.h"
#include "ModelViewInterface.h"
#include <vector>
#include <functional>

 namespace MVSUI
{

}
 namespace Gui
{
    class ResolvePatientMixUp : public IGuiComponent, public IObserver
    {

    public:

        ResolvePatientMixUp();
        virtual ~ResolvePatientMixUp() = default;

        //IGuiComponent Implementation
        virtual int Init(const MONITOR_ENUM monNr)                                                                      override;
        virtual int Show(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& signalData)                                 override;
        virtual int Hide(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& signalData, const bool doInvalidate)        override;
        virtual int Cancel(const MONITOR_ENUM monNr, const bool showOld, const bool closeWindow)                        override;
        virtual void Destroy()                                                                                          override;
        virtual void SetLocale(std::shared_ptr<ILocale> localePtr)                                                      override;
        virtual void Notify(const GUI_NOTIFICATION_TYPE type, void* dataPtr)                                            override;
        void OnCancelButtonClicked();

        std::function<void(const GUI_ADMI_ROW_STRUCT&, ADMI_DATA_LAYER_TABLE_ENUM)> ExamUpdated;
        std::function<void()> ModelUpdated;
        std::function<void(const GUI_ADMI_ROW_STRUCT&, ADMI_DATA_LAYER_TABLE_ENUM)> ExamUpdated;
        std::function<void()> ModelUpdated;
        void LoadAllExams();

    private:
        void BindView();
        int OnResolvePatientMixUPAction(const MVSUI::ResolvePatMixUpEventTypes action);

        std::shared_ptr<MVSUI::GuiDataModel>          GuiDataModelPtr;
    };
}
#endif // RESOLVEPATIENTMIXUP_H
model cpp
//****************************************************************************//
//                                                                            //
//   Filename   : ResolvePatientMixUp.cpp                                     //
//                                                                            //
//   Description: Handles display of the GUI_SC_PAT_MIX_UP                    //
//                                                                            //
//   Copyright  : Koninklijke Philips N.V. 2025.                              //
//                                                                            //
//****************************************************************************//
#include <memory>
#include <math.h>

#include "ResolvePatientMixUp.h"
#include "Logger.h"
#include "GuiController.h"
#include "GuiUtils.h"
#include "IObservable.h"
#include "Session.h"
#include "gui_dir.h"

namespace Gui
{
    ResolvePatientMixUp::ResolvePatientMixUp()
    {
    }

    int ResolvePatientMixUp::Init(const MONITOR_ENUM monNr)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Init");
        if (MONITOR_VIEWPORT_1 == monNr)
        {
            BindView();
            GuiController::GetInstance().RegisterForAction(GUI_AC_PAT_MIX_UP, this);
        }
        return OK;
    }


    void ResolvePatientMixUp::BindView()
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::BindView");

        GuiDataModelPtr = GuiController::GetInstance().GetGuiDataModel();
        GuiDataModelPtr->Admi.ResolvePatMixUp.Action = [this](MVSUI::ResolvePatMixUpEventTypes action) { return OnResolvePatientMixUPAction(action); };
      
    }

    int ResolvePatientMixUp::OnResolvePatientMixUPAction(const MVSUI::ResolvePatMixUpEventTypes action)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::OnResolvePatientMixUPAction");

        switch (action)
        {
        case MVSUI::ResolvePatMixUpEventTypes::Cancel:
            OnCancelButtonClicked();
            break;

        default:
            break;
        }
        return OK;
    }

    int ResolvePatientMixUp::Show(const MONITOR_ENUM monNr , const GUI_SIGNAL_STRUCT& /*signalData*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Show");

        int status = OK;
        if (MONITOR_VIEWPORT_1 == monNr)
        {
            GuiDataModelPtr->Admi.ResolvePatMixUp.Visible = true;
            GuiDataModelPtr->Admi.ResolvePatMixUp.ModelUpdated();
        }
        return status;
    }

    int ResolvePatientMixUp::Hide(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& /*signalData*/, const bool /*doInvalidate*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Hide");

        int status = OK;
        if (MONITOR_VIEWPORT_1 == monNr)
        {
            GuiDataModelPtr->Admi.ResolvePatMixUp.Visible = false;
            GuiDataModelPtr->Admi.ResolvePatMixUp.ModelUpdated();
        }
        return status;
    }

    int ResolvePatientMixUp::Cancel(const MONITOR_ENUM /*monNr*/, const bool /*showOld*/, const bool /*closeWindow*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Cancel");

        return OK;
    }

    void ResolvePatientMixUp::Destroy()
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Destroy");

    }

    void ResolvePatientMixUp::SetLocale(std::shared_ptr<ILocale> /*localePtr*/) //TICS -R.30 Variable '' should be declared as a raw pointer.
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::SetLocale");

    }

    void ResolvePatientMixUp::Notify(const GUI_NOTIFICATION_TYPE /*type*/, void* /*dataPtr*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "ResolvePatientMixUp::Notify");

    }

    void ResolvePatientMixUp::OnCancelButtonClicked()
    {
        GuiDataModelPtr->Admi.ResolvePatMixUp.Visible = false;
        GuiDataModelPtr->Admi.ResolvePatMixUp.ModelUpdated();
    }

    void ResolvePatientMixUp::LoadAllExams()
    {
        GUI_ADMI_NODE_STRUCT* patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_FIRST);

        while (patExamNode != nullptr)
        {
            if (ExamUpdated)
            {
                ExamUpdated(patExamNode->applData, patExamNode->table);
            }
            patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_NEXT);
        }

        // Notify model updated after bulk load
        if (ModelUpdated)
        {
            ModelUpdated();
        }
    }
}

the above code is mine. below is the one which u need to refer.in the below code they have implemented listcontrol refilling which i need to implement in my dialog. the only difference is my dialog already has 2 tab pages
but no list control and list control headers. i need to programatically implement them and take the exixting studies and refill the listctrl of the respective tab pages. 

Admi is using the same from a left panel with slight changes. hope u will customise it with my requirements. we were working on thos yestwerday and u gave me approaches that i was following but unfortunately history got erased midway. 
u try to recollect your memory seeing my code. 
admi ui
// ********************* WARNING *****************************
// * This file was automatically generated by Sense Composer *
// *      Modifying this file manually is frowned upon       *
// ***********************************************************
#pragma once

#include <Sense.h>
#include <ExperienceIdentity.h>
#include "CustomControls.h"

namespace Sense { namespace Composer
{

using namespace Sense;
using namespace Sense::ExperienceIdentity;
using namespace MVSUI::CustomControls;

class AdmiUI : public Control
{
public:

	AdmiUI(Control &parent)
	:
		Control               (parent),
		admiMainTab           (*this),
		headerPanel           (*this),
		labelPhilipsWatermark (headerPanel),
		buttonHelp            (headerPanel),
		buttonSystem          (headerPanel),
		labelSystemType       (headerPanel),
		labelLoggedInUser     (headerPanel)
	,	buttonProfile         (headerPanel)
	{
		layoutUpdateBegin();

		size                                = Size(1280, 1000);
		font                                = Font(L"Philips Healthcare Font", 14, false, false, false, false, Font::Antialias::High);

		admiMainTab.position                = Point(0, 48);
		admiMainTab.size                    = Size(1280, 952);

		headerPanel.size                    = Size(1280, 48);
		headerPanel.border                  = Margin(1, 0, 1, 0);
		headerPanel.edge                    = Margin(0, 0, 0, 0);

		labelPhilipsWatermark.position      = Point(12, 0);
		labelPhilipsWatermark.size          = Size(100, 48);
		labelPhilipsWatermark.font          = Font(L"Philips Healthcare Font", 19, false, false, false, false, Font::Antialias::High);
		labelPhilipsWatermark.text          = L"";
		labelPhilipsWatermark.color         = Palette::Gray120;
		labelPhilipsWatermark.verticalAlign = VAlign::Middle;
		labelPhilipsWatermark.image         = Icons::Wordmark;
		labelPhilipsWatermark.imageSize     = Size(100, 48);
		labelPhilipsWatermark.imageSpacing  = 0;

		buttonHelp.position                 = Point(1152, 0);
		buttonHelp.size                     = Size(100, 44);

		buttonSystem.position               = Point(1016, 0);
		buttonSystem.size                   = Size(100, 44);

		labelSystemType.position            = Point(116, 0);
		labelSystemType.size                = Size(160, 48);
		labelSystemType.font                = Font(L"Philips Healthcare Font", 19, false, false, false, false, Font::Antialias::High);
		labelSystemType.text                = L"";
		labelSystemType.color               = Palette::Gray120;
		labelSystemType.verticalAlign       = VAlign::Middle;
		labelSystemType.imageSize           = Size(160, 48);
		labelSystemType.imageSpacing        = 0;

		labelLoggedInUser.position          = Point(415, 0);
		labelLoggedInUser.size              = Size(450, 48);
		labelLoggedInUser.text              = L"";
		labelLoggedInUser.horizontalAlign   = HAlign::Center;
		labelLoggedInUser.verticalAlign     = VAlign::Middle;
		buttonProfile.name					= L"buttonProfile";
		buttonProfile.position				= Point(904, 0);
		buttonProfile.size					= Size(100, 44);
		layoutUpdateEnd();
	}

public:

	TabEx		admiMainTab;
	Panel		headerPanel;
	Label		labelPhilipsWatermark;
	MenuButton	buttonHelp;
	MenuButton	buttonSystem;
	Label		labelSystemType;
	Label		labelLoggedInUser;
	QuietButton buttonProfile;

private:

	AdmiUI(const AdmiUI&);
	AdmiUI& operator=(const AdmiUI&);
};

}}

admiview header

/*************************************************************************************\
 *                                                                                   *
 *   Filename   : AdmiView.h                                                         *
 *                                                                                   *
 *  Description : Initialization and update definitions for AdmiView                 *
 *                                                                                   *
 *  Copyright   : Koninklijke Philips N.V., 2020.                                    *
 *                                                                                   *
\*************************************************************************************/

#ifndef ADMIVIEW_H
#define ADMIVIEW_H

#include <memory>
#include "IGuiViewComponent.h"
#include "Event.h"
#include "gui_exp.h"
#include "ListViewEx.h"
#include "ModelViewInterface.h"
#include "IViewEventHandler.h"
#include "RemoteAssistanceToolView.h"
#include "CustomControls.h"
#include "ui\AdmiUI.ui.h"
#include "ui\AdmiHeaderUI.ui.h"
#include "SenseDisplayer.h"
#include "ExportRibbonView.h"

namespace Sense
{
    namespace Composer
    {
        class DeleteUI;
        class MultipleDeleteConfirmUI;
        class Reminder;
        class ReviewTabLeftPanelUI;
        class ScheduleTabLeftPanelUI;
        class AddUI;
    }

    namespace ExperienceIdentity
    {
        class Button;
        class TabPage;
    }
}

namespace MVSUI
{
    class ListViewEx;

    enum class AdmiSystemMenu;
    enum class AddPanelKeyboardFocus;
    enum class AddPanelOptions;

    class AdmiView final : public IGuiViewComponent, public IEventHandler
    {
    public:
                 AdmiView();
        virtual ~AdmiView() = default;

        int  Init()                          override;
        void Destroy()                       override;

        int                                                    InitializeAdmiPanel();
        int                                                    InitializeSystemMenu();
        int                                                    InitializeProfileButtonClick();
        int                                                    InitializeScheduleTab();
        int                                                    InitializeReviewTab();
        int                                                    InitializeAddPanel();

        // Implementation for IEventHandler
        virtual int HandleEvent(const GUI_SENSE_EVENT& eventData)                  override;

    private:
        void BindModel()                     override;
        int  SetControlIDs()                 override;
        void OnLocaleChanged()               override;
        int  OnModelUpdated()                override;
        bool OnIsMenuExpanded() const;

        int  SetAdmiUIControlIDs();

        void SetDeleteDialogsControlsIDs();

        void AdmiLocaleChanged();
        int  GetMenuItemPosition   (const AdmiSystemMenu menuItem);
        void OnAddSystemMenuItem   (const AdmiSystemMenu menuItem, const std::wstring& itemText, std::function<void()> clickHandler, const std::wstring& controlID);
        void OnUpdateSystemMenuItem(const AdmiSystemMenu menuItem, const std::wstring& itemText);
        void OnEnableSystemMenuItem(const AdmiSystemMenu menuItem, const bool          status);
        void OnRemoveSystemMenuItem(const AdmiSystemMenu menuItem);
        int  OnScheduleModelUpdated();
        void OnScheduleLocaleChanged();
        void OnSystemMenuItemLocaleChanged();
        void OnHelpMenuLocaleChanged();
        int  OnReviewModelUpdated();
        void OnReviewLocaleChanged();
        int  OnShutdownModelUpdated();
        void OnShutdownLocaleChanged();
        int  OnAddPanelModelUpdated();
        void OnAddPanelLocaleChanged();
        int  InitializeExportRibbonPanel();

        int  InitializeReminderPanel();
        int  OnReminderModelUpdated();
        void OnReminderLocaleChanged();
        void SubscribeToEventClicked();

        // On delete dialogs
        int  InitializeDeleteConfirmationDlg();
        void OnDeleteLocaleChanged();
        int  OnShowDeleteDialog();
        int  OnHideDeleteDialog();
        void SubscribeToSingleDelete();
        void SubscribeToSingleCancel();
        void SubscribeToMultipleDelete();
        void SubscribeToMultipleCancel();

        // Schedule page button events
        void SubscribeToTaskReview();
        void SubscribeToAdd();
        void SubscribeToModify();
        void SubscribeToDelete();
        void SubscribeToStartExamination();
        void SubscribeToWorklist();
        void SubscribeToExaminationInfo();
        void InitializeScheduleListView();

        //List Selection
        void SubscribeToListSelectionChanged();
        void OnListSelectionChanged();
        void OnListSelectionTimer();
        void SetSelectedPatientID();
        void OnPageSelection(const ADMI_DATA_LAYER_TABLE_ENUM listType);

        // Review page button events
        void SubscribeToTaskSchedule();
        void SubscribeToModifyReview();
        void SubscribeToDeleteReview();
        void SubscribeToShowExamination();
        void SubscribeToExaminationInfoReview();
        void SubscribeToDoseReport();
        void SubscribeToCloseExam();
        void SubscribeToBackToAcquisition();
        void InitializeReviewListView();

        // Add Panel button events
        void SubscribeToAddPanelOK();
        void SubscribeToAddPanelCancel();
        void SubscribeToAddPanelStartExam();
        void SubscribeToAddPanelPatientTypeAdult();
        void SubscribeToAddPanelPatientTypePediatric();
        void SubscribeToAddPanelExamtype();
        void SubscribeToAddPanelPhysician();
        void SubscribeToAddPanelDetProcType();
        void SubscribeToAddPanelProfile();
        void SubscribeToAddPanelPatientName();
        void SubscribeToAddPanelPatientId();
        void SubscribeToAddPanelAccno();
        void SubscribeToAddPanelPatientWeight();
        void SubscribeToAddPanelPatientHeight();
        void SubscribeToAddPanelFeet();
        void SubscribeToAddPanelInch();

        void UpdateGuiDataModelOnAddPanelEvents();

        int          FindPatRowIndex(const ADMI_DATA_LAYER_TABLE_ENUM table, int patId);
        int          GetNumberOfRows(const ADMI_DATA_LAYER_TABLE_ENUM table ) const;
        int          GetPatientIDfromRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex);
        int          GetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table);
        void         OnExamUpdated(const GUI_ADMI_ROW_STRUCT& patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table);
        void         UpdateScheduleExam(const GUI_ADMI_ROW_STRUCT& patExamData);
        void         UpdateReviewExam(const GUI_ADMI_ROW_STRUCT& patExamData);
        void         SetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex);
        Sense::Image ExamStateToIcon(EXAM_STATUS_ENUM examStatus, EXAM_EXPORT_STATUS_ENUM exportStatus, EXAM_WORKLIST_STATUS_ENUM worklistStatus);
        void         OnListHeaderClicked(const ADMI_DATA_LAYER_TABLE_ENUM table, const int columnIndex);
        static bool  SortByDate(const ListViewCell& cellLHS, const ListViewCell& cellRHS);
        static bool  SortByNoOfImage(const ListViewCell& cellLHS, const ListViewCell& cellRHS);
        void         OnExamClear();
        void         OnExamDeleted(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId);
        void         OnExamHidden(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId);
        void         OnExamSelection(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId);
        int          DeleteTableRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const long row);
        void         DeleteSelectedPatientId(const KEY_TYPE patId);
        bool         IsSubPanelVisible();
        bool         IsMenuExpanded() const;
        void         OnPopupUpdated(const bool visibility);

        void SetTabOrderForAddPanel();
        void SetKeyboardFocusForAddPanel(const AddPanelKeyboardFocus control);
        void SetDOBDateFormat           (const DATE_FORMAT_ENUM      dateFormat);
        void SetDOBText                 (const std::wstring&         newText);
        bool GetDOBText                 (      std::wstring&         dateStr);
        void ClearDOBText();

    private:
        std::shared_ptr<GuiDataModel>                             GuiDataModelPtr             = nullptr;
        std::shared_ptr<Sense::Composer::AdmiUI>                  AdmiUIPtr                   = nullptr;
        std::shared_ptr<Sense::Composer::AdmiHeaderUI>            AdmiHeaderUIPtr             = nullptr;
        std::shared_ptr<Sense::Composer::DeleteUI>                DeletePtr                   = nullptr;
        std::shared_ptr<Sense::Composer::MultipleDeleteConfirmUI> MultipleDeleteConfirmUIPtr = nullptr;

        std::shared_ptr<Sense::Composer::ScheduleTabLeftPanelUI>  ScheduleTabLeftPanelUIPtr  = nullptr;
        std::shared_ptr<Sense::ExperienceIdentity::TabPage>       ScheduleTabPagePtr         = nullptr;
        std::shared_ptr<ListViewEx>                               ScheduleListViewExPtr      = nullptr;

        std::shared_ptr<Sense::Composer::ReviewTabLeftPanelUI>   ReviewTabLeftPanelUIPtr     = nullptr;
        std::shared_ptr<Sense::ExperienceIdentity::TabPage>      ReviewTabPagePtr            = nullptr;
        std::shared_ptr<ListViewEx>                              ReviewListViewExPtr         = nullptr;
        std::shared_ptr<Sense::Composer::AddUI>                  AddPtr                      = nullptr;
        std::shared_ptr<Sense::Composer::Reminder>               ReminderDlgPtr              = nullptr;
        std::unique_ptr<RemoteAssistanceToolView>                RACToolViewPtr              = nullptr;
        std::shared_ptr<Sense::Timer>                            ListSelectionTimerPtr       = nullptr;
        std::shared_ptr<MVSUI::CustomControls::MenuButton>       ButtonHelpAdmi              = nullptr;
        ExportRibbonView                                         ExportRibbonPanelView;
        Event<>::Subscription                                    PopupUpdatedSubscription;
    };
}
#endif // !ADMIVIEW_H

admiview pp:

/*************************************************************************************\
 *                                                                                   *
 *   Filename   : AdmiView.cpp                                                       *
 *                                                                                   *
 *  Description : Initialization and update definitions for AdmiView                 *
 *                                                                                   *
 *  Copyright   : Koninklijke Philips N.V., 2020.                                    *
 *                                                                                   *
\*************************************************************************************/

#include <array>
#include <iomanip>

#include "AdmiView.h"
#include "ExportRibbonView.h"
#include "ExperienceIdentity\Controls\Button.h"
#include "ExperienceIdentity\Controls\ComboBox.h"
#include "MainView.h"
#include "gui_util.h"
#include "ControlIDs.h"
#include "GuiUtilities.h"
#include "StringIDs.h"
#include "PopupDisplay.h"
#include "Resources.h"
#include "ExperienceIdentity\Controls\Tab.h"
#include "ListViewEx.h"
#include "ExportRibbonUtility.h"
#include "SenseDisplayer.h"

#include "ui\ScheduleTabLeftPanelUI.ui.h"
#include "ui\ReviewTabLeftPanelUI.ui.h"
#include "ui\AddUI.ui.h"
#include "ui\Reminder.ui.h"
#include "ui\DeleteUI.ui.h"
#include "ui\MultipleDeleteConfirmUI.ui.h"
#include "ViewLogger.h"
#include "UserMouseKeyboardEx.h"

#include "StringConverter.h"
#include "DateUtility.h"
#include "GuiUtilities.h"
#include "gui_all.h"

namespace MVSUI
{
    constexpr int            SCHEDULELIST_COLUMNCOUNT   = 7;
    constexpr int            REVIEWLIST_COLUMNCOUNT     = 9;
    constexpr double         IMAGE_SPACING              = 30.0;
    const     Sense::Point   SCHED_REVIEW_LEFTPANELPOS  = Sense::Point(0.0, 0.0);
    const     Sense::Size    SCHED_REVIEW_LEFTPANELSIZE = Sense::Size(587.0, 1940.0);
    const     Sense::Point   EXAMINFO_BTN_POS_WO_CLOSE  = Sense::Point(0.0, 966.0);
    const     Sense::Point   EXAMINFO_BTN_POS_W_CLOSE   = Sense::Point(0.0, 1126.0);
    const     Sense::Point   BACKTOACQ_BTN_POS_WO_CLOSE = Sense::Point(0.0, 1126.0);
    const     Sense::Point   BACKTOACQ_BTN_POS_W_CLOSE  = Sense::Point(0.0, 1286.0);
    const     Sense::Margin  TEXT_MARGIN                = Margin(80.0, 0.0, 0.0, 0.0);
    const     Sense::HAlign  HORIZONTAL_ALIGNMENT       = Sense::Composer::HAlign::Left;
    const     Sense::Size    IMAGE_SIZE                 = Size(52.0, 64.0);                    //left panel button images
    const     Sense::Corners BUTTON_CORNER_RADIUS      = Corners(8, 8, 8, 8);
    const     Sense::Font    TEXT_FONT                  = Font(L"Philips Healthcare Font", 32.0, false, false, false, false, Font::Antialias::High);
    const     Sense::Point   SYSBTN_POS                 = Sense::Point(745.0, 0.0);
    const     Sense::Point   LOGGEDINUSERBTN_POS        = Sense::Point(1.0, 0.0);
    const     Sense::Point   ADDPROFILE_POS             = Sense::Point(422.0, 0.0);
    constexpr int            INDEX_NOT_FOUND            = -1;
    std::array<bool, static_cast<int>(AdmiSystemMenu::SYS_MENU_NUMBEROFITEMS)> SysMenuItemAvailability;
    const     Sense::Point   ADMIDATAHANDLER_POS        = Sense::Point(0.0, 80.0);
    const     Sense::Point   ADMIHEADER_POS             = Sense::Point(2535.0, 0.0);
    constexpr int            MULTIPLE_ROW_SELECTED      = -2;

    //Controls Positions and Sizes
    const Sense::Point       SCHED_REVIEW_LISTPOS = Sense::Point(587.0, 0.0);
    const Sense::Size        SCHED_REVIEW_LISTSIZE = Sense::Size(3253.0, 1940.0);

    constexpr int            LISTVIEW_SCROLLBAR_SIZE = 28;
    constexpr double         ICON_SIZE = 48.0;
    constexpr double         SCHED_REVIEW_LIST_HEADERHEIGHT = 110.0;
    constexpr double         SCHED_REVIEW_LIST_ITEMHEIGHT = 110.0;
    constexpr bool           CHECKBOX_VISIBILITY = true;
    const     Sense::HAlign  LISTVIEW_ICON_ALIGNMENT = Sense::Composer::HAlign::Center;
    const  Margin            LIST_BORDER_MARGIN = Margin(2, 1, 0, 0);

    const std::wstring       EMPTYSTRING = L"";

    enum class REVIEWLIST_COLUMNINDEX
    {
        REVIEWLIST_COLIDX_ICON = 0,
        REVIEWLIST_COLIDX_NAME,
        REVIEWLIST_COLIDX_SEX,
        REVIEWLIST_COLIDX_DOB,
        REVIEWLIST_COLIDX_PATID,
        REVIEWLIST_COLIDX_EXAMDT,
        REVIEWLIST_COLIDX_EXAMTYPE,
        REVIEWLIST_COLIDX_PHYSICIAN,
        REVIEWLIST_COLIDX_IMAGE,
        REVIEWLIST_COLUMNCOUNT                  // This should be the last item in this enumeration.
    };

    constexpr int REVIEWLIST_COLWIDTH_ICON = 150;
    constexpr int REVIEWLIST_COLWIDTH_NAME = 541;
    constexpr int REVIEWLIST_COLWIDTH_SEX = 170;
    constexpr int REVIEWLIST_COLWIDTH_DOB = 280;
    constexpr int REVIEWLIST_COLWIDTH_PATID = 581;
    constexpr int REVIEWLIST_COLWIDTH_EXAMDT = 294;
    constexpr int REVIEWLIST_COLWIDTH_EXAMTYPE = 423;
    constexpr int REVIEWLIST_COLWIDTH_PHYSICIAN = 581;
    constexpr int REVIEWLIST_COLWIDTH_IMAGE = 200;

    enum class SCHEDULELIST_COLUMNINDEX
    {
        SCHEDULELIST_COLIDX_ICON = 0,
        SCHEDULELIST_COLIDX_NAME,
        SCHEDULELIST_COLIDX_SEX,
        SCHEDULELIST_COLIDX_DOB,
        SCHEDULELIST_COLIDX_PATID,
        SCHEDULELIST_COLIDX_EXAMTYPE,
        SCHEDULELIST_COLIDX_PHYSICIAN,
        SCHEDULELIST_COLUMNCOUNT                // This should be the last item in this enumeration.
    };

    constexpr int SCHEDULELIST_COLWIDTH_ICON = 150;
    constexpr int SCHEDULELIST_COLWIDTH_NAME = 707;
    constexpr int SCHEDULELIST_COLWIDTH_SEX = 181;
    constexpr int SCHEDULELIST_COLWIDTH_DOB = 429;
    constexpr int SCHEDULELIST_COLWIDTH_PATID = 576;
    constexpr int SCHEDULELIST_COLWIDTH_EXAMTYPE = 509;
    constexpr int SCHEDULELIST_COLWIDTH_PHYSICIAN = 668;

    AdmiView::AdmiView() : ListSelectionTimerPtr(nullptr),
                           ButtonHelpAdmi(nullptr),
                           PopupUpdatedSubscription(0u)
    {
        SysMenuItemAvailability.fill(false);
    }

    void AdmiView::BindModel()
    {
        ViewLogger::Trace("AdmiView::BindModel");

        GuiDataModelPtr                                         = MainView::Instance().GetGuiDataModel();
        GuiDataModelPtr->Admi.LocaleChanged                     = [this] { OnLocaleChanged(); };
        GuiDataModelPtr->Admi.IsMenuExpanded                    = [this] { return OnIsMenuExpanded();};

        GuiDataModelPtr->Admi.AddSystemMenuItem                 = [this] (const AdmiSystemMenu menuItem,
                                                                          const std::wstring& itemText,
                                                                          std::function<void()> clickHandler,
                                                                          const std::wstring& controlID)
                                                                         { OnAddSystemMenuItem(menuItem, itemText, clickHandler, controlID); };
        GuiDataModelPtr->Admi.EnableSystemMenuItem              = [this] (const AdmiSystemMenu menuItem, bool status)
                                                                         { OnEnableSystemMenuItem(menuItem, status); };
        GuiDataModelPtr->Admi.RemoveSystemMenuItem              = [this] (const AdmiSystemMenu menuItem) { OnRemoveSystemMenuItem(menuItem); };

        GuiDataModelPtr->Admi.ModelUpdated                      = [this] { OnModelUpdated();         };
        GuiDataModelPtr->Admi.Schedule.ModelUpdated             = [this] { OnScheduleModelUpdated(); };
        GuiDataModelPtr->Admi.Review.ModelUpdated               = [this] { OnReviewModelUpdated();   };
        GuiDataModelPtr->Admi.Reminder.ModelUpdated             = [this] { OnReminderModelUpdated(); };
        GuiDataModelPtr->Admi.Shutdown.ModelUpdated             = [this] { OnShutdownModelUpdated(); };

        GuiDataModelPtr->Admi.AddPanel.ModelUpdated             = [this]                                                                        { return OnAddPanelModelUpdated();       };
        GuiDataModelPtr->Admi.AddPanel.PatientDOBSetDateFormat  = [this] (const DATE_FORMAT_ENUM dateFormat)                                    {        SetDOBDateFormat(dateFormat);   };
        GuiDataModelPtr->Admi.AddPanel.PatientDOBSetText        = [this] (const std::wstring& newText)                                          {        SetDOBText(newText);            };
        GuiDataModelPtr->Admi.AddPanel.PatientDOBGetText        = [this] (std::wstring& dateStr)                                                { return GetDOBText(dateStr);            };
        GuiDataModelPtr->Admi.AddPanel.PatientDOBClearText      = [this]                                                                        {        ClearDOBText();                 };

        GuiDataModelPtr->Admi.Delete.ShowDeleteDialog           = [this] { OnShowDeleteDialog();     };
        GuiDataModelPtr->Admi.Delete.HideDeleteDialog           = [this] { OnHideDeleteDialog();     };
        GuiDataModelPtr->Admi.ExamUpdated                       = [this] (const GUI_ADMI_ROW_STRUCT& patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table){ OnExamUpdated(patExamData,table);          };
        GuiDataModelPtr->Admi.PageSelection                     = [this] (const ADMI_DATA_LAYER_TABLE_ENUM listType) { OnPageSelection(listType); };
        GuiDataModelPtr->Admi.ExamClear                         = [this] () { OnExamClear(); };
        GuiDataModelPtr->Admi.ExamDeleted                       = [this] (const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId) { OnExamDeleted(table, patId); };
        GuiDataModelPtr->Admi.ExamHidden                        = [this] (const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId) { OnExamHidden(table, patId); };
        GuiDataModelPtr->Admi.ExamSelection                     = [this] (const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId) { OnExamSelection(table, patId); };
        PopupUpdatedSubscription = GuiDataModelPtr->General.Popup.PopupUpdated += std::bind(&AdmiView::OnPopupUpdated, this, std::placeholders::_1);
    }

    int AdmiView::InitializeSystemMenu()
    {
        ViewLogger::Trace("AdmiView::InitializeSystemMenu");

        // Common options.
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_JOBVIEWER,                 L"Job Viewer",                [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::JobViewer); },             L"MenuItem_JobViewer");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_WIRELESS_NETWORK,          L"Wireless Network",          [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::WirelessNetwork); },       L"MenuItem_WirelessNetwork");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_SWITCH_USER,               L"Switch User",               [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::SwitchUser); },            L"MenuItem_SwitchUser");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_CHANGE_PASSWORD,           L"Change Password",           [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::ChangePassword); },        L"MenuItem_ChangePassword");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_REMOTE_ASSISTANCE,         L"Remote Assistance",         [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::RemoteAssistance); },      L"MenuItem_RemoteAssistance");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_SAVE_LOG_FILE_FOR_SERVICE, L"Save Log File for Service", [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::SaveLogFileForService); }, L"MenuItem_SaveLogFileForService");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_START_FIELD_SERVICE,       L"Start Field Service",       [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::FieldService); },          L"MenuItem_StartFS");
        OnAddSystemMenuItem(AdmiSystemMenu::SYS_MENU_SYSTEM_SETUP,              L"System Setup",              [this] { GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::Setup); },                 L"MenuItem_SystemSetup");

        return OK;
    }

    int AdmiView::GetMenuItemPosition(const AdmiSystemMenu menuItem)
    {
        ViewLogger::Trace("AdmiView::GetMenuItemPosition");
        int itemPosition = 0;

        int index = 0;
        for (index = 0; ((index < static_cast<int>(AdmiSystemMenu::SYS_MENU_NUMBEROFITEMS)) && (index != static_cast<int>(menuItem))); ++index)
        {
            if (SysMenuItemAvailability[index])
            {
                itemPosition++;
            }
        }

        if (index == static_cast<int>(AdmiSystemMenu::SYS_MENU_NUMBEROFITEMS))
        {
            // SYS Menu not found.
            itemPosition = INDEX_NOT_FOUND;
            ViewLogger::Debug("menu item %d is not found", menuItem);
        }

        return itemPosition;
    }

    void AdmiView::OnAddSystemMenuItem(const AdmiSystemMenu  menuItem,
                                       const std::wstring&   itemText,
                                       std::function<void()> clickHandler,
                                       const std::wstring&   controlID)
    {
        ViewLogger::Trace("AdmiView::OnAddSystemMenuItem");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, menuItem, &itemText, clickHandler, &controlID]
        {
            int itemPosition = GetMenuItemPosition(menuItem);
            if ((!SysMenuItemAvailability[static_cast<int>(menuItem)]) && (INDEX_NOT_FOUND != itemPosition))
            {
                std::wstring iconName;
                switch (menuItem)
                {
                case AdmiSystemMenu::SYS_MENU_JOBVIEWER:
                    iconName = ICON_JOBVIEWER;
                    break;
                case AdmiSystemMenu::SYS_MENU_WIRELESS_NETWORK:
                    iconName = ICON_WIFISIGNAL_HIGH;
                    break;
                case AdmiSystemMenu::SYS_MENU_SWITCH_USER:
                    iconName = ICON_SWITCHUSER;
                    break;
                case AdmiSystemMenu::SYS_MENU_CHANGE_PASSWORD:
                    iconName = ICON_CHANGE_PASSWORD;
                    break;
                case AdmiSystemMenu::SYS_MENU_REMOTE_ASSISTANCE:
                    iconName = ICON_REMOTE_ASSISTANCE;
                    break;
                case AdmiSystemMenu::SYS_MENU_SAVE_LOG_FILE_FOR_SERVICE:
                    iconName = ICON_SAVE_LOG_FILE;
                    break;
                case AdmiSystemMenu::SYS_MENU_START_FIELD_SERVICE:
                    iconName = ICON_START_FIELD_SERVICE;
                    break;
                case AdmiSystemMenu::SYS_MENU_SYSTEM_SETUP:
                    iconName = ICON_SETUP_CONFIGURATION;
                    break;
                default:
                    break;
                }

                AdmiHeaderUIPtr->buttonSystem.Menu.InsertItem(itemPosition, ContextMenu::Item(itemText, Resources::LoadIconFromResource(iconName), clickHandler, true, controlID));
                AdmiHeaderUIPtr->buttonSystem.Menu.font = Font(L"Philips Healthcare Font", 28, false, false, false, false, Font::Antialias::High);
                AdmiHeaderUIPtr->buttonSystem.Menu.itemImageSize = Size(50.0, 50.0);
                AdmiHeaderUIPtr->buttonSystem.Menu.itemHeight = 90.0;

                // Update SysMenu Availability.
                SysMenuItemAvailability[static_cast<int>(menuItem)] = true;
            }
        });
    }

    void AdmiView::OnUpdateSystemMenuItem(const AdmiSystemMenu menuItem, const std::wstring& itemText)
    {
        ViewLogger::Trace("AdmiView::OnUpdateSystemMenuItem");

        int itemPosition = GetMenuItemPosition(menuItem);
        if ((SysMenuItemAvailability[static_cast<int>(menuItem)]) && (INDEX_NOT_FOUND != itemPosition))
        {
            AdmiHeaderUIPtr->buttonSystem.Menu.UpdateText(itemPosition, itemText);
        }
    }

    void AdmiView::OnSystemMenuItemLocaleChanged()
    {
        SenseDisplayer::SyncInvoke(*AdmiUIPtr, [this]
        {
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_JOBVIEWER,                   GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_JOBVIEWER)                 );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_WIRELESS_NETWORK,            GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_WIRELESS_NETWORK)          );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SWITCH_USER,                 GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_SWITCH_USER)               );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_CHANGE_PASSWORD,             GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_CHNG_PSWD)                 );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_REMOTE_ASSISTANCE,           GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_REMOTE_ASSISTANCE)         );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SAVE_LOG_FILE_FOR_SERVICE,   GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_SAVE_LOG_FILE_FOR_SERVICE) );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_START_FIELD_SERVICE,         GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_FIELD_SERVICE)             );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SYSTEM_SETUP,                GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_SETUP)                     );
            OnUpdateSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SHUTDOWN,                    GuiDataModelPtr->LocalePtr->GetText(STR_SYSMENU_SHUTDOWN)                  );
        });
    }

    void AdmiView::OnHelpMenuLocaleChanged()
    {
        SenseDisplayer::SyncInvoke(*ButtonHelpAdmi, [this]
        {
            ButtonHelpAdmi->text = GuiDataModelPtr->LocalePtr->GetText(BTN_HELP);
            ButtonHelpAdmi->Menu.UpdateText(static_cast<int>(HELPMENU::MENU_INDEX_IFU), GuiDataModelPtr->LocalePtr->GetText(STR_HELPMENU_IFU));
            ButtonHelpAdmi->Menu.UpdateText(static_cast<int>(HELPMENU::MENU_INDEX_ABOUT), GuiDataModelPtr->LocalePtr->GetText(STR_HELPMENU_ABOUT));
        });
    }

    void AdmiView::OnEnableSystemMenuItem(const AdmiSystemMenu menuItem, const bool status)
    {
        ViewLogger::Trace("AdmiView::OnEnableSystemMenuItem");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, menuItem, status]
        {
            int itemPosition = GetMenuItemPosition(menuItem);
            if ((SysMenuItemAvailability[static_cast<int>(menuItem)]) && (INDEX_NOT_FOUND != itemPosition))
            {
                AdmiHeaderUIPtr->buttonSystem.Menu.UpdateStatus(itemPosition, status);
            }
        });
    }

    void AdmiView::OnRemoveSystemMenuItem(const AdmiSystemMenu menuItem)
    {
        ViewLogger::Trace("AdmiView::OnRemoveSystemMenuItem");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, menuItem]
        {
            int itemPosition = GetMenuItemPosition(menuItem);
            if ((SysMenuItemAvailability[static_cast<int>(menuItem)]) && (INDEX_NOT_FOUND != itemPosition))
            {
                AdmiHeaderUIPtr->buttonSystem.Menu.DeleteItem(itemPosition);

                // Update SysMenu Availability.
                SysMenuItemAvailability[static_cast<int>(menuItem)] = false;
            }
        });
    }

    int AdmiView::OnScheduleModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnScheduleModelUpdated");

        SenseDisplayer::SyncInvoke(*ScheduleTabLeftPanelUIPtr, [this]
        {
            ScheduleTabLeftPanelUIPtr->buttonAdd.checked              = GuiDataModelPtr->Admi.Schedule.Add.Checked;
            ScheduleTabLeftPanelUIPtr->buttonAdd.enabled              = GuiDataModelPtr->Admi.Schedule.Add.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonAdd.visible              = GuiDataModelPtr->Admi.Schedule.Add.Visible;

            ScheduleTabLeftPanelUIPtr->buttonModifySchedule.checked   = GuiDataModelPtr->Admi.Schedule.Modify.Checked;
            ScheduleTabLeftPanelUIPtr->buttonModifySchedule.enabled   = GuiDataModelPtr->Admi.Schedule.Modify.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonModifySchedule.visible   = GuiDataModelPtr->Admi.Schedule.Modify.Visible;

            ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.checked   = GuiDataModelPtr->Admi.Schedule.Delete.Checked;
            ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.enabled   = GuiDataModelPtr->Admi.Schedule.Delete.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.visible   = GuiDataModelPtr->Admi.Schedule.Delete.Visible;

            ScheduleTabLeftPanelUIPtr->buttonStartExamination.checked = GuiDataModelPtr->Admi.Schedule.StartExam.Checked;
            ScheduleTabLeftPanelUIPtr->buttonStartExamination.enabled = GuiDataModelPtr->Admi.Schedule.StartExam.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonStartExamination.visible = GuiDataModelPtr->Admi.Schedule.StartExam.Visible;

            ScheduleTabLeftPanelUIPtr->buttonGetWorklist.checked      = GuiDataModelPtr->Admi.Schedule.GetWorklist.Checked;
            ScheduleTabLeftPanelUIPtr->buttonGetWorklist.enabled      = GuiDataModelPtr->Admi.Schedule.GetWorklist.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonGetWorklist.visible      = GuiDataModelPtr->Admi.Schedule.GetWorklist.Visible;

            ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.checked  = GuiDataModelPtr->Admi.Schedule.ExamInfo.Checked;
            ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.enabled  = GuiDataModelPtr->Admi.Schedule.ExamInfo.Enabled;
            ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.visible  = GuiDataModelPtr->Admi.Schedule.ExamInfo.Visible;
            SubscribeToListSelectionChanged();
        });

        return OK;
    }

    int AdmiView::OnReviewModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnReviewModelUpdated");

        SenseDisplayer::SyncInvoke(*ReviewTabLeftPanelUIPtr, [this]
        {
            if (true == GuiDataModelPtr->Admi.Review.CloseExam.Visible)
            {
                ReviewTabLeftPanelUIPtr->buttonExaminationInfo.position   = EXAMINFO_BTN_POS_W_CLOSE;
                ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.position = BACKTOACQ_BTN_POS_W_CLOSE;
            }
            else
            {
                ReviewTabLeftPanelUIPtr->buttonExaminationInfo.position   = EXAMINFO_BTN_POS_WO_CLOSE;
                ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.position = BACKTOACQ_BTN_POS_WO_CLOSE;
            }

            ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.visible = GuiDataModelPtr->Admi.Review.BackToAcquisition.Visible;
            ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.enabled = GuiDataModelPtr->Admi.Review.BackToAcquisition.Enabled;
            ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.checked = GuiDataModelPtr->Admi.Review.BackToAcquisition.Checked;

            ReviewTabLeftPanelUIPtr->buttonCloseExam.visible         = GuiDataModelPtr->Admi.Review.CloseExam.Visible;
            ReviewTabLeftPanelUIPtr->buttonCloseExam.enabled         = GuiDataModelPtr->Admi.Review.CloseExam.Enabled;
            ReviewTabLeftPanelUIPtr->buttonCloseExam.checked         = GuiDataModelPtr->Admi.Review.CloseExam.Checked;

            ReviewTabLeftPanelUIPtr->buttonDeleteReview.visible      = GuiDataModelPtr->Admi.Review.Delete.Visible;
            ReviewTabLeftPanelUIPtr->buttonDeleteReview.enabled      = GuiDataModelPtr->Admi.Review.Delete.Enabled;
            ReviewTabLeftPanelUIPtr->buttonDeleteReview.checked      = GuiDataModelPtr->Admi.Review.Delete.Checked;

            ReviewTabLeftPanelUIPtr->buttonDoseReport.visible        = GuiDataModelPtr->Admi.Review.DoseReport.Visible;
            ReviewTabLeftPanelUIPtr->buttonDoseReport.enabled        = GuiDataModelPtr->Admi.Review.DoseReport.Enabled;
            ReviewTabLeftPanelUIPtr->buttonDoseReport.checked        = GuiDataModelPtr->Admi.Review.DoseReport.Checked;

            ReviewTabLeftPanelUIPtr->buttonExaminationInfo.visible   = GuiDataModelPtr->Admi.Review.ExamInfo.Visible;
            ReviewTabLeftPanelUIPtr->buttonExaminationInfo.enabled   = GuiDataModelPtr->Admi.Review.ExamInfo.Enabled;
            ReviewTabLeftPanelUIPtr->buttonExaminationInfo.checked   = GuiDataModelPtr->Admi.Review.ExamInfo.Checked;

            ReviewTabLeftPanelUIPtr->buttonModifyReview.visible      = GuiDataModelPtr->Admi.Review.Modify.Visible;
            ReviewTabLeftPanelUIPtr->buttonModifyReview.enabled      = GuiDataModelPtr->Admi.Review.Modify.Enabled;
            ReviewTabLeftPanelUIPtr->buttonModifyReview.checked      = GuiDataModelPtr->Admi.Review.Modify.Checked;

            ReviewTabLeftPanelUIPtr->buttonShowExamination.visible   = GuiDataModelPtr->Admi.Review.ShowExam.Visible;
            ReviewTabLeftPanelUIPtr->buttonShowExamination.enabled   = GuiDataModelPtr->Admi.Review.ShowExam.Enabled;
            ReviewTabLeftPanelUIPtr->buttonShowExamination.checked   = GuiDataModelPtr->Admi.Review.ShowExam.Checked;
            SubscribeToListSelectionChanged();
        });

        return OK;
    }

    void AdmiView::AdmiLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::AdmiLocaleChanged");

        SenseDisplayer::SyncInvoke(*AdmiUIPtr, [this]
        {
            //System Drop down Menu
            AdmiHeaderUIPtr->buttonSystem.text = GuiDataModelPtr->LocalePtr->GetText(AdmiHeaderUIPtr->buttonSystem.name);

            //Profile Drop down Menu
            AdmiHeaderUIPtr->buttonProfile.text = GuiDataModelPtr->LocalePtr->GetText(AdmiHeaderUIPtr->buttonProfile.name);
        });
    }

    void AdmiView::OnScheduleLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnScheduleLocaleChanged");

        SenseDisplayer::SyncInvoke(*ScheduleTabLeftPanelUIPtr, [this]
        {
            if (nullptr != GuiDataModelPtr->LocalePtr)
            {
                ScheduleTabLeftPanelUIPtr->buttonAdd.text               = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonAdd.name);
                ScheduleTabLeftPanelUIPtr->buttonModifySchedule.text    = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonModifySchedule.name);
                ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.text    = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.name);
                ScheduleTabLeftPanelUIPtr->buttonStartExamination.text  = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonStartExamination.name);
                ScheduleTabLeftPanelUIPtr->buttonGetWorklist.text       = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonGetWorklist.name);
                ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.text   = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.name);
                ScheduleTabLeftPanelUIPtr->buttonTaskScheduled.text     = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonTaskScheduled.name);
                ScheduleTabLeftPanelUIPtr->buttonTaskReview.text        = GuiDataModelPtr->LocalePtr->GetText(ScheduleTabLeftPanelUIPtr->buttonTaskReview.name);

                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON), EMPTYSTRING);
                ScheduleListViewExPtr->SetIconSize(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON), ICON_SIZE);
                ScheduleListViewExPtr->DisableColumn(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON));

                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_NAME), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_NAME)          );
                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_SEX),  GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_SEX)           );
                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_DOB),  GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_DOB)           );
                if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
                {
                    ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PATID), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_ACCNUM)   );
                }
                else
                {
                    ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PATID), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_PATID)    );
                }
                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_EXAMTYPE),  GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_EXAMTYPE) );
                ScheduleListViewExPtr->SetHeaderText(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PHYSICIAN), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_PHYSICIAN));
            }
            else
            {
                ViewLogger::Warning("ILocale is NULL");
            }
        });
    }

    void AdmiView::OnReviewLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnReviewLocaleChanged");

        SenseDisplayer::SyncInvoke(*ReviewTabLeftPanelUIPtr, [this]
        {
            if (nullptr != GuiDataModelPtr->LocalePtr)
            {
                // Update Text of ReviewTabPage and its child controls.
                ReviewTabLeftPanelUIPtr->buttonModifyReview.text      = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonModifyReview.name);
                ReviewTabLeftPanelUIPtr->buttonDeleteReview.text      = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonDeleteReview.name);
                ReviewTabLeftPanelUIPtr->buttonShowExamination.text   = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonShowExamination.name);
                ReviewTabLeftPanelUIPtr->buttonDoseReport.text        = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonDoseReport.name);
                ReviewTabLeftPanelUIPtr->buttonExaminationInfo.text   = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonExaminationInfo.name);
                ReviewTabLeftPanelUIPtr->buttonCloseExam.text         = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonCloseExam.name);
                ReviewTabLeftPanelUIPtr->buttonTaskScheduled.text     = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonTaskScheduled.name);
                ReviewTabLeftPanelUIPtr->buttonTaskReview.text        = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonTaskReview.name);
                ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.text = GuiDataModelPtr->LocalePtr->GetText(ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.name);

                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_NAME),      GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_NAME)    );
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_SEX),       GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_SEX)     );
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB),       GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_DOB)     );
                if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
                {
                    ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_ACCNUM)   );
                }
                else
                {
                    ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_PATID)    );
                }
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT),    GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_EXAMDATE) );
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMTYPE),  GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_EXAMTYPE) );
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PHYSICIAN), GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_PHYSICIAN));
                ReviewListViewExPtr->SetHeaderText(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE),     GuiDataModelPtr->LocalePtr->GetText(STR_LISTHEADER_IMAGES)   );
            }
            else
            {
                ViewLogger::Warning("ILocale is NULL");
            }
        });
    }

    int AdmiView::OnShutdownModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnShutdownModelUpdated");

        return OK;
    }

    void AdmiView::OnShutdownLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnShutdownLocaleChanged");
    }

    int AdmiView::OnAddPanelModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnAddPanelModelUpdated");

        SenseDisplayer::SyncInvoke(*AddPtr, [this]
        {
            AddPtr->radioPediatric.visible       = GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Visible;
            AddPtr->radioPediatric.checked       = GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked;

            AddPtr->radioAdult.visible           = GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Visible;
            AddPtr->radioAdult.checked           = GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked;

            AddPtr->radioMale.enabled            = GuiDataModelPtr->Admi.AddPanel.GenderMale.Enabled;
            AddPtr->radioMale.checked            = GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked;

            AddPtr->radioFemale.enabled          = GuiDataModelPtr->Admi.AddPanel.GenderFemale.Enabled;
            AddPtr->radioFemale.checked          = GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked;

            AddPtr->radioUnknown.enabled         = GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Enabled;
            AddPtr->radioUnknown.checked         = GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked;

            AddPtr->labelProfile.visible         = GuiDataModelPtr->Admi.AddPanel.ProfileTextVisible;
            AddPtr->labelAdult.visible           = GuiDataModelPtr->Admi.AddPanel.AdultTextVisible;
            AddPtr->labelPounds.text             = GuiDataModelPtr->Admi.AddPanel.PoundsText;

            if (GuiDataModelPtr->Admi.AddPanel.EditMode)
            {
                AddPtr->image = Resources::LoadIconFromResource(ICON_ADDPATIENT);
            }
            else
            {
                AddPtr->image = Resources::LoadIconFromResource(ICON_EDIT);
            }
            AddPtr->text                         = GuiDataModelPtr->Admi.AddPanel.Text;

            AddPtr->buttonOk.text                = GuiDataModelPtr->Admi.AddPanel.Ok.Text;
            AddPtr->buttonOk.visible             = GuiDataModelPtr->Admi.AddPanel.Ok.Visible;
            AddPtr->buttonOk.position            = Point(GuiDataModelPtr->Admi.AddPanel.Ok.Position.xPos, GuiDataModelPtr->Admi.AddPanel.Ok.Position.yPos);
            AddPtr->buttonOk.enabled             = GuiDataModelPtr->Admi.AddPanel.Ok.Enabled;
            AddPtr->buttonOk.glow                = GuiDataModelPtr->Admi.AddPanel.Ok.Glow;

            AddPtr->buttonStartExam.visible      = GuiDataModelPtr->Admi.AddPanel.StartExam.Visible;

            AddPtr->editPatientname.text         = GuiDataModelPtr->Admi.AddPanel.PatientName.Text;
            AddPtr->editPatientname.enabled      = GuiDataModelPtr->Admi.AddPanel.PatientName.Enabled;

            AddPtr->editPatientId.text           = GuiDataModelPtr->Admi.AddPanel.PatientId.Text;
            AddPtr->editPatientId.enabled        = GuiDataModelPtr->Admi.AddPanel.PatientId.Enabled;

            AddPtr->editPatientwt.text           = GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text;
            AddPtr->editPatientwt.enabled        = GuiDataModelPtr->Admi.AddPanel.PatientWeight.Enabled;

            if (UNIT_OF_HEIGHT_ENUM::CMS_UNIT == GuiDataModelPtr->Admi.AddPanel.unitOfHeight)
            {
                AddPtr->labelCms.visible            = true;
                AddPtr->labelCms.text               = GuiDataModelPtr->LocalePtr->GetText(STR_HEIGHT_CMS);
                AddPtr->editPatientHeight.visible   = true;
                AddPtr->editPatientHeight.watermark = L"";
                AddPtr->labelFeet.visible           = false;
                AddPtr->labelInches.visible         = false;
                AddPtr->comboBoxFeet.visible        = false;
                AddPtr->comboBoxInches.visible      = false;

                std::wstring heightString = L"";
                if (MIN_HEIGHT_CMS < GuiDataModelPtr->Admi.AddPanel.HeightInCms)
                {
                    std::wstringstream wstringFormater;
                    wstringFormater << std::fixed << std::setprecision(1) << GuiDataModelPtr->Admi.AddPanel.HeightInCms;
                    heightString = wstringFormater.str();
                }
                else
                {
                    heightString = GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text;
                }
                AddPtr->editPatientHeight.text = heightString;
            }
            else
            {
                AddPtr->comboBoxFeet.visible      = true;
                AddPtr->comboBoxFeet.enabled      = true;
                AddPtr->comboBoxFeet.watermark    = L"";
                AddPtr->labelFeet.visible         = true;
                AddPtr->labelFeet.text            = GuiDataModelPtr->LocalePtr->GetText(STR_HEIGHT_FEET);
                AddPtr->comboBoxInches.visible    = true;
                AddPtr->comboBoxInches.enabled    = true;
                AddPtr->comboBoxInches.watermark  = L"";
                AddPtr->labelInches.visible       = true;
                AddPtr->labelInches.text          = GuiDataModelPtr->LocalePtr->GetText(STR_HEIGHT_INCH);
                AddPtr->labelCms.visible          = false;
                AddPtr->editPatientHeight.visible = false;

                AddPtr->comboBoxFeet.setItems(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.FeetComboItems));
                AddPtr->comboBoxInches.setItems(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.InchComboItems));

                if (MIN_HEIGHT_CMS < GuiDataModelPtr->Admi.AddPanel.HeightInCms)
                {
                    int feet   = 0;
                    int inches = 0;

                    if (MAX_HEIGHT_CMS < GuiDataModelPtr->Admi.AddPanel.HeightInCms)
                    {
                        feet   = GUI_MAX_HEIGHT_FEET;
                        inches = GUI_MAX_HEIGHT_INCH;
                    }
                    else
                    {
                        ViewUtilities::GuiUtils::GetFeetAndInches(GuiDataModelPtr->Admi.AddPanel.HeightInCms, feet, inches);
                    }

                    AddPtr->comboBoxFeet.assign(feet);
                    AddPtr->comboBoxInches.assign(inches);
                }
                else
                {
                    AddPtr->comboBoxFeet.assign(NO_ITEM_SELECTED);
                    AddPtr->comboBoxInches.assign(NO_ITEM_SELECTED);
                }
            }

            AddPtr->editAccno.enabled            = GuiDataModelPtr->Admi.AddPanel.Accno.Enabled;
            AddPtr->editAccno.text               = GuiDataModelPtr->Admi.AddPanel.Accno.Text;

            AddPtr->comboProfile.visible         = GuiDataModelPtr->Admi.AddPanel.Profile.Visible;
            AddPtr->comboProfile.enabled         = GuiDataModelPtr->Admi.AddPanel.Profile.Enabled;

            AddPtr->datePickerPatientDOB.enabled = GuiDataModelPtr->Admi.AddPanel.PatientDOBEnabled;

            AddPtr->comboProfile.assign(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.ProfileItems));
            AddPtr->comboPhysician.assign(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.PhysicianItems));
            AddPtr->comboExamtype.assign(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.ExamTypeItems));
            AddPtr->comboDetProcType.assign(ViewUtilities::GuiUtils::ConvertItemsToComboBoxItems(GuiDataModelPtr->Admi.AddPanel.ProcedureItems));

            AddPtr->comboProfile.assign    (GuiDataModelPtr->Admi.AddPanel.ProfileIndex);
            AddPtr->comboPhysician.assign  (GuiDataModelPtr->Admi.AddPanel.PhysicianIndex);
            AddPtr->comboExamtype.assign   (GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex);
            AddPtr->comboDetProcType.assign(GuiDataModelPtr->Admi.AddPanel.ProcedureIndex);

            if (GuiDataModelPtr->Admi.AddPanel.Visible)
            {
                PopupDisplay::ShowDialog(PopupDisplayID::PATEXEDIT_WINDOW, AddPtr.get());
            }
            else
            {
                PopupDisplay::HideDialog(PopupDisplayID::PATEXEDIT_WINDOW);
                AdmiUIPtr->bringToFront();
            }

            SetKeyboardFocusForAddPanel(GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus);
        });

        return OK;
    }

    void AdmiView::OnAddPanelLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnAddPanelLocaleChanged");

        SenseDisplayer::SyncInvoke(*AddPtr, [this]
        {
            if (nullptr != GuiDataModelPtr->LocalePtr)
            {
                GuiDataModelPtr->Admi.AddPanel.PatientNameText = AddPtr->labelPatientName.text = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelPatientName.name);
                GuiDataModelPtr->Admi.AddPanel.PatientIDText   = AddPtr->labelPatientID.text   = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelPatientID.name);
                GuiDataModelPtr->Admi.AddPanel.DateOfBirthText = AddPtr->labelDateOfBirth.text = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelDateOfBirth.name);
                GuiDataModelPtr->Admi.AddPanel.WeightText      = AddPtr->labelWeight.text      = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelWeight.name);
                GuiDataModelPtr->Admi.AddPanel.HeightText      = AddPtr->labelHeight.text      = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelHeight.name);
                GuiDataModelPtr->Admi.AddPanel.AccessionNrText = AddPtr->labelAccessionNr.text = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelAccessionNr.name);

                AddPtr->labelSex.text                          = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelSex.name);
                AddPtr->labelType.text                         = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelType.name);
                AddPtr->labelPhysician.text                    = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelPhysician.name);
                AddPtr->labelAdult.text                        = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelAdult.name);
                AddPtr->radioMale.text                         = GuiDataModelPtr->LocalePtr->GetText(AddPtr->radioMale.name);
                AddPtr->radioFemale.text                       = GuiDataModelPtr->LocalePtr->GetText(AddPtr->radioFemale.name);
                AddPtr->radioUnknown.text                      = GuiDataModelPtr->LocalePtr->GetText(AddPtr->radioUnknown.name);
                AddPtr->radioAdult.text                        = GuiDataModelPtr->LocalePtr->GetText(AddPtr->radioAdult.name);
                AddPtr->radioPediatric.text                    = GuiDataModelPtr->LocalePtr->GetText(AddPtr->radioPediatric.name);
                AddPtr->buttonCancel.text                      = GuiDataModelPtr->LocalePtr->GetText(AddPtr->buttonCancel.name);
                AddPtr->buttonStartExam.text                   = GuiDataModelPtr->LocalePtr->GetText(AddPtr->buttonStartExam.name);
                AddPtr->labelPatientType.text                  = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelPatientType.name);
                AddPtr->labelProfile.text                      = GuiDataModelPtr->LocalePtr->GetText(AddPtr->labelProfile.name);
                AddPtr->datePickerPatientDOB.SetLocale(GuiDataModelPtr->LocalePtr);
            }
            else
            {
                ViewLogger::Warning("ILocale is NULL");
            }
        });
    }

    int AdmiView::SetControlIDs()
    {
        ViewLogger::Trace("AdmiView::SetControlIDs");

        SetAdmiUIControlIDs();

        SenseDisplayer::SyncInvoke(*ScheduleTabLeftPanelUIPtr, [this]
        {
            // Localizable controls will override control name using ControlID.
            ScheduleTabLeftPanelUIPtr->name                        = ADMI_TAB_SCHEDULE_PANEL_TITLE;
            ScheduleTabLeftPanelUIPtr->buttonAdd.name              = ADMI_BTN_ADD;
            ScheduleTabLeftPanelUIPtr->buttonModifySchedule.name   = ADMI_BTN_MODIFYSCHEDULE;
            ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.name   = ADMI_BTN_DELETESCHEDULE;
            ScheduleTabLeftPanelUIPtr->buttonStartExamination.name = ADMI_BTN_STARTEXAM;
            ScheduleTabLeftPanelUIPtr->buttonGetWorklist.name      = ADMI_BTN_GETWL;
            ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.name  = ADMI_BTN_EXAMINFOSCHEDULE;
            ScheduleTabLeftPanelUIPtr->buttonTaskScheduled.name    = ADMI_TBTN_SCHEDULE;
            ScheduleTabLeftPanelUIPtr->buttonTaskReview.name       = ADMI_BTN_REVIEW;
        });

        SenseDisplayer::SyncInvoke(*ReviewTabLeftPanelUIPtr, [this]
        {
            // Localizable controls will override control name using ControlID.
            ReviewTabLeftPanelUIPtr->name                         = ADMI_TAB_REVIEW_PANEL_TITLE;
            ReviewTabLeftPanelUIPtr->buttonModifyReview.name      = ADMI_BTN_MODIFYREVIEW;
            ReviewTabLeftPanelUIPtr->buttonDeleteReview.name      = ADMI_BTN_DELETEREVIEW;
            ReviewTabLeftPanelUIPtr->buttonShowExamination.name   = ADMI_BTN_SHOWEXAM;
            ReviewTabLeftPanelUIPtr->buttonDoseReport.name        = ADMI_BTN_DOSEREPORT;
            ReviewTabLeftPanelUIPtr->buttonExaminationInfo.name   = ADMI_BTN_EXAMINFOREVIEW;
            ReviewTabLeftPanelUIPtr->buttonCloseExam.name         = ADMI_BTN_CLOSE;
            ReviewTabLeftPanelUIPtr->buttonTaskScheduled.name     = ADMI_BTN_SCHEDULE;
            ReviewTabLeftPanelUIPtr->buttonTaskReview.name        = ADMI_TBTN_REVIEW;
            ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.name = ADMI_BTN_BACKTOACQ;
        });

        SenseDisplayer::SyncInvoke(*AddPtr, [this]
        {
            // Update Text of AddDialog and its child controls.
            AddPtr->name                                        = ADD_DLG_TITLE;
            AddPtr->editPatientname.name                        = ADDPANEL_EDIT_PATNAME;
            AddPtr->editPatientId.name                          = ADD_EDIT_PATID;
            AddPtr->comboDetProcType.name                       = ADD_CMB_DETPROCTYPE;
            AddPtr->comboPhysician.name                         = ADD_CMB_PHYSICIAN;
            AddPtr->editAccno.name                              = ADD_EDIT_ACCESSIONNR;
            AddPtr->buttonOk.name                               = ADDPANEL_BTN_OK;
            AddPtr->labelPounds.name                            = ADD_LBL_POUNDS;
            AddPtr->labelPatientName.name                       = ADD_LBL_PATNAME;
            AddPtr->labelPatientID.name                         = ADD_LBL_PATID;
            AddPtr->labelDateOfBirth.name                       = ADD_LBL_DOB;
            AddPtr->labelWeight.name                            = ADD_LBL_WEIGHT;
            AddPtr->labelHeight.name                            = ADD_LBL_HEIGHT;
            AddPtr->labelSex.name                               = ADD_LBL_SEX;
            AddPtr->labelAccessionNr.name                       = ADD_LBL_ACCESSIONNUMBER;
            AddPtr->labelType.name                              = ADD_LBL_TYPE;
            AddPtr->labelPhysician.name                         = ADD_LBL_PHYSICIAN;
            AddPtr->labelProfile.name                           = ADD_LBL_PROFILE;
            AddPtr->labelAdult.name                             = ADD_LBL_ADULT;
            AddPtr->labelCms.name                               = ADD_LBL_CM;
            AddPtr->radioMale.name                              = ADD_RADIO_MALE;
            AddPtr->radioFemale.name                            = ADD_RADIO_FEMALE;
            AddPtr->radioUnknown.name                           = ADD_RADIO_UNKNOWN;
            AddPtr->radioAdult.name                             = ADD_RADIO_ADULT;
            AddPtr->radioPediatric.name                         = ADD_RADIO_PEDIATRIC;
            AddPtr->buttonStartExam.name                        = ADD_BTN_STARTEXAM;
            AddPtr->buttonCancel.name                           = ADD_BTN_CANCEL;
            AddPtr->comboProfile.name                           = ADD_CMB_PROFILE;
            AddPtr->comboExamtype.name                          = ADD_CMB_EXAMTYPE;
            AddPtr->datePickerPatientDOB.name                   = ADDPANEL_EDIT_PATIENTDOB;
            AddPtr->editPatientwt.name                          = ADDPANEL_EDIT_PATIENTWEIGHT;
            AddPtr->editPatientHeight.name                      = ADDPANEL_EDIT_PATIENTHEIGHT_CM;
            AddPtr->genderGroupControl.name                     = ADD_GENDER_GROUP_CONTROL;
            AddPtr->patientTypeGroupControl.name                = ADD_PATIENT_TYPE_GROUP_CONTROL;
            AddPtr->labelPatientType.name                       = ADD_LBL_PATIENTTYPE;
            AddPtr->comboBoxFeet.name                           = ADDPANEL_CMB_FEET;
            AddPtr->comboBoxInches.name                         = ADDPANEL_CMB_INCHES;
            AddPtr->labelFeet.name                              = ADDPANEL_LBL_FEET;
            AddPtr->labelInches.name                            = ADDPANEL_LBL_INCHES;
        });

        SenseDisplayer::SyncInvoke(*ReminderDlgPtr, [this]
        {
            // Update Text of ReminderPanel and its child controls.
            ReminderDlgPtr->name              = REMINDER_DLG_TITLE;
            ReminderDlgPtr->buttonOK.name     = REMINDER_BTN_OK;
            ReminderDlgPtr->labelMessage.name = REMINDER_LBL_MESSAGE;
        });

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {
            ScheduleTabPagePtr->name = MVSUI::ADMI_SCHEDULE_PAGE;
            ScheduleListViewExPtr->name = MVSUI::ADMI_SCHEDULELIST;
            ReviewTabPagePtr->name = MVSUI::ADMI_REVIEW_PAGE;
            ReviewListViewExPtr->name = MVSUI::ADMI_REVIEWLIST;
        });

        SetDeleteDialogsControlsIDs();

        return OK;
    }

    int AdmiView::SetAdmiUIControlIDs()
    {
        ViewLogger::Trace("AdmiView::SetAdmiUIControlIDs");

        AdmiUIPtr->name                             = ADMI_PANEL_MAINUI;
        AdmiUIPtr->admiMainTab.name                 = ADMI_MAIN_TAB;
        AdmiHeaderUIPtr->name                       = ADMI_HEADER;
        AdmiHeaderUIPtr->headerPanel.name           = ADMI_HEADER_PANEL;
        AdmiHeaderUIPtr->labelLoggedInUser.name     = ADMI_LBL_LOGGED_IN_USER;
        AdmiHeaderUIPtr->labelLoggedInUser.position = LOGGEDINUSERBTN_POS;

        //System Drop down Menu
        AdmiHeaderUIPtr->buttonSystem.name          = ADMI_BTN_SYSTEM;
        AdmiHeaderUIPtr->buttonProfile.name         = ADMI_BTN_PROFILE;

        return OK;
    }

    void AdmiView::SetDeleteDialogsControlsIDs()
    {
        ViewLogger::Trace("AdmiView::SetDeleteDialogsControlsIDs");

        // Update Text of DeleteDialog and its child controls.
        DeletePtr->name                      = DELETE_DLG_TITLE;
        DeletePtr->labelConfirmationMsg.name = DELETE_LBL_CONFIRMATIONMSG;
        DeletePtr->labelPatientName.name     = DELETE_LBL_PATNAME;
        DeletePtr->labelPatientId.name       = DELETE_LBL_PATID;
        DeletePtr->labelDateOfBirth.name     = DELETE_LBL_DOB;
        DeletePtr->labelGender.name          = DELETE_LBL_GENDER;
        DeletePtr->labelAccNr.name           = DELETE_LBL_ACCESSIONNR;
        DeletePtr->labelExamType.name        = DELETE_LBL_EXAMTYPE;
        DeletePtr->labelPhysician.name       = DELETE_LBL_PHYSICIAN;
        DeletePtr->buttonDelete.name         = DELETE_BTN_DELETE;
        DeletePtr->buttonCancel.name         = DELETE_BTN_CANCEL;
        DeletePtr->lblPatientName.name       = DELETE_LABEL_PATNAME;
        DeletePtr->lblDateOfBirth.name       = DELETE_LABEL_DOB;
        DeletePtr->lblGender.name            = DELETE_LABEL_GENDER;
        DeletePtr->lblExamType.name          = DELETE_LABEL_EXAMTYPE;
        DeletePtr->lblPatientId.name         = DELETE_LABEL_PATID;
        DeletePtr->lblPhysician.name         = DELETE_LABEL_PHYSICIAN;
        DeletePtr->lblAccNr.name             = DELETE_LABEL_ACCESSIONNR;

        MultipleDeleteConfirmUIPtr->name                      = MULTI_DELETE_DLG_TITLE;
        MultipleDeleteConfirmUIPtr->buttonDelete.name         = MULTI_DELETE_BTN_DELETE;
        MultipleDeleteConfirmUIPtr->buttonCancel.name         = MULTI_DELETE_BTN_CANCEL;
        MultipleDeleteConfirmUIPtr->labelConfirmationMsg.name = MULTI_DELETE_LBL_CONFIRMATION_MSG;
    }

    int AdmiView::HandleEvent(const GUI_SENSE_EVENT & eventData)
    {
        ViewLogger::Trace("AdmiView::HandleEvent");

        int status = EVENT_IGNORED;

        SenseDisplayer::SyncInvoke(*AdmiUIPtr.get(), [&]
        {
            switch (eventData.EventID)
            {
            case SE_KEYPRESS:
            {
                int keyCode = eventData.EventData.KeyCode;
                const int CHAR_A = 0x41;
                const int BITMASK_KEYSTATE = 0xF0;

                if ((VK_UP == keyCode) ||
                    (VK_DOWN == keyCode) ||
                    (VK_PRIOR == keyCode) ||
                    (VK_NEXT == keyCode) ||
                    (VK_LEFT == keyCode) ||
                    (VK_RIGHT == keyCode))
                {
                    // Navigation in the schedule or review list should happen only if there are no sub panels opened and menu is not expanded
                    if (!IsSubPanelVisible() && !IsMenuExpanded())
                    {
                        ListViewEx* activeTablePtr = (ADMI_TABLE_REVIEW == GuiDataModelPtr->Admi.ListType) ? ReviewListViewExPtr.get() : ScheduleListViewExPtr.get();
                        if (NULL != activeTablePtr)
                        {
                            activeTablePtr->FireKeyPressEvent(eventData.EventData.KeyCode);
                        }
                    }
                    status = EVENT_HANDLED;
                }

                else if ((CHAR_A == keyCode) && (0 < (GetKeyState(VK_CONTROL) & BITMASK_KEYSTATE)))
                {
                    // Select all entries in the schedule or review list should be allowed only if there are no sub panels opened and menu is not expanded
                    if (!IsSubPanelVisible() && !IsMenuExpanded())
                    {
                        ListViewEx* activeTablePtr = (ADMI_TABLE_REVIEW == GuiDataModelPtr->Admi.ListType) ? ReviewListViewExPtr.get() : ScheduleListViewExPtr.get();
                        if (NULL != activeTablePtr)
                        {
                            activeTablePtr->selectAll();
                        }
                    }
                    status = EVENT_HANDLED;
                }
                else
                {
                    GuiDataModelPtr->Admi.KeyPressEvent(eventData.EventData.KeyCode);
                    status = EVENT_HANDLED;
                }


                break;
            }
            case SE_ACTIVATEPANEL:
            {
                if (GUI_SC_WINDOW_ADMI == eventData.EventData.PanelID)
                {
                    SenseDisplayer::GetInstance().SetForeground(MONITOR_VIEWPORT_1);
                    AdmiUIPtr->bringToFront();
                    status = EVENT_HANDLED;
                }
                break;
            }
            case SE_LBUTTON_DOUBLECLICK:
            {
                if (ADMI_TABLE_REVIEW == GuiDataModelPtr->Admi.ListType)
                {
                    if (GuiDataModelPtr->Admi.Review.ShowExam.Visible && GuiDataModelPtr->Admi.Review.ShowExam.Enabled)
                    {
                        GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::ShowExamination);
                    }
                }
                else
                {
                    // Do nothing
                }
                status = EVENT_HANDLED;
                break;
            }
            default:
            {
                break;
            }
            }
        });

        return status;
    }

    bool AdmiView::IsSubPanelVisible()
    {
        ViewLogger::Trace("AdmiView::IsSubPanelVisible");

        return (GuiDataModelPtr->Admi.AddPanel.Visible                      ||
               (GuiDataModelPtr->Admi.Reminder.Visible)                     ||
               (GuiDataModelPtr->Admi.Delete.SingleDeleteDialogIsVisible)   ||
               (GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible) ||
               (GuiDataModelPtr->Admi.About.Visible)                        ||
               (GuiDataModelPtr->Admi.RAC.Visible));
    }

    bool AdmiView::IsMenuExpanded() const
    {
        return OnIsMenuExpanded();
    }

    void AdmiView::OnPopupUpdated(const bool visibility)
    {
        bool enabled = !visibility;

        AdmiHeaderUIPtr->enabled = enabled;
        AdmiHeaderUIPtr->buttonProfile.enabled = enabled;
        AdmiHeaderUIPtr->buttonSystem.enabled = enabled;
        ButtonHelpAdmi->enabled = enabled;
        ExportRibbonPanelView.Enable(enabled);
    }

    int AdmiView::Init()
    {
        ViewLogger::Trace("AdmiView::Init");

        int status = OK;

        BindModel();

        auto canvas = SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1);

        if (nullptr == canvas)
        {
            status = GUI_E_UI_COMPONENT;
        }

        if (OK == status)
        {
            AdmiUIPtr = std::make_shared<Composer::AdmiUI>(*canvas);
            AdmiUIPtr->position = ADMIDATAHANDLER_POS;
        }

        if (OK == status)
        {
            AdmiHeaderUIPtr = std::make_shared<Composer::AdmiHeaderUI>(SenseDisplayer::GetInstance().GetSystemHeader());
            AdmiHeaderUIPtr->position = ADMIHEADER_POS;
        }

        if (nullptr == AdmiUIPtr)
        {
            status = GUI_E_UI_COMPONENT;
        }

        if (OK == status)
        {
            RACToolViewPtr = std::make_unique<RemoteAssistanceToolView>();
            if (RACToolViewPtr)
            {
                RACToolViewPtr->Init();
            }
            else
            {
                ViewLogger::Error("%s: Failed to create RemoteAssistanceToolView", __FUNCTION__);
                status = GUI_E_UI_COMPONENT;
            }
        }

        if (OK == status)
        {
            status = InitializeAdmiPanel();
        }

        if (OK == status)
        {
            status = InitializeSystemMenu();
        }

        if (OK == status)
        {
            status = InitializeProfileButtonClick();
        }

        if (OK == status)
        {
            InitializeScheduleTab();
            InitializeReviewTab();
            InitializeAddPanel();
            InitializeExportRibbonPanel();
            InitializeReminderPanel();
            InitializeDeleteConfirmationDlg();
            SetControlIDs();

            // Subscribe to schedule page events
            SubscribeToTaskReview();
            SubscribeToAdd();
            SubscribeToModify();
            SubscribeToDelete();
            SubscribeToStartExamination();
            SubscribeToWorklist();
            SubscribeToExaminationInfo();

            // Subscribe to review page events
            SubscribeToTaskSchedule();
            SubscribeToModifyReview();
            SubscribeToDeleteReview();
            SubscribeToShowExamination();
            SubscribeToExaminationInfoReview();
            SubscribeToDoseReport();
            SubscribeToCloseExam();
            SubscribeToBackToAcquisition();
            SubscribeToAddPanelOK();
            SubscribeToAddPanelCancel();
            SubscribeToAddPanelStartExam();
            SubscribeToAddPanelPatientTypeAdult();
            SubscribeToAddPanelPatientTypePediatric();
            SubscribeToAddPanelExamtype();
            SubscribeToAddPanelPhysician();
            SubscribeToAddPanelDetProcType();
            SubscribeToAddPanelProfile();
            SubscribeToAddPanelPatientName();
            SubscribeToAddPanelPatientId();
            SubscribeToAddPanelAccno();
            SubscribeToAddPanelPatientWeight();
            SubscribeToAddPanelPatientHeight();
            SubscribeToAddPanelFeet();
            SubscribeToAddPanelInch();
            SetTabOrderForAddPanel();   

            ListSelectionTimerPtr             = SenseDisplayer::CreateTimer(MONITOR_VIEWPORT_1);
            ListSelectionTimerPtr->eventTick  = [this] { OnListSelectionTimer(); };
        }

        ButtonHelpAdmi = SenseDisplayer::GetInstance().GetButtonHelp();


        return status;
    }

    int AdmiView::InitializeAdmiPanel()
    {
        ViewLogger::Trace("AdmiView::InitializeAdmiPanel");

        AdmiHeaderUIPtr->buttonSystem.font        = Font(L"Philips Healthcare Font", 32.0, false, false, false, false, Font::Antialias::High);
        AdmiHeaderUIPtr->buttonSystem.position    = SYSBTN_POS;
        AdmiHeaderUIPtr->buttonSystem.radius      = Corners(0.0, 0.0, 0.0, 0.0);
        AdmiHeaderUIPtr->buttonSystem.Alignment   = HAlign::Center;

        AdmiHeaderUIPtr->buttonProfile.font       = Font(L"Philips Healthcare Font", 32.0, false, false, false, false, Font::Antialias::High);
        AdmiHeaderUIPtr->buttonProfile.position   = ADDPROFILE_POS;
        AdmiHeaderUIPtr->buttonProfile.radius     = Corners(0.0, 0.0, 0.0, 0.0);

        // Remove header from ADMI tab.
        AdmiUIPtr->admiMainTab.headerHeight = 0.0;

        AdmiUIPtr->visible                  = GuiDataModelPtr->Admi.Visible = false;
        AdmiHeaderUIPtr->visible            = GuiDataModelPtr->Admi.Visible = false;

        return OK;
    }

    int AdmiView::InitializeProfileButtonClick()
    {
        ViewLogger::Trace("AdmiView::InitializeProfileButtonClick");

        AdmiHeaderUIPtr->buttonProfile.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.AdmiAction(AdmiEventType::Profile);
        };

        return OK;
    }

    int AdmiView::InitializeScheduleTab()
    {
        ViewLogger::Trace("AdmiView::InitializeScheduleTab");

        int status = OK;

        ScheduleTabPagePtr                  = std::make_shared<TabPage>(AdmiUIPtr->admiMainTab);
        ScheduleListViewExPtr               = std::make_shared<ListViewEx>(*ScheduleTabPagePtr.get(), SCHEDULELIST_COLUMNCOUNT);
        ScheduleTabLeftPanelUIPtr           = std::make_shared<Sense::Composer::ScheduleTabLeftPanelUI>(*ScheduleTabPagePtr.get());

        ScheduleTabPagePtr->headerVisible   = false;
        ScheduleTabLeftPanelUIPtr->position = SCHED_REVIEW_LEFTPANELPOS;
        ScheduleTabLeftPanelUIPtr->size     = SCHED_REVIEW_LEFTPANELSIZE;

        ScheduleTabLeftPanelUIPtr->buttonAdd.textMargin                     = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonAdd.horizontalAlign                = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonAdd.imageSpacing                   = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonAdd.image                          = Resources::LoadIconFromResource(ICON_ADDPATIENT_4K);
        ScheduleTabLeftPanelUIPtr->buttonAdd.imageSize                      = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonAdd.font                           = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonAdd.radius                         = BUTTON_CORNER_RADIUS;

        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.textMargin          = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.horizontalAlign     = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.image               = Resources::LoadIconFromResource(ICON_EDIT_4K);
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.imageSpacing        = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.imageSize           = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.font                = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.radius              = BUTTON_CORNER_RADIUS;

        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.textMargin          = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.horizontalAlign     = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.image               = Resources::LoadIconFromResource(ICON_DELETE_4K);
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.imageSpacing        = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.imageSize           = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.font                = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.radius              = BUTTON_CORNER_RADIUS;

        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.textMargin             = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.horizontalAlign        = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.image                  = Resources::LoadIconFromResource(ICON_SCHEDULER_NOW_4K);
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.imageSpacing           = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.imageSize              = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.font                   = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.radius                 = BUTTON_CORNER_RADIUS;

        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.textMargin         = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.horizontalAlign    = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.image              = Resources::LoadIconFromResource(ICON_INFORMATION_4K);
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.imageSpacing       = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.imageSize          = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.font               = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.radius             = BUTTON_CORNER_RADIUS;

        ScheduleTabLeftPanelUIPtr->buttonStartExamination.textMargin        = TEXT_MARGIN;
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.horizontalAlign   = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.image             = Resources::LoadIconFromResource(ICON_PROCEDURE_STARTED_4K);
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.imageSpacing      = IMAGE_SPACING;
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.imageSize         = IMAGE_SIZE;
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.font              = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonStartExamination.radius            = BUTTON_CORNER_RADIUS;

        double taskButtonTextMargin                                         = (ScheduleTabLeftPanelUIPtr->buttonTaskScheduled.taskSize + ScheduleTabLeftPanelUIPtr->buttonTaskScheduled.textMargin->left);
        ScheduleTabLeftPanelUIPtr->buttonTaskReview.horizontalAlign         = HORIZONTAL_ALIGNMENT;
        ScheduleTabLeftPanelUIPtr->buttonTaskReview.textMargin              = Margin(taskButtonTextMargin, 0.0, 0.0, 0.0);
        ScheduleTabLeftPanelUIPtr->buttonTaskReview.font                    = TEXT_FONT;
        ScheduleTabLeftPanelUIPtr->buttonTaskReview.radius                  = BUTTON_CORNER_RADIUS;
        InitializeScheduleListView();
        return status;
    }

    void AdmiView::InitializeScheduleListView()
    {
        ViewLogger::Trace("AdmiView::OnInitializeScheduleListView");

        SenseDisplayer::SyncInvoke(*ScheduleListViewExPtr, [this]
        {
            ScheduleListViewExPtr->color = Palette::Black;
            ScheduleListViewExPtr->colorBorder = Palette::Black;
            ScheduleListViewExPtr->border = LIST_BORDER_MARGIN;
            ScheduleListViewExPtr->headerHeight = SCHED_REVIEW_LIST_HEADERHEIGHT;
            ScheduleListViewExPtr->position = SCHED_REVIEW_LISTPOS;
            ScheduleListViewExPtr->size = SCHED_REVIEW_LISTSIZE;
            ScheduleListViewExPtr->itemHeight = SCHED_REVIEW_LIST_ITEMHEIGHT;
            ScheduleListViewExPtr->scrollbarSize = LISTVIEW_SCROLLBAR_SIZE;
            ScheduleListViewExPtr->font = TEXT_FONT;
            ScheduleListViewExPtr->showCheckbox = CHECKBOX_VISIBILITY;
            ScheduleListViewExPtr->SetIconSize(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON), ICON_SIZE);
            ListViewHeader& columnHeaderIcon = ScheduleListViewExPtr->GetHeader(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON));
            columnHeaderIcon.cellHorizontalAlign = LISTVIEW_ICON_ALIGNMENT;

            ScheduleListViewExPtr->eventScrollBarVisibilityChanged = [this](Orientation sbType, bool sbVisibility)
            {
                if (Orientation::Vertical == sbType)
                {
                    int columnWidth = sbVisibility ? (SCHEDULELIST_COLWIDTH_PHYSICIAN - LISTVIEW_SCROLLBAR_SIZE) : SCHEDULELIST_COLWIDTH_PHYSICIAN;
                    ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PHYSICIAN), columnWidth);
                }
            };
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_ICON), SCHEDULELIST_COLWIDTH_ICON);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_NAME), SCHEDULELIST_COLWIDTH_NAME);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_SEX), SCHEDULELIST_COLWIDTH_SEX);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_DOB), SCHEDULELIST_COLWIDTH_DOB);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PATID), SCHEDULELIST_COLWIDTH_PATID);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_EXAMTYPE), SCHEDULELIST_COLWIDTH_EXAMTYPE);
            ScheduleListViewExPtr->SetColumnWidth(static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_PHYSICIAN), SCHEDULELIST_COLWIDTH_PHYSICIAN);

            for (int columnIndex = 0; columnIndex < static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLUMNCOUNT); columnIndex++)
            {
                ListViewHeader& columnHeader = ScheduleListViewExPtr->GetHeader(columnIndex);
                columnHeader.colorSeparator1 = Palette::Black;
                columnHeader.colorSeparator2 = Palette::Black;
                columnHeader.eventClicked = [this, columnIndex] { OnListHeaderClicked(ADMI_TABLE_SCHEDULE, columnIndex); };
            }

            // Enable multiple row selection
            ScheduleListViewExPtr->multiselect = true;
        });
    }

    int AdmiView::InitializeReviewTab()
    {
        ViewLogger::Trace("AdmiView::InitializeReviewTab");

        ReviewTabPagePtr        = std::make_shared<TabPage>(AdmiUIPtr->admiMainTab);
        ReviewListViewExPtr     = std::make_shared<ListViewEx>(*ReviewTabPagePtr, REVIEWLIST_COLUMNCOUNT);
        ReviewTabLeftPanelUIPtr = std::make_shared<Composer::ReviewTabLeftPanelUI>(*ReviewTabPagePtr);

        ReviewTabPagePtr->headerVisible   = false;
        ReviewTabLeftPanelUIPtr->position = SCHED_REVIEW_LEFTPANELPOS;
        ReviewTabLeftPanelUIPtr->size     = SCHED_REVIEW_LEFTPANELSIZE;

        ReviewTabLeftPanelUIPtr->buttonShowExamination.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonShowExamination.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonShowExamination.image           = Resources::LoadIconFromResource(ICON_APPLICATION_VIEWING_4K);
        ReviewTabLeftPanelUIPtr->buttonShowExamination.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonShowExamination.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonShowExamination.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonShowExamination.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonModifyReview.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonModifyReview.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonModifyReview.image           = Resources::LoadIconFromResource(ICON_EDIT_4K);
        ReviewTabLeftPanelUIPtr->buttonModifyReview.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonModifyReview.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonModifyReview.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonModifyReview.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonDeleteReview.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.image           = Resources::LoadIconFromResource(ICON_DELETE_4K);
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonDeleteReview.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonDoseReport.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonDoseReport.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonDoseReport.image           = Resources::LoadIconFromResource(ICON_REPORT_4K);
        ReviewTabLeftPanelUIPtr->buttonDoseReport.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonDoseReport.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonDoseReport.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonDoseReport.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonCloseExam.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonCloseExam.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonCloseExam.image           = Resources::LoadIconFromResource(ICON_PROCEDURE_COMPLETED_4K);
        ReviewTabLeftPanelUIPtr->buttonCloseExam.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonCloseExam.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonCloseExam.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonCloseExam.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.image           = Resources::LoadIconFromResource(ICON_INFORMATION_4K);
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.radius          = BUTTON_CORNER_RADIUS;

        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.textMargin      = TEXT_MARGIN;
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.image           = Resources::LoadIconFromResource(ICON_PATIENT_ACQUISITION_WIDESCREEN);
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.imageSpacing    = IMAGE_SPACING;
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.imageSize       = IMAGE_SIZE;
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.radius          = BUTTON_CORNER_RADIUS;

        double taskButtonTextMargin                                  = (ReviewTabLeftPanelUIPtr->buttonTaskReview.taskSize + ReviewTabLeftPanelUIPtr->buttonTaskReview.textMargin->left);
        ReviewTabLeftPanelUIPtr->buttonTaskScheduled.horizontalAlign = HORIZONTAL_ALIGNMENT;
        ReviewTabLeftPanelUIPtr->buttonTaskScheduled.textMargin      = Margin(taskButtonTextMargin, 0.0, 0.0, 0.0);
        ReviewTabLeftPanelUIPtr->buttonTaskScheduled.font            = TEXT_FONT;
        ReviewTabLeftPanelUIPtr->buttonTaskScheduled.radius          = BUTTON_CORNER_RADIUS;
        InitializeReviewListView();
        return OK;
    }

    void AdmiView::InitializeReviewListView()
    {
        ViewLogger::Trace("AdmiView::OnInitializeReviewListView");

        SenseDisplayer::SyncInvoke(*ReviewListViewExPtr, [this]
        {
            ReviewListViewExPtr->color = Palette::Black;
            ReviewListViewExPtr->colorBorder = Palette::Black;
            ReviewListViewExPtr->border = LIST_BORDER_MARGIN;
            ReviewListViewExPtr->headerHeight = SCHED_REVIEW_LIST_HEADERHEIGHT;
            ReviewListViewExPtr->position = SCHED_REVIEW_LISTPOS;
            ReviewListViewExPtr->size = SCHED_REVIEW_LISTSIZE;
            ReviewListViewExPtr->scrollbarSize = LISTVIEW_SCROLLBAR_SIZE;
            ReviewListViewExPtr->itemHeight = SCHED_REVIEW_LIST_ITEMHEIGHT;
            ReviewListViewExPtr->font = TEXT_FONT;
            ReviewListViewExPtr->eventScrollBarVisibilityChanged = [this](Orientation sbType, bool sbVisibility)
            {
                if (Orientation::Vertical == sbType)
                {
                    int columnWidth = sbVisibility ? (REVIEWLIST_COLWIDTH_IMAGE - LISTVIEW_SCROLLBAR_SIZE) : REVIEWLIST_COLWIDTH_IMAGE;
                    ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), columnWidth);
                }
            };
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), REVIEWLIST_COLWIDTH_ICON);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_NAME), REVIEWLIST_COLWIDTH_NAME);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_SEX), REVIEWLIST_COLWIDTH_SEX);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB), REVIEWLIST_COLWIDTH_DOB);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PATID), REVIEWLIST_COLWIDTH_PATID);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT), REVIEWLIST_COLWIDTH_EXAMDT);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMTYPE), REVIEWLIST_COLWIDTH_EXAMTYPE);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_PHYSICIAN), REVIEWLIST_COLWIDTH_PHYSICIAN);
            ReviewListViewExPtr->SetColumnWidth(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE), REVIEWLIST_COLWIDTH_IMAGE);
            
            ReviewListViewExPtr->showCheckbox = CHECKBOX_VISIBILITY;
            ReviewListViewExPtr->SetIconSize(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON), ICON_SIZE);
            ListViewHeader& columnHeaderIcon = ReviewListViewExPtr->GetHeader(static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_ICON));
            columnHeaderIcon.cellHorizontalAlign = LISTVIEW_ICON_ALIGNMENT;

            // Register for HeaderClick event for sorting.
            for (int columnIndex = 0; columnIndex < static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLUMNCOUNT); columnIndex++)
            {
                ListViewHeader& columnHeader = ReviewListViewExPtr->GetHeader(columnIndex);
                columnHeader.colorSeparator1 = Palette::Black;
                columnHeader.colorSeparator2 = Palette::Black;
                columnHeader.eventClicked = [this, columnIndex] { OnListHeaderClicked(ADMI_TABLE_REVIEW, columnIndex); };
            }

            // Enable multiple row selection
            ReviewListViewExPtr->multiselect = true;
        });
    }

    int AdmiView::InitializeAddPanel()
    {
        int status = PopupDisplay::CreatePopupDialog<Composer::AddUI>(AddPtr);

        if (OK == status)
        {
            // Setting default selection for gender to Unknown
            // This ensures the default value is selected correctly for the first time Show of Add panel
            GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked     = AddPtr->radioUnknown.checked = true;

            GuiDataModelPtr->Admi.AddPanel.BUTTON_POS_1.xPos         = static_cast<int>(AddPtr->buttonOk.position->x);
            GuiDataModelPtr->Admi.AddPanel.BUTTON_POS_1.yPos         = static_cast<int>(AddPtr->buttonOk.position->y);
            GuiDataModelPtr->Admi.AddPanel.StartExam.Position.xPos   = static_cast<int>(AddPtr->buttonStartExam.position->x);
            GuiDataModelPtr->Admi.AddPanel.StartExam.Position.yPos   = static_cast<int>(AddPtr->buttonStartExam.position->y);
        }
        else
        {
            status = GUI_E_UI_COMPONENT;
            ViewLogger::Error("Initialization of Add/Modify panel failed");
        }

        return status;
    }

    int AdmiView::InitializeExportRibbonPanel()
    {
        ViewLogger::Trace("AdmiView::InitializeExportRibbonPanel");

        ExportRibbonPanelView.Init();

        return OK;
    }

    int AdmiView::InitializeDeleteConfirmationDlg()
    {
        ViewLogger::Trace("AdmiView::InitializeDeleteConfirmationDlg");

        int status = OK;

        if (OK != PopupDisplay::CreatePopupDialog<Composer::DeleteUI>(DeletePtr))
        {
            status = GUI_E_UI_COMPONENT;
        }

        if (OK != PopupDisplay::CreatePopupDialog<Composer::MultipleDeleteConfirmUI>(MultipleDeleteConfirmUIPtr))
        {
            status = GUI_E_UI_COMPONENT;
        }

        // Register for call backs
        SubscribeToSingleDelete();
        SubscribeToSingleCancel();
        SubscribeToMultipleDelete();
        SubscribeToMultipleCancel();

        return status;
    }

    void AdmiView::SubscribeToSingleDelete()
    {
        ViewLogger::Trace("AdmiView::SubscribeToSingleDelete");

        DeletePtr->buttonDelete.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Delete.Action(DeleteAdmiExamindationEventType::SingleDelete);
        };
    }

    void AdmiView::SubscribeToSingleCancel()
    {
        ViewLogger::Trace("AdmiView::SubscribeToSingleCancel");

        DeletePtr->buttonCancel.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Delete.Action(DeleteAdmiExamindationEventType::SingleCancel);
        };
    }

    void AdmiView::SubscribeToMultipleDelete()
    {
        ViewLogger::Trace("AdmiView::SubscribeToMultipleDelete");

        MultipleDeleteConfirmUIPtr->buttonDelete.eventClicked = [this]
        {
            PopupDisplay::HideDialog(PopupDisplayID::PATEXMULTIDELETE_DIALOG);
            GuiDataModelPtr->Admi.Delete.Action(DeleteAdmiExamindationEventType::MultipleDelete);
        };
    }

    void AdmiView::SubscribeToMultipleCancel()
    {
        ViewLogger::Trace("AdmiView::SubscribeToMultipleCancel");

        MultipleDeleteConfirmUIPtr->buttonCancel.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Delete.Action(DeleteAdmiExamindationEventType::MultipleCancel);
        };
    }

    void AdmiView::Destroy()
    {
        ViewLogger::Trace("AdmiView::Destroy");
        
        GuiDataModelPtr->General.Popup.PopupUpdated -= PopupUpdatedSubscription;

        ScheduleListViewExPtr.reset();
        ScheduleTabLeftPanelUIPtr.reset();
        ScheduleTabPagePtr.reset();
        ExportRibbonPanelView.Destroy();
        ReviewTabLeftPanelUIPtr.reset();
        ReviewListViewExPtr.reset();
        ReviewTabPagePtr.reset();
        ReminderDlgPtr.reset();
        AddPtr.reset();
        DeletePtr.reset();
        MultipleDeleteConfirmUIPtr.reset();
        ListSelectionTimerPtr.reset();
        RACToolViewPtr->Destroy();
        RACToolViewPtr.reset();
        AdmiUIPtr.reset();
        GuiDataModelPtr.reset();
        ButtonHelpAdmi.reset();
        AdmiHeaderUIPtr.reset();
    }

    void AdmiView::SubscribeToTaskReview()
    {
        ViewLogger::Trace("AdmiView::SubscribeToTaskReview");

        ScheduleTabLeftPanelUIPtr->buttonTaskReview.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.SwitchPatientList(AdmiPageType::PAGE_REVIEW);
        };
    }

    void AdmiView::SubscribeToAdd()
    {
        ViewLogger::Trace("AdmiView::SubscribeToAdd");

        ScheduleTabLeftPanelUIPtr->buttonAdd.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::Add);
        };
    }

    void AdmiView::SubscribeToModify()
    {
        ViewLogger::Trace("AdmiView::SubscribeToModify");

        ScheduleTabLeftPanelUIPtr->buttonModifySchedule.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::Modify);
            AddPtr->editPatientname.setCaretPos(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.PatientName.Text.length()));
        };
    }

    void AdmiView::SubscribeToDelete()
    {
        ViewLogger::Trace("AdmiView::SubscribeToDelete");

        ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::Delete);
        };
    }

    void AdmiView::SubscribeToStartExamination()
    {
        ViewLogger::Trace("AdmiView::SubscribeToStartExamination");

        ScheduleTabLeftPanelUIPtr->buttonStartExamination.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::StartExamination);
            GuiDataModelPtr->Viewing.ExamPatex.ExamStatus= EXAM_ACTIVE;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        };
    }

    void AdmiView::SubscribeToWorklist()
    {
        ViewLogger::Trace("AdmiView::SubscribeToGetWorklist");

        ScheduleTabLeftPanelUIPtr->buttonGetWorklist.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::Worklist);
        };
    }

    void AdmiView::SubscribeToExaminationInfo()
    {
        ViewLogger::Trace("AdmiView::SubscribeToExaminationInfo");

        ScheduleTabLeftPanelUIPtr->buttonExaminationInfo.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Schedule.ScheduleListAction(ScheduleEventType::ExaminationInfo);
        };
    }

    void AdmiView::SubscribeToTaskSchedule()
    {
        ViewLogger::Trace("AdmiView::SubscribeToTaskSchedule");

        ReviewTabLeftPanelUIPtr->buttonTaskScheduled.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.SwitchPatientList(AdmiPageType::PAGE_SCHEDULE);
        };
    }

    void AdmiView::SubscribeToModifyReview()
    {
        ViewLogger::Trace("AdmiView::SubscribeToModifyReview");

        ReviewTabLeftPanelUIPtr->buttonModifyReview.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::Modify);
            AddPtr->editPatientname.setCaretPos(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.PatientName.Text.length()));
        };
    }

    void AdmiView::SubscribeToDeleteReview()
    {
        ViewLogger::Trace("AdmiView::SubscribeToDeleteReview");

        ReviewTabLeftPanelUIPtr->buttonDeleteReview.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::Delete);
        };
    }

    void AdmiView::SubscribeToShowExamination()
    {
        ViewLogger::Trace("AdmiView::SubscribeToShowExamination");

        ReviewTabLeftPanelUIPtr->buttonShowExamination.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::ShowExamination);
            if (ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.enabled)
            {
                GuiDataModelPtr->Viewing.ExamPatex.ExamStatus = EXAM_ACTIVE;
                GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
            }
            else
            {
                GuiDataModelPtr->Viewing.ExamPatex.ExamStatus = EXAM_CLOSE;
                GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
            }
        };
    }

    void AdmiView::SubscribeToExaminationInfoReview()
    {
        ViewLogger::Trace("AdmiView::SubscribeToExaminationInfoReview");

        ReviewTabLeftPanelUIPtr->buttonExaminationInfo.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::ExaminationInfo);
        };
    }

    void AdmiView::SubscribeToDoseReport()
    {
        ViewLogger::Trace("AdmiView::SubscribeToDoseReport");

        ReviewTabLeftPanelUIPtr->buttonDoseReport.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::DoseReport);
        };
    }

    void AdmiView::SubscribeToCloseExam()
    {
        ViewLogger::Trace("AdmiView::SubscribeToCloseExam");

        ReviewTabLeftPanelUIPtr->buttonCloseExam.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::CloseExam);
            GuiDataModelPtr->Viewing.ExamPatex.ExamStatus = EXAM_CLOSE;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        };
    }

    void AdmiView::SubscribeToBackToAcquisition()
    {
        ViewLogger::Trace("AdmiView::SubscribeToBackToAcquisition");

        ReviewTabLeftPanelUIPtr->buttonBackToAcquisition.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Review.ReviewListAction(ReviewEventType::BackToAcquisition);
            GuiDataModelPtr->Viewing.ExamPatex.ExamStatus = EXAM_ACTIVE;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        };
    }

    void AdmiView::SubscribeToAddPanelOK()
    {
        AddPtr->buttonOk.eventClicked = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::Ok, false);
        };
    }

    void AdmiView::SubscribeToAddPanelCancel()
    {
        AddPtr->buttonCancel.eventClicked = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::Cancel, false);
        };
    }

    void AdmiView::SubscribeToAddPanelStartExam()
    {
        AddPtr->buttonStartExam.eventClicked = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::StartExam, false);
            GuiDataModelPtr->Viewing.ExamPatex.ExamStatus = EXAM_ACTIVE;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        };
    }

    void AdmiView::SubscribeToAddPanelPatientTypeAdult()
    {
        AddPtr->radioAdult.eventClicked = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::AdultChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelPatientTypePediatric()
    {
        AddPtr->radioPediatric.eventClicked = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PediatricChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelExamtype()
    {
        AddPtr->comboExamtype.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::ExamTypeChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelPhysician()
    {
        AddPtr->comboPhysician.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PhysicianChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelDetProcType()
    {
        AddPtr->comboDetProcType.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::DetProcTypeChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelProfile()
    {
        AddPtr->comboProfile.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::ProfileChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelPatientName()
    {
        AddPtr->editPatientname.maxLength           = static_cast<int>(PATIENT_NAME_LENGTH);
        AddPtr->editPatientname.eventLengthExceeded = [this] (bool limitExceeded)
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PatientNameLengthExceeded, limitExceeded);
        };
    }

    void AdmiView::SubscribeToAddPanelPatientId()
    {
        AddPtr->editPatientId.maxLength             = static_cast<int>(PATIENT_ID_LENGTH);
        AddPtr->editPatientId.eventLengthExceeded = [this](bool limitExceeded)
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PatientIdLengthExceeded, limitExceeded);
        };
    }

    void AdmiView::SubscribeToAddPanelAccno()
    {
        AddPtr->editAccno.maxLength           = static_cast<int>(ACCESSION_NR_LENGTH);
        AddPtr->editAccno.eventLengthExceeded = [this] (bool limitExceeded)
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::AccnoLengthExceeded, limitExceeded);
        };
    }

    void AdmiView::SubscribeToAddPanelPatientWeight()
    {
        AddPtr->editPatientwt.maxLength           = static_cast<int>(WEIGHT_TEXT_LENGTH);
        AddPtr->editPatientwt.eventLengthExceeded = [this] (bool limitExceeded)
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PatientWeightLengthExceeded, limitExceeded);
        };
    }
     
    // Subscribe for Patient height in cms focus change event
    void AdmiView::SubscribeToAddPanelPatientHeight()
    {
        ViewLogger::Trace("AdmiView::SubscribeToAddPanelPatientHeight");

        AddPtr->editPatientHeight.eventFocusChanged = [this](bool focus)
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::PatientHeightFocusChanged, focus);
        };
    }

    void AdmiView::SubscribeToAddPanelFeet()
    {
        ViewLogger::Trace("AdmiView::SubscribeToAddPanelFeet");

        AddPtr->comboBoxFeet.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::FeetChanged, false);
        };
    }

    void AdmiView::SubscribeToAddPanelInch()
    {
        ViewLogger::Trace("AdmiView::SubscribeToAddPanelInch");

        AddPtr->comboBoxInches.eventSelectionChanged = [this]
        {
            UpdateGuiDataModelOnAddPanelEvents();
            GuiDataModelPtr->Admi.AddPanel.Action(AddPanelEventType::InchChanged, false);
        };
    }

    void AdmiView::UpdateGuiDataModelOnAddPanelEvents()
    {
        ViewLogger::Trace("AdmiView::UpdateGuiDataModelOnAddPanelEvents");

        GuiDataModelPtr->Admi.AddPanel.ProfileIndex                 = AddPtr->comboProfile.getSelectedItem();
        GuiDataModelPtr->Admi.AddPanel.PhysicianIndex               = AddPtr->comboPhysician.getSelectedItem();
        GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex                = AddPtr->comboExamtype.getSelectedItem();
        GuiDataModelPtr->Admi.AddPanel.ProcedureIndex               = AddPtr->comboDetProcType.getSelectedItem();
        GuiDataModelPtr->Admi.AddPanel.FeetComboIndex               = AddPtr->comboBoxFeet.getSelectedItem();
        GuiDataModelPtr->Admi.AddPanel.InchComboIndex               = AddPtr->comboBoxInches.getSelectedItem();

        GuiDataModelPtr->Admi.AddPanel.PatientNameText              = AddPtr->labelPatientName.text;
        GuiDataModelPtr->Admi.AddPanel.WeightText                   = AddPtr->labelWeight.text;
        GuiDataModelPtr->Admi.AddPanel.AccessionNrText              = AddPtr->labelAccessionNr.text;
        GuiDataModelPtr->Admi.AddPanel.PatientIDText                = AddPtr->labelPatientID.text;
        GuiDataModelPtr->Admi.AddPanel.HeightText                   = AddPtr->labelHeight.text;

        GuiDataModelPtr->Admi.AddPanel.PatientName.Text             = AddPtr->editPatientname.text;
        GuiDataModelPtr->Admi.AddPanel.PatientId.Text               = AddPtr->editPatientId.text;
        GuiDataModelPtr->Admi.AddPanel.Accno.Text                   = AddPtr->editAccno.text;
        GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text           = AddPtr->editPatientwt.text;
        GuiDataModelPtr->Admi.AddPanel.PatientWeight.Enabled        = AddPtr->editPatientwt.isEnabled();
        GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text           = AddPtr->editPatientHeight.text;

        GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked           = AddPtr->radioMale.checked;
        GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked         = AddPtr->radioFemale.checked;
        GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked        = AddPtr->radioUnknown.checked;

        GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked     = AddPtr->radioAdult.checked;
        GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked = AddPtr->radioPediatric.checked;
        GuiDataModelPtr->Admi.AddPanel.PatientDOBEnabled            = AddPtr->datePickerPatientDOB.isEnabled();
    }

    void AdmiView::OnLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnLocaleChanged");

        AdmiLocaleChanged();
        OnScheduleLocaleChanged();
        OnReviewLocaleChanged();
        OnShutdownLocaleChanged();
        OnReminderLocaleChanged();
        OnDeleteLocaleChanged();
        OnAddPanelLocaleChanged();
        OnSystemMenuItemLocaleChanged();
        OnHelpMenuLocaleChanged();
    }

    int  AdmiView::OnModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnModelUpdated");

        SenseDisplayer::SyncInvoke(*AdmiUIPtr, [this]
        {
            AdmiHeaderUIPtr->buttonProfile.visible = GuiDataModelPtr->Admi.ProfileVisibility;

            // Show Admi Window
            if (GuiDataModelPtr->Admi.Visible)
            {
                GuiDataModelPtr->Viewing.IPTools.Visible = false;
                GuiDataModelPtr->Viewing.IPTools.ModelUpdated();

                if (GuiDataModelPtr->Admi.DFIPasswordEnabled)
                {
                    auto iconName = (AdmiLoginType::FieldServiceUser == GuiDataModelPtr->Admi.LoginType) ? ICON_START_FIELD_SERVICE : ICON_LOGGEDON_USER;
                    AdmiHeaderUIPtr->labelLoggedInUser.image = Resources::LoadIconFromResource(iconName);
                    AdmiHeaderUIPtr->labelLoggedInUser.imageSize    = IMAGE_SIZE;
                    AdmiHeaderUIPtr->labelLoggedInUser.imageSpacing = IMAGE_SPACING;
                    AdmiHeaderUIPtr->labelLoggedInUser.font = Font(L"Philips Healthcare Font", 32.0, false, false, false, false, Font::Antialias::High);
                    AdmiHeaderUIPtr->labelLoggedInUser.text         = GuiDataModelPtr->Admi.LoggedInUser;

                }

                AdmiUIPtr->visible       = true;
                AdmiHeaderUIPtr->visible = true;

                AdmiUIPtr->bringToFront();

                SenseDisplayer::GetInstance().SetForeground(MONITOR_VIEWPORT_1);
                UserMouseKeyboardEx::SetActiveEventHandler(this);
            }
            else
            {
                // Close [System Menu] & [Help Menu], if opened.
                AdmiHeaderUIPtr->buttonSystem.Menu.collapse();
                ButtonHelpAdmi->Menu.collapse();

                AdmiUIPtr->visible = false;
                AdmiHeaderUIPtr->visible = false;

                UserMouseKeyboardEx::RemoveEventHandler(this);

            }
        });

        return OK;
    }

    void AdmiView::SetTabOrderForAddPanel()
    {
        ViewLogger::Trace("AdmiView::SetTabOrderForAddPanel");

        // Set proper tab order by changing Z-Order of controls.
        AddPtr->editPatientname.bringToFront();
        AddPtr->datePickerPatientDOB.bringToFront();
        AddPtr->editPatientwt.bringToFront();
        AddPtr->editPatientHeight.bringToFront();

        AddPtr->genderGroupControl.bringToFront();
        AddPtr->radioMale.bringToFront();
        AddPtr->radioFemale.bringToFront();
        AddPtr->radioUnknown.bringToFront();

        AddPtr->patientTypeGroupControl.bringToFront();
        AddPtr->radioAdult.bringToFront();
        AddPtr->radioPediatric.bringToFront();

        AddPtr->editPatientId.bringToFront();
        AddPtr->editAccno.bringToFront();

        AddPtr->comboProfile.bringToFront();
        AddPtr->comboPhysician.bringToFront();
        AddPtr->comboExamtype.bringToFront();
        AddPtr->comboDetProcType.bringToFront();

        AddPtr->buttonOk.bringToFront();
        AddPtr->buttonStartExam.bringToFront();
        AddPtr->buttonCancel.bringToFront();
    }

    void AdmiView::SetKeyboardFocusForAddPanel(const AddPanelKeyboardFocus control)
    {
        ViewLogger::Trace("AdmiView::SetKeyboardFocusForAddPanel");

        switch (control)
        {
            case AddPanelKeyboardFocus::PatientDOB:
                SenseDisplayer::SetKeyboardFocus(AddPtr->datePickerPatientDOB);
                break;
            
            case AddPanelKeyboardFocus::PatientWeight:
                SenseDisplayer::SetKeyboardFocus(AddPtr->editPatientwt);
                break;
            
            case AddPanelKeyboardFocus::PatientHeight:
                SenseDisplayer::SetKeyboardFocus(AddPtr->editPatientHeight);
                break;

            case AddPanelKeyboardFocus::PatientName:
                SenseDisplayer::SetKeyboardFocus(AddPtr->editPatientname);
                break;

            case AddPanelKeyboardFocus::None:
            default:
                break;
        }

        GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus = AddPanelKeyboardFocus::None;
    }

    void AdmiView::SetDOBDateFormat(const DATE_FORMAT_ENUM dateFormat)
    {
        ViewLogger::Trace("AdmiView::SetDOBDateFormat");

        SenseDisplayer::SyncInvoke(*AddPtr, [this, &dateFormat]
        {
            AddPtr->datePickerPatientDOB.SetDateFormat(dateFormat);
        });
    }

    void AdmiView::SetDOBText(const std::wstring& newText)
    {
        ViewLogger::Trace("AdmiView::SetDOBText");

        SenseDisplayer::SyncInvoke(*AddPtr, [this, &newText]
        {
            AddPtr->datePickerPatientDOB.SetText(newText);
        });
    }

    bool AdmiView::GetDOBText(std::wstring& dateStr)
    {
        bool validDate = false;

        SenseDisplayer::SyncInvoke(*AddPtr, [this, &validDate, &dateStr]
        {
            validDate = AddPtr->datePickerPatientDOB.GetText(dateStr);
        });

        return validDate;
    }

    void AdmiView::ClearDOBText()
    {
        ViewLogger::Trace("AdmiView::ClearDOBText");

        SenseDisplayer::SyncInvoke(*AddPtr, [this]
        {
            AddPtr->datePickerPatientDOB.ClearText();
        });
    }

    bool AdmiView::OnIsMenuExpanded() const
    {
        return (AdmiHeaderUIPtr->buttonSystem.Menu.isExpanded() ||
            ButtonHelpAdmi->Menu.isExpanded());
    }

    int AdmiView::InitializeReminderPanel()
    {
        ViewLogger::Trace("Admi::InitializeReminderPanel");
        int status = OK;

        if (OK == PopupDisplay::CreatePopupDialog<Composer::Reminder>(ReminderDlgPtr))
        {
            ReminderDlgPtr->image = Resources::LoadIconFromResource(ICON_INFORMATION);
            SubscribeToEventClicked();
        }
        else
        {
            status = GUI_E_UI_COMPONENT;
            ViewLogger::Error("Unable to initialize Reminder panel");
        }

        return status;
    }

    int AdmiView::OnReminderModelUpdated()
    {
        ViewLogger::Trace("AdmiView::OnReminderModelUpdated");

        SenseDisplayer::SyncInvoke(*ReminderDlgPtr, [this]
        {
            if (true == GuiDataModelPtr->Admi.Reminder.Visible)   // show  Reminder dialog 
            {
                ReminderDlgPtr->labelMessage.text = GuiDataModelPtr->Admi.Reminder.Message;
                SenseDisplayer::SetKeyboardFocus(ReminderDlgPtr->buttonOK);
                PopupDisplay::ShowDialog(PopupDisplayID::REMINDER_DIALOG, ReminderDlgPtr.get());
            }
            else   // hide
            {
                PopupDisplay::HideDialog(PopupDisplayID::REMINDER_DIALOG);
            }
        });
      
        return OK;
    }

    void AdmiView::OnReminderLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnReminderLocaleChanged");

        SenseDisplayer::SyncInvoke(*ReminderDlgPtr, [this]
        {
            if (nullptr != GuiDataModelPtr->LocalePtr)
            {
                ReminderDlgPtr->text = GuiDataModelPtr->LocalePtr->GetText(ReminderDlgPtr->name);
                ReminderDlgPtr->buttonOK.text = GuiDataModelPtr->LocalePtr->GetText(ReminderDlgPtr->buttonOK.name);
            }
            else
            {
                ViewLogger::Warning("ILocale is NULL");
            }
        });
    }

    void AdmiView::OnDeleteLocaleChanged()
    {
        ViewLogger::Trace("AdmiView::OnDeleteLocaleChanged");
        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {
            // Update Text of DeleteDialog and its child controls.
            DeletePtr->text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->name);
            DeletePtr->labelConfirmationMsg.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelConfirmationMsg.name);
            DeletePtr->labelPatientName.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelPatientName.name);
            DeletePtr->labelPatientId.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelPatientId.name);
            DeletePtr->labelDateOfBirth.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelDateOfBirth.name);
            DeletePtr->labelGender.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelGender.name);
            DeletePtr->labelAccNr.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelAccNr.name);
            DeletePtr->labelExamType.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelExamType.name);
            DeletePtr->labelPhysician.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->labelPhysician.name);
            DeletePtr->buttonDelete.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->buttonDelete.name);
            DeletePtr->buttonCancel.text = GuiDataModelPtr->LocalePtr->GetText(DeletePtr->buttonCancel.name);

            MultipleDeleteConfirmUIPtr->text = GuiDataModelPtr->LocalePtr->GetText(MultipleDeleteConfirmUIPtr->name);
            MultipleDeleteConfirmUIPtr->buttonDelete.text = GuiDataModelPtr->LocalePtr->GetText(MultipleDeleteConfirmUIPtr->buttonDelete.name);
            MultipleDeleteConfirmUIPtr->buttonCancel.text = GuiDataModelPtr->LocalePtr->GetText(MultipleDeleteConfirmUIPtr->buttonCancel.name);
        });
    }

    void AdmiView::SubscribeToEventClicked()
    {
        ViewLogger::Trace("AdmiView::SubscribeToEventClicked");

        ReminderDlgPtr->buttonOK.eventClicked = [this]
        {
            GuiDataModelPtr->Admi.Reminder.Action();
        };
    }

    int AdmiView::OnShowDeleteDialog()
    {
        ViewLogger::Trace("AdmiView::OnShowDeleteDialog");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {

            if (ScheduleTabPagePtr->isSelected())
            {
                ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.checked = GuiDataModelPtr->Admi.Schedule.Delete.Checked = true;
            }
            else if (ReviewTabPagePtr->isSelected())
            {
                ReviewTabLeftPanelUIPtr->buttonDeleteReview.checked = GuiDataModelPtr->Admi.Review.Delete.Checked = true;
            }
            else
            {
                //Nothing to do.
            }

            if (!GuiDataModelPtr->Admi.Delete.MultipleExamination)
            {
                DeletePtr->image = Resources::LoadIconFromResource(ICON_DELETE);

                // Set values
                DeletePtr->lblPatientName.text = GuiDataModelPtr->Admi.Delete.PatientName;
                DeletePtr->lblPatientId.text = GuiDataModelPtr->Admi.Delete.PatientId;
                DeletePtr->lblDateOfBirth.text = GuiDataModelPtr->Admi.Delete.PatientDateOfBirth;
                DeletePtr->lblGender.text = GuiDataModelPtr->Admi.Delete.PatientGender;
                DeletePtr->lblExamType.text = GuiDataModelPtr->Admi.Delete.PatientExamType;
                DeletePtr->lblPhysician.text = GuiDataModelPtr->Admi.Delete.Physician;
                DeletePtr->lblAccNr.text = GuiDataModelPtr->Admi.Delete.AccNr;

                DeletePtr->buttonCancel.glow = true;

                PopupDisplay::ShowDialog(PopupDisplayID::PATEXDELETE_DIALOG, DeletePtr.get());

                GuiDataModelPtr->Admi.Delete.SingleDeleteDialogIsVisible = true;
            }
            else
            {
                MultipleDeleteConfirmUIPtr->image = Resources::LoadIconFromResource(ICON_DELETE);

                MultipleDeleteConfirmUIPtr->labelConfirmationMsg.text = GuiDataModelPtr->Admi.Delete.ConfirmationMessage;

                MultipleDeleteConfirmUIPtr->buttonCancel.glow = true;

                PopupDisplay::ShowDialog(PopupDisplayID::PATEXMULTIDELETE_DIALOG, MultipleDeleteConfirmUIPtr.get());

                GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible = true;
            }
        });

        return OK;
    }

    int AdmiView::OnHideDeleteDialog()
    {
        ViewLogger::Trace("AdmiView::OnHideDeleteDialog");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {

            if (DeletePtr->isVisible())
            {
                PopupDisplay::HideDialog(PopupDisplayID::PATEXDELETE_DIALOG);

                GuiDataModelPtr->Admi.Delete.SingleDeleteDialogIsVisible = false;
            }
            else if (MultipleDeleteConfirmUIPtr->isVisible())
            {
                PopupDisplay::HideDialog(PopupDisplayID::PATEXMULTIDELETE_DIALOG);

                GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible = false;
            }
            else
            {
                // Do nothing
            }

            if (ScheduleTabPagePtr->isSelected())
            {
                ScheduleTabLeftPanelUIPtr->buttonDeleteSchedule.checked = GuiDataModelPtr->Admi.Schedule.Delete.Checked = false;
            }
            else if (ReviewTabPagePtr->isSelected())
            {
                ReviewTabLeftPanelUIPtr->buttonDeleteReview.checked = GuiDataModelPtr->Admi.Review.Delete.Checked = false;
            }
            else
            {
                // Do nothing.
            }
        });

        return OK;
    }

    void AdmiView::OnExamUpdated(const GUI_ADMI_ROW_STRUCT& patExamData, const ADMI_DATA_LAYER_TABLE_ENUM table)
    {
        ViewLogger::Trace("AdmiView::OnExamUpdated");

        if (ADMI_DATA_LAYER_TABLE_ENUM::ADMI_TABLE_SCHEDULE == table)
        {
            UpdateScheduleExam(patExamData);
        }
        else if (ADMI_DATA_LAYER_TABLE_ENUM::ADMI_TABLE_REVIEW == table)
        {
            UpdateReviewExam(patExamData);
        }
        else
        {
            //Do Nothing
        }
    }

    void AdmiView::UpdateScheduleExam(const GUI_ADMI_ROW_STRUCT& patExamData)
    {
        ViewLogger::Trace("AdmiView::ScheduledExamUpdate");

        SenseDisplayer::SyncInvoke(*AdmiUIPtr, [this, patExamData]
        {
            int modifiedRow = NO_ROW_SELECTED;
            Row scheduleRow;
            Image cellIcon = ExamStateToIcon(patExamData.status,
                                             patExamData.exportStatus,
                                             patExamData.worklistStatus);
            scheduleRow.AddCell(L" ", cellIcon);

            scheduleRow.AddCell(std::wstring(patExamData.patientName));

            char genderChar[2] = { 0 };
            ViewUtilities::GuiUtils::SexEnumToSexString(patExamData.sex,genderChar, static_cast<int>(sizeof(genderChar)), BOOLEAN_TRUE);
            scheduleRow.AddCell(Utilities::StringConverter::StringToWstring(genderChar));

            std::wstring date;
            Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.birthDate,
                                                               this->GuiDataModelPtr->Admi.Setup.DateFormat,
                                                               this->GuiDataModelPtr->LocalePtr,
                                                               date);
            scheduleRow.AddCell(date);

            if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
            {
                scheduleRow.AddCell(patExamData.accNr);
            }
            else
            {
                scheduleRow.AddCell(patExamData.regNr);
            }

            std::wstring examType = L"";
            examType = std::wstring(patExamData.examType);
            if (0 != wcslen(patExamData.detProcType))
            {
                examType = examType + L" - ";
                examType = examType + patExamData.detProcType;
            }
            scheduleRow.AddCell(examType);

            scheduleRow.AddCell(patExamData.physician);
            scheduleRow.SetExtendedData(std::to_wstring(patExamData.patientId));

            int rowIndex = FindPatRowIndex(ADMI_TABLE_SCHEDULE, patExamData.patientId);

            if (NO_ROW_SELECTED == rowIndex)
            {
                ScheduleListViewExPtr->AddItem(scheduleRow);
                modifiedRow = GetNumberOfRows(ADMI_TABLE_SCHEDULE) - 1;
                SetSelectedRow(ADMI_TABLE_SCHEDULE, modifiedRow);
            }
            else
            {
                ScheduleListViewExPtr->UpdateRow(rowIndex, scheduleRow);
                modifiedRow = rowIndex;
            }
        });

    }

    void AdmiView::UpdateReviewExam(const GUI_ADMI_ROW_STRUCT& patExamData)
    {
        ViewLogger::Trace("AdmiView::ReviewedExamUpdate");

        SenseDisplayer::SyncInvoke(*AdmiUIPtr, [this, patExamData]
        {
            Row reviewRow;
            Image cellIcon = ExamStateToIcon(patExamData.status,
                                             patExamData.exportStatus,
                                             patExamData.worklistStatus);
            reviewRow.AddCell(L" ", cellIcon);

            reviewRow.AddCell(std::wstring(patExamData.patientName));

            char genderChar[2] = { 0 };
            ViewUtilities::GuiUtils::SexEnumToSexString(patExamData.sex, genderChar, static_cast<int>(sizeof(genderChar)), BOOLEAN_TRUE);
            reviewRow.AddCell(Utilities::StringConverter::StringToWstring(genderChar));

            std::wstring dateOfBirth;
            Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.birthDate,
                                                               this->GuiDataModelPtr->Admi.Setup.DateFormat,
                                                               this->GuiDataModelPtr->LocalePtr,
                                                               dateOfBirth);
            reviewRow.AddCell(dateOfBirth);

            if (BOOLEAN_TRUE == GuiDataModelPtr->Admi.AccNumVisible)
            {
                reviewRow.AddCell(patExamData.accNr);
            }
            else
            {
                reviewRow.AddCell(patExamData.regNr);
            }

            std::wstring dateOfExam;
            Utilities::DateUtility::ConvertOsaTimeToDateString(patExamData.examDate,
                                                               this->GuiDataModelPtr->Admi.Setup.DateFormat,
                                                               this->GuiDataModelPtr->LocalePtr,
                                                               dateOfExam);
            reviewRow.AddCell(dateOfExam);

            std::wstring examType = L"";
            examType = std::wstring(patExamData.examType);
            if (0 != wcslen(patExamData.detProcType))
            {
                examType = examType + L" - ";
                examType = examType + patExamData.detProcType;
            }
            reviewRow.AddCell(examType);

            reviewRow.AddCell(patExamData.physician);
            reviewRow.AddCell(std::to_wstring(patExamData.nrOfImages));
            reviewRow.SetExtendedData(std::to_wstring(patExamData.patientId));

            int rowIndex = FindPatRowIndex(ADMI_TABLE_REVIEW, patExamData.patientId);
            int currentSelection = GetSelectedRow(ADMI_TABLE_REVIEW);
            if (NO_ROW_SELECTED == rowIndex)
            {
                ReviewListViewExPtr->AddItem(reviewRow);
            }
            else
            {
                ReviewListViewExPtr->UpdateRow(rowIndex, reviewRow);
            }
            // Maintain current selection.
            SetSelectedRow(ADMI_TABLE_REVIEW, currentSelection);

        });
    }

    //Sets the examination state icon.
    //Since only one state can be displayed the examState icon will be that state that has the highest priority in displaying.
    //The priority order is: acquisition,review,archived,scheduled,none 
    Sense::Image AdmiView::ExamStateToIcon(EXAM_STATUS_ENUM examStatus, EXAM_EXPORT_STATUS_ENUM exportStatus, EXAM_WORKLIST_STATUS_ENUM worklistStatus)
    {
        ViewLogger::Trace("AdmiView::ExamStateToIcon");

        Sense::Image cellIcon;

        if (EST_CURRENT_ACQ == examStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_PATIENT_ACQUISITION);
        }
        else if (EST_CURRENT_REV == examStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_APPLICATION_VIEWING);
        }
        else if (EEST_ARCHIVED_AND_MPPS == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_ARCHIVED_AND_MPPS);
        }
        else if (EEST_MPPS_ONLY == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_MPPS_ONLY);
        }
        else if (EEST_ARCHIVED_ONLY == exportStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_ARCHIVE_ONLY);
        }
        else if (EWST_NEVER_RECEIVED != worklistStatus)
        {
            cellIcon = Resources::LoadIconFromResource(MVSUI::ICON_SCHEDULER_NOW);
        }
        else if (EST_SCHEDULED == examStatus)
        {
            cellIcon = Image();
        }
        else
        {
            cellIcon = Image();
        }
        return cellIcon;
    }

    int AdmiView::FindPatRowIndex(const ADMI_DATA_LAYER_TABLE_ENUM table, int patId)
    {
        ViewLogger::Trace("AdmiView::FindPatRowIndex");

        int rowFound = NO_ROW_SELECTED;
        long patientID = NO_ROW_SELECTED;

        ViewLogger::Debug("ID=%d", patId);

        int numberOfRows = GetNumberOfRows(table);
        for (int rowIndex = 0; (rowIndex< numberOfRows) && (NO_ROW_SELECTED == rowFound); rowIndex++)
        {
            patientID = GetPatientIDfromRow(table, rowIndex);

            if (patientID == patId)
            {
                rowFound = rowIndex;
                break;
            }
        }

        ViewLogger::Debug("Row Found = %d", rowFound);
        return rowFound;
    }

    int AdmiView::GetNumberOfRows(const ADMI_DATA_LAYER_TABLE_ENUM table) const
    {
        ViewLogger::Trace("AdmiView::GetNumberOfRows");

        int numberOfRows = 0;

        if (ADMI_TABLE_SCHEDULE == table)
        {
            numberOfRows = ScheduleListViewExPtr->GetItemCount();
        }
        else if (ADMI_TABLE_REVIEW == table)
        {
            numberOfRows = ReviewListViewExPtr->GetItemCount();
        }
        else
        {
            // Do nothing.
        }

        return numberOfRows;
    }

    int AdmiView::GetPatientIDfromRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex)
    {
        ViewLogger::Trace("AdmiView::GetPatientIDfromRow");

        int patientID;
        if (ADMI_TABLE_SCHEDULE == table)
        {
            if (ScheduleListViewExPtr->GetRowExtendedData(rowIndex).empty())
            {
                patientID = NO_ROW_SELECTED;
            }
            else
            {
                patientID = static_cast<int>(std::stol(ScheduleListViewExPtr->GetRowExtendedData(rowIndex)));
            }
        }
        else
        {
            if (ReviewListViewExPtr->GetRowExtendedData(rowIndex).empty())
            {
                patientID = NO_ROW_SELECTED;
            }
            else
            {
                patientID = static_cast<int>(std::stol(ReviewListViewExPtr->GetRowExtendedData(rowIndex)));
            }
        }
        return patientID;
    }

    void AdmiView::SetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const int rowIndex)
    {
        ViewLogger::Trace("AdmiView::SetSelectedRow");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, rowIndex]
        {
            std::set<int> selectedItems;
            selectedItems.insert(rowIndex);

            if (ADMI_TABLE_SCHEDULE == table)
            {
                ScheduleListViewExPtr->setSelection(selectedItems);
                ScheduleListViewExPtr->setSelectedItem(rowIndex);
                ScheduleListViewExPtr->ensureVisible(rowIndex);
            }
            else if (ADMI_TABLE_REVIEW == table)
            {
                ReviewListViewExPtr->setSelection(selectedItems);
                ReviewListViewExPtr->setSelectedItem(rowIndex);
                ReviewListViewExPtr->ensureVisible(rowIndex);
            }
            else
            {
                // Do nothing.
            }
        });
    }

    // GetSelectedRow
    // Returns -1                    : No row selected
    //         -2                    : Multiple rows selected
    //          Current selected row : One row selected

    int AdmiView::GetSelectedRow(const ADMI_DATA_LAYER_TABLE_ENUM table)
    {
        ViewLogger::Trace("AdmiView::GetSelectedRow");

        int selectedIndex = NO_ROW_SELECTED;
        SenseDisplayer::AsyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this,table, &selectedIndex]
        {
            std::set<int> selectedItems;
            if (ADMI_TABLE_SCHEDULE == table)
            {
                selectedItems = ScheduleListViewExPtr->getSelection();
            }
            else if (ADMI_TABLE_REVIEW == table)
            {
                selectedItems = ReviewListViewExPtr->getSelection();
            }
            else
            {
                // Do nothing.
            }

            if (static_cast<size_t>(1) < selectedItems.size())
            {
                // Multiple rows selected
                selectedIndex = MULTIPLE_ROW_SELECTED;
            }
            else if (static_cast<size_t>(1) == selectedItems.size())
            {
                // Single row selected
                selectedIndex = *(selectedItems.begin());
            }
            else
            {
                // Do nothing
            }
        });
        return selectedIndex;
    }

    void AdmiView::OnListHeaderClicked(const ADMI_DATA_LAYER_TABLE_ENUM table, const int columnIndex)
    {
        ViewLogger::Trace("AdmiView::OnListHeaderClicked");

        // Backup current selected Patient ID.
        int currentSelectedPatID= NO_ROW_SELECTED;
        int currentSelectedPatRowIndex = GetSelectedRow(table);
        if (NO_ROW_SELECTED < currentSelectedPatRowIndex)
        {
            currentSelectedPatID = GetPatientIDfromRow(table, currentSelectedPatRowIndex);
        }
        
        // Sort the list based on Column.
        if (ADMI_TABLE_SCHEDULE == table)
        {
            if (static_cast<int>(SCHEDULELIST_COLUMNINDEX::SCHEDULELIST_COLIDX_DOB) == columnIndex)
            {
                ScheduleListViewExPtr->Sort(columnIndex, &AdmiView::SortByDate);
            }
            else
            {
                ScheduleListViewExPtr->Sort(columnIndex);
            }
        }
        else
        {
            if ((static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_DOB) == columnIndex) ||
                (static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_EXAMDT) == columnIndex))
            {
                ReviewListViewExPtr->Sort(columnIndex, &AdmiView::SortByDate);
            }
            else if (static_cast<int>(REVIEWLIST_COLUMNINDEX::REVIEWLIST_COLIDX_IMAGE) == columnIndex)
            {
                ReviewListViewExPtr->Sort(columnIndex, &AdmiView::SortByNoOfImage);
            }
            else
            {
                ReviewListViewExPtr->Sort(columnIndex);
            }
        }
        // Put selection back on previously selected patient.
        if (NO_ROW_SELECTED < currentSelectedPatRowIndex)
        {
            int newRowIndex = FindPatRowIndex(table, currentSelectedPatID);
            SetSelectedRow(table, newRowIndex);
        }
        
    }

    bool AdmiView::SortByDate(const ListViewCell& cellLHS, const ListViewCell& cellRHS)
    {
        ViewLogger::Trace("AdmiView::SortByDate");

        int lhs = 0;
        int rhs = 0;

        GUI_BOUNDARY_STRUCT dobYear;
        dobYear.lowerLimit = GUI_DOB_LOWER_LIMIT;
        dobYear.upperLimit = GUI_DOB_UPPER_LIMIT;

        AdmiView *thisPtr = dynamic_cast<AdmiView*>(MainView::Instance().GetComponentByID(GUI_SC_WINDOW_ADMI).get());
        OsaTime lhsDate;
        memset(&lhsDate, 0, sizeof(lhsDate));
        if (Utilities::DateUtility::ConvertDateStringToOsaTime(cellLHS.cellText,
                                                               thisPtr->GuiDataModelPtr->Admi.Setup.DateFormat,
                                                               thisPtr->GuiDataModelPtr->LocalePtr,
                                                               lhsDate, 1900))
        {
            lhs = ViewUtilities::GuiUtils::OsaTimeToSortableDate(&lhsDate);
        }

        OsaTime rhsDate;
        memset(&rhsDate, 0, sizeof(rhsDate));
        if (Utilities::DateUtility::ConvertDateStringToOsaTime(cellRHS.cellText,
                                                               thisPtr->GuiDataModelPtr->Admi.Setup.DateFormat,
                                                               thisPtr->GuiDataModelPtr->LocalePtr,
                                                               rhsDate, 1900))
        {
            rhs = ViewUtilities::GuiUtils::OsaTimeToSortableDate(&rhsDate);
        }
        return (lhs < rhs);
    }

    bool AdmiView::SortByNoOfImage(const ListViewCell& cellLHS, const ListViewCell& cellRHS)
    {
        ViewLogger::Trace("AdmiView::SortByNoOfImage");

        int lhs = std::stoi(cellLHS.cellText);
        int rhs = std::stoi(cellRHS.cellText);

        return (lhs < rhs);
    }

    void AdmiView::SubscribeToListSelectionChanged()
    {
        ViewLogger::Trace("AdmiView::SubscribeToListSelectionChanged");

        ScheduleListViewExPtr->eventSelectionChanged = [this] { OnListSelectionChanged(); };
        ReviewListViewExPtr->eventSelectionChanged =   [this] { OnListSelectionChanged(); };
    }

    void AdmiView::OnListSelectionChanged()
    {
        ViewLogger::Trace("AdmiView::OnListSelectionChanged");

        const double LISTSELECTION_TICKTIME = 0.1; // 100 Milliseconds.
        ListSelectionTimerPtr->start(LISTSELECTION_TICKTIME);
    }

    void AdmiView::OnListSelectionTimer()
    {
        ViewLogger::Trace("AdmiView::OnListSelectionTimer");

        // Stop the timer. One selection change will cause only one Timer Tick
        ListSelectionTimerPtr->stop();

        SetSelectedPatientID();

        GuiDataModelPtr->Admi.ExamSelectionChanged();
    }

    void AdmiView::SetSelectedPatientID()
    {
        ViewLogger::Trace("AdmiView::SetSelectedPatientID");

        std::set<int> selectedItems;
        int patId = NO_ROW_SELECTED;

        if (ADMI_TABLE_SCHEDULE == GuiDataModelPtr->Admi.ListType)
        {
            selectedItems = ScheduleListViewExPtr->getSelection();
        }
        else if (ADMI_TABLE_REVIEW == GuiDataModelPtr->Admi.ListType)
        {
            selectedItems = ReviewListViewExPtr->getSelection();
        }
        else
        {
            //Nothing to do.
        }

        GuiDataModelPtr->Admi.SelectedPatientIDs.clear();

        for (int selectedItem = 0; selectedItem < static_cast<int>(selectedItems.size()); selectedItem++)
        {
            int pos = *std::next(selectedItems.begin(), selectedItem);

            patId = GetPatientIDfromRow(GuiDataModelPtr->Admi.ListType, pos);
            GuiDataModelPtr->Admi.SelectedPatientIDs.push_back(patId);
        }

    }

    void AdmiView::OnPageSelection(const ADMI_DATA_LAYER_TABLE_ENUM listType)
    {
        ViewLogger::Trace("AdmiView::OnPageSelection");

        if (ADMI_TABLE_SCHEDULE == listType)
        {
            SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
            {
                // Show Schedule table
                ScheduleTabPagePtr->select();

                // UnSelect rows
                ScheduleListViewExPtr->UnSelectRows();
            });

            int rowIndex = GetNumberOfRows(ADMI_TABLE_SCHEDULE) - 1;
            SetSelectedRow(ADMI_TABLE_SCHEDULE, rowIndex);
            SetSelectedPatientID();
        }

        else if (ADMI_TABLE_REVIEW == listType)
        {
            SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
            {
                // Show Review table
                ReviewTabPagePtr->select();
                SetSelectedPatientID();
            });

        }
        else
        {
            // Do Nothing
        }
    }

    void AdmiView::OnExamDeleted(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId)
    {
        ViewLogger::Trace("AdmiView::OnExamDelete");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, patId]
        {
            int patientRow = NO_ROW_SELECTED;
            int status = OK;
            patientRow = FindPatRowIndex(table, patId);

            if (NO_ROW_SELECTED == patientRow)
            {
                status = GUI_E_DIR_INFO;
                ViewLogger::Warning("PatientID %d is not present in the list", patId);
            }
            else
            {
                int previouslySelectedRow = GetSelectedRow(table);
                status = DeleteTableRow(table, patientRow);
                DeleteSelectedPatientId(patId);
                if ((OK == status) && (NO_ROW_SELECTED != previouslySelectedRow))
                {

                    if (patientRow >= GetNumberOfRows(table))
                    {
                        // If last row is deleted, highlight the new last row in the review/schedule list.
                        patientRow = GetNumberOfRows(table) - 1;
                    }

                    //During auto delete, eventSelectionChanged should not be triggered 
                    //  for intermediate exams deletion in Review/Schedule panel.
                    if (previouslySelectedRow == patientRow)
                    {
                        SetSelectedRow(table, patientRow);
                    }
                }
            }
            
        });
    }

    void AdmiView::OnExamHidden(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId)
    {
        ViewLogger::Trace("AdmiView::OnExamHidden");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, patId]
        {
            int row = FindPatRowIndex(table, patId);
            if (NO_ROW_SELECTED != row)
            {
                (void)DeleteTableRow(table, row);
                DeleteSelectedPatientId(patId);
            }
        });
    }

    void AdmiView::OnExamSelection(const ADMI_DATA_LAYER_TABLE_ENUM table, const KEY_TYPE patId)
    {
        ViewLogger::Trace("AdmiView::OnExamSelection");

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, table, patId]
        {
            int row = FindPatRowIndex(table, patId);
            if (NO_ROW_SELECTED != row)
            {
                SetSelectedRow(table, row);
                SetSelectedPatientID();
            }
        });
    }

    int AdmiView::DeleteTableRow(const ADMI_DATA_LAYER_TABLE_ENUM table, const long row)
    {
        ViewLogger::Trace("AdmiView::DeleteTableRow");

        int status = OK;
        ViewLogger::Debug("Table %d=[%d], row %d", table, GuiDataModelPtr->Admi.ListType, row);

        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this, row, table]
        {
            if (ADMI_TABLE_SCHEDULE == table)
            {
                ScheduleListViewExPtr->Delete(row);
            }
            else
            {
                ReviewListViewExPtr->Delete(row);
            }
        });

        return(status);
    }

    void AdmiView::OnExamClear()
    {
        ViewLogger::Trace("AdmiView::OnExamClear");
        SenseDisplayer::SyncInvoke(*SenseDisplayer::GetInstance().GetCanvas(MONITOR_VIEWPORT_1), [this]
        {
            // Clear the entire Schedule table
            ScheduleListViewExPtr->DeleteList();

            // Clear the entire review table
            ReviewListViewExPtr->DeleteList();
        });

    }

    void AdmiView::DeleteSelectedPatientId(const KEY_TYPE patId)
    {
        ViewLogger::Trace("AdmiView::DeleteTableRow");

        auto it = find(GuiDataModelPtr->Admi.SelectedPatientIDs.begin(), GuiDataModelPtr->Admi.SelectedPatientIDs.end(), patId);
        if (it != GuiDataModelPtr->Admi.SelectedPatientIDs.end()) 
        {
            GuiDataModelPtr->Admi.SelectedPatientIDs.erase(it);
        }

    }
}

model header:
//****************************************************************************//
//                                                                            //
//   Filename   : Admi.h                                                      //
//                                                                            //
//   Description: Patient Adminstration UI                                    //
//                                                                            //
//   Copyright  : Philips Medical Systems Nederland B.V., 2020.               //
//                                                                            //
//****************************************************************************//

#ifndef ADMI_H
#define ADMI_H

#include <array>
#include <mutex>

#include "IGuiComponent.h"
#include "IAdmiModel.h"
#include "ISuspendable.h"
#include "IUpdateInternals.h"
#include "ModelViewInterface.h"

namespace Gui
{
    // GUI_ADMI_STRUCT keeps track of internal ADMI situation: which actions are requested, which row is edited.
    typedef struct
    {
        bool                      patientEditSuspended;
        bool                      examEditSuspended;
        bool                      examAcqSuspended;
        bool                      examRevSuspended;
        bool                      examRevHiLiSuspended;
        bool                      examExpSuspended;
        bool                      retrWlSuspended;
        bool                      examInfoSuspended;
        GUI_ADMI_ROW_STRUCT       selectedRow;
        bool                      patexEditActive;        // Patient/exam edit window is active
        bool                      patDelQuesActive;       // Patient delete question is active
        bool                      startupReminderActive;  // Startup reminder message is active
        bool                      showFreeImagesMsg;
        int                       nrFreeImgs;
        bool                      showQueuedImagesMsg;
        bool                      showQueuedRsmLoggingMsg;
        bool                      rowModified;            // Patient/exam is modified
        bool                      shutdownConfirmationActive;
        GUI_SC_WINDOW_ADMI_STRUCT admi;
    } GUI_ADMI_STRUCT;

    // Forward Declaration
    class  AdmiTab;
    class  AdmiTabPage;
    class  UserMouseKeyboardEx;
    class  About;
    class  RemoteAssistanceTool;
    class  ListViewEx;
    struct ListViewCell;

    class Admi final : public IGuiComponent, public IAdmiModel, public ISuspendable, public IUpdateInternals, public IObserver
    {

    public:

                 Admi();
        virtual ~Admi() = default;

        // IGuiComponent Implementation
        virtual int Init(const MONITOR_ENUM monNr)                                                                      override;
        virtual int Show(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& signalData)                                 override;
        virtual int Hide(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& signalData, const bool doInvalidate)        override;
        virtual int Cancel(const MONITOR_ENUM monNr, const bool showOld, const bool closeWindow)                        override;
        virtual void Destroy()                                                                                          override;
        virtual void SetLocale(std::shared_ptr<ILocale> localePtr)                                                      override;

        // IAdmiModel Implementation
        virtual int PatientAdd(GUI_ADMI_NODE_STRUCT& patExamNode)                                                       override;
        virtual int PatientModify(GUI_ADMI_NODE_STRUCT& patExamNode)                                                    override;
        virtual int PatientDelete(GUI_ADMI_NODE_STRUCT& patExamNode, bool repaintFlag)                                  override;
        virtual int PatientClear()                                                                                      override;
        virtual int ExamAdd(GUI_ADMI_NODE_STRUCT& patExamNode)                                                          override;
        virtual int ExamModify(GUI_ADMI_NODE_STRUCT& patExamNode, bool tableChange)                                     override;
        virtual int ExamDelete(GUI_ADMI_NODE_STRUCT& patExamNode)                                                       override;

        // Implementation of ISuspendable.
        virtual int Suspend(const MONITOR_ENUM monNr, const GUI_ACTION_ENUM actionCode)                                 override;
        virtual int Resume(const MONITOR_ENUM monNr, const GUI_ACTION_ENUM actionCode)                                  override;

        // Implementation for IUpdateInternals
        virtual int Update(const MONITOR_ENUM monNr, const GUI_UPDATE_STRUCT& updateInfo)                               override;

        // Implementation for IObserver
        virtual void Notify(const GUI_NOTIFICATION_TYPE type, void* dataPtr)                                            override;

        // Method for updating button check status from other panels.
        void SetButtonCheck(const std::wstring& controlID, bool checkState);

    private:

        void OnExamSelectionChanged();
        void OnSwitchPatientList(const MVSUI::AdmiPageType activeTab);
        int  OnKeyPress(const int keyCode);
        void OnIFUClicked();
        void OnChangePasswordClicked();
        void OnRemoteAssistanceClicked() const;
        void OnFieldServiceClicked();
        void OnSwitchUserClicked(); 
        void OnWirelessNetworkClicked();

        // Button event handlers
        void AddClicked();
        void ModifyClicked();
        void DeleteClicked();
        void StartExamClicked();
        void ShowExamClicked();
        void GetWorkListClicked();
        void DoseReportClicked();
        void CloseExamClicked();
        void WorkListInfoClicked();
        void BackToAcquisitionClicked();

        void PatexEditOkClicked();
        void PatexEditCancelClicked();
        void PatexEditStartExamClicked();
        void DeleteQuestionYesClicked();
        void DeleteQuestionNoClicked();

        void MultipleDeleteConfirmClicked();
        void MultipleDeleteCancelClicked();
        void ProfileBtnClicked();


        //Display current logged-In user
        void DisplayLoggedInUserName();

        // Patex Edit

        void PatexEditInd();
        void PatexEditRem();
        int  GetPatExEditData();
        void SetPatExEditData();
        int  CheckValidDateEntered(std::wstring& inputString, OsaTime& outputDate);
        int  CheckValidWeightEntered(std::string& weightString,  const UNIT_OF_WEIGHT_ENUM unitOfWeight);
        int  CheckValidHeightEntered(std::wstring& heightString, const UNIT_OF_HEIGHT_ENUM unitOfHeight);
        int  CheckStringFormatForCms(std::wstring& heightString);
        int  CheckAndCorrectStringFormatForFeetAndInches(std::wstring& heightString);
        int  ValidateHeightRange(const double cms, const UNIT_OF_HEIGHT_ENUM unitOfHeight);
        void PatexEditHandleExamType();
        void PatexEditHandleProfile();
        void PatexEditHandlePatientType(const PATIENT_TYPE_ENUM& patientType);
        void PatexEditHandlePhysician();
        void PatexEditHandleDefProc();

        // Patient Delete
        int  PatDeleteQuestionInd();
        void PatDeleteQuestionRem();

        void RefillExamTypes(const PATIENT_TYPE_ENUM patientType);
      

        bool GetExaminationType(const PATIENT_TYPE_ENUM patientType, const int& selectedIndex, GUI_ET_NODE_STRUCT*& etNode);
        int InitializeAnatomyList(const PATIENT_TYPE_ENUM patientType, GUI_ET_NODE_STRUCT*& etNode);
        bool IsExaminationPresentOnOtherPatientType(const PATIENT_TYPE_ENUM patientType, GUI_ET_NODE_STRUCT*& examTypeNode, int& examIndex);
        bool IsAnatomyPresentOnOtherPatientType(const std::wstring& anatomyName, int& anatomyIndex);
        void SetExamAndAnatomyType(const PATIENT_TYPE_ENUM patientType, int selectedExamIndex, int selectedAnatamyIndex);

        // Default exam panel
        void ShowUserInformationDialog(const GUI_INFO_MESSAGE_ENUM& messageType);
        void HideUserInformationDialog();
        bool IsUserInformationDialogVisible();
        
        // Reminder Message Panel
        void ShowReminderPanel();
        void HideReminderPanel();
        void SetReminderMsg(bool showFreeImagesMsg, int nrFreeImgs, bool showQueuedImagesMsg, bool showQueuedRsmLoggingMsg);
        int  GetDiskInfo(int& freeSpace, int& totalCapacity);
        bool GetLoggingRsmQueueShowInfo();
        bool IsRadarFileOlderThan(int noOfDays, std::string dirPath);

        // About panel
        int  InitializeAboutPanel();
        void OnAboutMenuClicked();

        // Delete dialog
        int  OnDeleteDialogAction(const MVSUI::DeleteAdmiExamindationEventType);

        // RAC Tool
        int InitRemoteAssistanceTool();

        // Main Event handlers
        void SelectScheduleActivity();
        void SelectReviewingActivity();
        void SelectSetupActivity();
        void SelectSaveLogFileForServiceActivity();
        void HighlightReviewTableRow();
        int  SetPatientExam(const ADMI_DATA_LAYER_TABLE_ENUM table, const int index, const GUI_ADMI_ROW_STRUCT& patExamData);
        void ClearPatientExamRow(GUI_ADMI_ROW_STRUCT& admiRow);
        int  SetSelectedPatientExam(const int rowIndex);
        void OnShutdown();          // When user clicks on Shut Down option from system menu
        void OnShutdownCancel();    // When user clicks on Cancel button on pop-up dialog or when admi screen 
                                    // is hidden due to some other action like acquisition
        void OnShutdownOK();        // When user clicks on OK button on pop-up dialog

        // Data handlers
        int HndlEvtRevHiLi();
        int HndlEvtAcq();
        int HndlEvtRev();
        int HndlEvtDose();
        int HndlEvtGetWL();
        int HndlEvtWLInfo();
        int HndlEvtExport();
        int Reply(GUI_OPERATION_ENUM operation);
        int DeleteSelectedRows();

        // Gui updates
        void         UpdateButtons();
        void         SelectPhysicianInPatExEditList(const std::wstring& physicianName);
        void         ExamDisableEditFields();
        void         SelectProfileInPatExEditList();
        void         GetProfileData(std::wstring profileName, GUI_PROFILE_NODE_STRUCT* &node) const;
        bool         FindExamNode(GUI_ET_NODE_STRUCT* &etNode, int examIndex);
        void         ResetDetProcList(GUI_ET_NODE_STRUCT* etNode);
        bool         IsEmptyNoNameAcqExamSelected();
        void         UpdateUserMessage(bool displayWarning, const GUI_MESSAGE_ENUM msgID, const std::wstring& fieldName);
        void         UpdatePatientHeightOnFocusChange(bool focus);
        void         DisplayWarning(const GUI_MESSAGE_ENUM msgID);
        void         UpdatePatientHeightOnFeetAndInchesChange();

        std::wstring FormatMessageString(const std::wstring formatString, ...);
        static bool  SortbyName(const std::wstring& item1, const std::wstring& item2);

        bool IsSubPanelVisible();
        bool IsMenuExpanded() const;

        void UpdateWeightUnit(const UNIT_OF_WEIGHT_ENUM unitOfWeight);
        void UpdateHeightUnit(const UNIT_OF_HEIGHT_ENUM unitOfHeight);
        void FillFeetAndInchesComboItems();

        void InitializePatientDialogWithWeightUnit(const UNIT_OF_WEIGHT_ENUM unitOfWeight);
        void InitializePatientDialogWithHeightUnit(const UNIT_OF_HEIGHT_ENUM unitOfHeight);

        // Profile Panel
        void            LoadProfileList(const PATIENT_TYPE_ENUM& patientType);
        GUI_PROFILE_NODE_STRUCT* GetSelectedUserProfile(std::wstring& profileName);
        PROFILE_ID_TYPE GetProfileIDFromGuiDirectory(std::wstring& profileName);

        // Other helper functions
        void HideAdmiSubPanels();
        void BindView();
        int OnScheduleListAction(const MVSUI::ScheduleEventType type);
        int OnReviewListAction(const MVSUI::ReviewEventType type);
        void OnShutdownAction(const MVSUI::ShutdownEventType);
        void OnAdmiAction(const MVSUI::AdmiEventType);
        int  OnAddPanelChangedAction(const MVSUI::AddPanelEventType type, const bool statusChange);
        int GetSelectedExam();

        void InitializeGridMessageStatus();

    private:

        std::once_flag                                      m_SetPatTypeFlag;
        std::shared_ptr<About> AboutPtr = nullptr;

        GUI_ADMI_STRUCT            AdmiStruct = { 0 };
        ADMI_DATA_LAYER_TABLE_ENUM ActiveTable;
        std::string                AtrLabelString;

        bool StartExamOnNewPatient;
        PATIENT_TYPE_ENUM m_PatientType;
        std::unique_ptr<RemoteAssistanceTool> RACToolPtr;

        std::wstring                         m_CurrentUsrNameBkup;
        std::shared_ptr<MVSUI::GuiDataModel> GuiDataModelPtr = nullptr;
        bool                                 mvsPowerUP;

        PATIENT_TYPE_ENUM m_OldPatientType;
        double            HeightCms; // Local cache for storing height precision conversion from ft_in to cm and vice versa

        bool ExportRibbonVisibility;
        bool ExportAllowed;
    };
} // Namespace Gui

#endif //ADMI_H

model cp
//*************************************************************************/
//                                                                        //
//   Filename   : Admi.cpp                                                //
//                                                                        //
//   Description: Patient Adminstration  UI                               //
//                                                                        //
//   Copyright  : Philips Medical Systems Nederland B.V., 2020.           //
//                                                                        //
/*************************************************************************/

#include <regex>

#include "Admi.h"
#include "GuiController.h"
#include "GuiGlobal.h"
#include "StringConverter.h"
#include "ControlIDs.h"
#include "StringIDs.h"
#include "Logger.h"
#include "UserGuidance.h"
#include "IObservable.h"
#include "ExportRibbonUtility.h"
#include "DateUtility.h"
#include "GuiUtils.h"
#include "About.h"
#include "AuthenticationStorage.h"
#include "RemoteAssistanceTool.h"
#include "upidr_exp.h"
#include "UnitConversion.h"
#include "ModelViewInterface.h"
#include "UserInformation.h"
#include "co_glo.h"
#include "gui_exp.h"
#include "gui_dir.h"
#include "gui_util.h"

extern "C"
{
    #include "db_loc.h"
    #include "admi_glo.h"
}

namespace Gui
{
    // Useful definitions
    #define GUI_MAX_REMINDER_SUB_STRING_LENGTH      200
    #define GUI_DECIMAL_POINT_SEPARATOR             '.'
    #define GUI_DECIMAL_COMMA_SEPARATOR             ','
    #define GUI_MIN_WEIGHT_LBS                      MIN_WEIGHT_KG
    #define GUI_MAX_WEIGHT_LBS                      999.0
    #define KG_2_LBS                                2.205
    #define LBS_2_KG                                (1.0/KG_2_LBS)


    constexpr int           MULTIPLE_ROW_SELECTED          = -2;
    const     std::string   STARTUP_EVENT_NAME             = "Global\\StartupDoneEvent";

    constexpr wchar_t       CMS_MIN[]                      = L"0";
    constexpr wchar_t       CMS_MAX[]                      = L"300";
    constexpr wchar_t       FEET_AND_INCHES_MIN[]          = L"0";
    constexpr wchar_t       FEET_AND_INCHES_MAX[]          = L"9'10\"";


    const std::wstring EMPTYSTRING              = L"";
    static bool isDoseReportOpened              = false;

    //Constructor
    Admi::Admi() : AboutPtr(0),
                   ActiveTable(ADMI_TABLE_SCHEDULE),
                   StartExamOnNewPatient(false),
                   m_PatientType(PATIENT_ADULT),
                   RACToolPtr(nullptr),
                   m_CurrentUsrNameBkup(L""),
                   m_OldPatientType(PATIENT_ADULT),
                   HeightCms(0.0),
                   ExportRibbonVisibility(false),
                   ExportAllowed(false)
    {
        mvsPowerUP = true;
    }

    //Creates the Admi panel
    int Admi::Init(const MONITOR_ENUM monNr)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Init");

        int status = OK;
        if(MONITOR_VIEWPORT_1 == monNr)
        {
            BindView();
            mvsPowerUP = true;

            if (OK == status)
            {
                status = InitializeAboutPanel();
            }
            if (OK == status)
            {
                status = InitRemoteAssistanceTool();
            }

            if (OK != status)
            {
                status = GUI_E_UI_COMPONENT;
                LOG_ERROR(status, "Admi main panel not initialized");
            }

            if(OK == status)
            {
                AdmiStruct.patientEditSuspended       = false;
                AdmiStruct.examEditSuspended          = false;
                AdmiStruct.examAcqSuspended           = false;
                AdmiStruct.examRevSuspended           = false;
                AdmiStruct.examRevHiLiSuspended       = false;
                AdmiStruct.examExpSuspended           = false;
                AdmiStruct.retrWlSuspended            = false;
                AdmiStruct.examInfoSuspended          = false;
                AdmiStruct.patexEditActive            = false;
                AdmiStruct.patDelQuesActive           = false;
                AdmiStruct.startupReminderActive      = false;
                AdmiStruct.showFreeImagesMsg          = false;
                AdmiStruct.nrFreeImgs                 = 0;
                AdmiStruct.showQueuedImagesMsg        = false;
                AdmiStruct.showQueuedRsmLoggingMsg    = false;
                AdmiStruct.admi.nrOfPendingExportJobs = 0;
                AdmiStruct.admi.enableWLM             = BOOLEAN_FALSE;
                AdmiStruct.shutdownConfirmationActive = false;
            }

            GuiController::GetInstance().RegisterForAction(GUI_RAC_PATIENT, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_EXAM, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_EXAM_ACQ, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_EXAM_REVIEW, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_EXAM_REVIEW_HILI, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_RETRIEVE_WL, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_MWL_REVIEW, this);
            GuiController::GetInstance().RegisterForAction(GUI_RAC_EXAM_EXPORT, this);
            GuiController::GetInstance().RegisterForAction(GUI_AC_RESUME_ADMI, this);
            GuiGlobal::Data().winADMI[monNr] = BOOLEAN_TRUE;
            ExportRibbonUtility::Init();
            ExportRibbonUtility::GetInstance().ShutdownAction = std::bind(&Admi::OnShutdown, this);
        }

        return status;
    }

    //Display Admi panel
    int Admi::Show(const MONITOR_ENUM monNr,const GUI_SIGNAL_STRUCT& signalData)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Show");

        int status = OK;

        if((GUI_SC_WINDOW_ADMI == signalData.scType) && (MONITOR_VIEWPORT_1 == monNr))
        {
            bool showReminderPanel = false;

            //Copy the ADMI Indicate info to the local data struct
            AdmiStruct.admi = signalData.scInfo.admi;

            AdmiStruct.selectedRow.patientType = GuiGlobal::Data().config.patientType;

            if(mvsPowerUP)
            {
                // Register for JobViewer status change notifications. This will be done only once after SystemStart.
                IObservable* observablePtr = dynamic_cast<IObservable*>(GuiController::GetInstance().GetComponentByID(GUI_SC_WINDOW_JOBVIEWER));
                if(NULL != observablePtr)
                {
                    observablePtr->RegisterObserver(this);
                }

                SelectScheduleActivity();

                if((BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled) ||
                   ((BOOLEAN_TRUE  == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled) && (BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.correctPasswordEntered)))
                {
                    // After startup the panel is displayed on top of the scheduled list
                    // If the free space is less than 10% of the total image storage capacity
                    // and/or images are queued for transfer to the DICOM network
                    int maxNrOfImages = 0;
                    int freeImg = 0;
                    bool showFreeImagesMsg = false;
                    status = GetDiskInfo(freeImg, maxNrOfImages);
                    if(OK == status)
                    {
                        int freeImagesPct = 0;
                        freeImagesPct = static_cast<int>((freeImg * 100)/ maxNrOfImages);
                        LOG_DEBUG("FreeImagesPct = %d", freeImagesPct);

                        showFreeImagesMsg = ((freeImagesPct < 10) ? true : false);
                    }

                    bool showQueuedImagesMsg = false;
                    showQueuedImagesMsg = ((0 < AdmiStruct.admi.nrOfPendingExportJobs) ? true : false);

                    bool showQueuedRsmLoggingMsg = GetLoggingRsmQueueShowInfo();

                    // Set reminder message visibility status.
                    SetReminderMsg(showFreeImagesMsg, freeImg, showQueuedImagesMsg, showQueuedRsmLoggingMsg);

                    if(showFreeImagesMsg || showQueuedImagesMsg || showQueuedRsmLoggingMsg)
                    {
                        // Show reminder panel
                        showReminderPanel = true;
                    }
                }

                mvsPowerUP = false;
                status = OK;
            }
            else
            {
                if (!isDoseReportOpened)
                {
                    SelectReviewingActivity();
                }
            }


            //Display current logged-In user
            DisplayLoggedInUserName();

            //if the Close Exam button is enabled, the examInfo button is re-positioned.
            if (TRUE == AdmiStruct.admi.enableCloseExamButton)
            {
                GuiDataModelPtr->Admi.Review.CloseExam.Enabled = true;
            }
            else
            {
                GuiDataModelPtr->Admi.Review.CloseExam.Enabled = false;
            }

            GuiDataModelPtr->Admi.Review.ModelUpdated();

            // Reset StartExamOnNewPatient. This will be turned on when user clicks 'Start Exam' in Add Panel.
            StartExamOnNewPatient = false;

            // Show Admi Window
            GuiDataModelPtr->Admi.Visible = true;

            // Check whether the password is entered correctly
            if ((BOOLEAN_TRUE != GuiGlobal::Data().pswdProtect.correctPasswordEntered))
            {
                GuiDataModelPtr->Admi.ProfileVisibility = false;
            }
            else
            {
                GuiDataModelPtr->Admi.ProfileVisibility = true;
            }


            GuiDataModelPtr->Admi.ModelUpdated();

            // Signal Startup completion to StartupScreen application.
            // StartupScreen application will close after receiving this event.
            HANDLE startupEvent = OpenEventA(EVENT_ALL_ACCESS, FALSE, STARTUP_EVENT_NAME.c_str());
            if(NULL != startupEvent)
            {
                SetEvent(startupEvent);
                CloseHandle(startupEvent);
            }

            if(showReminderPanel)
            {
                // Spawn a new thread and detach it from caller thread
                std::thread panelShowThread([this]
                {
                    // Wait for startup screen to close before displaying Reminder panel.
                    // This is to avoid PopupDisplay::SemiTransparentWindow displaying on top of startup screen.
                    // There is a wait time of 500 millisecond in StartupScreen to close. 
                    // Hence putting 1 second delay before showing Reminder panel.
                    // Putting this code in a seperate thread because of the Sleep in it.
                    const int WAITTIME_FORSTARTUPSCREENCLOSE = 1000;
                    Sleep(WAITTIME_FORSTARTUPSCREENCLOSE);
                    ShowReminderPanel();
                });
                panelShowThread.detach();
            }
        }

        return status;
    }

    //Hide Admi panel
    int Admi::Hide(const MONITOR_ENUM monNr, const GUI_SIGNAL_STRUCT& signalData, const bool doInvalidate)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Hide");

        UNREFERENCED_PARAMETER(doInvalidate);

        int status = OK;

        if((GUI_SC_WINDOW_ADMI == signalData.scType) && (MONITOR_VIEWPORT_1 == monNr))
        {

            /* Hide the panels if shown already */
            HideAdmiSubPanels();

            // Hide Admi Window
            GuiDataModelPtr->Admi.Visible = false;
            GuiDataModelPtr->Admi.ModelUpdated();
        }

        isDoseReportOpened = false;
        return status;
    }

    //Cancel Admi panel
    int Admi::Cancel(const MONITOR_ENUM /*monNr*/, const bool /*showOld*/, const bool /*closeWindow*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Cancel");

        return OK;
    }

    //Delete Admi panel
    void Admi::Destroy()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Destroy");

        GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.clear();
        GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
        GuiDataModelPtr->Admi.AddPanel.PhysicianItems.clear();
        GuiDataModelPtr->Admi.AddPanel.ProfileItems.clear();
        GuiDataModelPtr->Admi.AddPanel.FeetComboItems.clear();
        GuiDataModelPtr->Admi.AddPanel.InchComboItems.clear();
        RACToolPtr->Destroy();
        RACToolPtr.reset();

        if (AboutPtr != nullptr)
        {
            AboutPtr->Destroy();
            AboutPtr.reset();
            AboutPtr = nullptr;
        }

        GuiDataModelPtr.reset();
    }

    //Add patient to Admi Gui
    int Admi::PatientAdd(GUI_ADMI_NODE_STRUCT& patExamNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatientAdd");

        int status = OK;

        LOG_DEBUG_W(L"Id=%d, Name=[%s]", patExamNode.applData.patientId, patExamNode.applData.patientName);

        // when password option is present AND correct password is not entered AND
        // patient is password protected: don't add the patient data
        if((BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled) &&
           (BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) &&
           (BOOLEAN_TRUE == patExamNode.applData.passwordProtected))
        {
            patExamNode.visible = BOOLEAN_FALSE;
        }
        else
        {
            patExamNode.visible = BOOLEAN_TRUE;
        }

        // Select the new patient when: the new patient is added by the user and it is not the NoName patient
        if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            LOG_DEBUG_W(L"Selected Patient Name [%s]",AdmiStruct.selectedRow.patientName);

            if(((NO_ROW_SELECTED == AdmiStruct.selectedRow.patientId) && 
                (0 == wcsncmp(AdmiStruct.selectedRow.patientName, patExamNode.applData.patientName, static_cast<size_t>(PATIENT_NAME_LENGTH + 1)))) &&
                (BOOLEAN_FALSE == patExamNode.applData.noNamePatient))
            {
                AdmiStruct.selectedRow.patientId = patExamNode.applData.patientId;
                LOG_DEBUG("Selected Patient Id [%ld]",AdmiStruct.selectedRow.patientId);
            }
        }
        LOG_DEBUG("Status [%d]", status);

        return status;
    }

    //Modify patient on Admi gui
    int Admi::PatientModify(GUI_ADMI_NODE_STRUCT& patExamNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatientModify");

         int status = OK;

         LOG_DEBUG_W(L"Id=%d, Name=[%s], PSWD_Protected=%d",
                     patExamNode.applData.patientId,
                     patExamNode.applData.patientName,
                     patExamNode.applData.passwordProtected);

         if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            LOG_DEBUG_W(L"Selected Patient Name [%s]",AdmiStruct.selectedRow.patientName);

            if(0 == wcsncmp(AdmiStruct.selectedRow.patientName, patExamNode.applData.patientName, static_cast<size_t>(PATIENT_NAME_LENGTH + 1)))
            {
                AdmiStruct.selectedRow.patientId = patExamNode.applData.patientId;
                LOG_DEBUG("Selected Patient Id [%ld]",AdmiStruct.selectedRow.patientId);
            }
            AdmiStruct.selectedRow.patientType = patExamNode.applData.patientType;
            // If Password protection is set, remove the patient from list
            if((BOOLEAN_TRUE == patExamNode.visible) && 
               (BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled) && 
               (BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) &&
               (BOOLEAN_TRUE == patExamNode.applData.passwordProtected))
            {
                LOG_DEBUG("The patient is now password protected");
                GuiDataModelPtr->Admi.ExamHidden(patExamNode.table, patExamNode.applData.patientId);
                patExamNode.visible = BOOLEAN_FALSE;
            }
        }
        LOG_DEBUG("Status [%d]", status);
        return status;
    }

    //Delete patient from Admi GuipatientFound
    int Admi::PatientDelete(GUI_ADMI_NODE_STRUCT& patExamNode, bool repaintFlag)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatientDelete")
        UNREFERENCED_PARAMETER(repaintFlag);
        int status = OK;

        // Delete the table entry
        if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            // Find patient in table
            if(BOOLEAN_FALSE != patExamNode.visible)
            {
                GuiDataModelPtr->Admi.ExamDeleted(patExamNode.table, patExamNode.applData.patientId);
                patExamNode.visible = FALSE;
            }

            if(OK == status)
            {
                UpdateButtons();
            }
        }
        LOG_DEBUG("status [%d]", status);

        return status;
    }

    //Clear patient list
    int Admi::PatientClear()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatientClear");

        int status = OK;

       // Delete all the patients and update the cells on screen
        if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            GuiDataModelPtr->Admi.ExamClear();
        }

        LOG_DEBUG("status [%d]", status);

        return status;
    }

    // Add patient exam
    int Admi::ExamAdd(GUI_ADMI_NODE_STRUCT& patExamNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ExamAdd");
        int status = OK;

        if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            // Update selectedRow info
            if(AdmiStruct.selectedRow.patientId == patExamNode.applData.patientId)
            {
                AdmiStruct.selectedRow = patExamNode.applData;
            }

            ADMI_DATA_LAYER_TABLE_ENUM table = (EST_SCHEDULED == patExamNode.applData.status) ? ADMI_TABLE_SCHEDULE : ADMI_TABLE_REVIEW;
            patExamNode.table = table;

            // When password option is present AND correct password is not entered and patient is password protected: don't add the patient data
            if(BOOLEAN_FALSE != patExamNode.visible)
            {

                status = SetPatientExam(patExamNode.table, static_cast<int>(patExamNode.index), (patExamNode.applData));

                // If this was the newly added one, highlight the row
                if((OK == status) && (table == ActiveTable))
                {
                    if(EST_SCHEDULED == patExamNode.applData.status)
                    {

                        if(StartExamOnNewPatient)
                        {
                            // Start acquisition on newly added patient/exam.
                            StartExamClicked();
                            StartExamOnNewPatient = false;
                        }
                    }

                    // Update the state of the icon buttons
                    // Note : Because an add patient from ADMI is always followed by an add exam, the function UpdateButtons is only called here
                   UpdateButtons();
                }
            }
        }

        return status;
    }

    //Modify patient exam
    int Admi::ExamModify(GUI_ADMI_NODE_STRUCT& patExamNode, bool tableChange)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ExamModify");

        int status = OK;

        if(BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {

            if(AdmiStruct.selectedRow.patientId == patExamNode.applData.patientId)
            {
                AdmiStruct.selectedRow = patExamNode.applData;
            }

            if(tableChange)
            {
                if(BOOLEAN_TRUE == patExamNode.visible)
                {
                    GuiDataModelPtr->Admi.ExamHidden(patExamNode.table, patExamNode.applData.patientId);
                }

                // Create new row, in new table
                if(OK == status)
                {
                    // When password option is present AND correct password is not entered AND patient is password protected: don't add the patient data
                    if((BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled) &&
                        (BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) &&
                        (BOOLEAN_TRUE == patExamNode.applData.passwordProtected))
                    {
                        patExamNode.visible = BOOLEAN_FALSE;
                    }
                }
            }

            if((OK == status) && (BOOLEAN_TRUE == patExamNode.visible))
            {
                patExamNode.table = (EST_SCHEDULED == patExamNode.applData.status) ? ADMI_TABLE_SCHEDULE : ADMI_TABLE_REVIEW;
                status = SetPatientExam(patExamNode.table, static_cast<int>(patExamNode.index), (patExamNode.applData));

                // If this is the selected row, highlight the row
                if((OK == status) && (patExamNode.table == ActiveTable))
                {
                    // Update the state of the icon buttons
                    // Note : Because an modify patient from ADMI is always followed by an modify exam, the function UpdateButtons is only called here
                    UpdateButtons();
                }
            }
        }

        return status;
    }

    //Delete patient exam
    int Admi::ExamDelete(GUI_ADMI_NODE_STRUCT& patExamNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ExamDelete");

        int status = OK;

        if (BOOLEAN_FALSE != GuiGlobal::Data().winADMI[MONITOR_VIEWPORT_1])
        {
            // Find patient and exam in table
            if (BOOLEAN_FALSE != patExamNode.visible)
            {
                status = SetPatientExam(patExamNode.table, static_cast<int>(patExamNode.index), (patExamNode.applData));
            }
        }
        LOG_DEBUG("status [%d]", status);
        return status;
    }

    void Admi::DisplayLoggedInUserName()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DisplayLoggedInUserName");

        //Chek whether the password protection is enabled
        if(BOOLEAN_TRUE  == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled)
        {
            if(BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.fseLogin)
            {
                GuiDataModelPtr->Admi.LoginType = MVSUI::AdmiLoginType::FieldServiceUser;
            }
            else
            {
                GuiDataModelPtr->Admi.LoginType = MVSUI::AdmiLoginType::HospitalUser;
            }

            GuiDataModelPtr->Admi.DFIPasswordEnabled = true;

            std::wstring loggedInUserName = L"";

            //Valid logged-In user
            MultiUserAuthentication::Storage::AuthenticationStorage::GetCurrentUser(loggedInUserName);

            if ((BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) && (m_CurrentUsrNameBkup.empty()))
            {
                GuiDataModelPtr->Admi.LoggedInUser = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_EMERGENCY_USE);
            }
            else
            {
                GuiDataModelPtr->Admi.LoggedInUser = m_CurrentUsrNameBkup = loggedInUserName;
            }
        }
        else
        {
            GuiDataModelPtr->Admi.DFIPasswordEnabled = false;
        }
    }

    void Admi::PatexEditInd()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditInd");

        // Hide pediatric option if pediatric license not available
        if (BOOLEAN_FALSE == GuiGlobal::Data().config.optPediatric)
        {
            GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Visible = false;
            GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Visible     = false;
            GuiDataModelPtr->Admi.AddPanel.AdultTextVisible             = true;
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Visible = true;
            GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Visible     = true;
            GuiDataModelPtr->Admi.AddPanel.AdultTextVisible             = false;
        }

        if(AdmiStruct.rowModified)
        {
            GuiDataModelPtr->Admi.AddPanel.EditMode           = true;
            GuiDataModelPtr->Admi.AddPanel.Text               = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_TITLEMODIFY);
            GuiDataModelPtr->Admi.AddPanel.Ok.Text            = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_BTNMODIFY);

            // Hide StartExam button and rearrange Add button to button StartExam Pos.
            GuiDataModelPtr->Admi.AddPanel.Ok.Visible         = true;
            GuiDataModelPtr->Admi.AddPanel.Ok.Position        = GuiDataModelPtr->Admi.AddPanel.StartExam.Position;
            GuiDataModelPtr->Admi.AddPanel.StartExam.Visible  = false;
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.EditMode           = false;
            GuiDataModelPtr->Admi.AddPanel.Text               = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_TITLEADD);
            GuiDataModelPtr->Admi.AddPanel.Ok.Text            = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_BTNADD);

            GuiDataModelPtr->Admi.AddPanel.Ok.Visible         = true;
            GuiDataModelPtr->Admi.AddPanel.Ok.Position        = GuiDataModelPtr->Admi.AddPanel.BUTTON_POS_1;
            GuiDataModelPtr->Admi.AddPanel.StartExam.Visible  = true;
        }

        // Update Unit of weight according to configuration TRUE (pound), FALSE(kg).
        if(BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight)
        {
            GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_KGS);
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_POUNDS);
        }

        FillFeetAndInchesComboItems();
        GuiDataModelPtr->Admi.AddPanel.unitOfHeight       = AdmiStruct.admi.unitOfHeight;
        GuiDataModelPtr->Admi.AddPanel.HeightInCms        = 0.0;
        GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text = L"";

        if (!AdmiStruct.rowModified)
        {
            AdmiStruct.selectedRow.patientType = GuiGlobal::Data().config.patientType;
        }

        if (PATIENT_ADULT == AdmiStruct.selectedRow.patientType)
        {
            GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked     = true;
            GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked = false;
            m_OldPatientType = PATIENT_ADULT;
            GuiDataModelPtr->Viewing.ExamPatex.PatientType = PATIENT_ADULT;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked = true;
            GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked     = false;
            m_OldPatientType = PATIENT_PEDIATRIC;
            GuiDataModelPtr->Viewing.ExamPatex.PatientType = PATIENT_PEDIATRIC;
            GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
        }

        // Reset the input values
        GuiDataModelPtr->Admi.AddPanel.PatientName.Enabled   = true;
        GuiDataModelPtr->Admi.AddPanel.PatientName.Text      = L"";

        GuiDataModelPtr->Admi.AddPanel.PatientId.Enabled     = true;
        GuiDataModelPtr->Admi.AddPanel.PatientId.Text        = L"";

        GuiDataModelPtr->Admi.AddPanel.PatientDOBEnabled     = true;
        GuiDataModelPtr->Admi.AddPanel.PatientDOBClearText();
        GuiDataModelPtr->Admi.AddPanel.PatientDOBSetDateFormat(GuiGlobal::Data().service[MONITOR_VIEWPORT_1].dateFormat);

        GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text    = L"";

        HeightCms                                            = 0.0;

        GuiDataModelPtr->Admi.AddPanel.Accno.Text            = L"";
        GuiDataModelPtr->Admi.AddPanel.Accno.Enabled         = (BOOLEAN_TRUE == GuiGlobal::Data().service[MONITOR_VIEWPORT_1].accNumEditable) ? true : false;

        GuiDataModelPtr->Admi.AddPanel.GenderMale.Enabled    = true;
        GuiDataModelPtr->Admi.AddPanel.GenderFemale.Enabled  = true;
        GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Enabled = true;

        // Fill Exam Type list
        RefillExamTypes(AdmiStruct.selectedRow.patientType);

        // Fill Physician list
        GUI_PHYSICIAN_NODE_STRUCT *physicianNode = GUI_DIR_GetPhysicianNode(GUI_DIR_FIRST);
        while(physicianNode != static_cast<GUI_PHYSICIAN_NODE_STRUCT *>(nullptr))
        {
            GuiDataModelPtr->Admi.AddPanel.PhysicianItems.emplace_back(physicianNode->physician.name);
            physicianNode = GUI_DIR_GetPhysicianNode(GUI_DIR_NEXT);
        }
        // Sort Physician list: Ascii + Ascending
        std::sort(GuiDataModelPtr->Admi.AddPanel.PhysicianItems.begin(), GuiDataModelPtr->Admi.AddPanel.PhysicianItems.end(), Admi::SortbyName);

        //Chek whether the password is entered correctly
        if ((BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.correctPasswordEntered))
        {
            // Load all available profile list
            GuiDataModelPtr->Admi.AddPanel.Profile.Visible    = true;
            GuiDataModelPtr->Admi.AddPanel.ProfileTextVisible = true;
            GuiDataModelPtr->Admi.AddPanel.Profile.Enabled    = true;
            LoadProfileList(AdmiStruct.selectedRow.patientType);
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.ProfileItems.clear();
            GuiDataModelPtr->Admi.AddPanel.ProfileItems.emplace_back(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_DEFAULT_PROFILE));
            GuiDataModelPtr->Admi.AddPanel.ProfileIndex = 0;
            GuiDataModelPtr->Admi.AddPanel.Profile.Enabled = false;
        }

        PatexEditHandleProfile();

        // Display the Edit window
        if (AdmiStruct.rowModified)
        {
            GuiDataModelPtr->Admi.Schedule.Modify.Checked = true;
            GuiDataModelPtr->Admi.Review.Modify.Checked   = true;
            GuiDataModelPtr->Admi.Review.ModelUpdated();
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Add.Checked = true;
        }

        GuiDataModelPtr->Admi.Schedule.ModelUpdated();

        // Reset StartExamOnNewPatient. This will be set when user clicks 'Start Exam' in Add Panel.
        StartExamOnNewPatient = false;

        AdmiStruct.patexEditActive                      = true;

        GuiDataModelPtr->Admi.AddPanel.Ok.Visible       = true;
        GuiDataModelPtr->Admi.AddPanel.Ok.Enabled       = true;
        GuiDataModelPtr->Admi.AddPanel.Ok.Glow          = true;
        GuiDataModelPtr->Admi.AddPanel.Visible          = true;
        GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus = MVSUI::AddPanelKeyboardFocus::PatientName;
    }

    bool Admi::SortbyName(const std::wstring& item1, const std::wstring& item2)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SortbyName");

        // Convert all characters to upper case/(lower case) to get case insensitive sorting
        std::wstring string1 = item1;
        std::wstring string2 = item2;
        std::transform(string1.begin(), string1.end(), string1.begin(), ::toupper);
        std::transform(string2.begin(), string2.end(), string2.begin(), ::toupper);
        return(0 >= string1.compare(string2));
    }

    void Admi::PatexEditRem()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditRem");

        AdmiStruct.patexEditActive = false;

        if (GuiDataModelPtr->Admi.AddPanel.ProfileItems.size() > 0u)
        {
            GuiDataModelPtr->Admi.AddPanel.ProfileItems.clear();
        }

        if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.size()) > 0)
        {
            GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.clear();
        }

        if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.PhysicianItems.size()) > 0)
        {
            GuiDataModelPtr->Admi.AddPanel.PhysicianItems.clear();
        }

        if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProcedureItems.size()) > 0)
        {
            GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
        }

        if(!AdmiStruct.rowModified)
        {
            GuiDataModelPtr->Admi.Schedule.Add.Checked = false;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Modify.Checked = false;
            GuiDataModelPtr->Admi.Review.Modify.Checked   = false;
            GuiDataModelPtr->Admi.Review.ModelUpdated();
        }

        GuiDataModelPtr->Admi.Schedule.ModelUpdated();

        // Remove invalid format message
        USERGUIDANCE_HIDE(MONITOR_VIEWPORT_1, GUI_MSG_FORMAT_INCORRECT);
        UpdateButtons();

        // Setting default selection for gender to Unknown
        // Setting after panel is hidden to avoid flicker of radio button selection in the next Show
        GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked = true;
        GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked    = false;
        GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked  = false;

        GuiDataModelPtr->Admi.AddPanel.Ok.Visible             = false;
        GuiDataModelPtr->Admi.AddPanel.Ok.Enabled             = false;
        GuiDataModelPtr->Admi.AddPanel.Ok.Glow                = false;
        GuiDataModelPtr->Admi.AddPanel.Visible                = false;
    }

    void Admi::BindView()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::BindView");

        GuiDataModelPtr                                     = GuiController::GetInstance().GetGuiDataModel();
        GuiDataModelPtr->Admi.AdmiAction                    = [this] (const MVSUI::AdmiEventType action) { OnAdmiAction(action); };
        GuiDataModelPtr->Admi.SwitchPatientList             = std::bind(&Admi::OnSwitchPatientList,  this, std::placeholders::_1);
        GuiDataModelPtr->Admi.Schedule.ScheduleListAction   = std::bind(&Admi::OnScheduleListAction, this, std::placeholders::_1);
        GuiDataModelPtr->Admi.Review.ReviewListAction       = std::bind(&Admi::OnReviewListAction,   this, std::placeholders::_1);
        GuiDataModelPtr->Admi.Shutdown.ShutdownAction       = std::bind(&Admi::OnShutdownAction,     this, std::placeholders::_1);
        GuiDataModelPtr->Admi.Reminder.Action               = [this] {HideReminderPanel(); };
        GuiDataModelPtr->Admi.AddPanel.Action               = [this] (const MVSUI::AddPanelEventType type, const bool status) { return OnAddPanelChangedAction(type, status); };
        GuiDataModelPtr->Admi.Delete.Action                 = [this](MVSUI::DeleteAdmiExamindationEventType action) { OnDeleteDialogAction(action); };
        GuiDataModelPtr->Admi.ExamSelectionChanged          = [this]() { OnExamSelectionChanged(); };
        GuiDataModelPtr->Admi.KeyPressEvent                 = [this](const int keyCode) {OnKeyPress(keyCode); };
    }

    int Admi::OnScheduleListAction(const MVSUI::ScheduleEventType type)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnScheduleListAction");

        switch (type)
        {
            case MVSUI::ScheduleEventType::Add:
                AddClicked();
                break;
            case MVSUI::ScheduleEventType::Delete:
                DeleteClicked();
                break;
            case MVSUI::ScheduleEventType::Modify:
                ModifyClicked();
                break;
            case MVSUI::ScheduleEventType::StartExamination:
                StartExamClicked();
                break;
            case MVSUI::ScheduleEventType::Worklist:
                GetWorkListClicked();
                break;
            case MVSUI::ScheduleEventType::ExaminationInfo:
                WorkListInfoClicked();
                break;
            default:
                break;
        }

        return OK;
    }

    int Admi::OnReviewListAction(MVSUI::ReviewEventType type)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnReviewListAction");

        switch (type)
        {
        case MVSUI::ReviewEventType::Modify:
            ModifyClicked();
            break;
        case MVSUI::ReviewEventType::Delete:
            DeleteClicked();
            break;
        case MVSUI::ReviewEventType::ShowExamination:
            ShowExamClicked();
            break;
        case MVSUI::ReviewEventType::ExaminationInfo:
            WorkListInfoClicked();
            break;
        case MVSUI::ReviewEventType::DoseReport:
            DoseReportClicked();
            isDoseReportOpened = true;
            break;
        case MVSUI::ReviewEventType::CloseExam:
            CloseExamClicked();
            break;
        case MVSUI::ReviewEventType::BackToAcquisition:
            BackToAcquisitionClicked();
            break;
        default:
            break;
        }

        return OK;
    }

    int Admi::OnDeleteDialogAction(const MVSUI::DeleteAdmiExamindationEventType action)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnDeleteDialogAction");

        switch (action)
        {
            case MVSUI::DeleteAdmiExamindationEventType::SingleDelete:
                DeleteQuestionYesClicked();
                break;

            case MVSUI::DeleteAdmiExamindationEventType::SingleCancel:
                DeleteQuestionNoClicked();
                break;

            case MVSUI::DeleteAdmiExamindationEventType::MultipleDelete:
                MultipleDeleteConfirmClicked();
                break;

            case MVSUI::DeleteAdmiExamindationEventType::MultipleCancel:
                MultipleDeleteCancelClicked();
                break;

            default:
                break;
        }

        return OK;
    }

    void Admi::OnAdmiAction(const MVSUI::AdmiEventType action)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnAdmiAction");

        switch (action)
        {
            case MVSUI::AdmiEventType::Profile:
                ProfileBtnClicked();
                break;

            case::MVSUI::AdmiEventType::JobViewer:
                ExportRibbonUtility::ExportRibbonJobViewer();
                break;

            case::MVSUI::AdmiEventType::WirelessNetwork:
                OnWirelessNetworkClicked();
                break;

            case::MVSUI::AdmiEventType::SwitchUser:
                OnSwitchUserClicked();
            break;           

            case::MVSUI::AdmiEventType::ChangePassword:
                OnChangePasswordClicked();
            break;

            case::MVSUI::AdmiEventType::RemoteAssistance:
                OnRemoteAssistanceClicked();
            break;

            case::MVSUI::AdmiEventType::FieldService:
                OnFieldServiceClicked();
            break;

            case::MVSUI::AdmiEventType::Setup:
                SelectSetupActivity();
            break;

            case::MVSUI::AdmiEventType::Shutdown:
                OnShutdown();
            break;
            
            case::MVSUI::AdmiEventType::SaveLogFileForService:
                SelectSaveLogFileForServiceActivity();
            break;
            
            case::MVSUI::AdmiEventType::About:
                OnAboutMenuClicked();
            break;

            case::MVSUI::AdmiEventType::IFU:
                OnIFUClicked();
            break;
        default:
            break;
        }
    }

    void Admi::OnShutdownAction(const MVSUI::ShutdownEventType type)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnShutdownAction");

        switch (type)
        {
        case MVSUI::ShutdownEventType::Cancel:
            OnShutdownCancel();
            break;
        case MVSUI::ShutdownEventType::Ok:
            OnShutdownOK();
            break;
        default:
            break;
        }
    }

    int Admi::OnAddPanelChangedAction(const MVSUI::AddPanelEventType type, const bool statusChange)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnAddPanelChangedAction");

        int status = OK;

        switch (type)
        {
            case MVSUI::AddPanelEventType::Ok:
                PatexEditOkClicked();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::Cancel:
                PatexEditCancelClicked();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::StartExam:
                PatexEditStartExamClicked();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::ExamTypeChanged:
                PatexEditHandleExamType();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::PhysicianChanged:
                PatexEditHandlePhysician();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::DetProcTypeChanged:
                PatexEditHandleDefProc();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::ProfileChanged:
                PatexEditHandleProfile();
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::AdultChanged:
                PatexEditHandlePatientType(PATIENT_ADULT);
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::PediatricChanged:
                PatexEditHandlePatientType(PATIENT_PEDIATRIC);
                GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                break;

            case MVSUI::AddPanelEventType::FeetChanged:
            case MVSUI::AddPanelEventType::InchChanged:
                UpdatePatientHeightOnFeetAndInchesChange();
                break;

            case MVSUI::AddPanelEventType::PatientNameLengthExceeded:
                UpdateUserMessage(statusChange, GUI_MSG_MAX_NR_CHARS, GuiDataModelPtr->Admi.AddPanel.PatientNameText);
                break;

            case MVSUI::AddPanelEventType::PatientIdLengthExceeded:
                UpdateUserMessage(statusChange, GUI_MSG_MAX_NR_CHARS, GuiDataModelPtr->Admi.AddPanel.PatientIDText);
                break;

            case MVSUI::AddPanelEventType::PatientWeightLengthExceeded:
                UpdateUserMessage(statusChange, GUI_MSG_MAX_NR_CHARS, GuiDataModelPtr->Admi.AddPanel.WeightText);
                break;

            case MVSUI::AddPanelEventType::AccnoLengthExceeded:
                UpdateUserMessage(statusChange, GUI_MSG_MAX_NR_CHARS, GuiDataModelPtr->Admi.AddPanel.AccessionNrText);
                break;

            case MVSUI::AddPanelEventType::PatientHeightFocusChanged:
                UpdatePatientHeightOnFocusChange(statusChange);
                break;

            default:
                break;
        }

        return status;
    }

    void Admi::PatexEditHandleExamType()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditHandleExamType");

        if (AdmiStruct.patexEditActive)
        {
            const int selectedExamIndex = GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex;
            LOG_DEBUG("Selected exam type index = [%d]", selectedExamIndex);

            if (0 <= selectedExamIndex)
            {
                bool etFound = false;
                GUI_ET_NODE_STRUCT* etNode = nullptr;

                // Validate exam type selected
                etFound = FindExamNode(etNode, selectedExamIndex);

                if (etFound)
                {
                    // Clear detailed procedure list
                    ResetDetProcList(etNode);

                    GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = 0;

                    if ((0 < GuiDataModelPtr->Admi.AddPanel.ProfileIndex))
                    {
                        GuiDataModelPtr->Admi.AddPanel.ProfileIndex = 0;

                        // Update Unit of weight according to configuration.
                        if (BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight)
                        {
                            UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::KG_UNIT);
                        }
                        else
                        {
                            UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::LBS_UNIT);
                        }

                        // Update Unit of height according to configuration.
                        UpdateHeightUnit(AdmiStruct.admi.unitOfHeight);
                        ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                    }
                }
                else
                {
                    // Clear detailed procedure list
                    GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();

                    // Add current detailed procedure to selection list when it isn't in the current detailed procedure directory anymore
                    LOG_DebugW(LOG_MI_GUI, L"Add current detailed procedure to selection list: [%s]", AdmiStruct.selectedRow.detProcType);

                    GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(AdmiStruct.selectedRow.detProcType);
                }
            }
        }
    }

    int Admi::GetPatExEditData() //TICS !CFL#016 [Do not have overly complex functions.] - Legacy code
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetPatExEditData");

        int status = OK;

        GUI_ADMI_ROW_STRUCT editRow = AdmiStruct.selectedRow;


        if(!AdmiStruct.rowModified)
        {
            ClearPatientExamRow(editRow);
        }

        // Get Patient name
        if(OK == status)
        {
            std::wstring pName = std::wstring(GuiDataModelPtr->Admi.AddPanel.PatientName.Text);
            OsaWcsCpy(editRow.patientName, static_cast<size_t>(PATIENT_NAME_LENGTH + 1), Utilities::StringConverter::TrimStringW(pName).c_str());

            if(0 == static_cast<int>(wcslen(editRow.patientName)))
            {
                LOG_DEBUG("Empty patient name, create a fake NoName patient");

                const std::wstring patientName = std::wstring(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_NONAME_PATIENTNAME));
                OsaWcsCpy(editRow.patientName, static_cast<size_t>(PATIENT_NAME_LENGTH + 1), patientName.c_str());

                editRow.noNamePatient = BOOLEAN_FALSE;
            }
        }

        // Get Patient ID and Accession number
        if(OK == status)
        {
            const std::wstring regNumber = GuiDataModelPtr->Admi.AddPanel.PatientId.Text;
            OsaWcsCpy(editRow.regNr, REGISTRATION_NUMBER_LENGTH + 1, regNumber.c_str());

            const std::wstring accessionNumber = GuiDataModelPtr->Admi.AddPanel.Accno.Text;
            OsaWcsCpy(editRow.accNr, ACCESSION_NR_LENGTH + 1, accessionNumber.c_str());
        }

        // Get Patient DOB
        if(OK == status)
        {
            std::wstring birthDateString = L"";

            if (GuiDataModelPtr->Admi.AddPanel.PatientDOBEnabled)
            {
                const bool validDate = GuiDataModelPtr->Admi.AddPanel.PatientDOBGetText(birthDateString);

                if(validDate)
                {
                    if(!birthDateString.empty())
                    {
                        status = CheckValidDateEntered(birthDateString, (editRow.birthDate));
                    }
                    else
                    {
                        editRow.birthDate.Year = GUI_NOT_DISPLAY_DATE;
                    }
                }
                else
                {
                    status = GUI_E_DATE;
                }

                if(OK != status)
                {
                    std::wstring fieldName(GuiDataModelPtr->Admi.AddPanel.DateOfBirthText);

                    wchar_t* args[GUI_MAX_NR_OF_ARGS];
                    args[0] = const_cast<wchar_t*>(fieldName.c_str());                                 //TICS !CON#002 [const_cast is unavoidable]
                    USERGUIDANCE_SHOW_WITHARGS(MONITOR_VIEWPORT_1, GUI_MSG_FORMAT_INCORRECT, 1, args);

                    // Set Keyboard focus to DOB
                    GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus = MVSUI::AddPanelKeyboardFocus::PatientDOB;
                }
            }
        }

        if(OK == status)
        {
            std::string weightString = Utilities::StringConverter::WstringToString(GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text).c_str();

            // Get unit of weight type form UI control
            const UNIT_OF_WEIGHT_ENUM unitOfWeight = (GuiDataModelPtr->Admi.AddPanel.PoundsText.compare(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_KGS)) == 0) ? UNIT_OF_WEIGHT_ENUM::KG_UNIT : UNIT_OF_WEIGHT_ENUM::LBS_UNIT;

            //Check is weight is editable
            if (GuiDataModelPtr->Admi.AddPanel.PatientWeight.Enabled)
            {
                status = CheckValidWeightEntered(weightString, unitOfWeight);
            }

            if(OK == status)
            {
                AdmiStruct.selectedRow.unitOfWeight = unitOfWeight;

                if (UNIT_OF_WEIGHT_ENUM::KG_UNIT == unitOfWeight)
                {
                    editRow.weightKG = atof(weightString.c_str());
                }
                else
                {
                    editRow.weightKG = atof(weightString.c_str())*LBS_2_KG;
                }
            }
        }

        // Get Patient Height
        if (OK == status)
        {
            std::wstring heightString = GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text;

            // Get unit of height type form UI control
            const UNIT_OF_HEIGHT_ENUM unitOfHeight = GuiDataModelPtr->Admi.AddPanel.unitOfHeight;

            status = CheckValidHeightEntered(heightString, unitOfHeight);

            if (OK == status)
            {
                AdmiStruct.selectedRow.unitOfHeight = unitOfHeight;

                if (UNIT_OF_HEIGHT_ENUM::CMS_UNIT == unitOfHeight)
                {
                    editRow.heightCm = _wtof(heightString.c_str());
                }
                else
                {
                    editRow.heightCm = HeightCms;
                }
            }
            else
            {
                if (UNIT_OF_HEIGHT_ENUM::CMS_UNIT == unitOfHeight)
                {
                    GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus = MVSUI::AddPanelKeyboardFocus::PatientHeight;
                }
            }
        }

        // Get Patient Sex
        if(OK == status)
        {
            if (GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked)
            {
                editRow.sex = SEX_FEMALE;
            }
            else if (GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked)
            {
                editRow.sex = SEX_MALE;
            }
            else
            {
                editRow.sex = SEX_UNKNOWN;
            }
        }

        if (BOOLEAN_FALSE == GuiGlobal::Data().config.optPediatric || GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
        {
            editRow.patientType = PATIENT_ADULT;
            m_PatientType       = PATIENT_ADULT;
        }
        else
        {
            editRow.patientType = PATIENT_PEDIATRIC;
            m_PatientType       = PATIENT_PEDIATRIC;
        }

        // Get profile
        const int selectedProfileIndex               = GuiDataModelPtr->Admi.AddPanel.ProfileIndex;
        PROFILE_ID_TYPE profileID                    = DEFAULT_PROFILE_ID;
        wchar_t profileName[PROFILE_NAME_LENGTH + 1] = { 0 };
        if (NO_ROW_SELECTED != selectedProfileIndex)
        {
            OsaWcsCpy(profileName, static_cast<size_t>(PROFILE_NAME_LENGTH + 1), (GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex]).c_str());
            GUI_PROFILE_NODE_STRUCT *profileNode = nullptr;
            GetProfileData(GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex], profileNode);

            if (profileNode != nullptr)
            {
                profileID                            = profileNode->userProfile.profileId;
                AdmiStruct.selectedRow.unitOfMeasure = profileNode->userProfile.profileData.unitofMeasurement;
            }
            else
            {
                LOG_DEBUG("Selected profile not found in gui directory");
            }
        }
        else
        {
            LOG_DEBUG("No Profile selected");
        }

        editRow.profileID = profileID;
        OsaWcsCpy(editRow.profileName,  static_cast<size_t>(PROFILE_NAME_LENGTH + 1), profileName);

        // Set unit of measurement from configuration for default profile
        if (editRow.profileID == DEFAULT_PROFILE_ID)
        {
            AdmiStruct.selectedRow.unitOfMeasure = GuiGlobal::Data().service[MONITOR_ENUM::MONITOR_VIEWPORT_1].units;
        }

        editRow.unitOfMeasure = AdmiStruct.selectedRow.unitOfMeasure;
        editRow.unitOfWeight  = AdmiStruct.selectedRow.unitOfWeight;
        editRow.unitOfHeight  = AdmiStruct.selectedRow.unitOfHeight;

        // Get accession number
        const std::wstring accessionNumber = GuiDataModelPtr->Admi.AddPanel.Accno.Text;
        OsaWcsCpy(editRow.accNr, ACCESSION_NR_LENGTH + 1, accessionNumber.c_str());

        // Get Exam Type
        if(OK == status)
        {
            if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.size()) > 0)
            {
                int selectedIndex = GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex;
                if(NO_ROW_SELECTED != selectedIndex)
                {
                    std::wstring examTypeString = GuiDataModelPtr->Admi.AddPanel.ExamTypeItems[selectedIndex];
                    OsaWcsCpy(editRow.examType, EXAMINATION_NAME_LENGTH + 1, examTypeString.c_str());
                }
            }
        }

        // Get Anatomy

        // Get detailed procedure
        if(OK == status)
        {
            if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProcedureItems.size()) > 0)
            {
                int selectedIndex = GuiDataModelPtr->Admi.AddPanel.ProcedureIndex;
                if(NO_ROW_SELECTED != selectedIndex)
                {
                    std::wstring anatomyStr = GuiDataModelPtr->Admi.AddPanel.ProcedureItems[selectedIndex];
                    OsaWcsCpy(editRow.detProcType, DETPROC_NAME_LENGTH + 1, anatomyStr.c_str());
                }
                else
                {
                    OsaWcsCpy(editRow.detProcType, DETPROC_NAME_LENGTH + 1, GuiDataModelPtr->Admi.AddPanel.ProcedureItems[0].c_str());
                }
            }
        }

        // Get Exam Physician
        if(OK == status)
        {
            if(static_cast<int>(GuiDataModelPtr->Admi.AddPanel.PhysicianItems.size()) > 0)
            {
                int selectedIndex = GuiDataModelPtr->Admi.AddPanel.PhysicianIndex;
                if(NO_ROW_SELECTED != selectedIndex)
                {
                    std::wstring physicianString = GuiDataModelPtr->Admi.AddPanel.PhysicianItems[selectedIndex];
                    OsaWcsCpy(editRow.physician, PHYSICIAN_NAME_LENGTH + 1, physicianString.c_str());
                }
                else
                {
                    OsaWcsCpy(editRow.physician, PHYSICIAN_NAME_LENGTH + 1, L"");
                }
            }
        }

        if(OK == status)
        {
            AdmiStruct.selectedRow = editRow;

            LOG_DEBUG_W(L"Exam [%d], type=[%s], detProc type=[%s], physician=[%s]",
                        AdmiStruct.selectedRow.examId,
                        AdmiStruct.selectedRow.examType,
                        AdmiStruct.selectedRow.detProcType,
                        AdmiStruct.selectedRow.physician);
        }
        LOG_DEBUG("Status [%d]", status);
        return status;
    }

    int Admi::PatDeleteQuestionInd()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatDeleteQuestionInd");
        int status = OK;

        AdmiStruct.patDelQuesActive = true;

        if(MULTIPLE_ROW_SELECTED != GetSelectedExam())
        {
            GuiDataModelPtr->Admi.Delete.MultipleExamination = false;

            char sexString[GUI_SEX_STRING_LENGTH + 1]       = {};
            GuiDataModelPtr->Admi.Delete.PatientDateOfBirth = L"";

            Utilities::DateUtility::ConvertOsaTimeToDateString(AdmiStruct.selectedRow.birthDate, GuiGlobal::Data().service[MONITOR_VIEWPORT_1].dateFormat, GuiDataModelPtr->LocalePtr, GuiDataModelPtr->Admi.Delete.PatientDateOfBirth);

                if(OK == status)
                {
                    status = GUI_UTIL_SexEnumToSexString(AdmiStruct.selectedRow.sex,
                                                         sexString,
                                                         static_cast<int>(sizeof(sexString)),
                                                         BOOLEAN_FALSE);
                }

                // Set values
            GuiDataModelPtr->Admi.Delete.PatientName = std::wstring(AdmiStruct.selectedRow.patientName);
            wcscpy(GuiDataModelPtr->Admi.Delete.PatientId, AdmiStruct.selectedRow.regNr);
            GuiDataModelPtr->Admi.Delete.PatientGender = Utilities::StringConverter::StringToWstring(sexString);

                std::wstring examType = AdmiStruct.selectedRow.examType;
                if(static_cast<size_t>(0) != wcslen(AdmiStruct.selectedRow.detProcType))
                {
                    const std::wstring EXAMTYPE_SEPERATOR = L" - ";
                    examType = examType + EXAMTYPE_SEPERATOR + AdmiStruct.selectedRow.detProcType;
                }

            GuiDataModelPtr->Admi.Delete.PatientExamType = examType;
            wcscpy(GuiDataModelPtr->Admi.Delete.Physician, AdmiStruct.selectedRow.physician);
            wcscpy(GuiDataModelPtr->Admi.Delete.AccNr, AdmiStruct.selectedRow.accNr);
        }
        else
        {
            GuiDataModelPtr->Admi.Delete.MultipleExamination = true;

            unsigned int selectedItems=0;

            if(ADMI_TABLE_SCHEDULE == ActiveTable)
            {
                selectedItems = static_cast<unsigned int>(GuiDataModelPtr->Admi.SelectedPatientIDs.size());
            }
            else if(ADMI_TABLE_REVIEW == ActiveTable)
            {
                selectedItems = static_cast<unsigned int>(GuiDataModelPtr->Admi.SelectedPatientIDs.size());
            }
            else
            {
                //Nothing to do.
            }

            std::wstringstream stringFormater;
            stringFormater << FormatMessageString(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_MULTIDELETE_CONFIRMATION_MSG), selectedItems) << std::endl;
            GuiDataModelPtr->Admi.Delete.ConfirmationMessage = stringFormater.str();
        }

        GuiDataModelPtr->Admi.Delete.ShowDeleteDialog();

        LOG_DEBUG("status=%d", status);
        return status;
    }

    void Admi::PatDeleteQuestionRem()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatDeleteQuestionRem");

        AdmiStruct.patDelQuesActive = false;

        GuiDataModelPtr->Admi.Delete.HideDeleteDialog();

    }

    int Admi::GetDiskInfo(int& freeSpace, int& totalCapacity)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetDiskInfo");

        int status = OK;
        int freeImg = 0;
        int maxNrOfImages = 0;

        status = DB_GetDiskCapacity(&freeImg,
                                    &maxNrOfImages);
        if(OK == status)
        {
            // DB Capacity includes reserved buffer for 1 RUN (999 Images). Decrement that from FreeSpace and MaxCapacity.
            freeImg         -= MAX_NR_OF_IMAGES_PER_RUN;
            maxNrOfImages   -= MAX_NR_OF_IMAGES_PER_RUN;

            LOG_DEBUG("DiskCapacity = %d, FreeImg = %d", totalCapacity, freeSpace);

            freeSpace = freeImg;
            totalCapacity = maxNrOfImages;
        }

        LOG_DEBUG("Status = %d", status);
        return status;
    }

    bool Admi::GetLoggingRsmQueueShowInfo()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetLoggingRsmQueueShowInfo");
        bool result = false;
        char radarConfigFilePath[MAX_PATH];
        CoReadCBEConfig("RADAR","ConfigFilePath",radarConfigFilePath,static_cast<size_t>(MAX_PATH));
        char keyValue[3][10];
        GetPrivateProfileStringA("RADAR", "EnableRemoteProactiveSupport", "FALSE", keyValue[0], 32, radarConfigFilePath);
        GetPrivateProfileStringA("RADAR", "EnableRemoteProactiveOnScreenSupport", "FALSE", keyValue[1], 32, radarConfigFilePath);
        GetPrivateProfileStringA("RADAR", "NotificationTime", "7", keyValue[2], 32, radarConfigFilePath);

        if((0 == strcmp("TRUE",keyValue[0])) && (0 == strcmp("TRUE", keyValue[1])))
        {
            std::string tempRadarConfigFilePath (radarConfigFilePath);
            std::size_t found = tempRadarConfigFilePath.find_last_of("/\\");
            if(std::string::npos != found)
            {
                tempRadarConfigFilePath = tempRadarConfigFilePath.substr(0,found+1);
            }
            result = IsRadarFileOlderThan(atoi(keyValue[2]), tempRadarConfigFilePath);
        }

        LOG_DEBUG("Show Reminder RSM Logging Queue: %d", result);

        return result;
    }

    bool Admi::IsRadarFileOlderThan(int noOfDays, std::string dirPath)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::IsRadarFileOlderThan");
        bool result = false;
        SYSTEMTIME currentTime;
        FILETIME currentTimeAsFileTime;
        GetLocalTime(&currentTime);
        SystemTimeToFileTime(&currentTime,&currentTimeAsFileTime);
        HANDLE hFind = INVALID_HANDLE_VALUE;
        WIN32_FIND_DATAA ffd;
        hFind = FindFirstFileA((dirPath + std::string("*")).c_str(), &ffd);
        if((INVALID_HANDLE_VALUE != hFind))
        {
            std::vector<std::string> listFiles;
            ULARGE_INTEGER t1, t2;
            ULONGLONG diff;
            const int noOfSecondsInADay = 24*60*60;
            const ULONGLONG fileTimeTicsInASecond = static_cast<ULONGLONG>(10000000);
            while(FindNextFileA(hFind, &ffd) != FALSE)
            {
                if(('.' == ffd.cFileName[0]) ||(0 == strcmp("RPSC.ini",ffd.cFileName)))
                {
                    continue;
                }
                std::string fileName(ffd.cFileName);
                WIN32_FILE_ATTRIBUTE_DATA fileAttrData = {0};
                GetFileAttributesExA((dirPath + fileName).c_str(), GetFileExInfoStandard, &fileAttrData);

                memcpy(&t1, &currentTimeAsFileTime, sizeof(t1));
                memcpy(&t2, &fileAttrData.ftCreationTime, sizeof(t2));
                diff = (t1.QuadPart<t2.QuadPart)?(t2.QuadPart-t1.QuadPart):(t1.QuadPart-t2.QuadPart);
                if(diff >  static_cast<ULONGLONG>(noOfDays* noOfSecondsInADay)*fileTimeTicsInASecond)
                {
                    result = true;
                    break;
                }
            }
        }
        return result;
    }

    int Admi::InitializeAboutPanel()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::InitializeAboutPanel");

        int status = OK;

        AboutPtr = std::make_shared<About>();

        if(nullptr != AboutPtr)
        {
            status = AboutPtr->Init();
        }
        else
        {
            status = GUI_E_UI_COMPONENT;
            LOG_ERROR(GUI_E_UI_COMPONENT, "Initialization of About panel failed");
        }

        return status;
    }

    void Admi::OnAboutMenuClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnAboutMenuClicked");

        if(nullptr != AboutPtr)
        {
            AboutPtr->Show();
        }
    }

    int Admi::InitRemoteAssistanceTool()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::InitRemoteAssistanceTool");
        int status = OK;

        RACToolPtr = std::make_unique<RemoteAssistanceTool>();
        if(RACToolPtr)
        {
            status = RACToolPtr->Init();
        }
        else
        {
            status = GUI_E_UI_COMPONENT;
            LOG_ERROR(status, "Initialization of RACTool failed");
        }

        return status;
    }

    void Admi::SelectScheduleActivity()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectScheduleActivity");

        GuiDataModelPtr->Admi.ListType = ADMI_TABLE_SCHEDULE;
        // Clear selected patient/exam data
        ClearPatientExamRow(AdmiStruct.selectedRow);

        // Set selection
        ActiveTable = ADMI_TABLE_SCHEDULE;
        GuiGlobal::Data().admiActiveTab = TABPAGE_SCHEDULE;

        //Select the Schedule page of View
        GuiDataModelPtr->Admi.PageSelection(ADMI_TABLE_SCHEDULE);

       int patId = GetSelectedExam();
       SetSelectedPatientExam(patId);

        // Make the correct window object visible
        UpdateButtons();
    }

    void Admi::SelectReviewingActivity()
     {
         LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectReviewingActivity");

         GuiDataModelPtr->Admi.ListType = ADMI_TABLE_REVIEW;
         // Clear selected patient/exam data
         ClearPatientExamRow(AdmiStruct.selectedRow);

         // Set selection
         ActiveTable = ADMI_TABLE_REVIEW;
         GuiGlobal::Data().admiActiveTab = TABPAGE_REVIEW;

         //Select the Review page of view
         GuiDataModelPtr->Admi.PageSelection(ADMI_TABLE_REVIEW);

         // Highlight and make the rev/acq row visible
         HighlightReviewTableRow();

         // Make the correct buttons visible
         UpdateButtons();

         HndlEvtRevHiLi();
    }

    void Admi::SelectSetupActivity()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectSetupActivity");

        GUI_ACTION_STRUCT guiAction;

        // Send GUI_RAC_SETUP
        guiAction.acType = GUI_RAC_SETUP;
        GUI_ReplyAction(MONITOR_VIEWPORT_1,&guiAction);
        GUI_UTIL_LOG_Action(&guiAction);
    }

    void Admi::SelectSaveLogFileForServiceActivity()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectSaveLogFileForServiceActivity");

        GUI_ACTION_STRUCT guiAction;

        // Send GUI_AC_WINDOW_SAVELOGFILEFORSERVICE
        guiAction.acType = GUI_RAC_SAVE_LOG_FILE_FOR_SERVICE;
        GUI_ReplyAction(MONITOR_VIEWPORT_1,&guiAction);
        GUI_UTIL_LOG_Action(&guiAction);
    }

    void Admi::HighlightReviewTableRow()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HighlightReviewTableRow");

        GUI_ADMI_NODE_STRUCT *patExamNode         = (GUI_ADMI_NODE_STRUCT *)NULL;
        GUI_ADMI_NODE_STRUCT *acqPatientNode      = (GUI_ADMI_NODE_STRUCT *)NULL;
        GUI_ADMI_NODE_STRUCT *revPatientNode      = (GUI_ADMI_NODE_STRUCT *)NULL;
        GUI_ADMI_NODE_STRUCT *selectedPatientNode = (GUI_ADMI_NODE_STRUCT *)NULL;
        bool patientFound = false;

        patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_FIRST);
        while((patExamNode != static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr)) && (revPatientNode == static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr)))
        {
            if(ADMI_TABLE_REVIEW == patExamNode->table)
            {
                if(EST_CURRENT_REV == patExamNode->applData.status)
                {
                    revPatientNode = patExamNode;
                    patientFound = true;
                }
                else if(EST_CURRENT_ACQ == patExamNode->applData.status)
                {
                    acqPatientNode = patExamNode;
                    patientFound = true;
                }
                else
                {
                    //Nothing to do.
                }
            }
            patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_NEXT);
        }

        if(patientFound)
        {
            // Determine the row to highlight, see header description
            if(revPatientNode != static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr))
            {
                selectedPatientNode = revPatientNode;
            }
            else if(acqPatientNode != static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr))
            {
                selectedPatientNode = acqPatientNode;
            }
            else
            {
                //Nothing to do.
            }

        }

        // Select (and highlight) the new row
        if(selectedPatientNode != static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr))
        {
            LOG_DEBUG("Selectable patient ID %d", selectedPatientNode->applData.patientId);

            // Make the selected (and highlighted) row visble (top row in table)
            GuiDataModelPtr->Admi.ExamSelection(ADMI_TABLE_REVIEW, selectedPatientNode->applData.patientId);

            if(0 < GuiDataModelPtr->Admi.SelectedPatientIDs.size())
            {
                LOG_DEBUG("Selected Patient Id %d", selectedPatientNode->applData.patientId);

                // Update AdmiStruct.selectedRow
                AdmiStruct.selectedRow = selectedPatientNode->applData;

            }
            else if(BOOLEAN_FALSE != selectedPatientNode->visible)
            {
                LOG_ERROR(GUI_E_PROGRAM, "No row selected");
            }
            else
            {
                // Do nothing
            }
        }
    }

    int Admi::SetPatientExam(const ADMI_DATA_LAYER_TABLE_ENUM table, const int index, const GUI_ADMI_ROW_STRUCT& patExamData)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetPatientExam");

        int status = OK;
        UNREFERENCED_PARAMETER(index);

        LOG_DEBUG("SetPatientExam, Table = %d, PatientID = %d", table, patExamData.patientId);

        GuiDataModelPtr->Admi.ExamUpdated(patExamData, table);

        return status;
    }

    void Admi::ClearPatientExamRow(GUI_ADMI_ROW_STRUCT& admiRow)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ClearPatientExamRow");

        admiRow.patientId            = NO_ROW_SELECTED;
        admiRow.patientName[0]       = '\0';
        admiRow.noNamePatient        = BOOLEAN_FALSE;
        admiRow.sex                  = SEX_UNKNOWN;
        admiRow.weightKG             = 0.0;
        admiRow.heightCm             = 0.0;
        admiRow.examType[0]          = '\0';
        admiRow.detProcType[0]       = '\0';
        admiRow.physician[0]         = '\0';
        admiRow.regNr[0]             = '\0';
        admiRow.accNr[0]             = '\0';
        admiRow.examId               = NO_ROW_SELECTED;
        admiRow.nrOfImages           = 0;
        admiRow.nrOfRuns             = 0;
        admiRow.doseReport           = BOOLEAN_FALSE;
        admiRow.examAvailable        = BOOLEAN_FALSE;
        admiRow.examDate.Year        = GUI_NOT_DISPLAY_DATE;
        admiRow.status               = EST_SCHEDULED;
        admiRow.exportStatus         = EEST_NOT_EXPORTED;
        admiRow.worklistStatus       = EWST_NEVER_RECEIVED;
        admiRow.passwordProtected    = BOOLEAN_FALSE;
        admiRow.profileID            = DEFAULT_PROFILE_ID;
    }

    int Admi::SetSelectedPatientExam(const int patId)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetSelectedPatientExam");

        int status = OK;
        if( 0 <= patId)
        {
            GUI_ADMI_NODE_STRUCT *patExamNode;
            bool patientFound = false;

            // Find application data of selected row
            patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_FIRST);
            while(!patientFound && (patExamNode != static_cast<GUI_ADMI_NODE_STRUCT *>(nullptr)))
            {
                if(patExamNode->applData.patientId == patId)
                {
                    patientFound = true;
                    LOG_Message(LOG_MI_GUI,"Selected patient with PatientId [%d], examId [%d]",
                                patExamNode->applData.patientId,
                                patExamNode->applData.examId);
                }
                else
                {
                    patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_NEXT);
                }
            }

            if(patientFound)
            {
                m_PatientType = patExamNode->applData.patientType;
                AdmiStruct.selectedRow = patExamNode->applData;
                status = OK;
            }
            else
            {
                AdmiStruct.selectedRow.patientId = NO_ROW_SELECTED;
                status = GUI_E_PROGRAM;
                LOG_WARNING("Selected Patient not found in GUIDIR");
            }
        }
        else if(NO_ROW_SELECTED == patId)
        {
            AdmiStruct.selectedRow.patientId = NO_ROW_SELECTED;
            status = NO_ROW_SELECTED;
        }
        else if(MULTIPLE_ROW_SELECTED == patId)
        {
            LOG_Message(LOG_MI_GUI,"SELECTED MULTIPLE PATIENTS IN %s LIST", (ADMI_TABLE_REVIEW == ActiveTable) ? "REVIEW" : "SCHEDULE");
            AdmiStruct.selectedRow.patientId = NO_ROW_SELECTED;
            status = MULTIPLE_ROW_SELECTED;
        }
        else
        {
            //Do nothing
        }
        UpdateButtons();
        return status;
    }

    void Admi::OnShutdown()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnShutdown");
        AdmiStruct.shutdownConfirmationActive  = true;
        GuiDataModelPtr->Admi.Shutdown.Visible = true;
        GuiDataModelPtr->Admi.Shutdown.ModelUpdated();
    }

    void Admi::OnShutdownCancel()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnShutdownCancel");
        AdmiStruct.shutdownConfirmationActive  = false;
        GuiDataModelPtr->Admi.Shutdown.Visible = false;
        GuiDataModelPtr->Admi.Shutdown.ModelUpdated();
    }

    void Admi::OnShutdownOK()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnShutdownOK");

        UPIDR_SIGNAL_STRUCT upidrSignal;
        upidrSignal.scType = UPIDR_SC_GUI_SHUTDOWN_REQ;
        if (OK != UPIDR_Signal(&upidrSignal))
        {
            LOG_Warning(LOG_MI_GUI, "Shutdown process could not be initiated. Check if MosDiskService is running.");
        }
    }

    void Admi::SetPatExEditData()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetPatExEditData");

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            GUI_PHYSICIAN_NODE_STRUCT *physicianNode  = nullptr;
            bool                       etFound        = false;
            bool                       physicianFound = false;
            GUI_DET_PROC_NODE_STRUCT  *detProcNode    = nullptr;
            GUI_ET_NODE_STRUCT        *etNode         = nullptr;

            GuiDataModelPtr->Admi.AddPanel.PatientName.Text         = std::wstring(AdmiStruct.selectedRow.patientName);

            if(SEX_FEMALE == AdmiStruct.selectedRow.sex)
            {
                GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked  = true;
                GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked    = false;
                GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked = false;
            }
            else if(SEX_MALE == AdmiStruct.selectedRow.sex)
            {
                GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked    = true;
                GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked  = false;
                GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked = false;
            }
            else
            {
                GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Checked = true;
                GuiDataModelPtr->Admi.AddPanel.GenderFemale.Checked  = false;
                GuiDataModelPtr->Admi.AddPanel.GenderMale.Checked    = false;
            }

            std::wstring dateOfBirth;
            Utilities::DateUtility::ConvertOsaTimeToDateString(AdmiStruct.selectedRow.birthDate,
                                                               GuiGlobal::Data().service[MONITOR_VIEWPORT_1].dateFormat,
                                                               GuiDataModelPtr->LocalePtr, dateOfBirth);
            GuiDataModelPtr->Admi.AddPanel.PatientDOBSetText(dateOfBirth);

            GuiDataModelPtr->Admi.AddPanel.PatientId.Text = AdmiStruct.selectedRow.regNr;

            if (GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked)
            {
                AdmiStruct.selectedRow.patientType = PATIENT_PEDIATRIC;
                GuiDataModelPtr->Viewing.ExamPatex.PatientType = PATIENT_PEDIATRIC;
                GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
            }
            else
            {
                AdmiStruct.selectedRow.patientType = PATIENT_ADULT;
                GuiDataModelPtr->Viewing.ExamPatex.PatientType = PATIENT_ADULT;
                GuiDataModelPtr->Viewing.ExamPatex.ModelUpdated(MONITOR_VIEWPORT_1);
            }

            // Initialize unit of weight as per patient database
            // TRUE = POUND and FALSE = KG
            InitializePatientDialogWithWeightUnit(AdmiStruct.selectedRow.unitOfWeight);

            // Initialize unit of height as per patient database
            InitializePatientDialogWithHeightUnit(AdmiStruct.selectedRow.unitOfHeight);

            GuiDataModelPtr->Admi.AddPanel.Accno.Text = AdmiStruct.selectedRow.accNr;

            // Set the current exam type

            // Clear exam type list
            GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.clear();

            etFound = false;
            GUI_DIR_GetPatientExamTypeNode(AdmiStruct.selectedRow.patientType, GUI_DIR_FIRST, etNode);

            while(etNode != static_cast<GUI_ET_NODE_STRUCT *>(nullptr))
            {
                GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.emplace_back(etNode->examType.name);
                GUI_DIR_GetPatientExamTypeNode(AdmiStruct.selectedRow.patientType, GUI_DIR_NEXT, etNode);
            }

            GUI_DIR_GetPatientExamTypeNode(AdmiStruct.selectedRow.patientType, GUI_DIR_FIRST, etNode);
            while ((!etFound) && (etNode != static_cast<GUI_ET_NODE_STRUCT *>(nullptr)))
            {
                if (0 == wcscmp(etNode->examType.name, AdmiStruct.selectedRow.examType))
                {
                    LOG_DEBUG("Select current exam type in list: index=%d", etNode->examType.guiExamTypeId);
                    GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = etNode->examType.guiExamTypeId;
                    etFound = true;
                }
                else
                {
                    GUI_DIR_GetPatientExamTypeNode(AdmiStruct.selectedRow.patientType, GUI_DIR_NEXT, etNode);
                }
            }

            // Add current exam type to selection list when it isn't in the current exam type directory anymore
            if(!etFound)
            {
                LOG_DEBUG_W(L"Add current exam type to selection list: [%s]", AdmiStruct.selectedRow.examType);

                GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.emplace_back(AdmiStruct.selectedRow.examType);

                // Set default selection to current exam type.
                GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.size() - 1);
            }

            ResetDetProcList(etNode);

            // Select current detailed procedure in list
            bool detProcFound = false;
            detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_FIRST, etNode);

            while((!detProcFound) && (detProcNode != static_cast<GUI_DET_PROC_NODE_STRUCT *>(nullptr)))
            {
                if(0 == wcscmp(detProcNode->detProc.name, AdmiStruct.selectedRow.detProcType))
                {
                    if(NO_ROW_SELECTED != detProcNode->detProc.guiDetProcId)
                    {
                        GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = detProcNode->detProc.guiDetProcId;
                    }
                    LOG_DEBUG("Select current detailed procedure / anatomy in list: index=%d", detProcNode->index);
                    detProcFound = true;
                }
                else
                {
                    detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_NEXT, nullptr);
                }
            }

            // Add current detailed procedure to selection list when it isn't in the current detailed procedure directory anymore
            if(!detProcFound)
            {
                LOG_DEBUG_W(L"Add current detailed procedure to selection list: [%s]", AdmiStruct.selectedRow.detProcType);

                GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(AdmiStruct.selectedRow.detProcType);

                // Set default selection to current procedure.
                GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProcedureItems.size() - 1);
            }

            // Search current selected physician in list
            physicianFound = false;
            physicianNode = GUI_DIR_GetPhysicianNode(GUI_DIR_FIRST);

            while(!physicianFound && (physicianNode != static_cast<GUI_PHYSICIAN_NODE_STRUCT*>(nullptr)))
            {
                if(0 == wcscmp(physicianNode->physician.name, AdmiStruct.selectedRow.physician))
                {
                    LOG_Debug(LOG_MI_GUI, "select current physician in list: index=%d", physicianNode->index);
                    physicianFound = true;
                }
                else
                {
                    physicianNode = GUI_DIR_GetPhysicianNode(GUI_DIR_NEXT);
                }
            }

            // Add current physician to selection list when it isn't in the current physician directory anymore
            if(!physicianFound)
            {
                LOG_DEBUG_W(L"Add current physician to selection list: [%s]", AdmiStruct.selectedRow.physician);
                GuiDataModelPtr->Admi.AddPanel.PhysicianItems.emplace_back(AdmiStruct.selectedRow.physician);
            }

            // Select the current Physician
            SelectPhysicianInPatExEditList(AdmiStruct.selectedRow.physician);

            // Select the current Profile
            SelectProfileInPatExEditList();
        }
        else
        {
            LOG_MESSAGE("No row selected");
        }
    }

    int Admi::CheckValidDateEntered(std::wstring& inputString, OsaTime& outputDate)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CheckValidDateEntered");
        int status = OK;
        //Minimum allowed date to add a patient is 1900.
        if(!Utilities::DateUtility::ConvertDateStringToOsaTime(inputString, GuiGlobal::Data().service[MONITOR_VIEWPORT_1].dateFormat, GuiDataModelPtr->LocalePtr, outputDate,1900))
        {
            status = GUI_E_DATE;
        }
        else
        {
            OsaTime systemDateTime = {0};
            if((GUI_NOT_DISPLAY_DATE != outputDate.Year) && (OSA_EOK == OsaTimeGetLocalTime(&systemDateTime)))
            {
                // Translate date in to long in YYYYMMDD format and compare it.
                const long MULTI_FACTOR = 100;
                long userDate = ((((static_cast<long>(outputDate.Year) * MULTI_FACTOR) + static_cast<long>(outputDate.Month)) * MULTI_FACTOR) + static_cast<long>(outputDate.Day));
                long systemDate = ((((static_cast<long>(systemDateTime.Year) * MULTI_FACTOR) + static_cast<long>(systemDateTime.Month)) * MULTI_FACTOR) + static_cast<long>(systemDateTime.Day));
                if(userDate > systemDate)
                {
                    status = GUI_E_DATE;
                }
            }
        }

        return status;
    }

    int Admi::CheckValidWeightEntered(std::string& weightString, const UNIT_OF_WEIGHT_ENUM unitOfWeight)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CheckValidWeightEntered");

        int status = OK;
        int weightStringLength = static_cast<int>(strlen(weightString.c_str()));

        // Check for empty string
        if(0 != weightStringLength)
        {
            int nrOfSeparators = 0;
            int nrOfDecimals = 0;
            bool invalidChar = false;

            for(int u = 0; u < weightStringLength; u++)
            {
                // Check if character is a numeric value
                if(0 != isdigit(static_cast<unsigned char>(weightString[u])))
                {
                    if(nrOfSeparators > 0)
                    {
                        nrOfDecimals++;
                    }
                }
                else if(GUI_DECIMAL_COMMA_SEPARATOR == weightString[u])
                {
                    // Replace decimal comma separator with the decimal point separator
                    weightString[u] = GUI_DECIMAL_POINT_SEPARATOR;
                    nrOfSeparators++;
                }
                else if(GUI_DECIMAL_POINT_SEPARATOR == weightString[u])
                {
                    nrOfSeparators++;
                }
                else
                {
                    invalidChar = true;
                }
            }

            // Check valid entry
            if((!invalidChar) && (nrOfDecimals <= 1) && (nrOfSeparators <= 1))
            {
                double weight = atof(weightString.c_str());
                double minWeight = 0.0;
                double maxWeight = 0.0;

                if (UNIT_OF_WEIGHT_ENUM::KG_UNIT == unitOfWeight)
                {
                    minWeight = MIN_WEIGHT_KG;
                    maxWeight = MAX_WEIGHT_KG;
                }
                else
                {
                    minWeight = GUI_MIN_WEIGHT_LBS;
                    maxWeight = GUI_MAX_WEIGHT_LBS;
                }
                if((weight < minWeight) || (weight > maxWeight))
                {
                    // Boundary not ok
                    LOG_WARNING("Weight out of boundaries");
                    status = GUI_E_WEIGHT;
                }
            }
            else    // No valid entry
            {
                LOG_WARNING("Weight format is not ok");
                // Format not ok
                status = GUI_E_WEIGHT;
            }
        }
        else    // strlen(weightString) == 0
        {
            // Valid entry, do nothing
        }

        if(OK != status)
        {
            std::wstring fieldName(GuiDataModelPtr->Admi.AddPanel.WeightText);

            wchar_t* args[GUI_MAX_NR_OF_ARGS];
            args[0] = const_cast<wchar_t*>(fieldName.c_str());                                 //TICS !CON#002 [const_cast is unavoidable]
            USERGUIDANCE_SHOW_WITHARGS(MONITOR_VIEWPORT_1, GUI_MSG_FORMAT_INCORRECT, 1, args);

            // Set Keyboard focus to PatientWeight edit box.
            GuiDataModelPtr->Admi.AddPanel.SetKeyboardFocus = MVSUI::AddPanelKeyboardFocus::PatientWeight;
        }

        return status;
    }

    int Admi::CheckValidHeightEntered(std::wstring& heightString, const UNIT_OF_HEIGHT_ENUM unitOfHeight)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CheckValidHeightEntered");

        int status = OK;
        double heightInCms = 0.0;

        if (UNIT_OF_HEIGHT_ENUM::CMS_UNIT == unitOfHeight)
        {
            if (0 != heightString.length())
            {
                status = CheckStringFormatForCms(heightString);

                if (OK == status)
                {
                    heightInCms = _wtof(heightString.c_str());
                }
            }
        }
        else
        {
            if (OK == status)
            {
                heightInCms = HeightCms;
            }
        }

        if (OK == status)
        {
            status = ValidateHeightRange(heightInCms, unitOfHeight);
        }

        return status;
    }

    int Admi::CheckStringFormatForCms(std::wstring& heightString)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CheckStringFormatForCms");

        int status = OK;

        // sample example for cmsPattern
        // [0-9]+  - one or more occurence of number between 0-9
        // [.]     - mandatory decimal point([] is used to escape the wild card)
        // [0-9]*  - zero or more occurence of number between 0-9
        // |       - logical OR (for more pattern matching)
        const std::wregex cmsPattern(L"[0-9]+[.][0-9]*|[0-9]*");            //match pattern -> { [1.2]  | [123] }
        const std::wregex cmsPatternWithComma(L"[0-9]+[,][0-9]*");          //match pattern -> { [1,2] }

        if (std::regex_match(heightString, cmsPattern))
        {
            //string is already in correct format, do nothing
        }
        else if(std::regex_match(heightString, cmsPatternWithComma))
        {
            const size_t commaPosition = heightString.find(L",");
            heightString[commaPosition] = '.';   //Replace comma with dot
        }
        else
        {
            LOG_WARNING("Height format is not correct");
            status = GUI_E_HEIGHT_FORMAT_INCORRECT;

            UpdateUserMessage(true, GUI_MSG_FORMAT_INCORRECT, GuiDataModelPtr->Admi.AddPanel.HeightText);
        }

        return status;
    }

    int Admi::CheckAndCorrectStringFormatForFeetAndInches(std::wstring& heightString)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CheckAndCorrectStringFormatForFeetAndInches");

        int status = OK;

        // sample example for feetAndInchesPattern
        // [0-9]+  - one or more occurence of number between 0-9
        // \'      - mandatory single quote(\ is used to escape the wild card)
        // [0-9]   - mandatory one occurence of number between 0-9
        // \"      - mandatory double quotes(\ is used to escape the wild card)
        // |       - logical OR (for more pattern matching)
        const std::wregex feetAndInchesPattern(L"[0-9]+\'[0-9]\"|[0-9]+\'1[0-1]\"|[0-9]+\'0[0-9]\"");                //match pattern -> 12'3"  | 9'10" | 9'01"
        const std::wregex inchesPattern(L"[0-9]+\"");                                                                //match pattern -> 12"
        const std::wregex feetAndInchesWithoutDoubleQuotesPattern(L"[0-9]+\'[0-9]|[0-9]+\'1[0-1]|[0-9]+\'0[0-9]");   //match pattern -> 12'34
        const std::wregex feetPattern(L"[0-9]+\'");
        const std::wregex inchesWithoutDoubleQuotesPattern(L"[0-9]+");

        if (std::regex_match(heightString, feetAndInchesPattern))
        {
            //string is already in correct format, do nothing
        }
        else if(std::regex_match(heightString, inchesPattern))
        {
            heightString = Utilities::UnitConversion::ConvertInchesToFeetAndInches(heightString);
        }
        else if (std::regex_match(heightString, feetAndInchesWithoutDoubleQuotesPattern))
        {
            heightString = heightString + L"\"";    //Append Double Quotes to string;
        }
        else if (std::regex_match(heightString, feetPattern))
        {
            heightString = heightString + L"0\"";   //Append 0" to string
        }
        else if (std::regex_match(heightString, inchesWithoutDoubleQuotesPattern))
        {
            heightString = heightString + L"\"";    //Append Double Quotes to string;
            CheckAndCorrectStringFormatForFeetAndInches(heightString);  //call the function again to format
        }
        else
        {
            LOG_WARNING("Height format is not correct");
            status = GUI_E_HEIGHT_FORMAT_INCORRECT;

            UpdateUserMessage(true, GUI_MSG_FORMAT_INCORRECT, GuiDataModelPtr->Admi.AddPanel.HeightText);
        }

        return status;
    }

    int Admi::ValidateHeightRange(const double cms, const UNIT_OF_HEIGHT_ENUM unitOfHeight)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ValidateHeightRange");

        int status = OK;

         if((MAX_HEIGHT_CMS < cms) ||
            (MIN_HEIGHT_CMS > cms))
        {
             wchar_t* args[GUI_MAX_NR_OF_ARGS] = {};

            if (UNIT_OF_HEIGHT_ENUM::CMS_UNIT == unitOfHeight)
            {
                args[0] = const_cast<wchar_t*>(CMS_MIN);
                args[1] = const_cast<wchar_t*>(CMS_MAX);
            }
            else
            {
                args[0] = const_cast<wchar_t*>(FEET_AND_INCHES_MIN);
                args[1] = const_cast<wchar_t*>(FEET_AND_INCHES_MAX);
            }

            USERGUIDANCE_SHOW_WITHARGS(MONITOR_VIEWPORT_1, GUI_MSG_RANGE_INCORRECT, 2, args);
            status = GUI_E_HEIGHT_OUT_OF_RANGE;
        }

        return status;
    }

    int Admi::HndlEvtRevHiLi()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtRevHiLi");
        int status = OK;

        if(!AdmiStruct.examRevHiLiSuspended)
        {
            // Reply highlighted Exam
            // Note :
            // An exam with status SCH or containing no images is replied because this way ADMI can synchronise with GUI in case GUI performed an implicit
            // selection (=highlight) of a new exam row (e.g. after a ADMI delete action)
            // An exam with status ACQ is replied because although this exam can also be the REV exam already, this is not known to GUI

            if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
            {
                GUI_ACTION_STRUCT    guiAction;
                guiAction.acInfo.acqExam.patientId = AdmiStruct.selectedRow.patientId;
                guiAction.acInfo.acqExam.examId = AdmiStruct.selectedRow.examId;
                guiAction.acType = GUI_RAC_EXAM_REVIEW_HILI;
                GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
                GUI_UTIL_LOG_Action(&guiAction);
            }
            else
            {
                UpdateButtons();
                status = GUI_E_PROGRAM;
                LOG_ERROR(status, "No patientID");
            }
        }
        else
        {
            UpdateButtons();
            LOG_DEBUG("Exam review suspended");
        }

        LOG_DEBUG("Status=%d", status);
        return status;
    }

    //Handle the aquisition Icon's event
    int Admi::HndlEvtAcq()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtAcq");
        int status = OK;

        std::call_once(m_SetPatTypeFlag, [this]
        { 
            InitializeGridMessageStatus();
        });

        if(!AdmiStruct.examAcqSuspended)
        {
            if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
            {
                GUI_ACTION_STRUCT guiAction;
                guiAction.acInfo.acqExam.patientId = AdmiStruct.selectedRow.patientId;
                guiAction.acInfo.acqExam.examId = AdmiStruct.selectedRow.examId;
                guiAction.acInfo.acqExam.lastGridMessage = GuiGlobal::Data().lastGridMessage;

                guiAction.acType = GUI_RAC_EXAM_ACQ;
                GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
                GUI_UTIL_LOG_Action(&guiAction);
            }
            else
            {
                status = GUI_E_PROGRAM;
                LOG_ERROR(status, "No patientID");
            }
        }
        else
        {
            LOG_DEBUG("Exam acquisition suspended");
        }

        LOG_DEBUG("Status [%d]", status);
        return status;
    }

    //Handle the review icon event
    int Admi::HndlEvtRev()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtRev");
        int status;

        status = OK;

        if(!AdmiStruct.examRevSuspended)
        {
            if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
            {
                GUI_ACTION_STRUCT guiAction;
                guiAction.acInfo.acqExam.patientId = AdmiStruct.selectedRow.patientId;
                guiAction.acInfo.acqExam.examId = AdmiStruct.selectedRow.examId;
                guiAction.acType = GUI_RAC_EXAM_REVIEW;
                GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
                GUI_UTIL_LOG_Action(&guiAction);
            }
            else
            {
                status = GUI_E_PROGRAM;
                LOG_ERROR(status, "No patientID");
            }
        }
        else
        {
            LOG_DEBUG("Exam review suspended");
        }

        LOG_DEBUG("status [%d]", status);
        return status;
    }

    //Handle the dosereport icon event
    int Admi::HndlEvtDose()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtDose");
        int status = OK;

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            GUI_ACTION_STRUCT guiAction;
            guiAction.acInfo.doseReport.patientId = AdmiStruct.selectedRow.patientId;
            guiAction.acInfo.doseReport.examId = AdmiStruct.selectedRow.examId;
            guiAction.acType = GUI_RAC_DOSE_REPORT;
            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
            GUI_UTIL_LOG_Action(&guiAction);
        }
        else
        {
            status = GUI_E_PROGRAM;
            LOG_ERROR(status, "No patientID");
        }

        LOG_DEBUG("status [%d]", status);

        return status;
    }

    //Handle the Get Worklist button event
    int Admi::HndlEvtGetWL()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtGetWL");

        GUI_ACTION_STRUCT guiAction;

        int status = OK;
        guiAction.acType = GUI_RAC_WLQ_START;
        GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
        GUI_UTIL_LOG_Action(&guiAction);

        if(BOOLEAN_TRUE == GuiGlobal::Data().getWorklist.isQueryActive)
        {
            // Returning an error ensures that the ADMI panel is restored
            // when the Get Worklist Panel may not be shown.
            status = GUI_E_QUERY_ACTIVE;
        }

        LOG_DEBUG("Status [%d]", status);

        return status;
    }

    //Handle the Worklist Info button event
    int Admi::HndlEvtWLInfo()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtWLInfo");

        int status = OK;

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            GUI_ACTION_STRUCT guiAction;
            guiAction.acInfo.examInfo.patientId = AdmiStruct.selectedRow.patientId;
            guiAction.acInfo.examInfo.examId = AdmiStruct.selectedRow.examId;
            guiAction.acType = GUI_RAC_MWL_REVIEW;

            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
            GUI_UTIL_LOG_Action(&guiAction);
        }
        else
        {
            status = GUI_E_PROGRAM;
            LOG_ERROR(status, "No patientID");
        }

        LOG_DEBUG("Status [%d]", status);
        return status;
    }

    //Handle the export icon event -When the start export iconbutton in the ADMI panel is pressed,
    //this function replies the GUI_RAC_EXAM_EXPORT action.
    int Admi::HndlEvtExport()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HndlEvtExport");

        int status = OK;

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            GUI_ACTION_STRUCT guiAction;
            guiAction.acInfo.doseReport.patientId = AdmiStruct.selectedRow.patientId;
            guiAction.acInfo.doseReport.examId = AdmiStruct.selectedRow.examId;
            guiAction.acType = GUI_RAC_EXAM_EXPORT;
            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
            GUI_UTIL_LOG_Action(&guiAction);
        }
        else
        {
            status = GUI_E_PROGRAM;
            LOG_ERROR(status, "No patientID");
        }

        LOG_DEBUG("status [%d]", status);
        return status;
    }

    //Reply the patient and examination if edited.
    int Admi::Reply(GUI_OPERATION_ENUM operation)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Reply");

        int status = OK;
        GUI_ACTION_STRUCT guiPatientAction;
        GUI_ACTION_STRUCT guiExamAction;

        GUI_ACTION_STRUCT guiPatientTypeUpdate;

        // Send patient type and taste ID info to ADMI
        if ((GUI_OPER_MODIFY == operation) && (EST_CURRENT_ACQ == AdmiStruct.selectedRow.status))
        {
            GUI_PROFILE_NODE_STRUCT* profileNode;

            guiPatientTypeUpdate.acType = GUI_RAC_PATIENT_TYPE;
            guiPatientTypeUpdate.acInfo.patientInfo.patientType = m_PatientType;
            const int selectedProfileIndex = GuiDataModelPtr->Admi.AddPanel.ProfileIndex;
            GetProfileData(GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex], profileNode);
            if (NULL != profileNode)
            {
                if (PATIENT_TYPE_ENUM::PATIENT_ADULT == guiPatientTypeUpdate.acInfo.patientInfo.patientType)
                {
                    guiPatientTypeUpdate.acInfo.profileData.profileStruct.iqTasteAdult.tasteId = profileNode->userProfile.profileData.iqTasteAdult.tasteId;
                    OsaStrCpy(guiPatientTypeUpdate.acInfo.profileData.profileStruct.iqTasteAdult.tasteName,
                              sizeof(profileNode->userProfile.profileData.iqTasteAdult.tasteName),
                              profileNode->userProfile.profileData.iqTasteAdult.tasteName);
                }
                else
                {
                    guiPatientTypeUpdate.acInfo.profileData.profileStruct.iqTastePediatric.tasteId = profileNode->userProfile.profileData.iqTastePediatric.tasteId;
                    OsaStrCpy(guiPatientTypeUpdate.acInfo.profileData.profileStruct.iqTastePediatric.tasteName,
                              sizeof(profileNode->userProfile.profileData.iqTastePediatric.tasteName),
                              profileNode->userProfile.profileData.iqTastePediatric.tasteName);
                }
            }
            else
            {
                OsaWcsNCpy(guiPatientTypeUpdate.acInfo.profileData.profileStruct.profileName, static_cast<size_t>(PROFILE_NAME_LENGTH + 1),
                    GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex].c_str(), static_cast<size_t>(PROFILE_NAME_LENGTH + 1));
            }
            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiPatientTypeUpdate);
            GUI_UTIL_LOG_Action(&guiPatientTypeUpdate);
        }

        //GUI_LANG_GetNoNameString(noNameStr);
        // First fill both GUI_ACTION_STRUCT's before sending the ReplyAction
        // See SURG00000731: PatientID by new patients not in sched list

        // Fill guiPatientAction
        guiPatientAction.acType = GUI_RAC_PATIENT;
        guiPatientAction.acInfo.admiPatient.operation = operation;

        if((BOOLEAN_TRUE == AdmiStruct.selectedRow.noNamePatient) &&
           (0 == wcscmp(AdmiStruct.selectedRow.patientName, GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_NONAME_PATIENTNAME).c_str())))
        {
            OsaWcsNCpy(guiPatientAction.acInfo.admiPatient.patient.name, static_cast<size_t>(PATIENT_NAME_LENGTH + 1),
                       GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_NONAME_PATIENTNAME).c_str(), static_cast<size_t>(PATIENT_NAME_LENGTH + 1));
            LOG_DEBUG("The NoName patient has been modified");
        }
        else
        {
            OsaWcsNCpy(guiPatientAction.acInfo.admiPatient.patient.name, static_cast<size_t>(PATIENT_NAME_LENGTH + 1),
                       AdmiStruct.selectedRow.patientName, static_cast<size_t>(PATIENT_NAME_LENGTH + 1));
        }

        guiPatientAction.acInfo.admiPatient.patient.sex               = AdmiStruct.selectedRow.sex;
        guiPatientAction.acInfo.admiPatient.patient.passwordProtected = AdmiStruct.selectedRow.passwordProtected;
        guiPatientAction.acInfo.admiPatient.patientId                 = AdmiStruct.selectedRow.patientId;
        guiPatientAction.acInfo.admiPatient.patient.birthDate         = AdmiStruct.selectedRow.birthDate;
        guiPatientAction.acInfo.admiPatient.patient.weightKG          = AdmiStruct.selectedRow.weightKG;
        guiPatientAction.acInfo.admiPatient.patient.heightCm          = AdmiStruct.selectedRow.heightCm;
        guiPatientAction.acInfo.admiPatient.patient.patientType       = AdmiStruct.selectedRow.patientType;
        guiPatientAction.acInfo.admiPatient.patient.profileID         = AdmiStruct.selectedRow.profileID;
        OsaWcsNCpy(guiPatientAction.acInfo.admiPatient.patient.profileName, static_cast<size_t>(PROFILE_NAME_LENGTH + 1),
                   AdmiStruct.selectedRow.profileName, static_cast<size_t>(PROFILE_NAME_LENGTH + 1));
        guiPatientAction.acInfo.admiPatient.patient.unitOfMeasure     = AdmiStruct.selectedRow.unitOfMeasure;
        guiPatientAction.acInfo.admiPatient.patient.unitOfWeight      = AdmiStruct.selectedRow.unitOfWeight;
        guiPatientAction.acInfo.admiPatient.patient.unitOfHeight      = AdmiStruct.selectedRow.unitOfHeight;

        // Fill guiExamAction
        guiExamAction.acType = GUI_RAC_EXAM;
        guiExamAction.acInfo.exam.operation = operation;
        guiExamAction.acInfo.exam.patientId = AdmiStruct.selectedRow.patientId;
        guiExamAction.acInfo.exam.examId    = AdmiStruct.selectedRow.examId;

        OsaWcsNCpy(guiExamAction.acInfo.exam.regNr, static_cast<size_t>(REGISTRATION_NUMBER_LENGTH + 1),
                   AdmiStruct.selectedRow.regNr, static_cast<size_t>(REGISTRATION_NUMBER_LENGTH+1));

        OsaWcsNCpy(guiExamAction.acInfo.exam.accNr, static_cast<size_t>(ACCESSION_NR_LENGTH + 1),
                   AdmiStruct.selectedRow.accNr, static_cast<size_t>(ACCESSION_NR_LENGTH+1));

        OsaWcsNCpy(guiExamAction.acInfo.exam.examType, static_cast<size_t>(EXAMINATION_NAME_LENGTH + 1),
                   AdmiStruct.selectedRow.examType, static_cast<size_t>(EXAMINATION_NAME_LENGTH+1));

        OsaWcsNCpy(guiExamAction.acInfo.exam.detProcType, static_cast<size_t>(DETPROC_NAME_LENGTH + 1),
                   AdmiStruct.selectedRow.detProcType, static_cast<size_t>(DETPROC_NAME_LENGTH+1));

        if(0 == static_cast<int>(wcslen(AdmiStruct.selectedRow.physician)))
        {
            OsaWcsNCpy(guiExamAction.acInfo.exam.physician, static_cast<size_t>(PHYSICIAN_NAME_LENGTH + 1),
                GUI_NO_NAME_WSTRING, static_cast<size_t>(PHYSICIAN_NAME_LENGTH + 1));
        }
        else
        {
            OsaWcsNCpy(guiExamAction.acInfo.exam.physician, static_cast<size_t>(PHYSICIAN_NAME_LENGTH + 1),
                       AdmiStruct.selectedRow.physician, static_cast<size_t>(PHYSICIAN_NAME_LENGTH+1));
        }

        // Send Action Reply to ADMI for Patient data
        if(!AdmiStruct.patientEditSuspended)
        {
            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiPatientAction);
            GUI_UTIL_LOG_Action(&guiPatientAction);
        }

        // Send Action Reply to ADMI for Examination data
        if((OK == status) && (!AdmiStruct.examEditSuspended))
        {
            LOG_DEBUG_W(L"Reply patient id[%d], exam Id[%d] Reg[%s] DerProc type [%s] Phys[%s] ExamType[%s]",
                        guiExamAction.acInfo.exam.patientId,
                        guiExamAction.acInfo.exam.examId,
                        guiExamAction.acInfo.exam.regNr,
                        guiExamAction.acInfo.exam.detProcType,
                        guiExamAction.acInfo.exam.physician,
                        guiExamAction.acInfo.exam.examType);

            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiExamAction);
            GUI_UTIL_LOG_Action(&guiExamAction);
        }

        LOG_DEBUG("status [%d]", status);
        return status;
    }

    int Admi::DeleteSelectedRows()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DeleteSelectedRows");

        int status = OK;
        GUI_ACTION_STRUCT exams;
        exams.acType = GUI_RAC_DEL_EXAM;
        exams.acInfo.selectedExams.nrOfExams = static_cast<long>(GuiDataModelPtr->Admi.SelectedPatientIDs.size());

        for(int selectedItem = 0; selectedItem < static_cast<int>(exams.acInfo.selectedExams.nrOfExams); selectedItem++)
        {
            int patID = GuiDataModelPtr->Admi.SelectedPatientIDs.at(selectedItem);
            SetSelectedPatientExam(patID);

            GUI_AC_EXAM_ID_STRUCT guiExamAction;

            guiExamAction.patientId = AdmiStruct.selectedRow.patientId;
            guiExamAction.examId    = AdmiStruct.selectedRow.examId;

            exams.acInfo.selectedExams.selectedExamList[selectedItem] = guiExamAction;
        }

        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &exams);
        GUI_UTIL_LOG_Action(&exams);

        return status;
    }

    // Update the state of the following button controls:ADD_EXAM, ACQUISTION, REVIEW, DOSE_REPORT, EXPORT, DEL_EXAM, RETRIEVE_WL
    // The controls are enabled/disabled to reflect the functionality for the highlighted patient/exam.
    void Admi::UpdateButtons()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdateButtons");

        int selectedRow = GetSelectedExam();

        // Add Button-If system type is unequal BASIC and SCHEDULE activity is selected, show the Add button, hide it otherwise
        if (ADMI_GUI_FunctionMultiPatPresent())
        {
            GuiDataModelPtr->Admi.Schedule.Add.Visible = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Add.Visible = false;
        }

        if (!AdmiStruct.examEditSuspended)
        {
            GuiDataModelPtr->Admi.Schedule.Add.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Add.Enabled = false;
        }

        // Modify Button-If not basic, not locked and a row selected, enable the Modify, disable it otherwise
        if (!AdmiStruct.examEditSuspended && ADMI_GUI_FunctionMultiPatPresent() && (NO_ROW_SELECTED != selectedRow) && (MULTIPLE_ROW_SELECTED != selectedRow))
        {
            GuiDataModelPtr->Admi.Schedule.Modify.Enabled = true;
            GuiDataModelPtr->Admi.Review.Modify.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Modify.Enabled = false;
            GuiDataModelPtr->Admi.Review.Modify.Enabled = false;
        }

        // Delete Button-If not basic, not locked and a row selected and this is not the empty NoName acq patient, enable the Delete button, disable it otherwise
        if (!AdmiStruct.examEditSuspended && ADMI_GUI_FunctionMultiPatPresent() && (NO_ROW_SELECTED != selectedRow) && !IsEmptyNoNameAcqExamSelected() || (MULTIPLE_ROW_SELECTED == selectedRow))
        {
            GuiDataModelPtr->Admi.Schedule.Delete.Enabled = true;
            GuiDataModelPtr->Admi.Review.Delete.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.Delete.Enabled = false;
            GuiDataModelPtr->Admi.Review.Delete.Enabled = false;
        }

        // Start Exam Button- If not basic, not locked and a row selected,enable the Start Exam button, disable it otherwise
        if (!AdmiStruct.examAcqSuspended && (NO_ROW_SELECTED != selectedRow) && (MULTIPLE_ROW_SELECTED != selectedRow))
        {
            GuiDataModelPtr->Admi.Schedule.StartExam.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.StartExam.Enabled = false;
        }

        // Show Exam Button- IF not locked and a row selected and this selected exam has images, enable the Show Exam button, disable it otherwise
        if(!AdmiStruct.examRevSuspended &&(NO_ROW_SELECTED != selectedRow) &&
            (AdmiStruct.selectedRow.nrOfImages > 0) && (MULTIPLE_ROW_SELECTED != selectedRow))
        {
            GuiDataModelPtr->Admi.Review.ShowExam.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Review.ShowExam.Enabled = false;
        }

        // Dose Report Button- If a row selected and this selected exam has a dose, enable the Dose Report button, disable it otherwise
        if((NO_ROW_SELECTED != selectedRow) && AdmiStruct.selectedRow.doseReport && (MULTIPLE_ROW_SELECTED != selectedRow))
        {
            GuiDataModelPtr->Admi.Review.DoseReport.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Review.DoseReport.Enabled = false;
        }

        // Close exam button
        if((ADMI_TABLE_REVIEW == ActiveTable) && (TRUE == AdmiStruct.admi.enableCloseExamButton))
        {
            GuiDataModelPtr->Admi.Review.CloseExam.Visible = true;
            // If a row is selected and this selected exam is the current acquisition exam,
            // and this selected exam has a dose,enable the Close Examination button
            if((NO_ROW_SELECTED != selectedRow) &&
                (AdmiStruct.selectedRow.status == EST_CURRENT_ACQ) &&
                (AdmiStruct.selectedRow.doseReport == TRUE) && (MULTIPLE_ROW_SELECTED != selectedRow))
            {
                GuiDataModelPtr->Admi.Review.CloseExam.Enabled = true;
            }
            else
            {
                GuiDataModelPtr->Admi.Review.CloseExam.Enabled = false;
            }
        }
        else
        {
            GuiDataModelPtr->Admi.Review.CloseExam.Visible = false;
        }

        // Get Worklist Button- Hide when advanced DICOM options are not installed
        if (TRUE == GuiGlobal::Data().config.dicomExtended)
        {
            GuiDataModelPtr->Admi.Schedule.GetWorklist.Visible = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.GetWorklist.Visible = false;
        }

        // Disabled when there is no WLM target configured and the password options is present and no valid password is entered
        if (!AdmiStruct.retrWlSuspended && AdmiStruct.admi.enableWLM &&
            (!GuiGlobal::Data().pswdProtect.dfiPasswordEnabled ||
            (GuiGlobal::Data().pswdProtect.dfiPasswordEnabled &&
                GuiGlobal::Data().pswdProtect.correctPasswordEntered)))
        {
            GuiDataModelPtr->Admi.Schedule.GetWorklist.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.GetWorklist.Enabled = false;
        }

        // Exam Info Button- Hide when the advanced DICOM options is not installe
        if (TRUE == GuiGlobal::Data().config.dicomExtended)
        {
            GuiDataModelPtr->Admi.Schedule.ExamInfo.Visible = true;
            GuiDataModelPtr->Admi.Review.ExamInfo.Visible = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.ExamInfo.Visible = false;
            GuiDataModelPtr->Admi.Review.ExamInfo.Visible = false;
        }

        // Disabled when the password options is present and no valid password is entered or the selected exam is not received via a Worklist from a RIS/HIS
        if(!AdmiStruct.examInfoSuspended && 
            (NO_ROW_SELECTED != selectedRow) &&
            (EWST_NEVER_RECEIVED != AdmiStruct.selectedRow.worklistStatus) &&
            (!GuiGlobal::Data().pswdProtect.dfiPasswordEnabled ||
            (GuiGlobal::Data().pswdProtect.dfiPasswordEnabled &&
            GuiGlobal::Data().pswdProtect.correctPasswordEntered)) && (MULTIPLE_ROW_SELECTED != selectedRow))
        {
            GuiDataModelPtr->Admi.Schedule.ExamInfo.Enabled = true;
            GuiDataModelPtr->Admi.Review.ExamInfo.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Schedule.ExamInfo.Enabled = false;
            GuiDataModelPtr->Admi.Review.ExamInfo.Enabled = false;
        }

        if((NO_ROW_SELECTED != selectedRow) && (MULTIPLE_ROW_SELECTED != selectedRow) && !IsEmptyNoNameAcqExamSelected() && (EST_CURRENT_ACQ == AdmiStruct.selectedRow.status))
        {
            GuiDataModelPtr->Admi.Review.BackToAcquisition.Enabled = true;
        }
        else
        {
            GuiDataModelPtr->Admi.Review.BackToAcquisition.Enabled = false;
        }

        if (ADMI_TABLE_SCHEDULE == ActiveTable)
        {
            GuiDataModelPtr->Admi.Schedule.ModelUpdated();
        }
        else if (ADMI_TABLE_REVIEW == ActiveTable)
        {
            GuiDataModelPtr->Admi.Review.ModelUpdated();
        }

        // If [no exam is selected] or [multiple exams selected] or [no dose information available], then disable all export buttons
        bool bIsExportAllowed = !(GuiDataModelPtr->Admi.Visible && ((NO_ROW_SELECTED == selectedRow) || (MULTIPLE_ROW_SELECTED == selectedRow) || (BOOLEAN_FALSE == AdmiStruct.selectedRow.doseReport)));
        bool jobVwrEnabled = ExportRibbonUtility::UpdateRibbonPanelModel(&GuiDataModelPtr->General.ExportRibbon, bIsExportAllowed);
        GuiDataModelPtr->General.ExportRibbon.ModelUpdatedAdmi();
        // Update JobViewer in SystemMenu.
        GuiDataModelPtr->Admi.EnableSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_JOBVIEWER, jobVwrEnabled);

    }

    void Admi::SelectPhysicianInPatExEditList(const std::wstring& physicianName)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectPhysicianInPatExEditList");

        bool physicianSelected = false;

        // Get number of items
        for(int i = 0; i < static_cast<int>(GuiDataModelPtr->Admi.AddPanel.PhysicianItems.size()); i++)
        {
            std::wstring physicianString = GuiDataModelPtr->Admi.AddPanel.PhysicianItems[i];

            // Is this physician currently selected
            if(0 == physicianName.compare(physicianString))
            {
                GuiDataModelPtr->Admi.AddPanel.PhysicianIndex = i;
                physicianSelected = true;
            }
        }
    }

    //Disable the fields that belong to the examination retrieved from the HIS/RIS via WLM.
    void Admi::ExamDisableEditFields()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ExamDisableEditFields");

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            if(EWST_NEVER_RECEIVED != AdmiStruct.selectedRow.worklistStatus)
            {
                GuiDataModelPtr->Admi.AddPanel.PatientName.Enabled    = false;
                GuiDataModelPtr->Admi.AddPanel.PatientId.Enabled      = false;
                GuiDataModelPtr->Admi.AddPanel.PatientDOBEnabled      = false;
                GuiDataModelPtr->Admi.AddPanel.GenderFemale.Enabled   = false;
                GuiDataModelPtr->Admi.AddPanel.GenderMale.Enabled     = false;
                GuiDataModelPtr->Admi.AddPanel.GenderUnknown.Enabled  = false;
                GuiDataModelPtr->Admi.AddPanel.Accno.Enabled          = false;
            }
        }
    }

    //Check whether the selected exam is the empty NoName acq exam.
    //See also admi.pad.c (ADMI_ExamNotNoNameAnymore) for a simular check.
    bool Admi::IsEmptyNoNameAcqExamSelected()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::IsEmptyNoNameAcqExamSelected");

        return((BOOLEAN_TRUE == AdmiStruct.selectedRow.noNamePatient) &&                           // Noname patient/exam
              (EST_CURRENT_ACQ == AdmiStruct.selectedRow.status) &&                                // Acquisition exam
              (0 == AdmiStruct.selectedRow.nrOfImages) &&                                          // number of images
              (BOOLEAN_FALSE == AdmiStruct.selectedRow.doseReport));                               // dose report
    }

    // Admi panel callback methods

    void Admi::AddClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::AddClicked");

        AdmiStruct.rowModified = false;

        // Display PatEx Edit window
        PatexEditInd();

        GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
    }

    void Admi::ModifyClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ModifyClicked");

        AdmiStruct.rowModified = true;

        // Display PatEx Edit window
        PatexEditInd();
        SetPatExEditData();

        // Modify of an exam received from the RIS/HIS via WLM is not possible except for the Physician name and the Exam type
        ExamDisableEditFields();

        GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
    }

    void Admi::DeleteClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DeleteClicked");
       // IF not basic, not locked and a row selected and
       // this is not the empty NoName acq patient,
       // allow the Delete function ELSE ignore the DELETE request
        if((!AdmiStruct.examEditSuspended) &&
           (BOOLEAN_TRUE == ADMI_GUI_FunctionMultiPatPresent()) &&
           (NO_ROW_SELECTED != GetSelectedExam()) &&
           ((!IsEmptyNoNameAcqExamSelected()) || (MULTIPLE_ROW_SELECTED == GetSelectedExam())))
        {
            PatDeleteQuestionInd();
        }
    }

    void Admi::StartExamClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::StartExamClicked");

        int status = OK;
        status = HndlEvtAcq();
        LOG_DEBUG("status=%d", status);
    }

    void Admi::ShowExamClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ShowExamClicked");

        int status = OK;
        status = HndlEvtRev();
        LOG_DEBUG("status=%d", status);
    }

    void Admi::GetWorkListClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetWorkListClicked");

        int status = OK;
        status = HndlEvtGetWL();
        LOG_DEBUG("status=%d", status);
    }

    void Admi::DoseReportClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DoseReportClicked");

        int status = OK;
        status = HndlEvtDose();
        LOG_DEBUG("status=%d", status);
    }

    void Admi::CloseExamClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::CloseExamClicked");

        // Request exam-close to ADMI.
        Reply(GUI_OPER_CLOSE);
    }

    void Admi::WorkListInfoClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::WorkListInfoClicked");

        int status = OK;
        status = HndlEvtWLInfo();
        LOG_DEBUG("status=%d", status);
    }

    void Admi::BackToAcquisitionClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::BackToAcquisitionClicked");

        int status = OK;

        std::call_once(m_SetPatTypeFlag, [this]
        {
            InitializeGridMessageStatus();
        });

        if(NO_ROW_SELECTED != AdmiStruct.selectedRow.patientId)
        {
            GUI_ACTION_STRUCT guiAction;

            guiAction.acType = GUI_RAC_BACK_TO_ACQ;
            guiAction.acInfo.acqExam.patientId = AdmiStruct.selectedRow.patientId;
            guiAction.acInfo.acqExam.examId = AdmiStruct.selectedRow.examId;
            guiAction.acInfo.acqExam.lastGridMessage = GuiGlobal::Data().lastGridMessage;
            GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
            GUI_UTIL_LOG_Action(&guiAction);
        }
        else
        {
            status = GUI_E_PROGRAM;
            LOG_ERROR(status, "No patient selected");
        }

        LOG_DEBUG("status [%d]", status);
    }

    // PatexEdit Callback methods
    void Admi::PatexEditOkClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditOkClicked");

        int status = GetPatExEditData();

        if(OK == status)
        {
            if(BOOLEAN_FALSE == ADMI_GUI_FunctionMultiPatPresent())  // Basic system
            {
                status = Reply(GUI_OPER_DELETE);
            }
            else
            {
                status = Reply(AdmiStruct.rowModified ? GUI_OPER_MODIFY : GUI_OPER_ADD);
            }
        }

        else
        {
           StartExamOnNewPatient = false;
        }

        // Close add/modify window when no patient name is entered
        if((OK == status) || (GUI_E_UNKNOWN_NAME == status))
        {
            PatexEditRem();
        }
    }

    void Admi::PatexEditCancelClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditCancelClicked");

        // Hide patient add/modify panel
        PatexEditRem();
    }

    void Admi::PatexEditStartExamClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditStartExamClicked");
        StartExamOnNewPatient = true;

        // Redirect the call to PatexEditOK_Click.
        PatexEditOkClicked();
    }

    // Delete Question callback methods
    void Admi::DeleteQuestionYesClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DeleteQuestionYesClicked");

        int status = OK;

        status = DeleteSelectedRows();

        if(OK == status)
        {
            PatDeleteQuestionRem();
        }
        LOG_DEBUG("status=%d", status);
    }

    void Admi::DeleteQuestionNoClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DeleteQuestionNoClicked");

        PatDeleteQuestionRem();
    }

    void Admi::MultipleDeleteConfirmClicked()
    {
         LOG_FUNCTION(LOG_MI_GUI, "Admi::MultipleDeleteConfirmClicked");

         GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible = false;
        if(ADMI_TABLE_SCHEDULE == ActiveTable)
        {
            GuiDataModelPtr->Admi.Schedule.Delete.Checked = false;
            GuiDataModelPtr->Admi.Schedule.ModelUpdated();
        }
        else if(ADMI_TABLE_REVIEW == ActiveTable)
        {
            GuiDataModelPtr->Admi.Review.Delete.Checked = false;
            GuiDataModelPtr->Admi.Review.ModelUpdated();
        }
        else
        {
            //Nothing to do.
        }

        DeleteSelectedRows();

        PatDeleteQuestionRem();
    }

     void Admi::MultipleDeleteCancelClicked()
     {
         LOG_FUNCTION(LOG_MI_GUI, "Admi::MultipleDeleteCancelClicked");

        if(ADMI_TABLE_SCHEDULE == ActiveTable)
        {
            GuiDataModelPtr->Admi.Schedule.Delete.Checked = false;
            GuiDataModelPtr->Admi.Schedule.ModelUpdated();
        }
        else if(ADMI_TABLE_REVIEW == ActiveTable)
        {
            GuiDataModelPtr->Admi.Review.Delete.Checked = false;
            GuiDataModelPtr->Admi.Review.ModelUpdated();
        }
        else
        {
            //Nothing to do.
        }

        PatDeleteQuestionRem();
     }

    void Admi::ProfileBtnClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ProfileBtnClicked");

        GUI_ACTION_STRUCT guiAction;

        // Send GUI_RAC_PROFILE
        guiAction.acType = GUI_RAC_PROFILE;
        GUI_ReplyAction(MONITOR_VIEWPORT_1,&guiAction);
        GUI_UTIL_LOG_Action(&guiAction);
    }

    void Admi::UpdateUserMessage(bool displayWarning, const GUI_MESSAGE_ENUM msgID, const std::wstring& fieldName)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdateUserMessage");

        if(displayWarning)
        {
            wchar_t* args[GUI_MAX_NR_OF_ARGS];
            args[0] = const_cast<wchar_t*>(fieldName.c_str());                                 //TICS !CON#002 [const_cast is unavoidable]
            USERGUIDANCE_SHOW_WITHARGS(MONITOR_VIEWPORT_1, msgID, 1, args);
        }
        else
        {
            USERGUIDANCE_HIDE(MONITOR_VIEWPORT_1, msgID);
        }
    }

    void Gui::Admi::UpdatePatientHeightOnFocusChange(bool focus)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdatePatientHeightOnFocusChange");

        if (!focus)
        {
            int status = E_ERROR;

            if (!GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text.empty())
            {
                std::wstring heightString = GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text;

                // Get unit of height type form UI control
                const UNIT_OF_HEIGHT_ENUM unitOfHeight = GuiDataModelPtr->Admi.AddPanel.unitOfHeight;

                status = CheckValidHeightEntered(heightString, unitOfHeight);

                if (OK == status)
                {
                    HeightCms = _wtof(heightString.c_str());
                }
                else
                {
                    HeightCms = 0.0;
                }

                GuiDataModelPtr->Admi.AddPanel.HeightInCms = HeightCms;
            }
            else
            {
                HeightCms = 0.0;
                GuiDataModelPtr->Admi.AddPanel.HeightInCms = HeightCms;
                status    = OK;
            }

            if (OK == status)
            {
                UpdateUserMessage(false, GUI_MSG_FORMAT_INCORRECT, GuiDataModelPtr->Admi.AddPanel.HeightText);
            }
        }
    }

    void Gui::Admi::UpdatePatientHeightOnFeetAndInchesChange()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdatePatientHeightOnFeetAndInchesChange");

        std::wstringstream stringstream(L"");
        int selectedFeetIndex = GuiDataModelPtr->Admi.AddPanel.FeetComboIndex;
        if (NO_ROW_SELECTED != selectedFeetIndex)
        {
            stringstream << GuiDataModelPtr->Admi.AddPanel.FeetComboItems[selectedFeetIndex] << L'\'';
        }

        int selectedInchIndex = GuiDataModelPtr->Admi.AddPanel.InchComboIndex;
        if (NO_ROW_SELECTED != selectedInchIndex)
        {
            if (NO_ROW_SELECTED == selectedFeetIndex)
            {
                stringstream << FEET_AND_INCHES_MIN << L'\'';
            }
            stringstream << GuiDataModelPtr->Admi.AddPanel.InchComboItems[selectedInchIndex] << L'\"';
        }

        HeightCms = Utilities::UnitConversion::ConvertFeetAndInchesToCms(stringstream.str());
        GuiDataModelPtr->Admi.AddPanel.HeightInCms = HeightCms;

        // Remove invalid format message if displayed
        USERGUIDANCE_HIDE(MONITOR_VIEWPORT_1, GUI_MSG_FORMAT_INCORRECT);
    }

    void Gui::Admi::DisplayWarning(const GUI_MESSAGE_ENUM msgID)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::DisplayWarning");

        USERGUIDANCE_SHOW(MONITOR_VIEWPORT_1, msgID);
    }

    void Admi::ShowReminderPanel()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ShowReminderPanel");

        const std::wstring LINE_SEPARATOR = L"\n\n";
        std::wstring reminderMessage;

        // Append FreeImage message to Reminder message, if present.
        if(AdmiStruct.showFreeImagesMsg)
        {
            wchar_t freeImageMessage[GUI_MAX_REMINDER_SUB_STRING_LENGTH + 1];
            std::wstring freeImageMessageFormat = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_REM_FREE_IMAGES);
            if(0 < swprintf(freeImageMessage, static_cast<size_t>(GUI_MAX_REMINDER_SUB_STRING_LENGTH),
                            freeImageMessageFormat.data(), AdmiStruct.nrFreeImgs))
            {
                reminderMessage += freeImageMessage + LINE_SEPARATOR;
            }
        }

        // Append QueuedImage message to Reminder message, if present.
        if(AdmiStruct.showQueuedImagesMsg)
        {
            std::wstring queuedImageMessage = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_REM_QUEUED_IMAGES);
            reminderMessage += queuedImageMessage + LINE_SEPARATOR;
        }
        // Append RsmLogging message to Reminder message, if present.
        if(AdmiStruct.showQueuedRsmLoggingMsg)
        {
            std::wstring queuedRsmLoggingMessage = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_REM_QUEUED_RSM_LOGGING);
            reminderMessage += queuedRsmLoggingMessage;
        }

        // Update Reminder message to message label and show Reminder panel.
        if(AdmiStruct.showFreeImagesMsg || AdmiStruct.showQueuedImagesMsg || AdmiStruct.showQueuedRsmLoggingMsg)
        {
            GuiDataModelPtr->Admi.Reminder.Visible = true;
            AdmiStruct.startupReminderActive        = true;
            GuiDataModelPtr->Admi.Reminder.Message  = reminderMessage;
            GuiDataModelPtr->Admi.Reminder.ModelUpdated();
        }
    }

    void Admi::HideReminderPanel()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HideReminderPanel");

        if(AdmiStruct.startupReminderActive)
        {
            AdmiStruct.startupReminderActive       = false;
            GuiDataModelPtr->Admi.Reminder.Visible = false;
            GuiDataModelPtr->Admi.Reminder.ModelUpdated();
        }
    }

    void Admi::SetReminderMsg(bool showFreeImagesMsg, int nrFreeImgs,
                              bool showQueuedImagesMsg, bool showQueuedRsmLoggingMsg)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetReminderMsg");

        AdmiStruct.showFreeImagesMsg        = showFreeImagesMsg;
        AdmiStruct.nrFreeImgs               = nrFreeImgs;
        AdmiStruct.showQueuedImagesMsg      = showQueuedImagesMsg;
        AdmiStruct.showQueuedRsmLoggingMsg  = showQueuedRsmLoggingMsg;
    }

    void Admi::SetLocale(std::shared_ptr<ILocale> /*localePtr*/)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetLocale");

        GuiDataModelPtr->Admi.LocaleChanged();

        // Update RAC Tool Title.
        RACToolPtr->ChangeLocale();
    }

    int Admi::Suspend(const MONITOR_ENUM /*monNr*/, const GUI_ACTION_ENUM actionCode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Suspend");

        int status = OK;
        switch(actionCode)
        {
            case GUI_RAC_PATIENT:
                AdmiStruct.patientEditSuspended = true;
                break;

            case GUI_RAC_EXAM:
                AdmiStruct.examEditSuspended = true;
                break;

            case GUI_RAC_EXAM_ACQ:
                AdmiStruct.examAcqSuspended = true;
                break;

            case GUI_RAC_EXAM_REVIEW:
                AdmiStruct.examRevSuspended = true;
                break;

            case GUI_RAC_EXAM_REVIEW_HILI:
                AdmiStruct.examRevHiLiSuspended = true;
                break;

            case GUI_RAC_RETRIEVE_WL:
                AdmiStruct.retrWlSuspended = true;
                break;

            case GUI_RAC_MWL_REVIEW:
                AdmiStruct.examInfoSuspended = true;
                break;

            case GUI_RAC_EXAM_EXPORT:
                AdmiStruct.examExpSuspended = true;
                break;

            default:
                // Ignore.
                break;
            }

        UpdateButtons();
        return status;
    }

    int Admi::Resume(const MONITOR_ENUM /*monNr*/, const GUI_ACTION_ENUM actionCode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Resume");

        int status = OK;
        switch(actionCode)
        {
            case GUI_RAC_PATIENT:
                AdmiStruct.patientEditSuspended = false;
                break;

            case GUI_RAC_EXAM:
                AdmiStruct.examEditSuspended = false;
                break;

            case GUI_RAC_EXAM_ACQ:
                AdmiStruct.examAcqSuspended = false;
                break;

            case GUI_RAC_EXAM_REVIEW:
                AdmiStruct.examRevSuspended = false;
                break;

            case GUI_RAC_EXAM_REVIEW_HILI:
                AdmiStruct.examRevHiLiSuspended = false;
                break;

            case GUI_RAC_RETRIEVE_WL:
                AdmiStruct.retrWlSuspended = false;
                break;

            case GUI_RAC_MWL_REVIEW:
                AdmiStruct.examInfoSuspended = false;
                break;

            case GUI_RAC_EXAM_EXPORT:
                AdmiStruct.examExpSuspended = false;
                break;

            case GUI_AC_RESUME_ADMI:
                // This is a special case to Resume/Activate Admi main tab.
                // This code will be used to resume admi after Setup, Dose or Export
                if(TABPAGE_SCHEDULE == GuiGlobal::Data().admiActiveTab)
                {
                    SelectScheduleActivity();
                }
                else
                {
                    SelectReviewingActivity();
                }
                break;

            default:
                // Ignore.
                break;
            }

        UpdateButtons();
        return status;
    }

    int Admi::Update(const MONITOR_ENUM monNr, const GUI_UPDATE_STRUCT& updateInfo)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Update");

        int status = OK;

        if((GUI_UC_PSWD_PROTECT == updateInfo.ucType))
        {
            GuiGlobal::Data().pswdProtect.correctPasswordEntered = updateInfo.ucInfo.pswdProtect.correctPasswordEntered;
            GuiGlobal::Data().pswdProtect.dfiPasswordEnabled = updateInfo.ucInfo.pswdProtect.dfiPasswordEnabled;
            GuiGlobal::Data().pswdProtect.switchToEmergency = updateInfo.ucInfo.pswdProtect.switchToEmergency;
            GuiGlobal::Data().pswdProtect.fseLogin = updateInfo.ucInfo.pswdProtect.fseLogin;

            //Display current logged-In user
            DisplayLoggedInUserName();
            GuiDataModelPtr->Admi.ModelUpdated();

            if((BOOLEAN_TRUE == GuiGlobal::Data().winADMI[monNr]) &&
               (BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) &&
               (BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled))
            {
                // Clear both Review & Schedule list. Reload all patient information from GUI DIR.
                GuiDataModelPtr->Admi.ExamClear();

                // Search for password protected patients that are not visible 
                GUI_ADMI_NODE_STRUCT* patExamNode = nullptr;
                patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_FIRST);
                while((OK == status) && (nullptr != patExamNode))
                {
                    status = SetPatientExam(patExamNode->table, patExamNode->index, patExamNode->applData);
                    if(OK == status)
                    {
                        patExamNode->visible = BOOLEAN_TRUE;
                    }

                    patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_NEXT);
                }

                if(OK != status)
                {
                    LOG_ERROR(status, "Unable to add all password protected patients");
                }

                // Update Schedule list with newly added patients/exams 
                SelectScheduleActivity();

                // Ensure SwitchUser/Change password options are available.
                if(BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.fseLogin)
                {
                    GuiDataModelPtr->Admi.AddSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SWITCH_USER,     GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_SYSMENU_SWITCH_USER), [this] { OnSwitchUserClicked();     }, L"MenuItem_SwitchUser");
                    GuiDataModelPtr->Admi.AddSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_CHANGE_PASSWORD, GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_SYSMENU_CHNG_PSWD), [this] { OnChangePasswordClicked(); }, L"MenuItem_ChangePassword");
                }
            }
            else if(((BOOLEAN_TRUE == GuiGlobal::Data().winADMI[monNr]) &&
                    (BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.correctPasswordEntered) &&
                    (BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled))||
                    ((BOOLEAN_TRUE == GuiGlobal::Data().winADMI[monNr]) &&
                    (BOOLEAN_FALSE == GuiGlobal::Data().pswdProtect.dfiPasswordEnabled)))
            {
                if(BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.switchToEmergency)
                {

                    /* Hide the panels if it is shown */
                    HideAdmiSubPanels();
                    GuiDataModelPtr->Admi.ModelUpdated();

                    /* Clear both Review & Schedule list */
                    GuiDataModelPtr->Admi.ExamClear();

                    // Search for auto-generated No Name patient from the GUI DIR
                    GUI_ADMI_NODE_STRUCT* patExamNode = nullptr;
                    patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_FIRST);
                    while((OK == status) && (NULL != patExamNode))
                    {
                        if((BOOLEAN_TRUE == patExamNode->applData.noNamePatient) && (EST_CURRENT_ACQ == patExamNode->applData.status))
                        {
                            status = SetPatientExam(patExamNode->table, patExamNode->index, patExamNode->applData);
                            if(OK == status)
                            {
                                patExamNode->visible = BOOLEAN_TRUE;
                            }
                        }
                        else
                        {
                            patExamNode->visible = BOOLEAN_FALSE;
                        }

                        patExamNode = GUI_DIR_GetPatientExamNode(GUI_DIR_NEXT);
                    }
                    // Update Schedule list
                    SelectScheduleActivity();
                }

                //In emergency mode or Password option is disabled, Remove ChangePassword and SwitchUser option
                GuiDataModelPtr->Admi.RemoveSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_SWITCH_USER);
                GuiDataModelPtr->Admi.RemoveSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_CHANGE_PASSWORD);

            }
            else
            {
                //Nothing to do.
            }
        }
        else if(GUI_UC_UPDATE_PSC == updateInfo.ucType)
        {
            bool enable = true;
            if(updateInfo.ucInfo.fldSrvc.enable == BOOLEAN_FALSE)
            {
                enable = false;
            }

            GuiDataModelPtr->Admi.EnableSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_START_FIELD_SERVICE, enable);

        }
        else if(GUI_UC_DICOM_TARGET == updateInfo.ucType)
        {
            UpdateButtons();
        }
        else if (GUI_UC_SHUTDOWN == updateInfo.ucType)
        {
            if (CO_GetActiveApplication() == REF_MON_APPS::REFMONAPP_PSC)
            {
                OnShutdown();
            }
        }
        else if(GUI_UC_SERVICE == updateInfo.ucType)
        {
            // Set DateFormat to ADD Panel DatePicker.
            GuiDataModelPtr->Admi.AddPanel.PatientDOBSetDateFormat(GuiGlobal::Data().service[MONITOR_VIEWPORT_1].dateFormat);
            GuiDataModelPtr->Admi.AccNumVisible = GuiGlobal::Data().service[MONITOR_VIEWPORT_1].accNumVisible;
        }
        else if(GUI_UC_CONFIGURATION == updateInfo.ucType)
        {
            // If wireless is not available in license, remove it.
            if(BOOLEAN_FALSE == GuiGlobal::Data().config.wireless)
            {
                LOG_Message(LOG_MI_GUI, "Admi::Update : Update type [%d], wireless license is not present", updateInfo.ucType);

                GuiDataModelPtr->Admi.RemoveSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_WIRELESS_NETWORK);
            }
            else
            {
                LOG_Message(LOG_MI_GUI, "Admi::Update : Update type [%d], wireless license is present", updateInfo.ucType);
            }
        }
        else if (GUI_UC_WIFI_INITIALIZED == updateInfo.ucType)
        {
            // Here wireless license check is not required because during wireless initialization 
            // wireless license is already checked before sending to gui
            LOG_Message(LOG_MI_GUI, "Admi::Update : Update type [%d], wireless initialisation is called", updateInfo.ucType);

            GuiDataModelPtr->Admi.EnableSystemMenuItem(MVSUI::AdmiSystemMenu::SYS_MENU_WIRELESS_NETWORK, true);


        }
        else if (GUI_UC_DISKCOPY == updateInfo.ucType)
        {
            ExportRibbonVisibility = (static_cast<BOOLEAN>(TRUE) == updateInfo.ucInfo.diskcopy.allowDiskCopy);
            ExportAllowed          = (static_cast<BOOLEAN>(TRUE) == updateInfo.ucInfo.diskcopy.allowDiskCopy);
            GuiGlobal::Data().config.allowDiskCopy = updateInfo.ucInfo.diskcopy.allowDiskCopy;

            ExportRibbonUtility::UpdateRibbonPanelModel(&GuiDataModelPtr->General.ExportRibbon, ExportAllowed);
            GuiDataModelPtr->General.ExportRibbon.ModelUpdatedAdmi();
        }
        else
        {
            LOG_Warning(LOG_MI_GUI, "Admi::Update : Unexpected update type [%d] received", updateInfo.ucType);
        }

        return status;
    }

    void Admi::Notify(const GUI_NOTIFICATION_TYPE type, void* dataPtr)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::Notify");

        if(JOBVIEWER_STATUS_CHANGE == type)
        {
            GUI_JOBVIEWER_STATUS_ENUM jobViewerStatus = *(reinterpret_cast<GUI_JOBVIEWER_STATUS_ENUM*>(dataPtr));

           GuiDataModelPtr->General.ExportRibbon.JobViewerStatus = jobViewerStatus;
           GuiDataModelPtr->General.ExportRibbon.JobViewerStatusUpdated();
        }
    }

    void Admi::SetButtonCheck(const std::wstring& controlID, bool checkState)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SetButtonCheck");

        if (0 == controlID.compare(MVSUI::ADMI_BTN_GETWL))
        {
            GuiDataModelPtr->Admi.Schedule.GetWorklist.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_EXAMINFOSCHEDULE))
        {
            GuiDataModelPtr->Admi.Schedule.ExamInfo.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_EXAMINFOREVIEW))
        {
            GuiDataModelPtr->Admi.Review.ExamInfo.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_ADD))
        {
            GuiDataModelPtr->Admi.Schedule.Add.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_MODIFYSCHEDULE))
        {
            GuiDataModelPtr->Admi.Schedule.Modify.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_DELETESCHEDULE))
        {
            GuiDataModelPtr->Admi.Schedule.Delete.Checked = checkState;
        }
        else if (0 == controlID.compare(MVSUI::ADMI_BTN_STARTEXAM))
        {
            GuiDataModelPtr->Admi.Schedule.StartExam.Checked = checkState;
        }
        else if(0 == controlID.compare(MVSUI::ADMI_BTN_MODIFYREVIEW))
        {
            GuiDataModelPtr->Admi.Review.Modify.Checked = checkState;
        }
        else if(0 == controlID.compare(MVSUI::ADMI_BTN_DELETEREVIEW))
        {
            GuiDataModelPtr->Admi.Review.Delete.Checked = checkState;
        }
        else if(0 == controlID.compare(MVSUI::ADMI_BTN_SHOWEXAM))
        {
            GuiDataModelPtr->Admi.Review.ShowExam.Checked = checkState;
        }
        else if(0 == controlID.compare(MVSUI::ADMI_BTN_DOSEREPORT))
        {
            GuiDataModelPtr->Admi.Review.DoseReport.Checked = checkState;
        }
        else
        {
            // Do nothing. This [if...elseif...else] ladder can be extended on demand.
        }

        GuiDataModelPtr->Admi.Schedule.ModelUpdated();
        GuiDataModelPtr->Admi.Review.ModelUpdated();
    }

    void Admi::OnExamSelectionChanged()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnExamSelectionChanged");

        int status = OK;
        KEY_TYPE prevPatientId = AdmiStruct.selectedRow.patientId;
        int patId = GetSelectedExam();
        status = SetSelectedPatientExam(patId);

        if(OK == status)
        {
            KEY_TYPE curPatientId = AdmiStruct.selectedRow.patientId;
            if((ADMI_TABLE_REVIEW == ActiveTable) && (curPatientId != prevPatientId))
            {
                status = HndlEvtRevHiLi();
            }
            else if(ADMI_TABLE_SCHEDULE == ActiveTable)
            {
                // Log the user action.
                GUI_ACTION_STRUCT guiAction;
                guiAction.acType = GUI_AC_SCHEDULED_EXAM_SELECT;
                GUI_UTIL_LOG_Action(&guiAction);
            }
            else
            {
                // Do nothing.
            }
        }
    }

    int Admi::GetSelectedExam()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetSelectedExam");

        int patId = NO_ROW_SELECTED;

        if (1 < GuiDataModelPtr->Admi.SelectedPatientIDs.size())
        {
            patId = MULTIPLE_ROW_SELECTED;
        }
        else if (0 == GuiDataModelPtr->Admi.SelectedPatientIDs.size())
        {
            patId = NO_ROW_SELECTED;
        }
        else //Single Selection
        {
            patId = GuiDataModelPtr->Admi.SelectedPatientIDs.at(0);
        }

        return patId;
    }

    void Admi::OnSwitchPatientList(const MVSUI::AdmiPageType activeTab)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnSwitchPatientList");

        switch (activeTab)
        {
            case MVSUI::AdmiPageType::PAGE_SCHEDULE:
                SelectScheduleActivity();
                break;

            case MVSUI::AdmiPageType::PAGE_REVIEW:
                SelectReviewingActivity();
                break;

            default:
                // Ignore.
                break;
        }
    }

    int Admi::OnKeyPress(const int keyCode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnKeyPress");

        int status                  = EVENT_IGNORED;

        if(KC_ACCEPT == keyCode)
        {
            if(IsSubPanelVisible())
            {
                if (GuiDataModelPtr->Admi.Reminder.Visible)// This needs to be removed once Admi is moved to fleui design.
                {
                    HideReminderPanel();
                    status = EVENT_HANDLED;
                }
                else if (GuiDataModelPtr->Admi.AddPanel.Visible)
                {
                    PatexEditOkClicked();
                    GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
                    status = EVENT_HANDLED;
                }
                else if (GuiDataModelPtr->Admi.Delete.SingleDeleteDialogIsVisible)
                {
                    DeleteQuestionNoClicked();
                    status = EVENT_HANDLED;
                }
                else if (GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible)
                {
                    MultipleDeleteCancelClicked();
                    status = EVENT_HANDLED;
                }
                else
                {
                    status = EVENT_HANDLED;
                }
            }
        }
        else if((VK_DELETE == keyCode) || (KC_CLOSE == keyCode))
        {
            // delete action should be allowed only if there are no sub panels opened and menu is not expanded 
            if(!IsSubPanelVisible() && !IsMenuExpanded())
            {
                if(TABPAGE_SCHEDULE == GuiGlobal::Data().admiActiveTab)
                {
                    if (GuiDataModelPtr->Admi.Schedule.Delete.Visible && GuiDataModelPtr->Admi.Schedule.Delete.Enabled)
                    {
                        DeleteClicked();
                        status = EVENT_HANDLED;
                    }
                }
                else
                {
                    if (GuiDataModelPtr->Admi.Review.Delete.Visible && GuiDataModelPtr->Admi.Review.Delete.Enabled)
                    {
                        DeleteClicked();
                        status = EVENT_HANDLED;
                    }
                }
            }
        }
        else
        {
            // If...ElseIf...Else can be extended on demand.
        }
        return status;
    }

    void Admi::OnChangePasswordClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnChangePasswordClicked");

        int status;
        GUI_ACTION_STRUCT changePassword;

        changePassword.acType = GUI_RAC_DISP_PSWD_CHANGE;
        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &changePassword);
        if(OK != status)
        {
            LOG_ERROR(status, "Failed to send reply to Function Coordinator for Password change");
        }
        GUI_UTIL_LOG_Action(&changePassword);
    }

    void Admi::OnRemoteAssistanceClicked() const
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnRemoteAssistanceClicked");

        // Spawn a new thread and detach it from caller thread
        std::thread racLaunchThread([this]
        {
            RACToolPtr->Launch();
        });
        racLaunchThread.detach();
    }

    void Admi::OnFieldServiceClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnFieldServiceClicked");
        
        GUI_ACTION_STRUCT startFS;
        int status;

        startFS.acType = GUI_RAC_START_FS;
        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &startFS);
        if(OK != status)
        {
            LOG_ERROR(status, "Failed to send reply to Function Coordinator to Start Feild Service");
        }
        GUI_UTIL_LOG_Action(&startFS);
    }

    void Admi::OnSwitchUserClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnSwitchUserClicked");

        GUI_ACTION_STRUCT switchUser;
        int status;

        switchUser.acType = GUI_RAC_DISP_SWITCH_USER;
        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &switchUser);
        if(OK != status)
        {
            LOG_ERROR(status, "Failed to send reply to Function Coordinator to Switch User");
        }
        GUI_UTIL_LOG_Action(&switchUser);
    }

    void Admi::OnIFUClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnIFUClicked");

        int status = OK;

        // Show help
        GUI_ACTION_STRUCT guiAction;
        guiAction.acType = GUI_RAC_HELP;

        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &guiAction);
        if(OK == status)
        {
            GUI_UTIL_LOG_Action(&guiAction);
        }
    }

    void Admi::OnWirelessNetworkClicked()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::OnWirelessNetworkClicked");

        GUI_ACTION_STRUCT wifiUtility;
        int status;

        wifiUtility.acType = GUI_RAC_DISP_WIFI_NETWORKS;
        status = GUI_ReplyAction(MONITOR_VIEWPORT_1, &wifiUtility);
        if(OK != status)
        {
            LOG_ERROR(status, "Failed to send reply to Function Coordinator to Handle Wifi Adapter");
        }
        GUI_UTIL_LOG_Action(&wifiUtility);
    }

    std::wstring Admi::FormatMessageString(const std::wstring formatString, ...) //TICS !PCA#003: Function accepts variable number of arguments, Unavoidable.
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::FormatMessageString");

        const int MAX_FORMATTED_MSG_LENGTH = 200;
        wchar_t resultString[MAX_FORMATTED_MSG_LENGTH] = {0};

        va_list args = nullptr;
        va_start(args, formatString);
        vswprintf_s(resultString, static_cast<size_t>(MAX_FORMATTED_MSG_LENGTH), formatString.data(), args);
        va_end(args);

        return resultString;
    }

    bool Admi::IsSubPanelVisible()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::IsSubPanelVisible");

        return (GuiDataModelPtr->Admi.AddPanel.Visible                      ||
               (GuiDataModelPtr->Admi.Reminder.Visible)                     ||
               (GuiDataModelPtr->Admi.Delete.SingleDeleteDialogIsVisible)   ||
               (GuiDataModelPtr->Admi.Delete.MultipleDeleteDialogIsVisible) ||
               (RACToolPtr->IsRunning())                                    ||
               (AboutPtr->IsVisible()));
    }

    bool Gui::Admi::IsMenuExpanded() const
    {
        return GuiDataModelPtr->Admi.IsMenuExpanded();
    }

    /*======================================================================*/
    /*  UpdateWeightUnit()                                                  */
    /*======================================================================*/
    void Admi::UpdateWeightUnit(const UNIT_OF_WEIGHT_ENUM unitOfWeight)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdateWeightUnit");

        double weight = _wtof((GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text).c_str());
        // Update Unit of weight according to configuration TRUE (pound), FALSE(kg).
        if (UNIT_OF_WEIGHT_ENUM::KG_UNIT == unitOfWeight)
        {
            if (0 != GuiDataModelPtr->Admi.AddPanel.PoundsText.compare(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_KGS)))
            {
                GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_KGS);
                weight = weight * LBS_2_KG;
            }
        }
        else if (UNIT_OF_WEIGHT_ENUM::LBS_UNIT == unitOfWeight)
        {
            if (0 != GuiDataModelPtr->Admi.AddPanel.PoundsText.compare(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_POUNDS)))
            {
                GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_POUNDS);                weight = weight * KG_2_LBS;
            }
        }
        else
        {
            LOG_WARNING("Invalid unit of weight %d received.", unitOfWeight);
        }

        if (!(GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text.empty()))
        {
            std::wstringstream stringFormater;
            stringFormater << std::fixed << std::setprecision(1) << weight;
            GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text = stringFormater.str();
        }
    }

    /*======================================================================*/
    /*  UpdateHeightUnit()                                                  */
    /*======================================================================*/
    void Admi::UpdateHeightUnit(const UNIT_OF_HEIGHT_ENUM unitOfHeight)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::UpdateHeightUnit");

        GuiDataModelPtr->Admi.AddPanel.unitOfHeight = unitOfHeight;

        std::wstring heightString = L"";
        if ((UNIT_OF_HEIGHT_ENUM::CMS_UNIT == unitOfHeight) && (GuiDataModelPtr->Admi.AddPanel.HeightInCms > 0.0))
        {
            std::wstringstream stringFormater;
            stringFormater << std::fixed << std::setprecision(1) << HeightCms;
            heightString = stringFormater.str();
        }
        GuiDataModelPtr->Admi.AddPanel.PatientHeight.Text = heightString;
    }

    void Admi::HideAdmiSubPanels()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HideAdmiSubPanels");

        if(AdmiStruct.patexEditActive)
        {
            PatexEditRem();
            GuiDataModelPtr->Admi.AddPanel.ModelUpdated();
        }

        if(AdmiStruct.patDelQuesActive)
        {
            PatDeleteQuestionRem();
        }

        if(AdmiStruct.startupReminderActive)
        {
            HideReminderPanel();
        }

        if(RACToolPtr->IsRunning())
        {
            RACToolPtr->Close();
        }

        if (AdmiStruct.shutdownConfirmationActive)
        {
            OnShutdownCancel();
        }

        // Close about panel
        if((nullptr != AboutPtr) && AboutPtr->IsVisible())
        {
            AboutPtr->Hide();
        }

        //Hide Profile Menu option.
        if(BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.switchToEmergency)
        {
            GuiDataModelPtr->Admi.ProfileVisibility = false;
        }
        else
        {
            GuiDataModelPtr->Admi.ProfileVisibility = true;
        }

        // Hide User information dialog if visible
        if (IsUserInformationDialogVisible())
        {
            HideUserInformationDialog();
        }
    }

    /*======================================================================*/
    /*  PatexEditHandleProfile()                                            */
    /*======================================================================*/
    void Admi::PatexEditHandleProfile()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditHandleProfile");
        if (static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProfileItems.size()) > 0)
        {
            int selectedProfileIndex = GuiDataModelPtr->Admi.AddPanel.ProfileIndex;

            LOG_DEBUG("Selected profileindex = [%d]", selectedProfileIndex);
            if (0 < selectedProfileIndex)
            {
                // Populate all profile data to add patient panel
                if (nullptr == GetSelectedUserProfile(GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex]))
                {
                    GuiDataModelPtr->Admi.AddPanel.PhysicianIndex = 0;
                    LOG_DEBUG("Failed to get selected profile");

                    //Display popup to show change in parameter with respect to Default profile
                    ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                }
            }
            else
            {
                // Default profile selected. Set profile parameters to default
                bool etFound  = false;
                int examIndex = NO_ROW_SELECTED;
                GUI_ET_NODE_STRUCT* etNode = nullptr;

                // Validate exam type selected
                if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
                {
                    examIndex = GuiGlobal::Data().defaultExamAdult.index;
                }
                else
                {
                    examIndex = GuiGlobal::Data().defaultExamPediatric.index;
                }
                etFound = FindExamNode(etNode, examIndex);

                if (etFound)
                {
                    ResetDetProcList(etNode);

                    if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
                    {
                        GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex =  GuiGlobal::Data().defaultExamAdult.index;
                        GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = GuiGlobal::Data().defaultExamAdult.detProcIdx;
                    }
                    else
                    {
                        GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex =  GuiGlobal::Data().defaultExamPediatric.index;
                        GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = GuiGlobal::Data().defaultExamPediatric.detProcIdx;
                    }
                    GuiDataModelPtr->Admi.AddPanel.PhysicianIndex = 0;
                }

                // Update Unit of weight according to configuration.
                if (BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight)
                {
                    UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::KG_UNIT);
                }
                else
                {
                    UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::LBS_UNIT);
                }

                // Update Unit of height according to configuration.
                UpdateHeightUnit(AdmiStruct.admi.unitOfHeight);

                // Update unit of measurement according to configuration.
                AdmiStruct.selectedRow.unitOfMeasure = GuiGlobal::Data().service[MONITOR_ENUM::MONITOR_VIEWPORT_1].units;
            }
        }
    }

    /*======================================================================*/
    /*  PatexEditHandlePatientType()                                        */
    /*======================================================================*/
    void Admi::PatexEditHandlePatientType(const PATIENT_TYPE_ENUM& patientType)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditHandlePatientType");

        // Get selected exam and detailed procedure
        const int selected_et_index = GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex;
        const int selected_at_index = GuiDataModelPtr->Admi.AddPanel.ProcedureIndex;

        const int profile_index   = GuiDataModelPtr->Admi.AddPanel.ProfileIndex;
        const int physician_index = GuiDataModelPtr->Admi.AddPanel.PhysicianIndex;

        if (patientType != m_OldPatientType)
        {
            //Chek whether the password is entered correctly
            if ((BOOLEAN_TRUE == GuiGlobal::Data().pswdProtect.correctPasswordEntered))
            {
                // Load all available profile list
                LoadProfileList(patientType);
            }
            SetExamAndAnatomyType(patientType, selected_et_index, selected_at_index);
            m_OldPatientType = patientType;
            if (0 != profile_index)
            {
                //Display popup to show change in parameter with respect to Default profile
                ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
            }
            // Keep physician name in Physician combo
            GuiDataModelPtr->Admi.AddPanel.PhysicianIndex = physician_index;
        }
    }


    /*======================================================================*/
    /*  RefillExamTypes()                                                   */
    /*======================================================================*/
    void Admi::RefillExamTypes(const PATIENT_TYPE_ENUM patientType)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::RefillExamTypes");

        GUI_ET_NODE_STRUCT* etNode = nullptr;
        GUI_ET_NODE_STRUCT* defEtNode = nullptr;
        GUI_DET_PROC_NODE_STRUCT* detProcNode = nullptr;
        int defExamIndex = NO_ROW_SELECTED;
        int defDetProcIndex = NO_ROW_SELECTED;
        int examIndex = 0;

        GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.clear();
        GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_FIRST, etNode);

        while (etNode != static_cast<GUI_ET_NODE_STRUCT *>(nullptr))
        {
            GuiDataModelPtr->Admi.AddPanel.ExamTypeItems.emplace_back(etNode->examType.name);
            etNode->index = examIndex;

            if (PATIENT_ADULT == patientType)
            {
                if (etNode->examType.guiExamTypeId == GuiGlobal::Data().defaultExamAdult.index)
                {
                    defEtNode = etNode;
                    defExamIndex = GuiGlobal::Data().defaultExamAdult.index;
                }
            }
            else
            {
                if (etNode->examType.guiExamTypeId == GuiGlobal::Data().defaultExamPediatric.index)
                {
                    defEtNode = etNode;
                    defExamIndex = GuiGlobal::Data().defaultExamPediatric.index;
                }
            }
            GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_NEXT, etNode);
            examIndex++;
        }

        detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_FIRST, defEtNode);

        GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
        while (detProcNode != static_cast<GUI_DET_PROC_NODE_STRUCT *>(nullptr))
        {
            GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(detProcNode->detProc.name);
            if (PATIENT_ADULT == patientType)
            {
                if (detProcNode->detProc.guiDetProcId == GuiGlobal::Data().defaultExamAdult.detProcIdx)
                {
                    defDetProcIndex = GuiGlobal::Data().defaultExamAdult.detProcIdx;
                }
            }
            else
            {
                if (detProcNode->detProc.guiDetProcId == GuiGlobal::Data().defaultExamPediatric.detProcIdx)
                {
                    defDetProcIndex = GuiGlobal::Data().defaultExamPediatric.detProcIdx;
                }
            }
            detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_NEXT, static_cast<GUI_ET_NODE_STRUCT*>(nullptr));
        }

        // Select the current active default examtype
        if (NO_ROW_SELECTED != defExamIndex)
        {
            GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = defExamIndex;
        }
        // Select the current active default anatomy
        if (NO_ROW_SELECTED != defDetProcIndex)
        {
            GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = defDetProcIndex;
        }
    }

    /*======================================================================*/
    /*  GetExaminationType()                                                */
    /*======================================================================*/
    bool Admi::GetExaminationType(const PATIENT_TYPE_ENUM patientType, const int& selectedIndex, GUI_ET_NODE_STRUCT*& etNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetExaminationType");
        bool etFound = false;
        // Retrieve the examination type node based on the patient type selected.
        GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_FIRST, etNode);
        while ((!etFound) && (nullptr != etNode))
        {
            if (etNode->index == selectedIndex)
            {
                etFound = true;
            }
            else
            {
                GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_NEXT, etNode);
            }
        }
        return etFound;
    }

    /*======================================================================*/
    /*  InitializeAnatomyList()                                             */
    /*======================================================================*/
    int Admi::InitializeAnatomyList(const PATIENT_TYPE_ENUM patientType, GUI_ET_NODE_STRUCT*& etNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::InitializeAnatomyList");
        int defaultExamIndex = { 0 };
        int detprocIndex = { 0 };

        GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
        int defaultGlobalIndex = { 0 };

        defaultGlobalIndex = (PATIENT_ADULT == patientType) ? GuiGlobal::Data().defaultExamAdult.detProcIdx :
                                                              GuiGlobal::Data().defaultExamPediatric.detProcIdx;
        // Fill detailed procedure list from GUI directory
        GUI_DET_PROC_NODE_STRUCT* dpNode = GUI_DIR_GetDetProcNode(GUI_DIR_FIRST, etNode);

        while (nullptr != dpNode)
        {
            GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(dpNode->detProc.name);
            dpNode->index = detprocIndex;

            LOG_DEBUG("+ index %d = ID %d [%s]", dpNode->index, dpNode->detProc.guiDetProcId, dpNode->detProc.name);
            if (dpNode->detProc.guiDetProcId == defaultGlobalIndex)
            {
                defaultExamIndex = detprocIndex;
            }
            detprocIndex++;
            dpNode = GUI_DIR_GetDetProcNode(GUI_DIR_NEXT, etNode);
        }

        return defaultExamIndex;
    }

    /*======================================================================*/
    /*  IsExaminationPresentOnOtherType()                                   */
    /*======================================================================*/
    bool Admi::IsExaminationPresentOnOtherPatientType(const PATIENT_TYPE_ENUM patientType, GUI_ET_NODE_STRUCT*& examTypeNode, int& examIndex)
    {
        GUI_ET_NODE_STRUCT* etNode = nullptr;
        bool etFound = false;

        // Retrieve the examination type node based on the patient type selected.
        GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_FIRST, etNode);
        while ((!etFound) && (nullptr != etNode))
        {
            if (wcscmp(etNode->examType.name, examTypeNode->examType.name) == 0)
            {
                etFound = true;
                examIndex = etNode->index;
                break;
            }
            else
            {
                GUI_DIR_GetPatientExamTypeNode(patientType, GUI_DIR_NEXT, etNode);
            }
        }
        return etFound;
    }

    /*======================================================================*/
    /*  IsAnatomyPresentOnOtherType()                                       */
    /*======================================================================*/
    bool Admi::IsAnatomyPresentOnOtherPatientType(const std::wstring& anatomyName, int& anatomyIndex)
    {
        bool found = false;
        int index = { 0 };
        for (auto& anatomyText : GuiDataModelPtr->Admi.AddPanel.ProcedureItems)
        {
            if (wcscmp(anatomyText.c_str(), anatomyName.c_str()) == 0)
            {
                found = true;
                anatomyIndex = index;
                break;
            }
            index++;
        }
        return found;
    }

    /*======================================================================*/
    /*  SetExamAndAnatomyType()                                             */
    /*======================================================================*/
    void Admi::SetExamAndAnatomyType(const PATIENT_TYPE_ENUM patientType, int selectedExamIndex, int selectedAnatamyIndex)
    {
        if ((NO_ROW_SELECTED != selectedExamIndex && NO_ROW_SELECTED != selectedAnatamyIndex))
        {
            GUI_ET_NODE_STRUCT* etNode = nullptr;
            PATIENT_TYPE_ENUM prevPatientType = (patientType == PATIENT_ADULT) ? PATIENT_PEDIATRIC : PATIENT_ADULT;

            // Get selected exam name
            if (GetExaminationType(prevPatientType, selectedExamIndex, etNode))
            {
                int examIndex    = 0;
                InitializeAnatomyList(prevPatientType, etNode);

                // Get selected detailed procedure
                const std::wstring anatomyItemText = GuiDataModelPtr->Admi.AddPanel.ProcedureItems[selectedAnatamyIndex];

                // Set default exam type
                RefillExamTypes(patientType);

                // Check selected exam present on other patient type
                if (IsExaminationPresentOnOtherPatientType(patientType, etNode, examIndex))
                {
                    GUI_ET_NODE_STRUCT* currentExamNode          = nullptr;
                    GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = examIndex;

                    if (GetExaminationType(patientType, examIndex, currentExamNode))
                    {
                        int anatomyIndex = 0;
                        InitializeAnatomyList(patientType, currentExamNode);

                        // Check selected anatomy present on other patient type
                        if (IsAnatomyPresentOnOtherPatientType(anatomyItemText, anatomyIndex))
                        {
                            GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = anatomyIndex;
                        }
                        else
                        {
                            int defExamTypeIndex = (PATIENT_ADULT == patientType) ? GuiGlobal::Data().defaultExamAdult.index:
                                                                                GuiGlobal::Data().defaultExamPediatric.index;
                            int defAnatomyIndex = (PATIENT_ADULT == patientType) ? GuiGlobal::Data().defaultExamAdult.detProcIdx :
                                                                                   GuiGlobal::Data().defaultExamPediatric.detProcIdx;
                            if (examIndex == defExamTypeIndex)
                            {
                                GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = defAnatomyIndex;
                            }
                            else
                            {
                                GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = 0;
                            }
                            ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                        }
                    }
                }
                else
                {
                    ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                }
            }
        }
    }


    /*======================================================================*/
    /*  ShowUserInformationDialog()                                         */
    /*======================================================================*/
    void Admi::ShowUserInformationDialog(const GUI_INFO_MESSAGE_ENUM& messageType)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ShowUserInformationDialog");
        GUI_SIGNAL_STRUCT signalData = {};
        signalData.scInfo.infoMessage.type = messageType;

        GuiController::GetInstance().GetComponentByID(GUI_SC_WINDOW_USER_INFORMATION)->Show(MONITOR_VIEWPORT_1, signalData);
    }

    /*======================================================================*/
    /*  HideUserInformationDialog()                                         */
    /*======================================================================*/
    void Admi::HideUserInformationDialog()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::HideUserInformationDialog");
        GUI_SIGNAL_STRUCT signalData = {};
        bool doInvalidate = false;

        GuiController::GetInstance().GetComponentByID(GUI_SC_WINDOW_USER_INFORMATION)->Hide(MONITOR_VIEWPORT_1, signalData, doInvalidate);
    }

    /*======================================================================*/
    /*  IsUserInformationDialogVisible()                                    */
    /*======================================================================*/
    bool Admi::IsUserInformationDialogVisible()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::isUserInformationDialogVisible");

        UserInformation* UserInformationptr = dynamic_cast<UserInformation*>(GuiController::GetInstance().GetComponentByID(GUI_SC_WINDOW_USER_INFORMATION));
        return UserInformationptr->isDialogVisible();
    }



    /*======================================================================*/
    /*  SelectProfileInPatExEditList()                                      */
    /*======================================================================*/
    void Admi::SelectProfileInPatExEditList()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::SelectProfileInPatExEditList");

        bool profileFound                = false;
        std::wstring patientProfileName  = L"";

        if (AdmiStruct.selectedRow.profileID != DEFAULT_PROFILE_ID)
        {
            // Get number of items
            for (int profileIndex = 0; profileIndex < static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProfileItems.size()); ++profileIndex)
            {
                // Set the corresponding profile to profile combo. If not found sets default profile
                if (AdmiStruct.selectedRow.profileID == GetProfileIDFromGuiDirectory(GuiDataModelPtr->Admi.AddPanel.ProfileItems[profileIndex]))
                {
                    patientProfileName = GuiDataModelPtr->Admi.AddPanel.ProfileItems[profileIndex];
                    GuiDataModelPtr->Admi.AddPanel.ProfileIndex = profileIndex;
                    profileFound = true;
                    break;
                }
            }

            switch (AdmiStruct.selectedRow.status)
            {
                case EXAM_STATUS_ENUM::EST_SCHEDULED:
                case EXAM_STATUS_ENUM::EST_CURRENT_ACQ:
                {
                    if (profileFound)
                    {
                        GUI_PROFILE_NODE_STRUCT* profileNode;
                        GetProfileData(patientProfileName, profileNode);
                        if (nullptr != profileNode)
                        {
                            // Set physician from profile data base
                            SelectPhysicianInPatExEditList(profileNode->userProfile.profileData.physician.name);
                            OsaWcsNCpy(AdmiStruct.selectedRow.physician, static_cast<size_t>(PHYSICIAN_NAME_LENGTH + 1),
                                       profileNode->userProfile.profileData.physician.name, static_cast<size_t>(PHYSICIAN_NAME_LENGTH+1));

                            // Set exam type and anatomy type from profile data base
                            GUI_ET_NODE_STRUCT* etNode = nullptr;
                            int examTypeIndex = GetExamIndexFromProcedureId(AdmiStruct.selectedRow.patientType, profileNode->userProfile.profileData.procedureId);
                            bool etFound = FindExamNode(etNode, examTypeIndex);
                            int detProcedureIndex = NO_ROW_SELECTED;

                            if (NO_ROW_SELECTED != profileNode->userProfile.profileData.detProcedureId)
                            {
                                detProcedureIndex = GetAnatomyIndexFromDetailedProcedureID(AdmiStruct.selectedRow.patientType,
                                                                                           profileNode->userProfile.profileData.procedureId,
                                                                                           profileNode->userProfile.profileData.detProcedureId);
                            }

                            if (etFound && (NO_ROW_SELECTED == profileNode->userProfile.profileData.detProcedureId || detProcedureIndex != NO_ROW_SELECTED))
                            {
                                const int detProcIdAll = INT_MAX;
                                GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = examTypeIndex;
                                ResetDetProcList(etNode);

                                // Check whether anatomy is set to 'All'
                                if (detProcIdAll != profileNode->userProfile.profileData.detProcedureId)
                                {
                                    GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = detProcedureIndex;
                                }
                            }
                            else
                            {
                                int defaultGlobalExamIndex    = 0;
                                int defaultGlobalAnatomyIndex = 0;
                                defaultGlobalExamIndex = (PATIENT_ADULT == profileNode->userProfile.profileData.patientType) ? GuiGlobal::Data().defaultExamAdult.index :
                                                         GuiGlobal::Data().defaultExamPediatric.index;

                                defaultGlobalAnatomyIndex = (PATIENT_ADULT == profileNode->userProfile.profileData.patientType) ? GuiGlobal::Data().defaultExamAdult.index :
                                                            GuiGlobal::Data().defaultExamPediatric.index;

                                // Fill Def Exam Type list
                                GUI_DIR_GetPatientExamTypeNode(profileNode->userProfile.profileData.patientType, GUI_DIR_FIRST, etNode);
                                while (nullptr != etNode)
                                {
                                    if (defaultGlobalExamIndex == etNode->examType.guiExamTypeId)
                                    {
                                        break;
                                    }

                                    GUI_DIR_GetPatientExamTypeNode(profileNode->userProfile.profileData.patientType, GUI_DIR_NEXT, etNode);
                                }
                                GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = defaultGlobalExamIndex;
                                ResetDetProcList(etNode);
                                GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = defaultGlobalAnatomyIndex;

                                LOG_WARNING("Exam type is set to default as exam type is not available in profile");
                            }

                            // Set patient weight in patient dialog as per associated profile database
                            InitializePatientDialogWithWeightUnit(profileNode->userProfile.profileData.unitofWeight);

                            // Set patient height in patient dialog as per associated profile database
                            InitializePatientDialogWithHeightUnit(profileNode->userProfile.profileData.unitofHeight);

                            // Set patient unit of measure as per associated profile database
                            AdmiStruct.selectedRow.unitOfMeasure = profileNode->userProfile.profileData.unitofMeasurement;
                        }
                    }
                    else
                    {
                        GuiDataModelPtr->Admi.AddPanel.PhysicianIndex = NO_ROW_SELECTED;
                        if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
                        {
                            GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex  = GuiGlobal::Data().defaultExamAdult.index;
                            GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = GuiGlobal::Data().defaultExamAdult.detProcIdx;
                        }
                        else
                        {
                            GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex  = GuiGlobal::Data().defaultExamPediatric.index;
                            GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = GuiGlobal::Data().defaultExamPediatric.detProcIdx;
                        }
                    }
                }break;
                case EXAM_STATUS_ENUM::EST_CURRENT_REV:
                case EXAM_STATUS_ENUM::EST_CLOSED:
                {
                    if ((profileFound) && (patientProfileName.compare(AdmiStruct.selectedRow.profileName) != 0))
                    {
                        profileFound = false;
                    }

                    if (!profileFound)
                    {
                        std::wstring profileName(AdmiStruct.selectedRow.profileName);
                        GuiDataModelPtr->Admi.AddPanel.ProfileItems.emplace_back(profileName);
                        GuiDataModelPtr->Admi.AddPanel.ProfileIndex = static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProfileItems.size() - 1);
                    }
                }break;
                default:
                    LOG_DEBUG("Invalid patient exam status");
                    break;
            }
        }
        else if(AdmiStruct.selectedRow.profileID == DEFAULT_PROFILE_ID)
        {
            // Update unit of weight in patient dialog as per configuration
            const UNIT_OF_WEIGHT_ENUM unitOfWeight = (BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight) ? UNIT_OF_WEIGHT_ENUM::KG_UNIT : UNIT_OF_WEIGHT_ENUM::LBS_UNIT;
            UpdateWeightUnit(unitOfWeight);

            // Update unit of height in patient dialog as per configuration
            UpdateHeightUnit(AdmiStruct.admi.unitOfHeight);

            // Set patient unit of measure as per configuration
            AdmiStruct.selectedRow.unitOfMeasure = GuiGlobal::Data().service[MONITOR_ENUM::MONITOR_VIEWPORT_1].units;
        }
        else
        {
            // Do nothing
        }
    }

    /*======================================================================*/
    /*  LoadProfileList()                                                   */
    /*======================================================================*/
    void Admi::LoadProfileList(const PATIENT_TYPE_ENUM& patientType)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::LoadProfileList");

        GuiDataModelPtr->Admi.AddPanel.ProfileItems.clear();

        GuiDataModelPtr->Admi.AddPanel.ProfileItems.emplace_back(GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_PATEX_DEFAULT_PROFILE));
        GUI_PROFILE_NODE_STRUCT* profileNode = GUI_DIR_GetProfileNode(GUI_DIR_FIRST);

        // Fill Profile list
        while (profileNode != static_cast<GUI_PROFILE_NODE_STRUCT *>(nullptr))
        {
            if (patientType == profileNode->userProfile.profileData.patientType)
            {
                GuiDataModelPtr->Admi.AddPanel.ProfileItems.emplace_back(profileNode->userProfile.profileData.profileName);
            }
            else
            {
                // Do Nothing
            }
            profileNode = GUI_DIR_GetProfileNode(GUI_DIR_NEXT);
        }

        GuiDataModelPtr->Admi.AddPanel.ProfileIndex = 0;
    }

    /*======================================================================*/
    /*  GetProfileIDFromGuiDirectory()                                      */
    /*======================================================================*/
    PROFILE_ID_TYPE Admi::GetProfileIDFromGuiDirectory(std::wstring& profileName)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetProfileIDFromGuiDirectory");

        GUI_PROFILE_NODE_STRUCT *profileNode = nullptr;
        profileNode = GUI_DIR_GetProfileNode(GUI_DIR_FIRST);
        PROFILE_ID_TYPE profileID = DEFAULT_PROFILE_ID;
        while (profileNode != static_cast<GUI_PROFILE_NODE_STRUCT*>(nullptr))
        {
            if (0 == wcscmp(profileNode->userProfile.profileData.profileName, profileName.c_str()))
            {
                profileID = profileNode->userProfile.profileId;
                break;
            }
            else
            {
                profileNode = GUI_DIR_GetProfileNode(GUI_DIR_NEXT);
            }
        }

        return profileID;
    }

    /*======================================================================*/
    /*  GetSelectedUserProfile()                                            */
    /*======================================================================*/
    GUI_PROFILE_NODE_STRUCT* Admi::GetSelectedUserProfile(std::wstring& profileName)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetSelectedUserProfile");

        // Search current selected profile in list
        bool profileFound = false;
        GUI_PROFILE_NODE_STRUCT *profileNode = nullptr;
        profileNode = GUI_DIR_GetProfileNode(GUI_DIR_FIRST);
        const int detProcIdAll = INT_MAX;

        while (!profileFound && (profileNode != static_cast<GUI_PROFILE_NODE_STRUCT*>(nullptr)))
        {
            if (0 == wcscmp(profileNode->userProfile.profileData.profileName, profileName.c_str()))
            {
                LOG_Debug(LOG_MI_GUI, "select current profile in list: index=%d", profileNode->index);

                const int examIndex = GetExamIndexFromProcedureId(profileNode->userProfile.profileData.patientType,
                                                                  profileNode->userProfile.profileData.procedureId);

                GuiDataModelPtr->Admi.AddPanel.ExamTypeIndex = examIndex;

                bool etFound = false;
                GUI_ET_NODE_STRUCT *etNode = nullptr;
                GUI_DIR_GetPatientExamTypeNode(profileNode->userProfile.profileData.patientType, GUI_DIR_FIRST, etNode);
                while ((!etFound) && (nullptr != etNode))
                {
                    if (etNode->examType.procedureId == profileNode->userProfile.profileData.procedureId)
                    {
                       etFound = true;
                    }
                    else
                    {
                        GUI_DIR_GetPatientExamTypeNode(profileNode->userProfile.profileData.patientType, GUI_DIR_NEXT, etNode);
                    }
                }

                if (etFound)
                {
                    GUI_DET_PROC_NODE_STRUCT* detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_FIRST, etNode);
                    GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
                    while (nullptr != detProcNode)
                    {
                        GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(detProcNode->detProc.name);
                        detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_NEXT, nullptr);
                    }
                }

                if (static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProcedureItems.size()) > 0)
                {
                    if (detProcIdAll == profileNode->userProfile.profileData.detProcedureId)
                    {
                        // If selected profile anatomy is set to All, then anatomy in add exam should be 0th item.
						GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = 0;

                    }
                    else
                    {
                        int detProcIndex = NO_ROW_SELECTED;
                        detProcIndex = GetAnatomyIndexFromDetailedProcedureID(profileNode->userProfile.profileData.patientType,
                                                                              profileNode->userProfile.profileData.procedureId,
                                                                              profileNode->userProfile.profileData.detProcedureId);
                        GuiDataModelPtr->Admi.AddPanel.ProcedureIndex = detProcIndex;
                    }
                }

                if (PATIENT_ADULT == profileNode->userProfile.profileData.patientType)
                {
                    GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked     = true;
                    GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked = false;
                }
                else
                {
                    GuiDataModelPtr->Admi.AddPanel.PatientTypePediatric.Checked = true;
                    GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked     = false;
                }

                // Update Unit of weight according to profile unit of weight.
                UpdateWeightUnit(profileNode->userProfile.profileData.unitofWeight);

                // Update Unit of height according to profile unit of height.
                UpdateHeightUnit(profileNode->userProfile.profileData.unitofHeight);

                // Update unit of measurement according to profile unit of measurement.
                AdmiStruct.selectedRow.unitOfMeasure = profileNode->userProfile.profileData.unitofMeasurement;

                // Update unit of height according to profile unit of height.
                AdmiStruct.selectedRow.unitOfHeight = profileNode->userProfile.profileData.unitofHeight;

                // Update unit of weight according to profile unit of weight.
                AdmiStruct.selectedRow.unitOfWeight = profileNode->userProfile.profileData.unitofWeight;


                // Update physician name according to profile physician mame
                SelectPhysicianInPatExEditList(profileNode->userProfile.profileData.physician.name);

                profileFound = true;
            }
            else
            {
                profileNode = GUI_DIR_GetProfileNode(GUI_DIR_NEXT);
            }
        }
        return profileNode;
    }

    /*======================================================================*/
    /*  PatexEditHandlePhysician                                            */
    /*======================================================================*/
    void Admi::PatexEditHandlePhysician()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditHandlePhysician");

        // If loggged in as emergency user, profile disabled.
        if ((AdmiStruct.patexEditActive) && (0 < GuiDataModelPtr->Admi.AddPanel.ProfileIndex))
        {
            int selected_PhyIndex = GuiDataModelPtr->Admi.AddPanel.PhysicianIndex;
            if (0 <= selected_PhyIndex)
            {
                const std::wstring phyName = GuiDataModelPtr->Admi.AddPanel.PhysicianItems[selected_PhyIndex];

                if ((phyName.empty()) || (0 != wcscmp(AdmiStruct.selectedRow.physician, phyName.c_str())))
                {
                    GuiDataModelPtr->Admi.AddPanel.ProfileIndex = 0;

                    PATIENT_TYPE_ENUM patientType;
                    // Validate exam type selected
                    if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
                    {
                        patientType = PATIENT_ADULT;
                    }
                    else
                    {
                        patientType = PATIENT_PEDIATRIC;
                    }

                    // Update Unit of weight according to configuration.
                    if (BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight)
                    {
                        UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::KG_UNIT);
                    }
                    else
                    {
                        UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::LBS_UNIT);
                    }

                    // Update Unit of height according to configuration.
                    UpdateHeightUnit(AdmiStruct.admi.unitOfHeight);

                    //Display popup to show change in parameter with respect to Default profile
                    ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                }
            }
        }
    }

    /*======================================================================*/
    /*  PatexEditHandleDefProc()                                            */
    /*======================================================================*/
    void Admi::PatexEditHandleDefProc()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::PatexEditHandleDefProc");
        const int selectedProfileIndex = GuiDataModelPtr->Admi.AddPanel.ProfileIndex;

        if ((AdmiStruct.patexEditActive) && (0 < selectedProfileIndex))
        {
            const int selected_DetProcindex = GuiDataModelPtr->Admi.AddPanel.ProcedureIndex;
            if (0 <= selected_DetProcindex)
            {
                GUI_PROFILE_NODE_STRUCT* profileData = nullptr;

                GetProfileData(std::wstring(GuiDataModelPtr->Admi.AddPanel.ProfileItems[selectedProfileIndex].c_str()), profileData);
                int detProcedureIndex = NO_ROW_SELECTED;

                if (nullptr != profileData)
                {
                    detProcedureIndex = GetAnatomyIndexFromDetailedProcedureID(profileData->userProfile.profileData.patientType,
                                                                               profileData->userProfile.profileData.procedureId,
                                                                               profileData->userProfile.profileData.detProcedureId);
                }

                if ((detProcedureIndex != selected_DetProcindex) && (detProcedureIndex != static_cast<int>(GuiDataModelPtr->Admi.AddPanel.ProcedureItems.size())))
                {
                    GuiDataModelPtr->Admi.AddPanel.ProfileIndex = 0;

                    // Update Unit of weight according to configuration.
                    if (BOOLEAN_FALSE == AdmiStruct.admi.unitsOfWeight)
                    {
                        UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::KG_UNIT);
                    }
                    else
                    {
                        UpdateWeightUnit(UNIT_OF_WEIGHT_ENUM::LBS_UNIT);
                    }

                    // Update Unit of height according to configuration.
                    UpdateHeightUnit(AdmiStruct.admi.unitOfHeight);
                    ShowUserInformationDialog(GUI_IFO_MSG_DEFAULT_EXAM_CHANGE);
                }
            }
        }
    }

    /*======================================================================*/
    /*  GetProfileData()                                                    */
    /*======================================================================*/
    void Admi::GetProfileData(std::wstring profileName, GUI_PROFILE_NODE_STRUCT* &profileNode) const
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::GetProfileData");

        profileNode = GUI_DIR_GetProfileNode(GUI_DIR_FIRST);
        while (profileNode != static_cast<GUI_PROFILE_NODE_STRUCT*>(NULL))
        {
            if (0 == wcscmp(profileNode->userProfile.profileData.profileName, profileName.c_str()))
            {
                break;
            }
            else
            {
                profileNode = GUI_DIR_GetProfileNode(GUI_DIR_NEXT);
            }
        }
    }

    /*======================================================================*/
    /*  FindExamNode()                                                      */
    /*======================================================================*/
    bool Admi::FindExamNode(GUI_ET_NODE_STRUCT* &etNode, int examIndex)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::FindExamNode");

        bool etFound = false;

        if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
        {
            GUI_DIR_GetPatientExamTypeNode(PATIENT_ADULT, GUI_DIR_FIRST, etNode);
        }
        else
        {
            GUI_DIR_GetPatientExamTypeNode(PATIENT_PEDIATRIC, GUI_DIR_FIRST, etNode);
        }

        while (!etFound && (etNode != static_cast<GUI_ET_NODE_STRUCT *>(NULL)))
        {
            if (examIndex == etNode->examType.guiExamTypeId)
            {
                etFound = true;
            }
            else
            {
                if (GuiDataModelPtr->Admi.AddPanel.PatientTypeAdult.Checked)
                {
                    GUI_DIR_GetPatientExamTypeNode(PATIENT_ADULT, GUI_DIR_NEXT, etNode);
                }
                else
                {
                    GUI_DIR_GetPatientExamTypeNode(PATIENT_PEDIATRIC, GUI_DIR_NEXT, etNode);
                }
            }
        }

        return etFound;
    }


    /*======================================================================*/
    /*  ResetDetProcList()                                                  */
    /*======================================================================*/
    void Admi::ResetDetProcList(GUI_ET_NODE_STRUCT* etNode)
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::ResetDetProcList");

        int indexDetProc = 0;
        GuiDataModelPtr->Admi.AddPanel.ProcedureItems.clear();
        GUI_DET_PROC_NODE_STRUCT* detProcNode;
        detProcNode = GUI_DIR_GetDetProcNode(GUI_DIR_FIRST, etNode);
        while (detProcNode != static_cast<GUI_DET_PROC_NODE_STRUCT*>(nullptr))
        {
            GuiDataModelPtr->Admi.AddPanel.ProcedureItems.emplace_back(detProcNode->detProc.name);
            detProcNode->index = indexDetProc;
            detProcNode        = GUI_DIR_GetDetProcNode(GUI_DIR_NEXT, static_cast<GUI_ET_NODE_STRUCT*>(nullptr));
            indexDetProc++;
        }
    }

    /*======================================================================*/
    /*  InitializePatientDialogWithWeightUnit                               */
    /*======================================================================*/
    void Admi::InitializePatientDialogWithWeightUnit(const UNIT_OF_WEIGHT_ENUM unitOfWeight)
    {
        std::wstring weightString = L"";
        if (UNIT_OF_WEIGHT_ENUM::KG_UNIT == unitOfWeight) // Configured weight is Kg
        {
            GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_KGS);

            if (AdmiStruct.selectedRow.weightKG >= MIN_WEIGHT_TO_DISPLAY)
            {
                std::wstringstream wstringFormater;
                wstringFormater << std::fixed << std::setprecision(1) << AdmiStruct.selectedRow.weightKG;
                weightString = wstringFormater.str();
            }
        }
        else
        {
            GuiDataModelPtr->Admi.AddPanel.PoundsText = GuiDataModelPtr->LocalePtr->GetText(MVSUI::STR_WEIGHT_POUNDS);

            double weightInPound = AdmiStruct.selectedRow.weightKG * KG_2_LBS;

            if (weightInPound >= MIN_WEIGHT_TO_DISPLAY)
            {
                std::wstringstream wstringFormater;
                wstringFormater << std::fixed << std::setprecision(1) << weightInPound;
                weightString = wstringFormater.str();
            }
        }

        GuiDataModelPtr->Admi.AddPanel.PatientWeight.Text = weightString;
    }

    /*======================================================================*/
    /*  InitializePatientDialogWithHeightUnit                               */
    /*======================================================================*/
    void Admi::InitializePatientDialogWithHeightUnit(const UNIT_OF_HEIGHT_ENUM unitOfHeight)
    {
        HeightCms                                   = AdmiStruct.selectedRow.heightCm;
        GuiDataModelPtr->Admi.AddPanel.unitOfHeight = unitOfHeight;
        GuiDataModelPtr->Admi.AddPanel.HeightInCms  = AdmiStruct.selectedRow.heightCm;
    }

    void Admi::FillFeetAndInchesComboItems()
    {
        LOG_FUNCTION(LOG_MI_GUI, "Admi::FillFeetAndInchesComboItems");

        GuiDataModelPtr->Admi.AddPanel.FeetComboItems.clear();
        for (int index = 0; index <= MVSUI::GUI_MAX_HEIGHT_FEET; index++)
        {
            GuiDataModelPtr->Admi.AddPanel.FeetComboItems.emplace_back(std::to_wstring(index));
        }

        GuiDataModelPtr->Admi.AddPanel.InchComboItems.clear();
        for (int index = 0; index <= MVSUI::GUI_MAX_HEIGHT_INCH; index++)
        {
            GuiDataModelPtr->Admi.AddPanel.InchComboItems.emplace_back(std::to_wstring(index));
        }
    }

    void Admi::InitializeGridMessageStatus()
    {
        if (GuiGlobal::Data().config.patientType == PATIENT_ADULT)
        {
            GuiGlobal::Data().lastGridMessage = GRID_MESSAGE_ENUM::MSG_PLACE_GRID;
        }
        else
        {
            // Set lastGridMessage to none initially, for the condition where we need to display 
            // grid removal message when default patient type is pediatric and the exam started
            // for the first time is also pediatric.
            GuiGlobal::Data().lastGridMessage = GRID_MESSAGE_ENUM::MSG_NONE;
        }
    }
}// Namespace Gui
point to note we are using view to communicate between ui and model. and we dnt make any changes to ui file manually. follow admis approach and look into my code and give me a code that can create and refill my list control in review page first.


this is how my code looks right now. i think im almost there but i cant figure out how is admi getting the patient data from that structure object. could u help me with that? help me fill my list control from  a structure object thats somewhere in admi.cpp file. 
follow admi's approach.