/// <summary>
        /// Get the items for the desired list
        /// </summary>
        /// <param name="provider">Data Provider used to retrieve the items</param>
        /// <param name="showCode">Whether to show codes on the items</param>
        /// <returns>A new collection of ListItemVM objects making up the desired list</returns>
        public IEnumerable <ViewModels.ListItemVM> GetItemVMs(DataProviders.IAppDataProvider provider, bool showCode, ViewModels.SearchVM parentVM)
        {
            if (String.IsNullOrWhiteSpace(SearchFor))
            {
                yield break;
            }

            var  allResults = provider.GetSearch(SearchFor, Skip, TakeAtATime + 1);
            bool hasMore    = (allResults.Count > TakeAtATime);

            Skip += (hasMore) ? TakeAtATime : allResults.Count;

            var index   = 0;
            var results = from result in allResults.Take(TakeAtATime)
                          group result by result.RetrievedFrom;

            foreach (var type in SearchTypes)
            {
                var currMatches = (from result in results
                                   where result.Key == type.Key
                                   from ret in result
                                   select ret).ToArray();
                if (currMatches.Length > 0)
                {
                    if (!String.Equals(lastRetrievedFrom, type.Key))
                    {
                        yield return(new ListItemVM(0,
                                                    IcdCodeItemMethods.NewDividerItem(type.Value),
                                                    Enumerable.Empty <string>(), showCode)
                        {
                            ParentVM = parentVM
                        });

                        lastRetrievedFrom = type.Key;
                    }

                    foreach (var match in currMatches)
                    {
                        ++index;
                        yield return(new ListItemVM(index,
                                                    match.ToIcdCodeItem(provider),
                                                    Enumerable.Empty <string>(), showCode)
                        {
                            ParentVM = parentVM
                        });
                    }
                }
            }

            if (hasMore)
            {
                yield return(new ListItemVM(0,
                                            IcdCodeItemMethods.NewMoreItem(),
                                            Enumerable.Empty <string>(), showCode)
                {
                    ParentVM = parentVM
                });
            }
        }
Exemple #2
0
 /// <summary>
 /// Wrap an IcdCode object into an IcdCodeItem object
 /// </summary>
 /// <param name="fromCode">IcdCode object to wrap</param>
 /// <param name="useProvider">Data Provider that additional information on the IcdCode will be retrieved from</param>
 /// <returns>New IcdCodeItem object wrapping the original IcdCode object</returns>
 public static IcdCodeItem ToIcdCodeItem(this IcdCode fromCode, DataProviders.IAppDataProvider useProvider)
 {
     return(new IcdCodeItem()
     {
         Code = fromCode,
         Comment = String.Empty,
         Enabled = false,
         Children = fromCode.DeferredOnceChildren(useProvider)
     });
 }
Exemple #3
0
 /// <summary>
 /// Get the enumerator for the children
 /// On first run, it retrieves the children; all initial runs use the previously retrieved children
 /// </summary>
 /// <returns>Enumerator for IcdCodeItem collection</returns>
 public IEnumerator <IcdCodeItem> GetEnumerator()
 {
     if (items == null)
     {
         items = (from child in dataProvider.GetChildren(parent.Code, parent.CodeType)
                  select child.ToIcdCodeItem(dataProvider))
                 .ToList();
         parent       = null;
         dataProvider = null;
     }
     return(items.GetEnumerator());
 }
        /// <summary>
        /// Get the items for the expected list from the given provider
        /// </summary>
        /// <param name="provider">Provider to get the list from</param>
        /// <param name="showCode">Whether to show codes on the items</param>
        /// <returns>A new collection of ListItemVM objects containing the list; Empty if none available or invalid ListId property</returns>
        public IEnumerable <ViewModels.ListItemVM> GetItemVMs(DataProviders.IAppDataProvider provider, bool showCode, ViewModels.SearchVM parentVM)
        {
            if (String.IsNullOrWhiteSpace(ListId))
            {
                return(Enumerable.Empty <ViewModels.ListItemVM>());
            }

            return(provider.GetList(ListId).Select((c, i) =>
                                                   new ViewModels.ListItemVM(i + 1, c.ToIcdCodeItem(provider), Enumerable.Empty <string>(), showCode)
            {
                ParentVM = parentVM
            }));
        }
Exemple #5
0
        /// <summary>
        /// START POINT OF APPLICATION
        /// </summary>
        private void ApplicationStart(object sender, StartupEventArgs e)
        {
            m_RememberMe  = false;
            m_StartupArgs = new StartupArgs(e.Args);

            m_DataProvider = new DataProviders.LocalSqliteDataProvider();
            //m_DataProvider = new DataProviders.AppNmsSvcDataProvider(StartupArgs.HostUri);

            Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;

            bool exist = false;

            try
            {
                exist = DataProvider.TryExistingSession(m_StartupArgs.SessionToken);
                if (exist)
                {
                    m_RememberMe = true;
                }
            }
            catch (DataProviders.InvalidLicenseException)
            {
                if (StartupArgs.SessionToken != null)
                {
                    System.Windows.MessageBox.Show("User does not have Search ICD License");
                    Application.Current.Shutdown();
                }
                else
                {
                    exist = false;
                }
            }
            catch (WebFaultException <NMS.Platform.NMSExceptionDetail> )
            {
                exist = false;
            }
            catch (MessageSecurityException)
            {
                exist = false;
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                System.Windows.MessageBox.Show("The connection to the NMS server failed. Check your internet connection, or the server may be temporarily down.",
                                               "Search ICD-10", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }

            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            if (!exist)
            {
                var loginWin = new LoginWindow();
                loginWin.ShowDialog();
                if (loginWin.DialogResult != true)
                {
                    Application.Current.Shutdown();
                    return;
                }
            }

            Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
            var listWin = new ListsWindow();

            listWin.Show();
            Application.Current.MainWindow = listWin;
        }
Exemple #6
0
 /// <summary>
 /// Initiate a new DeferredOnceChildren object with necessary data
 /// </summary>
 /// <param name="fromParent">Parent IcdCode object to get children from</param>
 /// <param name="useProvider">Data Provider to get the data from</param>
 public DeferredOnceChildren(IcdCode fromParent, DataProviders.IAppDataProvider useProvider)
 {
     items        = null;
     parent       = fromParent;
     dataProvider = useProvider;
 }
Exemple #7
0
 /// <summary>
 /// Get the Children of an IcdCode object with deferred once execution
 /// Does not execute retrieving the children until first enumeration; after, uses the first retrieved collection
 /// </summary>
 /// <param name="fromParent">Parent IcdCode to get the Children from</param>
 /// <param name="useProvider">Data Provider to get the Children from</param>
 /// <returns>Deferred Once Enumerable of IcdCodeItem objects representing the children</returns>
 public static IEnumerable <IcdCodeItem> DeferredOnceChildren(this IcdCode fromParent, DataProviders.IAppDataProvider useProvider)
 {
     return(new DeferredOnceChildren(fromParent, useProvider));
 }