/// <summary>
        /// Initializes a new instance of the <see cref="ConsultationStatusViewModel"/> class with cases
        /// </summary>
        /// <param name="readSites">list of known reading sites</param>
        public ConsultationStatusViewModel(CaseListItem item, ReadingSiteList sitelist)
        {
            this.Sites = new ObservableCollection<SiteConsultationStatusViewModel>();
            this.SelectedSites = new ObservableCollection<SiteConsultationStatusViewModel>();

            this.CancelConsultationCommand = new RelayCommand(CancelConsultation, () => CanCancelConsultation());
            this.RequestConsultationCommand = new RelayCommand(RequestConsultation, () => CanRequestConsultation());
            this.RefuseConsultationCommand = new RelayCommand(RefuseConsultation, () => CanRefuseConsultation());

            this.AccessionNr = item.AccessionNumber;
            this.PatientName = item.PatientName;
            this.PatientID = item.PatientID;

            bool canRequestConsultation = true;
            foreach (ReadingSiteInfo readingSiteInfo in sitelist.Items)
            {
                if ((readingSiteInfo.SiteStationNumber == UserContext.LocalSite.PrimarySiteStationNUmber) && (readingSiteInfo.SiteType == ReadingSiteType.consultation))
                {
                    canRequestConsultation = false;
                    break;
                }
            }

            // process consultation sites
            foreach (ReadingSiteInfo siteInfo in sitelist.Items)
            {
                SiteConsultationStatusViewModel itemVM = new SiteConsultationStatusViewModel();
                itemVM.Item = item;
                itemVM.SiteInfo = siteInfo;
                Site localSite = UserContext.LocalSite;
                itemVM.CanRequestConsultation = canRequestConsultation;

                foreach (CaseConsultation consult in item.ConsultationList.ConsultationList)
                {
                    if ((siteInfo.SiteStationNumber == consult.SiteID) && (consult.Type == "CONSULTATION"))
                    {
                        itemVM.ConsultationID = consult.ConsultationID;

                        if (consult.Status == "PENDING")
                        {
                            itemVM.IsPending = true;

                            // if request pending for current site
                            if ((siteInfo.SiteStationNumber == UserContext.LocalSite.PrimarySiteStationNUmber) &&
                                (consult.SiteID == UserContext.LocalSite.PrimarySiteStationNUmber))
                            {
                                itemVM.CanRefuseConsultation = true;
                            }
                        }
                        else if (consult.Status == "REFUSED")
                        {
                            itemVM.IsRefused = true;
                        }
                        else if (consult.Status == "COMPLETED")
                        {
                            itemVM.IsCompleted = true;
                        }
                    }
                }

                if (!itemVM.IsPending && !itemVM.IsCompleted && !siteInfo.Active)
                {
                    // not active and not pending. ignore this site
                    continue;
                }

                this.Sites.Add(itemVM);
            }

            // process consultation requests for current site
            foreach (CaseConsultation consult in item.ConsultationList.ConsultationList)
            {
                if ((consult.SiteID == UserContext.LocalSite.PrimarySiteStationNUmber) &&
                    (consult.Type == "CONSULTATION") && (consult.Status == "PENDING"))
                {
                    SiteConsultationStatusViewModel itemVM = new SiteConsultationStatusViewModel();
                    itemVM.Item = item;
                    itemVM.SiteInfo = new ReadingSiteInfo
                    {
                        SiteStationNumber = UserContext.LocalSite.PrimarySiteStationNUmber,
                        SiteAbr = UserContext.LocalSite.SiteAbbreviation,
                        SiteName = UserContext.LocalSite.SiteName,
                        Active = true
                    };
                    itemVM.IsCurrentSite = true;
                    itemVM.ConsultationID = consult.ConsultationID;
                    itemVM.IsPending = true;

                    this.Sites.Add(itemVM);
                }
            }
        }
        void OnViewConsultationStatus(CaseListItem item, WorklistViewModel worklist)
        {
            MainViewModel viewModel = (MainViewModel)DataContext;

            // check to see if the case already have an interpretation entry,
            // if there is no entry, create one
            if ((item.ConsultationList == null) || (item.ConsultationList.ConsultationList == null)
                || (item.ConsultationList.ConsultationList.Count == 0))
            {
                if (!viewModel.DataSource.RequestInterpretation(item.CaseURN, UserContext.LocalSite.PrimarySiteStationNUmber))
                {
                    MessageBox.Show("Case doesn't have an interpretation entry. Cannot proceed.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
            }

            // retrieve a list of reading sites that read for the site own the case
            // this way, only sites that are in agreement with the acquisition can access the data
            ReadingSiteList readSites = viewModel.DataSource.GetReadingSites(item.SiteCode);

            foreach (ReadingSiteInfo readSite in readSites.Items)
            {
                // if the user site is a consultation site, the user can't request more consultation on remote item,
                // however he/she must be able to refuse one that was just requested (report status id "Pending Verification")
                if ((readSite.SiteStationNumber == UserContext.LocalSite.PrimarySiteStationNUmber) && (readSite.SiteType == ReadingSiteType.consultation))
                {
                    MessageBox.Show("Your site is configured as a consultation site at " + item.AcquisitionSite + ".\r\nOnly primary interpreting site can request consultations.");

                    if (item.ReportStatus == "Pending Verification")
                    {
                        MessageBoxResult result = MessageBox.Show("From site " + item.AcquisitionSite + " for Case <" + item.AccessionNumber +
                                        "> Consultation is requested.\r\nDo you want to Decline this request?", "Choice", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.No /* default to No */);
                        if (result == MessageBoxResult.Yes)
                        {
                            // update Consult status to refused!
                            ConsultationStatusViewModel consultSVM = new ConsultationStatusViewModel(item, readSites);
                            consultSVM.SelectedSites = new ObservableCollection<SiteConsultationStatusViewModel>();
                            SiteConsultationStatusViewModel itemVM = new SiteConsultationStatusViewModel();
                            itemVM.Item = item;
                            itemVM.SiteInfo = readSite; // ReadingSiteInfo
                            itemVM.IsCurrentSite = false;
                            itemVM.CanRefuseConsultation = true;
                            itemVM.CanRequestConsultation = false;
                            itemVM.IsRecalled = false;
                            // Consultations are returned from originating DB if we got here
                            int lastConsultIndex = item.ConsultationList.ConsultationList.Count;
                            itemVM.ConsultationID = item.ConsultationList.ConsultationList[lastConsultIndex-1].ConsultationID;
                            itemVM.IsPending = true;
                            consultSVM.SelectedSites.Add(itemVM);

                            consultSVM.RefuseConsultation();
                            return;
                        }
                    }
                    return;
                }
            }

            ConsultationStatusViewModel dialogViewModel = new ConsultationStatusViewModel(item, readSites);
            ConsultationStatusView dialog = new ConsultationStatusView(dialogViewModel);
            dialog.Owner = this;
            dialog.ShowDialog();
        }