Пример #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 ImportCvx(string tempFileName, ProgressArgs progress, ref bool quit)
        {
            if (tempFileName == null)
            {
                return;
            }
            HashSet <string> codeHash = new HashSet <string>(Cvxs.GetAllCodes());

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayCvx;
            Cvx      cvx = new Cvx();

            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);
                }
                arrayCvx = lines[i].Split('\t');
                if (codeHash.Contains(arrayCvx[0]))                 //code already exists
                {
                    continue;
                }
                cvx.CvxCode     = arrayCvx[0];
                cvx.Description = arrayCvx[1];
                Cvxs.Insert(cvx);
            }
        }
Пример #2
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 ImportCvx(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated,
                                     bool updateExisting)
        {
            if (tempFileName == null)
            {
                return;
            }
            Dictionary <string, Cvx> dictCodes = Cvxs.GetAll().ToDictionary(x => x.CvxCode, x => x);

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayCvx;
            Cvx      cvx = new Cvx();

            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);
                }
                arrayCvx = lines[i].Split('\t');
                if (dictCodes.ContainsKey(arrayCvx[0]))                 //code already exists
                {
                    cvx = dictCodes[arrayCvx[0]];
                    if (updateExisting && cvx.Description != arrayCvx[1])                   //We do want to update and description is different.
                    {
                        cvx.Description = arrayCvx[1];
                        Cvxs.Update(cvx);
                        numCodesUpdated++;
                    }
                    continue;
                }
                cvx.CvxCode     = arrayCvx[0];
                cvx.Description = arrayCvx[1];
                Cvxs.Insert(cvx);
                numCodesImported++;
            }
        }
Пример #3
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.
        }
Пример #4
0
        /// <summary>If the number of codes in the code tables (I.e. Snomed, Loinc, Cpt, etc.) are greater than the number we expect then 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.
            #region Count Variables
            //Counts from the DB
            long countCdcDB    = -1;
            long countCdtDB    = -1;
            long countCptDB    = -1;
            long countCvxDB    = -1;
            long countHcpcsDB  = -1;
            long countIcd9DB   = -1;
            long countIcd10DB  = -1;
            long countLoincDB  = -1;
            long countRxNormDB = -1;
            long countSnomedDB = -1;
            long countSopDB    = -1;
            //Counts hard-coded from the EhrCodes.Listt. Lowered slightly to give a buffer, in case we decide to remove some codes later.
            const long countCdcList    = 5;
            const long countCdtList    = 10;
            const long countCptList    = 300;
            const long countCvxList    = 5;
            const long countHcpcsList  = 20;
            const long countIcd9List   = 1500;
            const long countIcd10List  = 2000;
            const long countLoincList  = 20;
            const long countRxNormList = 40;
            const long countSnomedList = 700;
            const long countSopList    = 100;
            #endregion
            for (int i = 0; i < listt.Count; i++)
            {
                if (listt[i].IsInDb)
                {
                    continue;                    //The codes are already present in the database, so we don't need to check again.
                }
                switch (listt[i].CodeSystem)
                {
                case "AdministrativeSex":                        //always "in DB", even though there is no DB table
                    listt[i].IsInDb = true;
                    break;

                case "CDCREC":
                    if (countCdcDB == -1)
                    {
                        countCdcDB = Cdcrecs.GetCodeCount();
                    }
                    if (countCdcDB > countCdcList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "CDT":
                    if (countCdtDB == -1)
                    {
                        countCdtDB = ProcedureCodes.GetCodeCount();
                    }
                    if (countCdtDB > countCdtList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "CPT":
                    if (countCptDB == -1)
                    {
                        countCptDB = Cpts.GetCodeCount();
                    }
                    if (countCptDB > countCptList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "CVX":
                    if (countCvxDB == -1)
                    {
                        countCvxDB = Cvxs.GetCodeCount();
                    }
                    if (countCvxDB > countCvxList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "HCPCS":
                    if (countHcpcsDB == -1)
                    {
                        countHcpcsDB = Hcpcses.GetCodeCount();
                    }
                    if (countHcpcsDB > countHcpcsList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "ICD9CM":
                    if (countIcd9DB == -1)
                    {
                        countIcd9DB = ICD9s.GetCodeCount();
                    }
                    if (countIcd9DB > countIcd9List)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "ICD10CM":
                    if (countIcd10DB == -1)
                    {
                        countIcd10DB = Icd10s.GetCodeCount();
                    }
                    if (countIcd10DB > countIcd10List)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "LOINC":
                    if (countLoincDB == -1)
                    {
                        countLoincDB = Loincs.GetCodeCount();
                    }
                    if (countLoincDB > countLoincList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "RXNORM":
                    if (countRxNormDB == -1)
                    {
                        countRxNormDB = RxNorms.GetCodeCount();
                    }
                    if (countRxNormDB > countRxNormList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "SNOMEDCT":
                    if (countSnomedDB == -1)
                    {
                        countSnomedDB = Snomeds.GetCodeCount();
                    }
                    if (countSnomedDB > countSnomedList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;

                case "SOP":
                    if (countSopDB == -1)
                    {
                        countSopDB = Sops.GetCodeCount();
                    }
                    if (countSopDB > countSopList)
                    {
                        listt[i].IsInDb = true;
                    }
                    break;
                }
            }

            //This updates the last column "ExistsInDatabse" based on weather or not the code is found in another table in the database.
        }