///<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 ImportIcd10(string tempFileName, ProgressArgs progress, ref bool quit) { if (tempFileName == null) { return; } HashSet <string> codeHash = new HashSet <string>(Icd10s.GetAllCodes()); string[] lines = File.ReadAllLines(tempFileName); string[] arrayICD10; Icd10 icd10 = new Icd10(); 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); } arrayICD10 = lines[i].Split('\t'); if (codeHash.Contains(arrayICD10[0])) //code already exists { continue; } icd10.Icd10Code = arrayICD10[0]; icd10.Description = arrayICD10[1]; icd10.IsCode = arrayICD10[2]; Icd10s.Insert(icd10); } }
///<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 ImportIcd10(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated, bool updateExisting) { if (tempFileName == null) { return; } Dictionary <string, Icd10> dictIcd10s = Icd10s.GetAll().ToDictionary(x => x.Icd10Code, x => x); string[] lines = File.ReadAllLines(tempFileName); string[] arrayICD10; Icd10 icd10 = new Icd10(); 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); } arrayICD10 = lines[i].Split('\t'); if (dictIcd10s.ContainsKey(arrayICD10[0])) //code already exists { icd10 = dictIcd10s[arrayICD10[0]]; if (updateExisting && (icd10.Description != arrayICD10[1] || icd10.IsCode != arrayICD10[2])) //Code informatin is different { icd10.Description = arrayICD10[1]; icd10.IsCode = arrayICD10[2]; Icd10s.Update(icd10); numCodesUpdated++; } continue; } icd10.Icd10Code = arrayICD10[0]; icd10.Description = arrayICD10[1]; icd10.IsCode = arrayICD10[2]; Icd10s.Insert(icd10); numCodesImported++; } }