///<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 ImportSnomed(string tempFileName, ProgressArgs progress, ref bool quit) { if (tempFileName == null) { return; } HashSet <string> codeHash = new HashSet <string>(Snomeds.GetAllCodes()); string[] lines = File.ReadAllLines(tempFileName); string[] arraySnomed; Snomed snomed = new Snomed(); 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); } arraySnomed = lines[i].Split('\t'); if (codeHash.Contains(arraySnomed[0])) //code already exists { continue; } snomed.SnomedCode = arraySnomed[0]; snomed.Description = arraySnomed[1]; Snomeds.Insert(snomed); } }
///<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 ImportSnomed(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated, bool updateExisting) { if (tempFileName == null) { return; } Dictionary <string, Snomed> dictSnomeds = Snomeds.GetAll().ToDictionary(x => x.SnomedCode, x => x); string[] lines = File.ReadAllLines(tempFileName); string[] arraySnomed; Snomed snomed = new Snomed(); 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); } arraySnomed = lines[i].Split('\t'); if (dictSnomeds.ContainsKey(arraySnomed[0])) //code already exists { snomed = dictSnomeds[arraySnomed[0]]; if (updateExisting && snomed.Description != arraySnomed[1]) { snomed.Description = arraySnomed[1]; Snomeds.Update(snomed); numCodesUpdated++; } continue; } snomed.SnomedCode = arraySnomed[0]; snomed.Description = arraySnomed[1]; Snomeds.Insert(snomed); numCodesImported++; } }