Exemple #1
0
        public static Int32 GetPreviewCount(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, List <REGISTRY_COHORT_DATA> cohorts)
        {
            Int32 objReturn = 0;
            REGISTRY_COHORT_DATADB objDB = new REGISTRY_COHORT_DATADB();

            RegistryWizard registryWizard = ConvertToRegistryWizard(cohorts);

            if (registryWizard != null)
            {
                objReturn = objDB.GetPreviewCount(CURRENT_USER, CURRENT_REGISTRY_ID, registryWizard);
            }

            return(objReturn);
        }
Exemple #2
0
        public static int PreviewRegistryCohort(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            int objReturn = 0;

            List <REGISTRY_COHORT_DATA> cohorts = REGISTRY_COHORT_DATAManager.GetItemsSelectedByRegistry(CURRENT_USER, CURRENT_REGISTRY_ID); //REGISTRY_COHORT_DATAManager.GetCdwFields(registryId);
            RegistryWizard wizard = REGISTRY_COHORT_DATAManager.ConvertToRegistryWizard(cohorts);

            if (wizard != null)
            {
                wizard.StdRegistryId = CURRENT_REGISTRY_ID;
                wizard.Username      = CURRENT_USER;
                wizard.Count         = true;

                ETLDB objDB = new ETLDB();
                objReturn = objDB.CDW_GetCount(CURRENT_USER, CURRENT_REGISTRY_ID, wizard);
            }

            return(objReturn);
        }
Exemple #3
0
        public static int UpdateRegistryCohort(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            int objReturn = 0;

            List <REGISTRY_COHORT_DATA> cohorts = REGISTRY_COHORT_DATAManager.GetItemsByRegistry(CURRENT_USER, CURRENT_REGISTRY_ID); //REGISTRY_COHORT_DATAManager.GetCdwFields(registryId);
            RegistryWizard wizard = REGISTRY_COHORT_DATAManager.ConvertToRegistryWizard(cohorts);

            if (wizard != null)
            {
                wizard.StdRegistryId = CURRENT_REGISTRY_ID;
                wizard.Username      = CURRENT_USER;
                wizard.Count         = false;

                ETLDB           objDB       = new ETLDB();
                List <SPATIENT> patientList = objDB.CDW_GetData(CURRENT_USER, CURRENT_REGISTRY_ID, wizard);
                if (patientList != null)
                {
                    objReturn = objDB.CDW_SaveData(CURRENT_USER, CURRENT_REGISTRY_ID, patientList);
                }
            }

            return(objReturn);
        }
        public Boolean PopulateRegistry(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, RegistryWizard registryWizard)
        {
            Boolean objReturn = false;

            SqlConnection sConn = null;
            SqlCommand    sCmd  = null;

            try
            {
                sConn = new SqlConnection(SqlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRS.RegWiz_PopulateRegistry", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@CURRENT_USER", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@CURRENT_REGISTRY_ID", CURRENT_REGISTRY_ID);
                sCmd.Parameters.AddWithValue("@StdRegistryId", registryWizard.StdRegistryId);
                sCmd.Parameters.AddWithValue("@CombatLocIds", registryWizard.CombatLocIds);
                sCmd.Parameters.AddWithValue("@EthnicityIds", registryWizard.EthnicityIds);
                sCmd.Parameters.AddWithValue("@GenderIds", registryWizard.GenderIds);
                sCmd.Parameters.AddWithValue("@OEFOIFLocationIds", DBNull.Value); //registryWizard.OEFOIFLocation);
                sCmd.Parameters.AddWithValue("@RaceIds", registryWizard.RaceIds);
                sCmd.Parameters.AddWithValue("@ServiceIds", registryWizard.ServiceIds);
                sCmd.Parameters.AddWithValue("@DOBMin", registryWizard.DOBMin);
                sCmd.Parameters.AddWithValue("@DOBMax", registryWizard.DOBMax);
                sCmd.Parameters.AddWithValue("@UserName", registryWizard.Username);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                int        cnt        = sCmd.ExecuteNonQuery();
                LogManager.LogTiming(logDetails);

                objReturn = true;

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
        public Int32 GetPreviewCount(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, RegistryWizard registryWizard)
        {
            Int32 objReturn = 0;

            SqlConnection sConn   = null;
            SqlCommand    sCmd    = null;
            SqlDataReader sReader = null;

            try
            {
                sConn = new SqlConnection(EtlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRSE.CDW_GETData_Wizard", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@StdRegistryId", CURRENT_REGISTRY_ID);
                sCmd.Parameters.AddWithValue("@CombatLocation", registryWizard.CombatLocIds);
                sCmd.Parameters.AddWithValue("@Ethnicity", registryWizard.EthnicityIds);
                sCmd.Parameters.AddWithValue("@Gender", registryWizard.GenderIds);

                if (registryWizard.OEFOIFLocation != null && registryWizard.OEFOIFLocation.Value)
                {
                    sCmd.Parameters.AddWithValue("@OEFOIF", 1);
                }
                else
                {
                    sCmd.Parameters.AddWithValue("@OEFOIF", DBNull.Value);
                }

                sCmd.Parameters.AddWithValue("@Race", registryWizard.RaceIds);
                sCmd.Parameters.AddWithValue("@ServiceBranch", registryWizard.ServiceIds);
                sCmd.Parameters.AddWithValue("@MaritalStatus", registryWizard.MaritalStatusIds);
                sCmd.Parameters.AddWithValue("@DOBMin", registryWizard.DOBMin);
                sCmd.Parameters.AddWithValue("@DOBMax", registryWizard.DOBMax);
                sCmd.Parameters.AddWithValue("@UserName", CURRENT_USER);
                sCmd.Parameters.AddWithValue("@Count", 1);
                sCmd.Parameters.AddWithValue("@ICD9", registryWizard.ICD9);
                sCmd.Parameters.AddWithValue("@ICD10", registryWizard.ICD10);
                sCmd.Parameters.AddWithValue("@HealthFactorType", registryWizard.HealthFactorType);
                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                sReader = sCmd.ExecuteReader();
                LogManager.LogTiming(logDetails);

                if (sReader != null && sReader.HasRows)
                {
                    sReader.Read();
                    objReturn = (Int32)GetNullableObject(sReader["Record_Count"]);
                    sReader.Close();
                }

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sReader != null)
                {
                    if (!sReader.IsClosed)
                    {
                        sReader.Close();
                    }
                    sReader.Dispose();
                    sReader = null;
                }
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }
Exemple #6
0
        public static Boolean PopulateRegistry(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, RegistryWizard registryWizard)
        {
            Boolean objReturn            = false;
            REGISTRY_COHORT_DATADB objDB = new REGISTRY_COHORT_DATADB();

            objReturn = objDB.PopulateRegistry(CURRENT_USER, CURRENT_REGISTRY_ID, registryWizard);

            return(objReturn);
        }
Exemple #7
0
        public static RegistryWizard ConvertToRegistryWizard(List <REGISTRY_COHORT_DATA> cohorts)
        {
            RegistryWizard objReturn = null;

            if (cohorts != null)
            {
                cohorts = cohorts.Where(data => data.SELECTED_FLAG == true).ToList();

                objReturn = new RegistryWizard();

                foreach (REGISTRY_COHORT_DATA cohort in cohorts)
                {
                    if (cohort.STD_REGISTRY_COHORT_TYPES != null)
                    {
                        DateTime dt = DateTime.Now;

                        switch (cohort.STD_REGISTRY_COHORT_TYPES.DESCRIPTION_TEXT)
                        {
                        case "Combat Location":
                            if (!string.IsNullOrEmpty(objReturn.CombatLocIds))
                            {
                                objReturn.CombatLocIds += "','";
                            }

                            objReturn.CombatLocIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "CPTCodes for a patient":
                            if (!string.IsNullOrEmpty(objReturn.CPTCodes))
                            {
                                objReturn.CPTCodes += "','";
                            }

                            objReturn.CPTCodes += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Ethnicity":
                            if (!string.IsNullOrEmpty(objReturn.EthnicityIds))
                            {
                                objReturn.EthnicityIds += "','";
                            }

                            objReturn.EthnicityIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Gender":
                            if (!string.IsNullOrEmpty(objReturn.GenderIds))
                            {
                                objReturn.GenderIds += "','";
                            }

                            objReturn.GenderIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "HealthFactor Type":
                            if (!string.IsNullOrEmpty(objReturn.HealthFactorType))
                            {
                                objReturn.HealthFactorType += "','";
                            }

                            objReturn.HealthFactorType += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "ICD10_Code":
                            if (!string.IsNullOrEmpty(objReturn.ICD10))
                            {
                                objReturn.ICD10 += "','";
                            }

                            objReturn.ICD10 += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "ICD9_Code":
                            if (!string.IsNullOrEmpty(objReturn.ICD9))
                            {
                                objReturn.ICD9 += "','";
                            }

                            objReturn.ICD9 += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Marital Status":
                            if (!string.IsNullOrEmpty(objReturn.MaritalStatusIds))
                            {
                                objReturn.MaritalStatusIds += "','";
                            }

                            objReturn.MaritalStatusIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Maximum age":
                            if (DateTime.TryParse(cohort.VALUE, out dt))
                            {
                                objReturn.DOBMax = dt;
                            }
                            break;

                        case "Minimum age":
                            if (DateTime.TryParse(cohort.VALUE, out dt))
                            {
                                objReturn.DOBMin = dt;
                            }
                            break;

                        case "Race":
                            if (!string.IsNullOrEmpty(objReturn.RaceIds))
                            {
                                objReturn.RaceIds += "','";
                            }

                            objReturn.RaceIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Service Branch":
                            if (!string.IsNullOrEmpty(objReturn.ServiceIds))
                            {
                                objReturn.ServiceIds += "','";
                            }

                            objReturn.ServiceIds += cohort.STD_REGISTRY_COHORT_TYPES.CODE;
                            break;

                        case "Shows participation in OEF/OIF":     //todo
                            if (cohort.SELECTED_FLAG)
                            {
                                objReturn.OEFOIFLocation = true;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            return(objReturn);
        }
Exemple #8
0
        public static List <REGISTRY_COHORT_DATA> ConvertToDataList(RegistryWizard wizard)
        {
            List <REGISTRY_COHORT_DATA> objReturn = null;

            REGISTRY_COHORT_DATA      cohort = null;
            STD_REGISTRY_COHORT_TYPES type   = null;

            if (wizard != null)
            {
                objReturn = new List <REGISTRY_COHORT_DATA>();

                if (wizard.DOBMin != null)
                {
                    cohort = new REGISTRY_COHORT_DATA();
                    type   = STD_REGISTRY_COHORT_TYPESManager.GetItemByTableCode("CUSTOM", "DOBMIN");
                    if (type != null)
                    {
                        cohort.STD_REGISTRY_COHORT_TYPE_ID = type.COHORT_TYPE_ID;
                    }
                    cohort.CREATED = cohort.UPDATED = DateTime.Now;
                    cohort.VALUE   = wizard.DOBMin.Value.ToString("yyyy-MM-dd");

                    objReturn.Add(cohort);
                }

                if (wizard.DOBMax != null)
                {
                    cohort = new REGISTRY_COHORT_DATA();
                    type   = STD_REGISTRY_COHORT_TYPESManager.GetItemByTableCode("CUSTOM", "DOBMAX");
                    if (type != null)
                    {
                        cohort.STD_REGISTRY_COHORT_TYPE_ID = type.COHORT_TYPE_ID;
                    }
                    cohort.CREATED = cohort.UPDATED = DateTime.Now;
                    cohort.VALUE   = wizard.DOBMax.Value.ToString("yyyy-MM-dd");

                    objReturn.Add(cohort);
                }

                if (wizard.OEFOIFLocation != null)
                {
                    cohort = new REGISTRY_COHORT_DATA();
                    type   = STD_REGISTRY_COHORT_TYPESManager.GetItemByTableCode("CUSTOM", "OEFOIF");
                    if (type != null)
                    {
                        cohort.STD_REGISTRY_COHORT_TYPE_ID = type.COHORT_TYPE_ID;
                    }
                    cohort.CREATED       = cohort.UPDATED = DateTime.Now;
                    cohort.SELECTED_FLAG = wizard.OEFOIFLocation.GetValueOrDefault();

                    objReturn.Add(cohort);
                }

                if (!string.IsNullOrEmpty(wizard.CombatLocIds))
                {
                    string[] idList = wizard.CombatLocIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(wizard.EthnicityIds))
                {
                    string[] idList = wizard.EthnicityIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(wizard.GenderIds))
                {
                    string[] idList = wizard.GenderIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(wizard.MaritalStatusIds))
                {
                    string[] idList = wizard.MaritalStatusIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(wizard.RaceIds))
                {
                    string[] idList = wizard.RaceIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(wizard.ServiceIds))
                {
                    string[] idList = wizard.ServiceIds.Split(',');
                    if (idList != null)
                    {
                        foreach (string idS in idList)
                        {
                            int id = 0;
                            if (int.TryParse(idS, out id))
                            {
                                cohort = new REGISTRY_COHORT_DATA();
                                cohort.STD_REGISTRY_COHORT_TYPE_ID = id;
                                cohort.CREATED = cohort.UPDATED = DateTime.Now;

                                objReturn.Add(cohort);
                            }
                        }
                    }
                }
            }

            return(objReturn);
        }
Exemple #9
0
        public List <SPATIENT> CDW_GetData(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, RegistryWizard registryWizard)
        {
            List <SPATIENT> objReturn = null;

            SqlConnection  sConn    = null;
            SqlCommand     sCmd     = null;
            SqlDataAdapter sAdapter = null;
            DataSet        objTemp  = null;

            try
            {
                sConn = new SqlConnection(EtlConnectionString);

                sConn.Open();

                sCmd = new SqlCommand("CRSE.CDW_GETData_Wizard", sConn);
                sCmd.CommandTimeout = SqlCommandTimeout;
                sCmd.CommandType    = CommandType.StoredProcedure;
                sCmd.Parameters.AddWithValue("@StdRegistryId", registryWizard.StdRegistryId);
                sCmd.Parameters.AddWithValue("@CombatLocation", registryWizard.CombatLocIds);
                sCmd.Parameters.AddWithValue("@Ethnicity", registryWizard.EthnicityIds);
                sCmd.Parameters.AddWithValue("@Gender", registryWizard.GenderIds);

                if (registryWizard.OEFOIFLocation == null)
                {
                    sCmd.Parameters.AddWithValue("@OEFOIF", DBNull.Value);
                }
                else if (registryWizard.OEFOIFLocation.Value)
                {
                    sCmd.Parameters.AddWithValue("@OEFOIF", "1");
                }
                else
                {
                    sCmd.Parameters.AddWithValue("@OEFOIF", "0");
                }

                sCmd.Parameters.AddWithValue("@Race", registryWizard.RaceIds);
                sCmd.Parameters.AddWithValue("@ServiceBranch", registryWizard.ServiceIds);
                sCmd.Parameters.AddWithValue("@MaritalStatus", registryWizard.MaritalStatusIds);
                sCmd.Parameters.AddWithValue("@DOBMin", registryWizard.DOBMin);
                sCmd.Parameters.AddWithValue("@DOBMax", registryWizard.DOBMax);
                sCmd.Parameters.AddWithValue("@UserName", registryWizard.Username);
                sCmd.Parameters.AddWithValue("@Count", registryWizard.Count);

                objTemp  = new DataSet();
                sAdapter = new SqlDataAdapter(sCmd);

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                sAdapter.Fill(objTemp);
                LogManager.LogTiming(logDetails);
                CheckDataSet(objTemp);

                if (objTemp != null && objTemp.Tables.Count > 0 && objTemp.Tables[0].Rows.Count > 0)
                {
                    var myData = objTemp.Tables[0].AsEnumerable().Select(r => ParseReader(r));
                    if (myData != null)
                    {
                        objReturn = myData.ToList <SPATIENT>();
                    }
                }

                sConn.Close();
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            finally
            {
                if (sAdapter != null)
                {
                    sAdapter.Dispose();
                    sAdapter = null;
                }
                if (sCmd != null)
                {
                    sCmd.Dispose();
                    sCmd = null;
                }
                if (sConn != null)
                {
                    if (sConn.State != ConnectionState.Closed)
                    {
                        sConn.Close();
                    }
                    sConn.Dispose();
                    sConn = null;
                }
            }

            return(objReturn);
        }