コード例 #1
0
        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportHcpcs(string tempFileName, ProgressArgs progress, ref bool quit)
        {
            if (tempFileName == null)
            {
                return;
            }
            HashSet <string> codeHash = new HashSet <string>(Hcpcses.GetAllCodes());

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayHCPCS;
            Hcpcs    hcpcs = new Hcpcs();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayHCPCS = lines[i].Split('\t');
                if (codeHash.Contains(arrayHCPCS[0]))                 //code already exists
                {
                    continue;
                }
                hcpcs.HcpcsCode        = arrayHCPCS[0];
                hcpcs.DescriptionShort = arrayHCPCS[1];
                Hcpcses.Insert(hcpcs);
            }
        }
コード例 #2
0
ファイル: CodeSystems.cs プロジェクト: royedwards/DRDNet
        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportHcpcs(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated,
                                       bool updateExisting)
        {
            if (tempFileName == null)
            {
                return;
            }
            Dictionary <string, Hcpcs> dictHcpcs = Hcpcses.GetAll().ToDictionary(x => x.HcpcsCode, x => x);

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayHCPCS;
            Hcpcs    hcpcs = new Hcpcs();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayHCPCS = lines[i].Split('\t');
                if (dictHcpcs.ContainsKey(arrayHCPCS[0]))                 //code already exists
                {
                    hcpcs = dictHcpcs[arrayHCPCS[0]];
                    if (updateExisting && hcpcs.DescriptionShort != arrayHCPCS[1])
                    {
                        hcpcs.DescriptionShort = arrayHCPCS[1];
                        Hcpcses.Update(hcpcs);
                        numCodesUpdated++;
                    }
                    continue;
                }
                hcpcs.HcpcsCode        = arrayHCPCS[0];
                hcpcs.DescriptionShort = arrayHCPCS[1];
                Hcpcses.Insert(hcpcs);
                numCodesImported++;
            }
        }