Exemplo n.º 1
0
        public static void CreateIctusDataTMPCollection2()
        {
            List <ictusDataTMP> ictusDataList = IctusDBManager.GetAllictusDataTMP();

            if (ictusDataList != null && ictusDataList.Count() > 0)
            {
                ncLog.Message("Nº rows ictusDataList:" + ictusDataList.Count());
                int cont = 0;

                foreach (ictusDataTMP iter in ictusDataList)
                {
                    ictusDataTMP2 newIctusDataTMP = new ictusDataTMP2(iter);

                    if (!newIctusDataTMP.IsOk())
                    {
                        ncLog.Error("Unable to create newIctusDataTMP2 for pacienteID:" + iter.pacienteID);
                    }
                    else
                    {
                        if (!IctusDBManager.NewIctusDataTMP2(newIctusDataTMP))
                        {
                            ncLog.Error("Unable to insert newIctusDataTMP2 for pacienteID:" + newIctusDataTMP.pacienteID);
                        }
                        else
                        {
                            ++cont;
                            ncLog.Message("Inserted ictusDataTMP2 nº:" + cont);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void DifferentUSVB()
        {
            List <ictusDataTMP> ictusDataTMPList = IctusDBManager.GetAllictusDataTMP();

            if (ictusDataTMPList != null && ictusDataTMPList.Count() > 0)
            {
                List <string> usbList = ictusDataTMPList.Select(x => x.usvb_nombre).Distinct().ToList();


                int svbN  = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("SVB") || x.usvb_nombre.Contains("ACU")).Count();
                int umeN  = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("UME") || x.usvb_nombre.Contains("UVI") || x.usvb_nombre.Contains("VIR")).Count();
                int heliN = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("HELI")).Count();

                ncLog.Message("DifferentUSVB::svbN:" + svbN + " - umeN:" + umeN + "heliN:" + heliN);

                Dictionary <int, List <ictusDataTMP> > svbMpa  = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("SVB") || x.usvb_nombre.Contains("ACU")).GroupBy(x => x.fecha.Year).ToDictionary(y => y.Key, y => y.ToList());
                Dictionary <int, List <ictusDataTMP> > umeMap  = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("UME") || x.usvb_nombre.Contains("UVI") || x.usvb_nombre.Contains("VIR")).GroupBy(x => x.fecha.Year).ToDictionary(y => y.Key, y => y.ToList());
                Dictionary <int, List <ictusDataTMP> > heliMap = ictusDataTMPList.Where(x => x.usvb_nombre.Contains("HELI")).GroupBy(x => x.fecha.Year).ToDictionary(y => y.Key, y => y.ToList());

                string msg = string.Empty;

                foreach (KeyValuePair <int, List <ictusDataTMP> > iter in svbMpa)
                {
                    msg += "\r\nAño:" + iter.Key + " - Nº Registrsos:" + iter.Value.Count();
                }

                ncLog.Message("SVBMap::" + msg);

                msg = string.Empty;

                foreach (KeyValuePair <int, List <ictusDataTMP> > iter in umeMap)
                {
                    msg += "\r\nAño:" + iter.Key + " - Nº Registrsos:" + iter.Value.Count();
                }

                ncLog.Message("umeMap::" + msg);

                msg = string.Empty;

                foreach (KeyValuePair <int, List <ictusDataTMP> > iter in heliMap)
                {
                    msg += "\r\nAño:" + iter.Key + " - Nº Registrsos:" + iter.Value.Count();
                }

                ncLog.Message("heliMap::" + msg);

                int a = 0;
            }
        }
Exemplo n.º 3
0
        public static bool LoaumeDataTMP()
        {
            bool result = false;

            try
            {
                umeDataTMPList = IctusDBManager.GetAllUmeDataTMP();

                if (umeDataTMPList != null && umeDataTMPList.Count() != 0)
                {
                    result = true;
                }
            }
            catch (Exception exp)
            {
                ncLog.Exception("LoaumeDataTMP::" + exp.Message);
            }

            return(result);
        }
Exemplo n.º 4
0
        private void btUpdateDB_Click(object sender, EventArgs e)
        {
            IctusDBManager.DropIctusData();

            ncLog.Message("ClearDB::Ictus data collection has been deleted");

            List <ictusData> ictusDataColletion = IctusDBManager.GetAllictusData();

            if (ictusDataColletion != null && ictusDataColletion.Count() > 0)
            {
                ncLog.Warning("LoadDB::ictusData collections is not empty. You must remove it!! Nº documents:" + ictusDataColletion.Count());
                return;
            }

            ictusDataColletion.Clear();

            foreach (KeyValuePair <long, List <umeDataTMP> > iter in Util.ictusDataMap)
            {
                ictusData newIctusdata = new ictusData(iter.Key, iter.Value);
                if (newIctusdata.IsOk())
                {
                    ictusDataColletion.Add(newIctusdata);
                }
            }

            ncLog.Message("LoadDB::Nº rows ictusDataColletion:[" + ictusDataColletion.Count() + "]");


            foreach (ictusData iter in ictusDataColletion)
            {
                if (!IctusDBManager.NewIctusData(iter))
                {
                    ncLog.Error("LoadDB::Unable to insert new ictusData for pacienteID:" + iter.pacienteID);
                }
            }

            List <ictusData> ictusDataInDB = IctusDBManager.GetAllictusData();

            ncLog.Message("LoadDB::Nº rows inserted:[" + ictusDataInDB.Count() + "]");
        }
Exemplo n.º 5
0
        public static bool LoadHospitalList()
        {
            bool result = false;

            try
            {
                hospitalList = IctusDBManager.GetAllHospitales();

                if (hospitalList != null && hospitalList.Count() != 0)
                {
                    result = true;
                }
                else
                {
                    ncLog.Error("LoadHospitalList::Unable to load Hospitales from database");
                }
            }
            catch (Exception exp)
            {
                ncLog.Exception("LoadHospitalList::" + exp.Message);
            }

            return(result);
        }
Exemplo n.º 6
0
        public static void InfoDifferentCIE()
        {
            Dictionary <long, List <umeDataTMP> > result = new Dictionary <long, List <umeDataTMP> >();

            try
            {
                List <umeDataTMP> umeDataTMPList = IctusDBManager.GetAllUmeDataTMP();

                if (umeDataTMPList == null || umeDataTMPList.Count() == 0)
                {
                    ncLog.Error("InfoDifferentCIE::Null or empty umeDataTMPList!!");
                    return;
                }

                string msg = "ID,CIE1,Responsable1,CIE2, Responsable2";

                Dictionary <long, List <umeDataTMP> > umeDataTMPMap = umeDataTMPList.GroupBy(x => x.inc_id).ToDictionary(y => y.Key, y => y.ToList());

                if (umeDataTMPMap != null && umeDataTMPMap.Count() != 0)
                {
                    foreach (KeyValuePair <long, List <umeDataTMP> > iter in umeDataTMPMap)
                    {
                        long pacienteID = iter.Key;

                        List <string> cieGroup = iter.Value.Select(x => x.cie_codigo).Distinct().ToList();

                        if (cieGroup != null && cieGroup.Count() > 1)
                        {
                            msg += "\r\n" + pacienteID;

                            int size    = cieGroup.Count;
                            int counter = 1;

                            foreach (string iterCie in cieGroup)
                            {
                                if (size == 3)
                                {
                                    if (counter == 2)
                                    {
                                        ++counter;
                                        continue;
                                    }
                                }

                                umeDataTMP dataFound = iter.Value.Where(x => x.cie_codigo == iterCie).FirstOrDefault();

                                msg += "," + iterCie + "," + dataFound.dim_responsable_nombre;

                                ++counter;
                            }

                            msg += "," + iter.Value.FirstOrDefault().inc_sello_temporal.Year;
                        }
                    }
                }

                ncLog.Message(msg);
            }
            catch (Exception exp)
            {
                ncLog.Exception("InfoDifferentCIE::" + exp.Message);
            }
        }
Exemplo n.º 7
0
        private void btClearDB_Click(object sender, EventArgs e)
        {
            IctusDBManager.DropIctusData();

            ncLog.Message("ClearDB::Ictus data collection has been deleted");
        }
Exemplo n.º 8
0
        private void btLoadZBS_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
                    openFileDialog.FilterIndex      = 2;
                    openFileDialog.RestoreDirectory = true;

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        //Get the path of specified file
                        string filePath = openFileDialog.FileName;
                        txtZBSPath.Text = filePath;

                        ncLog.Message("ExcelPath:" + filePath);

                        Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

                        Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing);

                        Worksheet sheet = (Worksheet)wb.Sheets["ZBS"];

                        Range excelRange = sheet.UsedRange;

                        int nRows = excelRange.Rows.Count;

                        ncLog.Message("Nº Rows:" + nRows);

                        foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows)
                        {
                            int rowNumber = row.Row;

                            if (rowNumber != 1) //Headers
                            {
                                string[] arrayAG = Util.GetRange("A" + rowNumber + ":G" + rowNumber + "", sheet);

                                zbs newZBS = new zbs(arrayAG);

                                if (!newZBS.IsOk())
                                {
                                    ncLog.Error("LoadZBS::Unable to create ZBS object row number:" + rowNumber);
                                    continue;
                                }

                                if (IctusDBManager.NewZBS(newZBS))
                                {
                                    ncLog.Message("LoadZBS::Inserted row number:" + rowNumber);
                                }
                                else
                                {
                                    ncLog.Message("LoadZBS::Unable to insert row number:" + rowNumber);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                ncLog.Exception("LoadZBS::" + exp.Message);
            }
        }
Exemplo n.º 9
0
        //private void btLoadDatosUME_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if(!Util.LoadDataMasterList())
        //        {
        //            ncLog.Error("LoadDatosUME::Unable to load data master in memory. We can NOT continue!!!");
        //            return;
        //        }


        //        using (OpenFileDialog openFileDialog = new OpenFileDialog())
        //        {
        //            //openFileDialog.InitialDirectory = "c:\\";
        //            openFileDialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
        //            openFileDialog.FilterIndex = 2;
        //            openFileDialog.RestoreDirectory = true;

        //            if (openFileDialog.ShowDialog() == DialogResult.OK)
        //            {
        //                //Get the path of specified file
        //                string filePath = openFileDialog.FileName;
        //                txtDatosUME.Text = filePath;

        //                ncLog.Message("ExcelPath:" + filePath);

        //                Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

        //                Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
        //                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
        //                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
        //                        Type.Missing, Type.Missing);


        //                int sheetsNumber = wb.Sheets.Count; //11 => from 11 to 1

        //                //From sheetsNumber to 1 => From 2008 to 2018
        //                for (int iter = sheetsNumber; iter >= 1; --iter)
        //                {
        //                    Worksheet sheet = (Worksheet)wb.Sheets[iter];

        //                    Range excelRange = sheet.UsedRange;

        //                    int nRows = excelRange.Rows.Count;

        //                    ncLog.Message("Sheet:[" + sheet.Name + "] - Nº Rows:" + nRows);

        //                    foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows)
        //                    {
        //                        int rowNumber = row.Row;

        //                        if (rowNumber != 1) //Headers
        //                        {

        //                            string[] arrayAO = GetRange("A" + rowNumber + ":O" + rowNumber + "", sheet);

        //                            umeData newUmeData = new umeData(arrayAO);

        //                            if (!newUmeData.IsOk())
        //                            {
        //                                ncLog.Error("LoadUMEData::Unable to create USVB object row number:" + rowNumber);
        //                                continue;
        //                            }

        //                            if (IctusDBManager.NewUmeData(newUmeData))
        //                            {
        //                                ncLog.Message("LoadUMEData::Inserted row number:" + rowNumber);
        //                            }
        //                            else
        //                            {
        //                                ncLog.Message("LoadUMEData::Unable to insert row number:" + rowNumber);
        //                            }
        //                        }

        //                    }

        //                }

        //            }
        //        }
        //    }
        //    catch (Exception exp)
        //    {
        //        ncLog.Exception("LoadHospitales::" + exp.Message);
        //    }
        //}

        private void btLoadDatosUME_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Util.LoadDataMasterList())
                {
                    ncLog.Error("LoadDatosUME::Unable to load data master in memory. We can NOT continue!!!");
                    return;
                }


                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    //openFileDialog.InitialDirectory = "c:\\";
                    openFileDialog.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
                    openFileDialog.FilterIndex      = 2;
                    openFileDialog.RestoreDirectory = true;

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        //Get the path of specified file
                        string filePath = openFileDialog.FileName;
                        txtDatosUME.Text = filePath;

                        ncLog.Message("ExcelPath:" + filePath);

                        Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

                        Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                        Type.Missing, Type.Missing);


                        int sheetsNumber = wb.Sheets.Count; //11 => from 11 to 1

                        sheetsNumber = sheetsNumber - 2;    //Because 2008 and 2009 are inserted yet

                        //From sheetsNumber to 1 => From 2008 to 2018
                        for (int iter = sheetsNumber; iter >= 1; --iter)
                        {
                            Worksheet sheet = (Worksheet)wb.Sheets[iter];

                            Range excelRange = sheet.UsedRange;

                            int nRows = excelRange.Rows.Count;

                            ncLog.Message("Sheet:[" + sheet.Name + "] - Nº Rows:" + nRows);

                            foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows)
                            {
                                int rowNumber = row.Row;

                                if (rowNumber != 1) //Headers
                                {
                                    string[] arrayAO = Util.GetRange("A" + rowNumber + ":O" + rowNumber + "", sheet);

                                    umeDataTMP newUmeData = new umeDataTMP(arrayAO);

                                    if (newUmeData.inc_id == Int64.MinValue)
                                    {
                                        ncLog.Error("LoadUMEDataTMP::Unable to create umeDataTMP document for id:" + arrayAO[0]);
                                        continue;
                                    }

                                    if (IctusDBManager.NewUmeDataTMP(newUmeData))
                                    {
                                        ncLog.Message("LoadUMEDataTMP::Inserted row number:" + rowNumber);
                                    }
                                    else
                                    {
                                        ncLog.Message("LoadUMEDataTMP::Unable to insert row number:" + rowNumber);
                                    }
                                }
                            }

                            //iter = 1; //For only year 2008
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                ncLog.Exception("LoadHospitales::" + exp.Message);
            }
        }