///<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>If the CodeValue of the EhrCode exists in its respective code table (I.e. Snomed, Loinc, Cpt, etc.) this will set IsInDb=true otherwise false.</summary> private static void updateCodeExistsHelper() { //No need to check RemotingRole; no call to db. if (listt.Count == 0) { return; } //Cache lists of codes. HashSet <string> cdcrecHS = new HashSet <string>(Cdcrecs.GetAllCodes()); HashSet <string> cdtHS = new HashSet <string>(ProcedureCodes.GetAllCodes()); HashSet <string> cptHS = new HashSet <string>(Cpts.GetAllCodes()); HashSet <string> cvxHS = new HashSet <string>(Cvxs.GetAllCodes()); HashSet <string> hcpcsHS = new HashSet <string>(Hcpcses.GetAllCodes()); HashSet <string> icd10HS = new HashSet <string>(Icd10s.GetAllCodes()); HashSet <string> icd9HS = new HashSet <string>(ICD9s.GetAllCodes()); HashSet <string> loincHS = new HashSet <string>(Loincs.GetAllCodes()); HashSet <string> rxnormHS = new HashSet <string>(RxNorms.GetAllCodes()); HashSet <string> snomedHS = new HashSet <string>(Snomeds.GetAllCodes()); HashSet <string> sopHS = new HashSet <string>(Sops.GetAllCodes()); for (int i = 0; i < listt.Count; i++) { switch (listt[i].CodeSystem) { case "AdministrativeSex": //always "in DB", even though there is no DB table listt[i].IsInDb = true; break; case "CDCREC": listt[i].IsInDb = cdcrecHS.Contains(listt[i].CodeValue); break; case "CDT": listt[i].IsInDb = cdtHS.Contains(listt[i].CodeValue); break; case "CPT": listt[i].IsInDb = cptHS.Contains(listt[i].CodeValue); break; case "CVX": listt[i].IsInDb = cvxHS.Contains(listt[i].CodeValue); break; case "HCPCS": listt[i].IsInDb = hcpcsHS.Contains(listt[i].CodeValue); break; case "ICD9CM": listt[i].IsInDb = icd9HS.Contains(listt[i].CodeValue); break; case "ICD10CM": listt[i].IsInDb = icd10HS.Contains(listt[i].CodeValue); break; case "LOINC": listt[i].IsInDb = loincHS.Contains(listt[i].CodeValue); break; case "RXNORM": listt[i].IsInDb = rxnormHS.Contains(listt[i].CodeValue); break; case "SNOMEDCT": listt[i].IsInDb = snomedHS.Contains(listt[i].CodeValue); break; case "SOP": listt[i].IsInDb = sopHS.Contains(listt[i].CodeValue); break; } } //This updates the last column "ExistsInDatabse" based on weather or not the code is found in another table in the database. }