I have a dialog that has a tab with 2 pages. each page should have a list control that i need to dynamically implement and fill from the existing studies. npw i found thos code where similar implementation is done in the review tab but here its not a dialog but a panel. could you tell me step by step hpw can i implementlist control in my review tab?

\*************************************************************************************/

#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();



////below is my code which is not working properly as i cant understand where to add what.

//****************************************************************************//
//                                                                            //
//   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 "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"


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();

         
            
                //InitializeScheduleTab();
                InitPatMixupReviewExamsTab();
            
        }
        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();
        GuiDataModelPtr->Admi.ResolvePatMixUp.ModelUpdated = [this] { OnModelUpdated(); };
        GuiDataModelPtr->Admi.ResolvePatMixUp.LocaleChanged = [this] { OnLocaleChanged(); };
        
    }

    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::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);
            }
        });
        return OK;
    }

    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()
    {


        return OK;
    }
}





        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);
        }

    }
}