Exemple #1
0
        /// <summary>
        /// get a dataset from the connection and a stored proc
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="strSPName"></param>
        /// <param name="ParamList"></param>
        /// <param name="lStatusCode"></param>
        /// <param name="strStatus"></param>
        /// <returns></returns>

        /*   public DataSet GetOracleDataSet(CDataConnection conn,
         *                                 string strSPName,
         *                                 CDataParameterList ParamList,
         *                                 out long lStatusCode,
         *                                 out string strStatus)
         * {
         *     lStatusCode = 0;
         *     strStatus = "";
         *     m_lStatusCode = 0;
         *     m_strStatus = "";
         *
         *     CDataUtils utils = new CDataUtils();
         *     string strAuditXML = "";
         *     strAuditXML += "<sp_name>" + strSPName + "</sp_name>";
         *
         *     //return null if no conn
         *     if (conn == null)
         *     {
         *         m_lStatusCode = 1;
         *         m_strStatus = "Unable to connect to data source, CDataConnection is null";
         *         lStatusCode = m_lStatusCode;
         *         strStatus = m_strStatus;
         *         return null;
         *     }
         *
         *     //create a new command object and set the command objects connection, text and type
         *     //must use OracleCommand or you cannot get back a ref cur out param which is how
         *     //we do things in medbase
         *     OracleCommand cmd = new OracleCommand(); // OleDbCommand();
         *     cmd.Connection = conn.GetOracleConnection();
         *     cmd.CommandText = strSPName;
         *     cmd.CommandType = CommandType.StoredProcedure;
         *
         *     //add the parameters from the parameter list to the command parameter list
         *     for (int i = 0; i < ParamList.Count; i++)
         *     {
         *         CDataParameter parameter = ParamList.GetItemByIndex(i);
         *         if (parameter != null)
         *         {
         *             //create a new oledb param from our param and add it to the list
         *             //this follows how we currently do it in medbase
         *             //TODO: get direction, length etc from the parameter not hard coded below
         *             OracleParameter oraParameter = new OracleParameter();
         *             oraParameter.ParameterName = parameter.ParameterName;
         *
         *             strAuditXML += "<" + oraParameter.ParameterName + ">";
         *
         *             //set the parameter value, default to string. Probably a better way than the
         *             //if then else, but this works and we can find it later,
         *             if (parameter.ParameterType == (int)DataParameterType.StringParameter)
         *             {
         *                 oraParameter.Value = parameter.StringParameterValue;
         *
         *                 //audit value
         *                 strAuditXML += parameter.StringParameterValue;
         *
         *             }
         *             else if (parameter.ParameterType == (int)DataParameterType.LongParameter)
         *             {
         *                 oraParameter.Value = parameter.LongParameterValue;
         *
         *                 //audit value
         *                 strAuditXML += Convert.ToString(parameter.LongParameterValue);
         *             }
         *             else if (parameter.ParameterType == (int)DataParameterType.DateParameter)
         *             {
         *                 oraParameter.Value = parameter.DateParameterValue;
         *
         *                 //audit value
         *                 strAuditXML += utils.GetDateAsString(parameter.DateParameterValue);
         *             }
         *             else if (parameter.ParameterType == (int)DataParameterType.CLOBParameter)
         *             {
         *                 oraParameter.Value = parameter.CLOBParameterValue;
         *
         *                 //audit value
         *                 strAuditXML += parameter.CLOBParameterValue;
         *             }
         *             else
         *             {
         *                 oraParameter.Value = parameter.StringParameterValue;
         *
         *                 //audit value
         *                 strAuditXML += parameter.StringParameterValue;
         *             }
         *
         *             strAuditXML += "</" + oraParameter.ParameterName + ">";
         *
         *             oraParameter.Direction = parameter.Direction;
         *             cmd.Parameters.Add(oraParameter);
         *         }
         *     }
         *
         *     //add in out params for stored proc, all sp's will return a status 1 = good, 0 = bad
         *     //status
         *     ParamList.AddParameter("po_nStatusCode", 0, ParameterDirection.Output);
         *     OracleParameter oraStatusParameter = new OracleParameter("po_nStatusCode",
         *                                                                OracleType.Int32);
         *     oraStatusParameter.Direction = ParameterDirection.Output;
         *     cmd.Parameters.Add(oraStatusParameter);
         *     //
         *     //comment
         *     ParamList.AddParameter("po_vStatusComment", "", ParameterDirection.Output);
         *     OracleParameter oraCommentParameter = new OracleParameter("po_vStatusComment",
         *                                                                 OracleType.VarChar,
         *                                                                 4000);
         *     oraCommentParameter.Direction = ParameterDirection.Output;
         *     cmd.Parameters.Add(oraCommentParameter);
         *     //
         *     //now add an out parameter to hold the ref cursor to the commands parameter list
         *     //returned ref cursor must always be named "RS" because OracleClient binds these
         *     //parameters by name, so you must name your parameter correctly
         *     //so the OracleParameter must be named the same thing.
         *     OracleParameter oraRSParameter = new OracleParameter( "RS",
         *                                                             OracleType.Cursor);
         *                                                            //OracleType.Cursor
         *     oraRSParameter.Direction = ParameterDirection.Output;
         *     cmd.Parameters.Add(oraRSParameter);
         *
         *     //create a new dataset to hold the conntent of the reference cursor
         *     m_DataSet = new DataSet();
         *
         *     //now audit the call.... ignore audit and get/set session values or
         *     //login is audited seperately
         *     if (conn.Audit)
         *     {
         *         if (strSPName.ToUpper().IndexOf("AUDIT") > -1 ||
         *             strSPName.ToUpper().IndexOf("GETSESSIONVALUE") > -1 ||
         *             strSPName.ToUpper().IndexOf("SETSESSIONVALUE") > -1 ||
         *             strSPName.ToUpper().IndexOf("LOGIN") > -1)
         *         {
         *             //ignore the audit
         *         }
         *         else
         *         {
         *             //audit the transaction
         *             CDataParameterList plistAudit = new CDataParameterList();
         *             plistAudit.AddInputParameter("pi_vSessionID", ParamList.GetItemByName("pi_vSessionID").StringParameterValue);
         *             plistAudit.AddInputParameter("pi_vSessionClientIP", ParamList.GetItemByName("pi_vSessionClientIP").StringParameterValue);
         *             plistAudit.AddInputParameter("pi_nUserID", ParamList.GetItemByName("pi_nUserID").LongParameterValue);
         *             plistAudit.AddInputParameter("pi_vSPName", strSPName);
         *             plistAudit.AddInputParameterCLOB("pi_clAuditXML", strAuditXML);
         *
         *             long lStat = 0;
         *             string strStat = "";
         *             conn.ExecuteOracleSP("PCK_FX_SEC.AuditTransaction",
         *                             plistAudit,
         *                             out lStat,
         *                             out strStat);
         *         }
         *     }
         *
         *     //create an adapter and fill the dataset. I like datasets because they are completely
         *     //disconnected and provide the most flexibility for later porting to a web service etc.
         *     //It could be argued that a data reader is faster and offers easier movement back and forth
         *     //through a dataset. But for the web and the fact that we work from lists
         *     //I think a dataset is best. Concept is similar to current medbase architecture
         *     try
         *     {
         *         OracleDataAdapter dataAdapter = new OracleDataAdapter(cmd);
         *         dataAdapter.Fill(m_DataSet);
         *     }
         *     catch (InvalidOperationException e)
         *     {
         *         m_strStatus = e.Message;
         *         m_lStatusCode = 1;
         *         m_DataSet = null;
         *         lStatusCode = m_lStatusCode;
         *         strStatus = m_strStatus;
         *     }
         *     catch (OracleException e)
         *     {
         *         m_strStatus = e.Message;
         *         m_lStatusCode = 1;
         *         m_DataSet = null;
         *         lStatusCode = m_lStatusCode;
         *         strStatus = m_strStatus;
         *     }
         *
         *     if (m_lStatusCode == 0)
         *     {
         *         //now read back out params into our list
         *         for (int i = 0; i < ParamList.Count; i++)
         *         {
         *             CDataParameter parameter = ParamList.GetItemByIndex(i);
         *             if (parameter != null)
         *             {
         *                 if (parameter.Direction == ParameterDirection.Output ||
         *                     parameter.Direction == ParameterDirection.InputOutput)
         *                 {
         *                     foreach (OracleParameter oP in cmd.Parameters)
         *                     {
         *                         if (oP.ParameterName.Equals(parameter.ParameterName))
         *                         {
         *                             if (parameter.ParameterType == (int)DataParameterType.StringParameter)
         *                             {
         *                                 if (oP.Value != null)
         *                                 {
         *                                     parameter.StringParameterValue = oP.Value.ToString();
         *                                 }
         *                             }
         *                             else if (parameter.ParameterType == (int)DataParameterType.LongParameter)
         *                             {
         *                                 if (oP.Value != null)
         *                                 {
         *                                     if (!oP.Value.ToString().Equals(""))
         *                                     {
         *                                         parameter.LongParameterValue = Convert.ToInt64(oP.Value);
         *                                     }
         *                                 }
         *                             }
         *                             else if (parameter.ParameterType == (int)DataParameterType.DateParameter)
         *                             {
         *                                 if (oP.Value != null)
         *                                 {
         *                                     if (!oP.Value.ToString().Equals(""))
         *                                     {
         *                                         parameter.DateParameterValue = Convert.ToDateTime(oP.Value);
         *                                     }
         *                                 }
         *                             }
         *                             else
         *                             {
         *                                 parameter.StringParameterValue = oP.Value.ToString();
         *                             }
         *                         }
         *                     }
         *                 }
         *             }
         *         }
         *
         *         //set status code and text
         *         CDataParameter pStatusCode = ParamList.GetItemByName("po_nStatusCode");
         *         if (pStatusCode != null)
         *         {
         *             m_lStatusCode = pStatusCode.LongParameterValue;
         *
         *         }
         *         CDataParameter pStatusComment = ParamList.GetItemByName("po_vStatusComment");
         *         if (pStatusComment != null)
         *         {
         *             m_strStatus = pStatusComment.StringParameterValue;
         *         }
         *     }
         *
         *     lStatusCode = m_lStatusCode;
         *     strStatus = m_strStatus;
         *
         *     return m_DataSet;
         * }*/

        /// <summary>
        /// get a dataset from the connection and a stored proc
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="strSPName"></param>
        /// <param name="ParamList"></param>
        /// <param name="lStatusCode"></param>
        /// <param name="strStatus"></param>
        /// <returns></returns>
        public DataSet GetOracleDataSet(CDataConnection conn,
                                        string strSPName,
                                        CDataParameterList ParamList,
                                        out long lStatusCode,
                                        out string strStatus)
        {
            lStatusCode   = 0;
            strStatus     = "";
            m_lStatusCode = 0;
            m_strStatus   = "";

            CDataUtils utils = new CDataUtils();

            //return null if no conn
            if (conn == null)
            {
                m_lStatusCode = 1;
                m_strStatus   = "Unable to connect to data source, CDataConnection is null";
                lStatusCode   = m_lStatusCode;
                strStatus     = m_strStatus;
                return(null);
            }

            //create a new command object and set the command objects connection, text and type
            //must use OracleCommand or you cannot get back a ref cur out param which is how
            //we do things in medbase
            OracleCommand cmd = new OracleCommand(); // OleDbCommand();

            cmd.Connection  = conn.GetOracleConnection();
            cmd.CommandText = strSPName;
            cmd.CommandType = CommandType.StoredProcedure;

            //add the parameters from the parameter list to the command parameter list
            for (int i = 0; i < ParamList.Count; i++)
            {
                CDataParameter parameter = ParamList.GetItemByIndex(i);
                if (parameter != null)
                {
                    //create a new oledb param from our param and add it to the list
                    //this follows how we currently do it in medbase
                    //TODO: get direction, length etc from the parameter not hard coded below
                    OracleParameter oraParameter = new OracleParameter();
                    oraParameter.ParameterName = parameter.ParameterName;

                    //set the parameter value, default to string. Probably a better way than the
                    //if then else, but this works and we can find it later,
                    if (parameter.ParameterType == (int)DataParameterType.StringParameter)
                    {
                        oraParameter.Value = parameter.StringParameterValue;
                    }
                    else if (parameter.ParameterType == (int)DataParameterType.LongParameter)
                    {
                        oraParameter.Value = parameter.LongParameterValue;
                    }
                    else if (parameter.ParameterType == (int)DataParameterType.DateParameter)
                    {
                        oraParameter.Value = parameter.DateParameterValue;
                    }
                    else if (parameter.ParameterType == (int)DataParameterType.CLOBParameter)
                    {
                        oraParameter.Value = parameter.CLOBParameterValue;
                    }
                    else
                    {
                        oraParameter.Value = parameter.StringParameterValue;
                    }

                    oraParameter.Direction = parameter.Direction;
                    cmd.Parameters.Add(oraParameter);
                }
            }

            //add in out params for stored proc, all sp's will return a status 1 = good, 0 = bad
            //status
            ParamList.AddParameter("po_nStatusCode", 0, ParameterDirection.Output);
            OracleParameter oraStatusParameter = new OracleParameter("po_nStatusCode",
                                                                     OracleType.Int32);

            oraStatusParameter.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(oraStatusParameter);
            //
            //comment
            ParamList.AddParameter("po_vStatusComment", "", ParameterDirection.Output);
            OracleParameter oraCommentParameter = new OracleParameter("po_vStatusComment",
                                                                      OracleType.VarChar,
                                                                      4000);

            oraCommentParameter.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(oraCommentParameter);
            //
            //now add an out parameter to hold the ref cursor to the commands parameter list
            //returned ref cursor must always be named "RS" because OracleClient binds these
            //parameters by name, so you must name your parameter correctly
            //so the OracleParameter must be named the same thing.
            OracleParameter oraRSParameter = new OracleParameter("RS",
                                                                 OracleType.Cursor);

            //OracleType.Cursor
            oraRSParameter.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(oraRSParameter);

            //create a new dataset to hold the conntent of the reference cursor
            m_DataSet = new DataSet();

            //create an adapter and fill the dataset. I like datasets because they are completely
            //disconnected and provide the most flexibility for later porting to a web service etc.
            //It could be argued that a data reader is faster and offers easier movement back and forth
            //through a dataset. But for the web and the fact that we work from lists
            //I think a dataset is best. Concept is similar to current medbase architecture
            try
            {
                OracleDataAdapter dataAdapter = new OracleDataAdapter(cmd);
                dataAdapter.Fill(m_DataSet);
            }
            catch (InvalidOperationException e)
            {
                m_strStatus   = e.Message;
                m_lStatusCode = 1;
                m_DataSet     = null;
                lStatusCode   = m_lStatusCode;
                strStatus     = m_strStatus;
            }
            catch (OracleException e)
            {
                m_strStatus   = e.Message;
                m_lStatusCode = 1;
                m_DataSet     = null;
                lStatusCode   = m_lStatusCode;
                strStatus     = m_strStatus;
            }

            if (m_lStatusCode == 0)
            {
                //now read back out params into our list
                for (int i = 0; i < ParamList.Count; i++)
                {
                    CDataParameter parameter = ParamList.GetItemByIndex(i);
                    if (parameter != null)
                    {
                        if (parameter.Direction == ParameterDirection.Output ||
                            parameter.Direction == ParameterDirection.InputOutput)
                        {
                            foreach (OracleParameter oP in cmd.Parameters)
                            {
                                if (oP.ParameterName.Equals(parameter.ParameterName))
                                {
                                    if (parameter.ParameterType == (int)DataParameterType.StringParameter)
                                    {
                                        if (oP.Value != null)
                                        {
                                            parameter.StringParameterValue = oP.Value.ToString();
                                        }
                                    }
                                    else if (parameter.ParameterType == (int)DataParameterType.LongParameter)
                                    {
                                        if (oP.Value != null)
                                        {
                                            if (!oP.Value.ToString().Equals(""))
                                            {
                                                parameter.LongParameterValue = Convert.ToInt64(oP.Value);
                                            }
                                        }
                                    }
                                    else if (parameter.ParameterType == (int)DataParameterType.DateParameter)
                                    {
                                        if (oP.Value != null)
                                        {
                                            if (!oP.Value.ToString().Equals(""))
                                            {
                                                parameter.DateParameterValue = Convert.ToDateTime(oP.Value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        parameter.StringParameterValue = oP.Value.ToString();
                                    }
                                }
                            }
                        }
                    }
                }

                //set status code and text
                CDataParameter pStatusCode = ParamList.GetItemByName("po_nStatusCode");
                if (pStatusCode != null)
                {
                    m_lStatusCode = pStatusCode.LongParameterValue;
                }
                CDataParameter pStatusComment = ParamList.GetItemByName("po_vStatusComment");
                if (pStatusComment != null)
                {
                    m_strStatus = pStatusComment.StringParameterValue;
                }
            }

            lStatusCode = m_lStatusCode;
            strStatus   = m_strStatus;

            //now audit the call if needed....
            if (conn.Audit)
            {
                long   lAuditStatusCode = 0;
                string strAuditStatus   = String.Empty;
                conn.AuditTransaction(strSPName,
                                      ParamList,
                                      lStatusCode,
                                      strStatus,
                                      out lAuditStatusCode,
                                      out strAuditStatus);
            }

            return(m_DataSet);
        }
Exemple #2
0
        /// <summary>
        /// get the selected id as a long
        /// </summary>
        /// <param name="ddl"></param>
        /// <returns></returns>
        public static long GetSelectedLongID(DropDownList ddl)
        {
            string strID = GetSelectedID(ddl);

            return(CDataUtils.ToLong(strID));
        }
Exemple #3
0
    /// <summary>
    /// US:1880 gets the most recent result, loops over all components and pieces together a string
    /// </summary>
    /// <param name="pid"></param>
    /// <param name="pidi"></param>
    /// <param name="strResult"></param>
    /// <returns></returns>
    public CStatus GetMostRecentResult(out string strResult)
    {
        strResult = string.Empty;

        //load the last result for this item
        CPatientItemData     pid  = new CPatientItemData(BaseMstr.BaseData);
        CPatientItemDataItem pidi = new CPatientItemDataItem();
        CStatus status            = pid.GetMostRecentPatientItemDI(PatientID, ItemID, out pidi);

        if (!status.Status)
        {
            return(status);
        }

        if (pidi.PatItemID < 1)
        {
            return(new CStatus());
        }

        DataSet dsComps = null;

        status = pid.GetPatientItemComponentDS(
            PatientID,
            pidi.PatItemID,
            pidi.ItemID,
            out dsComps);
        if (!status.Status)
        {
            return(status);
        }

        foreach (DataRow row in dsComps.Tables[0].Rows)
        {
            string strLabel = CDataUtils.GetDSStringValue(row, "item_component_label");
            string strValue = CDataUtils.GetDSStringValue(row, "component_value");
            string strUnits = CDataUtils.GetDSStringValue(row, "units");

            string strWarning = String.Empty;

            //question selection
            if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.QuestionSelection)
            {
                if (strValue == "1")
                {
                    strResult += "<font face=\"verdana,arial\" size=\"-1\">";
                    strResult += strLabel;
                    strResult += "<br /></font>";
                }
            }

            //question free text
            else if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.QuestionFreeText)
            {
                strResult += "<font face=\"verdana,arial\" size=\"-1\">";
                strResult += strLabel;
                strResult += ": ";
                strResult += strValue;
                strResult += "<br /></font>";
            }

            //lab
            else if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.Laboratory)
            {
                if (CDataUtils.IsNumeric(strValue))
                {
                    double dblLegalMin     = CDataUtils.GetDSDoubleValue(row, "LEGAL_MIN");
                    double dblLow          = CDataUtils.GetDSDoubleValue(row, "LOW");
                    double dblCritialLow   = CDataUtils.GetDSDoubleValue(row, "CRITICAL_LOW");
                    double dblHigh         = CDataUtils.GetDSDoubleValue(row, "HIGH");
                    double dblCriticalHigh = CDataUtils.GetDSDoubleValue(row, "CRITICAL_HIGH");
                    double dblLegalMax     = CDataUtils.GetDSDoubleValue(row, "LEGAL_MAX");

                    double dblValue = Convert.ToDouble(strValue);
                    if (dblValue < dblLegalMin)
                    {
                        strWarning = "LESS THAN LEGAL MIN";
                    }
                    else if (dblValue < dblCritialLow)
                    {
                        strWarning = "CRITICAL LOW";
                    }
                    else if (dblValue < dblLow)
                    {
                        strWarning = "LOW";
                    }
                    else if (dblValue > dblLegalMax)
                    {
                        strWarning = "GREATER THAN LEGAL MAX";
                    }
                    else if (dblValue > dblCriticalHigh)
                    {
                        strWarning = "CRITICAL HIGH";
                    }
                    else if (dblValue > dblHigh)
                    {
                        strWarning = "HIGH";
                    }
                }

                strResult += "<font face=\"verdana,arial\" size=\"-1\">";
                strResult += strLabel;
                strResult += ": ";
                strResult += strValue;
                strResult += " ";
                strResult += strUnits;
                strResult += " ";
                strResult += strWarning;
                strResult += "<br /></font>";

                string strLegalMin     = CDataUtils.GetDSStringValue(row, "LEGAL_MIN");
                string strLow          = CDataUtils.GetDSStringValue(row, "LOW");
                string strCritialLow   = CDataUtils.GetDSStringValue(row, "CRITICAL_LOW");
                string strHigh         = CDataUtils.GetDSStringValue(row, "HIGH");
                string strCriticalHigh = CDataUtils.GetDSStringValue(row, "CRITICAL_HIGH");
                string strLegalMax     = CDataUtils.GetDSStringValue(row, "LEGAL_MAX");

                strResult += "<font face=\"verdana,arial\" size=\"-2\">";
                strResult += "(Legal Min: " + strLegalMin + " ";
                strResult += "Low: " + strLow + " ";
                strResult += "Critical Low: " + strCritialLow + " ";
                strResult += "High: " + strHigh + " ";
                strResult += "Critical High: " + strCriticalHigh + " ";
                strResult += "Legal Max: " + strLegalMax + ") ";
                strResult += "<br /><br /></font>";
            }
        }

        return(new CStatus());
    }
Exemple #4
0
    /// <summary>
    /// logs the user in and returns info about the user. TODO: this will
    /// probably be heavily modified later...
    /// </summary>
    /// <param name="strUserName"></param>
    /// <param name="strPassword"></param>
    /// <param name="ds"></param>
    /// <param name="lLoginUserID"></param>
    /// <param name="lloginRoleID"></param>
    /// <param name="lStatusCode"></param>
    /// <param name="strStatus"></param>
    /// <returns></returns>
    public CStatus GetLoginUserDS(string strUserName,
                                  string strPassword,
                                  out DataSet ds,
                                  out long lLoginUserID,
                                  out long lloginRoleID)
    {
        //initialize parameters
        ds = null;

        lLoginUserID = 0;
        lloginRoleID = 0;
        ds           = null;

        //create a status object and check for valid dbconnection
        CStatus status = new CStatus();

        status = DBConnValid();
        if (!status.Status)
        {
            return(status);
        }

        //load the paramaters list

        //load standard paramaters
        CParameterList pList = new CParameterList(SessionID,
                                                  ClientIP,
                                                  UserID);

        //load additional paramaters
        pList.AddInputParameter("pi_vUserName", strUserName);
        pList.AddInputParameter("pi_vPassword", strPassword);

        //get the dataset
        CDataSet cds = new CDataSet();

        status = cds.GetOracleDataSet(DBConn,
                                      "PCK_USR.GetLoginUserRS",
                                      pList,
                                      out ds);

        if (status.StatusCode != k_STATUS_CODE.Success)
        {
            return(status);
        }

        if (ds == null)
        {
            status.StatusCode    = k_STATUS_CODE.Failed;
            status.StatusComment = "Invalid Username/Password";
            status.Status        = false;

            return(status);
        }

        if (status.Status)
        {
            lLoginUserID = CDataUtils.GetDSLongValue(ds, "USER_ID");
            lloginRoleID = CDataUtils.GetDSLongValue(ds, "USER_ROLE_ID");
        }

        if (lLoginUserID < 1)
        {
            status.StatusCode    = k_STATUS_CODE.Failed;
            status.StatusComment = "Invalid Username/Password";
            status.Status        = false;

            return(status);
        }

        return(status);
    }
    //runs when user presses the master save button in the app
    protected void MasterSave()
    {
        if (BaseMstr.IsPatientLocked)
        {
            string strBMComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> <b>Read-Only Access</b>: ";
            strBMComment          += "The patient's record is in use by " + Session["PAT_LOCK_PROVIDER"].ToString() + ".";
            BaseMstr.StatusCode    = 1;
            BaseMstr.StatusComment = strBMComment;
            ShowSysFeedback();
            return;
        }

        DataSet ds = (DataSet)Session["ENCOUNTERDS"];

        CDataUtils utils = new CDataUtils();

        long lCaseClosed      = utils.GetLongValueFromDS(ds, "CASE_CLOSED");
        long lEncounterClosed = utils.GetLongValueFromDS(ds, "CLOSED");

        bNoteLocked = (lEncounterClosed == 1);

        CSoapp soapp = new CSoapp();

        if (tabContSOAP.ActiveTab == btnSubjective)//subjective
        {
            if (lROSubjective > (long)RightMode.ReadOnly)
            {
                UpdateSubjectiveNote();
            }

            if (lROSubjective == (long)RightMode.ReadOnly)
            {
                BaseMstr.StatusCode    = 1;
                BaseMstr.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section.";
            }
        }

        if (tabContSOAP.ActiveTab == btnObjective)//objective
        {
            if (lROObjective > (long)RightMode.ReadOnly)
            {
                UpdateObjectiveNote();
            }

            if (lROObjective == (long)RightMode.ReadOnly)
            {
                BaseMstr.StatusCode    = 1;
                BaseMstr.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section.";
            }
        }

        if (tabContSOAP.ActiveTab == btnAssessment)//assessment
        {
            if (lROAssessment > (long)RightMode.ReadOnly)
            {
                long lDLC = 0;
                UpdateAssessmentNote();
            }

            if (lROAssessment == (long)RightMode.ReadOnly)
            {
                BaseMstr.StatusCode    = 1;
                BaseMstr.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section.";
            }
        }

        //TIU SUPPORT
        //they saved the note so update the text that
        //will go to tiu
        if (BaseMstr.APPMaster.TIU)
        {
            GetTIUNote();
        }

        // save session time
        soapp.updtSessionTime(BaseMstr,
                              BaseMstr.SelectedEncounterID,
                              BaseMstr.SelectedTreatmentID,
                              "N/A",
                              txtSessionTime.Text);

        //soapp.updtTreatmentPlan(BaseMstr,
        //                        BaseMstr.SelectedPatientID,
        //                        BaseMstr.SelectedEncounterID,
        //                        BaseMstr.SelectedTreatmentID);

        //get the data for this encounter
        Session["ENCOUNTERDS"] = enc.GetEncounterDS(BaseMstr,
                                                    BaseMstr.SelectedPatientID,
                                                    BaseMstr.SelectedTreatmentID,
                                                    BaseMstr.SelectedEncounterID);

        DisableSOAPNote();

        ShowSysFeedback();
    }
Exemple #6
0
    /// <summary>
    /// US:834 Connect to the database using info from the
    /// app.config file will also load a CData object for use
    /// by other data classes and setup the connectsion to MDWS and
    /// return a mdwsSOAPClient for accessing MDWD methods
    /// </summary>
    /// <param name="lStatusCode"></param>
    /// <param name="strStatus"></param>
    /// <returns></returns>
    public CStatus Connect(out CData data,
                           out EmrSvcSoapClient mdwsSOAPClient)
    {
        data           = null;
        mdwsSOAPClient = null;

        //initialize parameters
        string strConnString = String.Empty;
        bool   bAudit        = false;

        //get the connection info from the web.config
        CStatus status = new CStatus();

        status = GetConnectionInfo(out strConnString, out bAudit);
        if (!status.Status)
        {
            return(status);
        }

        //Connect to the db, if successful caller can use the
        //CDataConnection::Conn property for access to the DB connection
        status = Connect(strConnString, bAudit);
        if (!status.Status)
        {
            //todo handle error
            return(status);
        }

        //create a new base data object
        //todo: more later
        //
        //get the ipaddress
        string      strIPAddress = String.Empty;
        string      strHost      = System.Net.Dns.GetHostName();
        IPHostEntry host;

        host = Dns.GetHostEntry(strHost);
        foreach (IPAddress ip in host.AddressList)
        {
            strIPAddress = ip.ToString();
        }

        //build the base data item used by data classes
        string strNow = CDataUtils.GetDateTimeAsString(DateTime.Now);

        data = new CData(this,
                         strIPAddress,
                         0,
                         "VAPPCTCOMM_" + strNow,
                         null,
                         true);

        //comm data class
        CVAPPCTCommData commData = new CVAPPCTCommData(data);

        //login to MDWS
        long     lUserID = 0;
        CMDWSOps ops     = new CMDWSOps(data);

        //uid and pwd need come from config file:
        //TODO: they need to be encrypted
        status = ops.MDWSLogin(ConfigurationSettings.AppSettings["MDWSEmrSvcUID"],
                               ConfigurationSettings.AppSettings["MDWSEmrSvcPWD"],
                               CDataUtils.ToLong(ConfigurationSettings.AppSettings["MDWSEmrSvcSiteList"]),
                               out lUserID,
                               out mdwsSOAPClient);
        if (!status.Status)
        {
            commData.SaveCommEvent("MDWSLogin_FAILED",
                                   status.StatusComment);
            return(status);
        }

        //set the user id on the CData object
        data.UserID = lUserID;

        //create the session so that we can call stored proc
        CUserData ud             = new CUserData(data);
        string    strFXSessionID = String.Empty;

        status = ud.CreateFXSession(out strFXSessionID);
        if (!status.Status)
        {
            commData.SaveCommEvent("MDWSSessionCreate_FAILED",
                                   status.StatusComment);
            return(status);
        }

        return(status);
    }
    protected void btnChangePWD_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtNewP.Text) ||
            string.IsNullOrEmpty(txtVNewP.Text) ||
            string.IsNullOrEmpty(txtOldP.Text))
        {
            Master.StatusCode    = 1;
            Master.StatusComment = "Password entries are empty!";
            ShowSysFeedback();
            return;
        }

        if (txtNewP.Text != txtVNewP.Text)
        {
            Master.StatusCode    = 1;
            Master.StatusComment = "New Password and Verify Password do not match!";
            ShowSysFeedback();
            return;
        }

        if (pnlSecQuestions.Visible)
        {
            if (cboQuestion1.SelectedIndex < 1 ||
                cboQuestion2.SelectedIndex < 1 ||
                txtAnswer1.Text.Trim().Length < 1 ||
                txtAnswer2.Text.Trim().Length < 1)
            {
                Master.StatusCode    = 1;
                Master.StatusComment = "Please select two challenge questions and enter the corresponding answers!";
                ShowSysFeedback();
                return;
            }
        }

        long   lStatusCode      = 0;
        string strStatusComment = string.Empty;

        //validate the password rules
        CSec sec = new CSec();

        if (!sec.ValidateUserAccountRules(Master, (string)Session["USER_NAME"], txtNewP.Text))
        {
            Master.StatusCode    = lStatusCode;
            Master.StatusComment = strStatusComment;
            ShowSysFeedback();
            return;
        }

        //all good so far, change the pwd, login and redirect
        lStatusCode = sec.ChangePassword(Master, (string)Session["USER_NAME"], txtOldP.Text, txtNewP.Text);

        if (lStatusCode != 0)
        {
            Master.StatusCode    = lStatusCode;
            Master.StatusComment = strStatusComment;
            ShowSysFeedback();
            return;
        }

        //update security challenge questions & answers
        CSecQuestions secquest = new CSecQuestions(Master);

        if (!secquest.UpdateSecQuestions(Convert.ToInt32(cboQuestion1.SelectedValue),
                                         txtAnswer1.Text.Trim(),
                                         Convert.ToInt32(cboQuestion2.SelectedValue),
                                         txtAnswer2.Text.Trim(),
                                         -1,
                                         String.Empty))
        {
            Master.StatusCode    = lStatusCode;
            Master.StatusComment = strStatusComment;
            ShowSysFeedback();
            return;
        }

        //if we get here we have successfully changed the password
        //now login with the new account
        if (sec.Login(Master, (string)Session["USER_NAME"], txtNewP.Text) != 0)
        {
            Master.StatusCode    = lStatusCode;
            Master.StatusComment = strStatusComment;
            ShowSysFeedback();
            return;
        }

        Master.StatusCode    = lStatusCode;
        Master.StatusComment = strStatusComment;

        CPatient   pat   = new CPatient();
        CDataUtils utils = new CDataUtils();
        DataSet    dsPat = pat.GetPatientIDRS(Master, Master.FXUserID);

        Master.SelectedPatientID = utils.GetDSStringValue(dsPat, "PATIENT_ID");

        CPatientEvent evt = new CPatientEvent(Master);

        evt.CompletedEvent(1);


        ShowSysFeedback();

        //successful login so clear txt boxes
        lblUID.Text          = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        txtOldP.Text         = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        txtNewP.Text         = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        txtVNewP.Text        = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        lblUID.Text          = string.Empty;
        txtOldP.Text         = string.Empty;
        txtNewP.Text         = string.Empty;
        txtVNewP.Text        = string.Empty;
        Session["USER_NAME"] = null;

        //set a session variable with the login time
        Session["SESSION_INITIATED"] = DateTime.Now;

        //redirect, we are now logged in
        //Master.Response.Redirect("portal_revamp.aspx");
        Master.Response.Redirect("portal_start.aspx");
    }
Exemple #8
0
    /// <summary>
    /// US:894
    /// US:899
    /// user clicked the search button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OnClickSearch(object sender, EventArgs e)
    {
        Master.ClearStatusInfo();

        CParameterList pListStatus = null;
        CStatus        status      = ValidateUserInput(out pListStatus);

        if (!status.Status)
        {
            Master.ShowStatusInfo(status.StatusCode, pListStatus);
            return;
        }

        //set the date from and date to
        DateTime dtFrom = CDataUtils.GetNullDate();
        DateTime dtTo   = CDataUtils.GetNullDate();

        if (chkFilterByEvent.Checked)
        {
            dtFrom = CDataUtils.GetDate(txtFromDate.Text);
            dtTo   = CDataUtils.GetDate(txtToDate.Text);
        }

        //checklist id
        long lChecklistID = -1;

        if (chkChecklist.Checked)
        {
            lChecklistID = ChecklistID;
        }

        //set the checklist Status
        long lChecklistStatusID = -1;

        if (chkChecklistStatus.Checked &&
            ddlChecklistStatus.SelectedItem != null &&
            ddlChecklistStatus.SelectedValue != "-1")
        {
            lChecklistStatusID = CDataUtils.ToLong(ddlChecklistStatus.SelectedValue);
        }

        ThreadType = k_MULTI_PAT_THREAD_TYPE.Logic;


        //service
        long lServiceID = -1;

        if (chkFilterByCLService.Checked)
        {
            if (ddlFilterByService.SelectedItem != null)
            {
                if (ddlFilterByService.SelectedValue != "-1")
                {
                    lServiceID = CDataUtils.ToLong(ddlFilterByService.SelectedValue);
                }
            }
        }

        //has checklist service
        bool bHasChecklistService = false;

        if (ddlFilterByService.SelectedIndex > 0)
        {
            if (chkFilterByCLService.Checked)
            {
                bHasChecklistService = true;
            }
        }

        //get patient checklist ids
        GetPatCLIDs(
            dtFrom,
            dtTo,
            lChecklistID,
            lChecklistStatusID,
            lServiceID);

        ProcessingCancelled = false;

        //thread off the multi patient search
        status = ThreadMultiPatient();

        //handle a bad status that comes back with no message
        if (!status.Status)
        {
            if (String.IsNullOrEmpty(status.StatusComment))
            {
                status.StatusComment = "An error occured while processing records!";
            }
        }

        //show the status
        Master.ShowStatusInfo(status);
    }
Exemple #9
0
    /// <summary>
    /// loads the gridview after we are done updating the checklists
    /// </summary>
    protected CStatus LoadGridView()
    {
        //done processing the logic so now load the gridview
        //set the date from and date to
        DateTime dtFrom = CDataUtils.GetNullDate();
        DateTime dtTo   = CDataUtils.GetNullDate();

        if (chkFilterByEvent.Checked)
        {
            dtFrom = CDataUtils.GetDate(txtFromDate.Text);
            dtTo   = CDataUtils.GetDate(txtToDate.Text);
        }
        MPEventStartDate = dtFrom;
        MPEventEndDate   = dtTo;

        //checklist id
        long lChecklistID = -1;

        if (chkChecklist.Checked)
        {
            lChecklistID = ChecklistID;
        }
        MPChecklistID = lChecklistID;

        //set the checklist Status
        long lChecklistStatusID = -1;

        if (chkChecklistStatus.Checked &&
            ddlChecklistStatus.SelectedItem != null &&
            ddlChecklistStatus.SelectedValue != "-1")
        {
            lChecklistStatusID = CDataUtils.ToLong(ddlChecklistStatus.SelectedValue);
        }
        MPChecklistStatusID = lChecklistStatusID;

        long lChecklistServiceID = -1;

        if (chkFilterByCLService.Checked &&
            ddlFilterByService.SelectedItem != null &&
            ddlFilterByService.SelectedValue != "-1")
        {
            lChecklistServiceID = CDataUtils.ToLong(ddlFilterByService.SelectedValue);
        }
        MPChecklistServiceID = lChecklistServiceID;

        CStatus status = GetPatients(dtFrom,
                                     dtTo,
                                     lChecklistID,
                                     lChecklistStatusID,
                                     lChecklistServiceID);

        if (!status.Status)
        {
            return(status);
        }

        AddColumns();

        gvMultiPatientView.EmptyDataText = "No result(s) found.";
        gvMultiPatientView.DataSource    = MultiPatients;
        gvMultiPatientView.DataBind();

        //now that the grid is loaded check for new versions...

        //get all the patients for the mulitpatient
        string strCLIDs  = string.Empty;
        string strPatIDs = string.Empty;

        CPatientData pat = new CPatientData(Master.BaseData);
        DataSet      dsMultiPatientSearch = null;

        status = pat.GetMultiPatientSearchDS(
            MPEventStartDate,
            MPEventEndDate,
            MPChecklistID,
            MPChecklistStatusID,
            MPChecklistServiceID,
            out dsMultiPatientSearch);
        if (!status.Status)
        {
            return(status);
        }

        //patient ids
        CDataUtils.GetDSDelimitedData(
            dsMultiPatientSearch,
            "PATIENT_ID",
            ",",
            out strPatIDs);
        strPatIDs = "," + strPatIDs;

        //pat cl ids
        CDataUtils.GetDSDelimitedData(
            dsMultiPatientSearch,
            "CHECKLIST_ID",
            ",",
            out strCLIDs);

        strCLIDs = "," + strCLIDs;

        CPatChecklistData dta  = new CPatChecklistData(Master.BaseData);
        DataSet           dsCL = null;

        status = dta.GetOutOfDatePatCLDS(
            MPEventStartDate,
            MPEventEndDate,
            MPChecklistID,
            MPChecklistStatusID,
            strPatIDs,
            strCLIDs,
            out dsCL);
        if (!status.Status)
        {
            return(status);
        }

        btnUpdateCLVersion.Enabled = (!CDataUtils.IsEmpty(dsCL)) ? true : false;
        //EnableVersionUpdate = (!CDataUtils.IsEmpty(dsCL)) ? true : false;
        upLookup.Update();

        return(new CStatus());
    }
Exemple #10
0
    protected void GetPatientDetails()
    {
        trEditInfo.Visible = true;
        trReadInfo.Visible = false;

        Session["PATIENT_DOB"]    = null;
        Session["PATIENT_AGE"]    = null;
        Session["PATIENT_GENDER"] = null;
        Session["PATIENT_WEIGHT"] = null;
        Session["PATIENT_HEIGHT"] = null;

        CDataUtils utils   = new CDataUtils();
        CPatient   patient = new CPatient();
        CEncounter enc     = new CEncounter();

        DataSet dsPat = patient.GetPatientDemographicsDS(Master);

        if (dsPat != null)
        {
            Master.PatientDOB    = Convert.ToDateTime(utils.GetDateValueAsStringFromDS(dsPat, "DOB"));
            Master.PatientAge    = utils.GetLongValueFromDS(dsPat, "PATIENT_AGE");
            Master.PatientGender = utils.GetStringValueFromDS(dsPat, "GENDER");
        }

        DataSet dsEnc = enc.GetPatientDetailsDS(Master, Master.SelectedEncounterID);

        if (dsEnc != null)
        {
            long lPatHeight = utils.GetLongValueFromDS(dsEnc, "PATIENT_HEIGHT");
            if (lPatHeight > 0)
            {
                int iFeet   = (int)lPatHeight / 12;
                int iInches = (int)lPatHeight % 12;

                lblPatHeight.Text      = iFeet.ToString() + "' - " + iInches.ToString() + "\"";
                htxtHeightFeet.Value   = iFeet.ToString();
                htxtHeightInches.Value = iInches.ToString();

                Master.PatientHeight = lPatHeight;

                foreach (ListItem li in cboFeet.Items)
                {
                    if (li.Value == iFeet.ToString())
                    {
                        li.Selected = true;
                    }
                }

                foreach (ListItem li in cboInches.Items)
                {
                    if (li.Value == iInches.ToString())
                    {
                        li.Selected = true;
                    }
                }
            }
            else
            {
                lblPatHeight.Text      = String.Empty;
                htxtHeightFeet.Value   = String.Empty;
                htxtHeightInches.Value = String.Empty;

                cboFeet.SelectedIndex   = 0;
                cboInches.SelectedIndex = 0;

                Master.PatientHeight = 0;
            }

            long lPatWeight = utils.GetLongValueFromDS(dsEnc, "PATIENT_WEIGHT");
            if (lPatWeight > 0)
            {
                txtWeight.Text = lPatWeight.ToString();

                lblPatWeight.Text      = lPatWeight.ToString() + " pounds";
                htxtWeightPounds.Value = lPatWeight.ToString();

                Master.PatientWeight = lPatWeight;
            }
            else
            {
                txtWeight.Text = String.Empty;

                lblPatWeight.Text      = String.Empty;
                htxtWeightPounds.Value = String.Empty;

                Master.PatientWeight = 0;
            }

            if (lPatHeight > 0 && lPatWeight > 0)
            {
                trEditInfo.Visible = false;
                trReadInfo.Visible = true;
                HasWeightHeight    = true;
            }
            else
            {
                trEditInfo.Visible = true;
                trReadInfo.Visible = false;
                HasWeightHeight    = false;
            }
        }
    }