//<summary>
         //Initializes a new instance of the CaseOrganTissueViewModel class.
         //</summary>
		public ReportCodingViewModel()
		{
		    this.IsEditorReadOnly = true;
		    this.CurrentSiteType = ReadingSiteType.interpretation;

		    COT = new CaseOrganTissue();
		    CPTList = new PathologyCptCodesType();
		    this.SearchItems = new ObservableCollection<PathologyFieldValue>();
		    this.SearchLocationItems = new ObservableCollection<PathologyFieldValue>();

		    this.SearchSnomedItemCommand = new RelayCommand(SearchSnomedItem, () => this.CanSearchSnomedItem);
		    this.AddSnomedItemCommand = new RelayCommand(AddSnomedItem, () => this.CanAddSnomedItem);
		    this.RemoveSnomedItemCommand = new RelayCommand(RemoveSnomedItem, () => this.CanRemoveSnomedItem);

		    this.SearchLocationItemCommand = new RelayCommand(SearchLocationItem, () => this.CanSearchLocationItem);
		    this.AddCPTCommand = new RelayCommand(AddCPTItems, () => this.CanAddCPT);
		}
		public ReportCodingViewModel(IWorkListDataSource datasource, string caseURN, string siteNumber, bool isGlobalReadOnly = false, ReadingSiteType siteType = ReadingSiteType.interpretation)
		{
			this.IsEditorReadOnly = isGlobalReadOnly;
			this.CurrentSiteType = siteType;

			this.DataSource = datasource;
			this.CaseURN = caseURN;
			this.SiteStationNumber = siteNumber;

			COT = new CaseOrganTissue();
			CPTList = new PathologyCptCodesType();
			
			PathologySnomedCodesType snomedList = this.DataSource.GetSnomedCodeForCase(this.CaseURN);
			COT.InitializeList(snomedList);
			CPTList = this.DataSource.GetCptCodesForCase(this.CaseURN);
            
            this.SupportCPT = true;
            if (CPTList == null)
            {
                this.SupportCPT = false;
                MessageBox.Show("The current case does not support CPT coding.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                CPTList = new PathologyCptCodesType();
            }

			this.SearchItems = new ObservableCollection<PathologyFieldValue>();
			this.SearchLocationItems = new ObservableCollection<PathologyFieldValue>();

			// enable adding new organ intially
			this.SelectedItemType = "Organ/Tissue";
			this.SelectedSearchItem = null;

			this.SearchSnomedItemCommand = new RelayCommand(SearchSnomedItem, () => this.CanSearchSnomedItem);
			this.AddSnomedItemCommand = new RelayCommand(AddSnomedItem, () => this.CanAddSnomedItem);
			this.RemoveSnomedItemCommand = new RelayCommand(RemoveSnomedItem, () => this.CanRemoveSnomedItem);

			this.SearchLocationItemCommand = new RelayCommand(SearchLocationItem, () => this.CanSearchLocationItem );
			this.AddCPTCommand = new RelayCommand(AddCPTItems, () => this.CanAddCPT );
		}
		private string ProcessAddCPTItemsResult(PathologyCptCodeResultsType result)
		{
			if ((result != null) && (result.Items != null) && (result.Items.Count > 0))
			{
				string success = string.Empty;
				int successCount = 0;
				string failure = string.Empty;
				int failureCount = 0;

				foreach (CptCodeResult code in result.Items)
				{
					string res = String.Format("{0} {1}", code.CptCode, code.Description);
					if (code.Result)
					{
						// if successfully added, add to the success queue
						successCount++;
						if (!success.Contains(res))
						{
							success += res + Environment.NewLine;
						}
					}
					else
					{
						failureCount++;
						if (!failure.Contains(res))
						{
							failure += res + Environment.NewLine;
						}
					}
				}

				string successMess = "The following CPT code(s) are entered successfully and tracked:\n" + success;
				string failureMess = "Unable to enter the following CPT code(s):\n" + failure;

				if (successCount > 0)
				{
                    this.CPTText = string.Empty;
                    this.LocationSearchText = string.Empty;
                    // this.SearchLocationItems = null; *** preserve previously searched Hosp loc list

					CPTList = this.DataSource.GetCptCodesForCase(this.CaseURN);
                    if (CPTList == null)
                    {
                        Log.Debug("Failed to retrieve CPT list.");
                        CPTList = new PathologyCptCodesType();
                    }
				}

				if (failureCount <= 0)
				{
					// there is no failure
					return successMess;
				}
				else
				{
					// there is no success
					if (successCount <= 0)
					{
						return failureMess;
					}
					else
					{
						return successMess + Environment.NewLine + failureMess;
					}
				}
			}
			else
			{
				return "Nothing in the result.";
			}
        }