Esempio n. 1
0
        private string GetIQCareURL(String FacilityID, String ptnpk)
        {
            String url        = "";
            String encryptURL = "";
            String cryptURL   = "";

            // Prompt for Connect config if missing
            try
            {
                DataRow theDr = (DataRow)theObject.ReturnObject(Entity.getconnString(clsGbl.xmlPath), ClsUtility.theParams, "SELECT top 1 [IQServer],[IQPort],[IQUserName], u.UserID, [IQPassword],[IQTechnicalArea], [IQProtocol] FROM aa_IQCareConnect i inner join mst_user u on i.IQUserName = u.UserName WHERE i.DeleteFlag is Null And i.Active = 1", ClsUtility.ObjectEnum.DataRow, serverType);


                String IQCareUserName = theDr["IQUserName"].ToString().Trim();
                String UserID         = theDr["UserID"].ToString().Trim();
                String IQCarePassword = ClsUtility.Decrypt(theDr["IQPassword"].ToString().Trim());
                String TechnicalArea  = theDr["IQTechnicalArea"].ToString().Trim();
                String server         = theDr["IQServer"].ToString().Trim();
                String protocol       = theDr["IQProtocol"].ToString().Trim();
                String port           = theDr["IQPort"].ToString().Trim();


                cryptURL   = "Ptn_pk=" + ptnpk + "&UserName="******"&Password="******"&technicalArea=" + TechnicalArea + "&UserID=" + UserID + "&FacilityID=" + FacilityID + "";
                encryptURL = ClsUtility.Encrypt(cryptURL);

                //Format the URL
                url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
                return(url);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower() == "there is no row at position 0.")
                {
                    //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
                return(null);
            }
        }
Esempio n. 2
0
        private void activateSatelliteCombo()
        {
            if (emrType == "iqcare")
            {
                lblFacility.Visible = true;
                cboFacility.Visible = true;

                string sql = "Select FacilityName, FacilityID FROM mst_Facility WHERE DeleteFlag = 0";
                Entity en  = new Entity();

                DataRow dr = (DataRow)en.ReturnObject(Entity.GetConnString(), ClsUtility.theParams
                                                      , "Select ConnString,DBase,DBName From aa_Database", ClsUtility.ObjectEnum.DataRow, serverType);
                string emrConnString = ClsUtility.Decrypt(dr["ConnString"].ToString());

                DataTable dt = (DataTable)en.ReturnObject(emrConnString, ClsUtility.theParams
                                                          , sql, ClsUtility.ObjectEnum.DataTable, serverType);
                DataTableReader dtr = dt.CreateDataReader();
                cboFacility.Items.Clear();
                while (dtr.Read())
                {
                    cboFacility.Items.Add(dtr[0].ToString());
                }
            }
            else if (emrType == "cpad")
            {
                lblFacility.Visible = true;
                cboFacility.Visible = true;

                string    sql = "Select facilityname, facilityid FROM cpad.mst_facility WHERE configured = true";
                Entity    en  = new Entity();
                DataTable dt  = (DataTable)en.ReturnObject(Entity.GetConnString(), ClsUtility.theParams
                                                           , sql, ClsUtility.ObjectEnum.DataTable, serverType);
                DataTableReader dtr = dt.CreateDataReader();
                cboFacility.Items.Clear();
                while (dtr.Read())
                {
                    cboFacility.Items.Add(dtr[0].ToString());
                }
            }
        }
Esempio n. 3
0
        public void runReport(Hashtable reportParameters, DataTable satellites, bool bySatellite, bool lineLists)
        {
            //MessageBox.Show(ReportSaveName(ClsUtility.theParams));
            string reportName = reportParameters["ReportName"].ToString();
            //string xlTemplate = clsGbl.tmpFolder + reportParameters["ExcelTemplateName"].ToString();
            string xlTemplate = "Templates\\" + reportParameters["ExcelTemplateName"].ToString();
            string xlSheet    = reportParameters["ExcelWorksheetName"].ToString();
            string groupName  = reportParameters["GroupName"].ToString();
            Entity en         = new Entity();
            string sp         = "pr_GetReportData_IQTools";

            string fldName = String.Empty;

            Hashtable rName = new Hashtable();

            rName.Add(1, "@ReportName");
            rName.Add(2, "Varchar");
            rName.Add(3, reportName);

            DataSet ds = (DataSet)en.ReturnObject(iqtoolsConnString, rName
                                                  , sp, ClsUtility.ObjectEnum.DataSet, serverType);
            int             numberOfQueries = ds.Tables[1].Rows.Count;
            DataTableReader queries         = ds.Tables[1].CreateDataReader();
            DataTable       XLMapping       = ds.Tables[2];
            DataTable       ReportLineLists = ds.Tables[4];
            //string newF = clsGbl.tmpFolder + reportName + ".xlsx";
            //string newF = "IQTools Reports\\" + reportName + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString() + ".xlsx";
            string myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string newF       = myDocsPath + "\\IQTools Reports\\" + reportName + "\\" + clsGbl.loggedInUser.FacilityName + " - " + reportName + " - " + ReportSaveName(ClsUtility.theParams) + ".xlsx";
            //+ DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString() + ".xlsx";
            //MessageBox.Show(newF);
            //newF = newF.Replace("/", "-").Replace(":", "-");
            DataRow r        = ds.Tables[0].Rows[0];
            string  password = r["Password"].ToString();

            try
            {
                if (File.Exists(newF))
                {
                    File.Delete(newF);
                }

                var xl      = new FileInfo(xlTemplate);
                var newFile = new FileInfo(newF);
                newFile.Directory.Create();

                using (var package = new ExcelPackage(newFile, xl))
                {
                    ExcelWorksheet ews          = package.Workbook.Worksheets[xlSheet];
                    ExcelWorksheet blank        = package.Workbook.Worksheets.Add("Blank", ews);
                    DataTable      reportErrors = new DataTable("Errors");
                    reportErrors.Columns.Add("QUERY NAME");
                    reportErrors.Columns.Add("ERROR MESSAGE");
                    while (queries.Read())
                    {
                        try
                        {
                            DataTable       queryResults       = executeQuery(queries["qryDefinition"].ToString().Trim(), string.Empty);
                            DataTableReader queryResultsReader = queryResults.CreateDataReader();
                            XLMapping.DefaultView.RowFilter = "qryID = " + queries["qryID"].ToString();
                            DataTable mapping = XLMapping.DefaultView.ToTable();
                            mapQueryResults(queryResults, mapping, ews);
                        }
                        catch (Exception ex)
                        {
                            DataRow newError = reportErrors.NewRow();
                            newError["QUERY NAME"]    = queries["qryName"].ToString();
                            newError["ERROR MESSAGE"] = ex.Message;
                            reportErrors.Rows.Add(newError);
                        }
                    }
                    if (bySatellite)
                    {
                        DataTableReader sdr = satellites.CreateDataReader();
                        while (sdr.Read())
                        {
                            string         newWorksheet = sdr["FacilityName"].ToString();
                            ExcelWorksheet newWS        = package.Workbook.Worksheets.Add(newWorksheet, blank);
                            newWS.TabColor = System.Drawing.Color.Yellow;
                            queries        = ds.Tables[1].CreateDataReader();
                            while (queries.Read())
                            {
                                try
                                {
                                    DataTable queryResults = executeQuery(queries["qryDefinition"].ToString().Trim(), newWorksheet);
                                    XLMapping.DefaultView.RowFilter = "qryID = " + queries["qryID"].ToString();
                                    DataTable mapping = XLMapping.DefaultView.ToTable();
                                    mapQueryResults(queryResults, mapping, newWS);
                                }
                                catch (Exception ex)
                                {
                                    DataRow newError = reportErrors.NewRow();
                                    newError["QUERY NAME"]    = queries["qryName"].ToString();
                                    newError["ERROR MESSAGE"] = ex.Message;
                                    reportErrors.Rows.Add(newError);
                                }
                            }
                            if (password.Trim() != string.Empty)
                            {
                                newWS.Protection.IsProtected = true;
                                newWS.Protection.SetPassword(ClsUtility.Decrypt(password));
                            }
                        }
                    }
                    if (lineLists)
                    {
                        MapReportLineList(ReportLineLists, package);
                    }
                    mapErrors(reportErrors, package);
                    package.Workbook.Worksheets.Delete(blank);
                    //package.SaveAs(newFile);
                    if (password.Trim() != string.Empty)
                    {
                        ews.Protection.IsProtected = true;
                        ews.Protection.SetPassword(ClsUtility.Decrypt(password));
                    }
                    package.Save();

                    package.Dispose();
                }
                System.Diagnostics.Process.Start(newF);
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }
Esempio n. 4
0
        private string GetIQCareURL()
        {
            //Entity en = new Entity();
            //ClsUtility.Init_Hashtable();

            //String url = "";
            //String encryptURL = "";
            //String cryptURL = "";
            //try
            //{
            //    string IQCareUserName = clsGbl.loggedInUser.UserName;
            //    string UserID = clsGbl.loggedInUser.UserID.ToString();
            //    string IQCarePassword = ClsUtility.Decrypt(clsGbl.loggedInUser.Password);
            //    string TechnicalArea = "1";//theDr["IQTechnicalArea"].ToString().Trim(); Not used
            //    string server = "localhost";//theDr["IQServer"].ToString().Trim();
            //    string protocol = "http";//theDr["IQProtocol"].ToString().Trim();
            //    string port = "58789";//theDr["IQPort"].ToString().Trim();
            //    string FacilityID = clsGbl.loggedInUser.FacilityID.ToString();//"755";

            //    cryptURL = String.Format("Ptn_Pk={0}&UserName={1}&Password={2}&technicalArea={3}&UserID={4}&FacilityID={5}"
            //        , clsGbl.EMRPatientPK, IQCareUserName, IQCarePassword, TechnicalArea, UserID, FacilityID);
            //    encryptURL = ClsUtility.Encrypt(cryptURL);

            //    //Format the URL
            //    //url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
            //    url = String.Format("{0}://{1}:{2}/frmConnect.aspx?enc={3}"
            //        ,protocol,server,port,encryptURL);
            //    return url;
            //}
            //catch (Exception ex)
            //{
            //    if (ex.Message.ToLower() == "there is no row at position 0.")
            //    {
            //        //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
            //    }
            //    else
            //    {
            //        MessageBox.Show(ex.Message);
            //    }
            //    return null;
            //}

            string url        = string.Empty;
            string encryptURL = string.Empty;
            string cryptURL   = string.Empty;
            string page       = string.Empty;

            //if (Convert.ToDouble(clsGbl.EmrVersion) < Convert.ToDouble(3.6))
            //{
            //page = "frmConnect.aspx";
            //}
            //else
            page = "frmConnect36.aspx";
            try
            {
                string IQCareUserName = clsGbl.loggedInUser.UserName;
                string UserID         = clsGbl.loggedInUser.UserID.ToString();
                string IQCarePassword = ClsUtility.Decrypt(clsGbl.loggedInUser.Password);
                string TechnicalArea  = "1"; //Not used
                //string server = clsGbl.EMRIPAddress;
                string server     = "localhost";
                string protocol   = "http";
                string port       = "80";
                string FacilityID = clsGbl.loggedInUser.FacilityID.ToString();

                cryptURL = String.Format("Ptn_Pk={0}&UserName={1}&Password={2}&technicalArea={3}&UserID={4}&FacilityID={5}"
                                         , clsGbl.EMRPatientPK, IQCareUserName, IQCarePassword, TechnicalArea, UserID, FacilityID);
                encryptURL = ClsUtility.Encrypt(cryptURL);

                //Format the URL
                //url = protocol + "://" + server + ":" + port + "/iqcare/frmConnect.aspx?enc=" + encryptURL;
                url = String.Format("{0}://{1}:{2}/iqcare/{3}?enc={4}"
                                    , protocol, server, port, page, encryptURL);
                return(url);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToLower() == "there is no row at position 0.")
                {
                    //MessageBox.Show ( "Connection to IQCare Has Not Been Configured. Please Enter Your Connection Details Under The Administration Page", "IQTools", MessageBoxButtons.OK, MessageBoxIcon.Question );
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
                return(null);
            }
        }
Esempio n. 5
0
        private bool loginEMR(string emr, string userName, string password, string facilityName)
        {
            string emrConnString = "";

            ClsUtility.Init_Hashtable();
            Entity en = new Entity();

            try
            {
                if (emr.ToLower() == "iqcare")
                {
                    DataRow dr = (DataRow)en.ReturnObject(Entity.GetConnString(), ClsUtility.theParams
                                                          , "Select ConnString,DBase,DBName From aa_Database", ClsUtility.ObjectEnum.DataRow, serverType);
                    emrConnString = ClsUtility.Decrypt(dr["ConnString"].ToString());
                    string sPassword = ClsUtility.Encrypt(password);
                    string sSQL      = "SELECT top 1 a.userID, a.UserName, a.Password, a.UserFirstName, a.UserLastName, c.GroupName, f.FacilityID, f.PosID MFLCode FROM " +
                                       "(Select FacilityID, PosID FROM mst_Facility WHERE FacilityName = '" + facilityName + "') f, " +
                                       "mst_user a " +
                                       "INNER JOIN dbo.lnk_UserGroup b ON a.UserID = b.UserID " +
                                       "INNER JOIN dbo.mst_Groups c ON b.GroupID = c.GroupID " +
                                       "WHERE a.DeleteFlag = 0 AND a.UserName = '******' AND Password = '******'";
                    try
                    {
                        dr = (DataRow)en.ReturnObject(emrConnString, ClsUtility.theParams, sSQL, ClsUtility.ObjectEnum.DataRow, serverType);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is no row at position 0"))
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                            return(false);
                        }
                    }
                    if (dr.Table.Rows.Count >= 1)
                    {
                        clsGbl.loggedInUser.UserID       = Convert.ToInt16(dr["userID"]);
                        clsGbl.loggedInUser.UserName     = dr["UserName"].ToString();
                        clsGbl.loggedInUser.Password     = dr["Password"].ToString();
                        clsGbl.loggedInUser.FirstName    = dr["UserFirstName"].ToString();
                        clsGbl.loggedInUser.LastName     = dr["UserLastName"].ToString();
                        clsGbl.loggedInUser.Group        = dr["GroupName"].ToString();
                        clsGbl.loggedInUser.FacilityID   = Convert.ToInt16(dr["FacilityID"]);
                        clsGbl.loggedInUser.FacilityName = facilityName;
                        clsGbl.loggedInUser.MFLCode      = dr["MFLCode"].ToString();
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader);
                        return(false);
                    }
                }
                else if (emr.ToLower() == "cpad")
                {
                    DataRow dr        = null;
                    string  sPassword = ClsUtility.Encrypt(password);
                    string  sSQL      = "SELECT a.userID, a.UserName, a.Password, a.firstname, a.lastname, b.facilityname, a.salt FROM cpad.mst_user a" +
                                        ",(select a.facilityname from cpad.mst_facility a where configured = true limit 1)b " +
                                        "WHERE a.DeleteFlag = false AND a.username = '******' limit 1";
                    try
                    {
                        dr = (DataRow)en.ReturnObject(Entity.getconnString(clsGbl.xmlPath), ClsUtility.theParams
                                                      , sSQL, ClsUtility.ObjectEnum.DataRow, serverType);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is no row at position 0"))
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                        else
                        {
                            MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                            return(false);
                        }
                    }
                    if (dr.Table.Rows.Count >= 1)
                    {
                        string salt = dr["salt"].ToString();
                        string p    = password + salt;
                        string s    = ClsUtility.GetSHA1Hash(p);
                        if (s == dr["password"].ToString())
                        {
                            clsGbl.loggedInUser.UserID       = Convert.ToInt16(dr["userID"]);
                            clsGbl.loggedInUser.UserName     = dr["UserName"].ToString();
                            clsGbl.loggedInUser.Password     = dr["Password"].ToString();
                            clsGbl.loggedInUser.FirstName    = dr["FirstName"].ToString();
                            clsGbl.loggedInUser.LastName     = dr["LastName"].ToString();
                            clsGbl.loggedInUser.FacilityName = dr["facilityname"].ToString();
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Assets.Messages.InvalidUser, Assets.Messages.ErrorHeader);
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Assets.Messages.ErrorHeader);
                return(false);
            }
        }