Example #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 ImportIcd9(string tempFileName, ProgressArgs progress, ref bool quit)
        {
            if (tempFileName == null)
            {
                return;
            }
            //Customers may have an old codeset that has a truncated uppercase description, if so we want to update with new descriptions.
            bool             IsOldDescriptions = ICD9s.IsOldDescriptions();
            HashSet <string> codeHash          = new HashSet <string>(ICD9s.GetAllCodes());

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayICD9;
            ICD9     icd9 = new ICD9();

            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);
                }
                arrayICD9 = lines[i].Split('\t');
                if (codeHash.Contains(arrayICD9[0]))                 //code already exists
                {
                    if (!IsOldDescriptions)
                    {
                        continue;                        //code exists and has updated description
                    }
                    string command = "UPDATE icd9 SET description='" + POut.String(arrayICD9[1]) + "' WHERE ICD9Code='" + POut.String(arrayICD9[0]) + "'";
                    Db.NonQ(command);
                    continue;                    //we have updated the description of an existing code.
                }
                icd9.ICD9Code    = arrayICD9[0];
                icd9.Description = arrayICD9[1];
                ICD9s.Insert(icd9);
            }
        }
Example #2
0
        /// <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.
        }