Exemplo n.º 1
0
    /// <summary>
    /// US:840
    /// login to MDWS and transfer user to the checklist db
    /// </summary>
    /// <param name="strUID"></param>
    /// <param name="strPWD"></param>
    /// <param name="lUserID"></param>
    /// <param name="mdwsSOAPClient"></param>
    /// <returns></returns>
    public CStatus MDWSLogin(
        string strUID,
        string strPWD,
        long lSiteID,
        out long lUserID,
        out EmrSvcSoapClient mdwsSOAPClient)
    {
        //status
        lUserID        = 0;
        mdwsSOAPClient = null;

        //login to mdws
        UserTO  toUser = null;
        CStatus status = Login(
            strUID,
            strPWD,
            lSiteID,
            out toUser,
            out mdwsSOAPClient);

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

        //transfer the user data to the checklist db
        if (status.StatusCode != k_STATUS_CODE.NothingToDo)
        {
            CMDWSTransfer transfer = new CMDWSTransfer(this);
            status = transfer.TransferUser(toUser, out lUserID);
            if (!status.Status)
            {
                mdwsSOAPClient.disconnect();
                mdwsSOAPClient = null;
                return(status);
            }
        }

        //note: BaseMster.MDWSEmrSvcClient gets cached in session state
        //if the login was successful
        //if we get here we are logged in

        return(new CStatus());
    }
Exemplo n.º 2
0
    /// <summary>
    /// US:1883 US:834 loops through the checklist and moves data from MDWS to
    /// the VAPPCT database
    /// </summary>
    /// <returns></returns>
    public CStatus ProcessOpenChecklistItems()
    {
        //get a connection to the vappct database and MDWS
        CData            data           = null;
        EmrSvcSoapClient mdwsSOAPClient = null;
        CCommDBConn      conn           = null;
        CStatus          status         = GetConnections(
            out conn,
            out data,
            out mdwsSOAPClient);

        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            WriteEvent(data, "GetConnections", status.StatusComment);
            return(status);
        }

        //-----------------------------------------------------
        //do the work TODO: threading will come later
        //-----------------------------------------------------

        //1. get all of the open checklists
        DataSet         dsChecklistItems = null;
        CVAPPCTCommData commData         = new CVAPPCTCommData(data);

        status = commData.GetOpenPatChecklistItemDS(out dsChecklistItems);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            //write the event to the event table
            WriteEvent(data, "GetOpenPatChecklistItemDS", status.StatusComment);
            return(status);
        }

        //refresh the checklist items
        //status = RefreshPatientCheckList(
        //    conn,
        //    data,
        //    dsChecklistItems);
        status = CommRefreshPatientCheckList(dsChecklistItems);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            //write the event to the event table
            WriteEvent(data, "RefreshPatientCheckList", status.StatusComment);
            return(status);
        }

        //it could have taken a really long time for the first set
        //to process, so we reset the connections here before moving
        //to the collection items.

        //reset the data
        data = null;

        //close the current mdws connection
        mdwsSOAPClient.disconnect();
        mdwsSOAPClient = null;

        //close the connection to the database
        conn.Close();
        //conn = null;

        //get a connection to the vappct database and MDWS
        status = GetConnections(
            out conn,
            out data,
            out mdwsSOAPClient);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            WriteEvent(data, "GetConnections", status.StatusComment);
            return(status);
        }

        CVAPPCTCommData commData2 = new CVAPPCTCommData(data);

        //refresh the checklist collection items
        DataSet dsCLCollectionItems = null;

        status = commData2.GetOpenPatCLCollectionItemDS(out dsCLCollectionItems);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            //write the event to the event table
            WriteEvent(data, "GetOpenPatCLCollectionItemDS", status.StatusComment);
            return(status);
        }

        //refresh the checklist items
        //status = RefreshPatientCheckList(
        //    conn,
        //    data,
        //    dsCLCollectionItems);
        status = CommRefreshPatientCheckList(dsCLCollectionItems);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            //write the event to the event table
            WriteEvent(data, "RefreshPatientCheckList", status.StatusComment);
            return(status);
        }

        //-----------------------------------------------------
        //end of work
        //-----------------------------------------------------
        //cleanup: close the database connection, disconnect from MDWS
        conn.Close();
        mdwsSOAPClient.disconnect();

        return(status);
    }
Exemplo n.º 3
0
    /// <summary>
    /// US:1945 US:852 US:1883 US:834 helper to process checklist items, called from multiple places
    /// </summary>
    /// <param name="conn"></param>
    /// <param name="data"></param>
    /// <param name="dsChecklistItems"></param>
    /// <returns></returns>
    public CStatus CommRefreshPatientCheckList(DataSet dsChecklistItems)
    {
        CStatus status = new CStatus();

        //get a connection to the vappct database and MDWS
        CData            data           = null;
        EmrSvcSoapClient mdwsSOAPClient = null;
        CCommDBConn      conn           = null;

        status = GetConnections(
            out conn,
            out data,
            out mdwsSOAPClient);
        if (!status.Status)
        {
            conn.Close();
            mdwsSOAPClient.disconnect();

            WriteEvent(data, "GetConnections", status.StatusComment);
            return(status);
        }

        //this class is used to do all transfers
        //from MDWS to the VAPPCT database
        CMDWSTransfer xfer = new CMDWSTransfer(data);

        //if we do too many items at once the connection to MDWS will
        //timeout. This is only an issue when running from communicator
        //because there can be a large number of items.
        //
        //current item we are processing
        int nCount = 0;
        //number of items to process before we re-connect
        int nBatch = 50;

        //2.loop over all items and process each one
        foreach (DataTable table in dsChecklistItems.Tables)
        {
            foreach (DataRow dr in table.Rows)
            {
                nCount++;

                //if ncount is >= batch then reconnect and reset
                if (nCount >= nBatch)
                {
                    //reset the data
                    data = null;

                    //close the current mdws connection
                    mdwsSOAPClient.disconnect();
                    mdwsSOAPClient = null;

                    //close the connection to the database
                    conn.Close();
                    //conn = null;

                    //get a connection to the vappct database and MDWS
                    status = GetConnections(
                        out conn,
                        out data,
                        out mdwsSOAPClient);
                    if (!status.Status)
                    {
                        conn.Close();
                        mdwsSOAPClient.disconnect();

                        WriteEvent(data, "GetConnections", status.StatusComment);
                        return(status);
                    }

                    //reset the transfer object to use the new connection
                    xfer = null;
                    xfer = new CMDWSTransfer(data);

                    //reset the record count
                    nCount = 1;
                }

                //process the item
                if (dr["item_type_id"] != null)
                {
                    switch (Convert.ToInt32(dr["item_type_id"]))
                    {
                    case (int)k_ITEM_TYPE_ID.Collection:
                        //WriteEvent(data, "Collection", "Collection");
                        break;

                    case (int)k_ITEM_TYPE_ID.Laboratory:
                        //WriteEvent(data, "Laboratory", "Laboratory");
                        status = ProcessLab(data, xfer, dr);
                        if (!status.Status)
                        {
                            //write the start event to the event table
                            WriteEvent(data, "ProcessLab", status.StatusComment);
                            //dont return or other records will not update return status;
                        }
                        break;

                    case (int)k_ITEM_TYPE_ID.QuestionFreeText:
                        //WriteEvent(data, "QuestionFreeText", "QuestionFreeText");
                        break;

                    case (int)k_ITEM_TYPE_ID.QuestionSelection:
                        //WriteEvent(data, "QuestionSelection", "QuestionSelection");
                        break;

                    case (int)k_ITEM_TYPE_ID.NoteTitle:
                        status = ProcessNoteTitle(data, xfer, dr);
                        if (!status.Status)
                        {
                            //write the start event to the event table
                            WriteEvent(data, "ProcessNoteTitle", status.StatusComment);
                            //dont return or other records will not process return status;
                        }
                        break;
                    }
                }
            }
        }

        return(status);
    }
Exemplo n.º 4
0
    /// <summary>
    /// US:840
    /// helper to connect and login to MDWS
    /// </summary>
    /// <param name="strUN"></param>
    /// <param name="strPA"></param>
    /// <param name="toUser"></param>
    /// <param name="mdws"></param>
    /// <returns></returns>
    protected CStatus Login(
        string strUN,
        string strPA,
        long lSiteID,
        out UserTO toUser,
        out EmrSvcSoapClient mdws)
    {
        toUser = null;
        mdws   = null;

        //mdws
        try
        {
            mdws = new EmrSvcSoapClient("EmrSvcSoap");
        }
        catch (Exception e)
        {
            return(new CStatus(false, k_STATUS_CODE.Failed, e.Message));
        }

        //initialize sitelist and context
        //todo: using appsettings unencrypted
        string strSiteList = Convert.ToString(lSiteID);
        //site id is now passed in because user chooses it from
        //the login dialog.
        //ConfigurationSettings.AppSettings["MDWSEmrSvcSiteList"];

        string strContext = ConfigurationSettings.AppSettings["MDWSEmrSvcContext"];

        try
        {
            //connect to MDWS
            DataSourceArray dsa = mdws.connect(strSiteList);
            if (dsa == null || dsa.fault != null && dsa.fault.message != "You are already connected to that site")
            {
                if (dsa.fault != null)
                {
                    return(new CMDWSStatus(dsa.fault));
                }
                else
                {
                    return(new CStatus(false, k_STATUS_CODE.Failed, "An undefined error occurred while connecting to MDWS!"));
                }
            }

            //disconnect
            mdws.disconnect();

            //try to re-connect
            dsa = mdws.connect(strSiteList);
            if (dsa == null || dsa.fault != null)
            {
                //return new CMDWSStatus(dsa.fault);
                return(new CStatus(false, k_STATUS_CODE.Failed, "TODO"));
            }

            //login to mdws
            toUser = mdws.login(
                strUN,
                strPA,
                strContext);

            //todo: just a reminder....
            strUN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
            strPA = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
            if (toUser == null || toUser.fault != null)
            {
                //return new CMDWSStatus(toUser.fault);
                return(new CStatus(false, k_STATUS_CODE.Failed, ErrorMessages.ERROR_LOGIN));
            }
        }
        catch (Exception e)
        {
            return(new CStatus(false, k_STATUS_CODE.Failed, e.Message));
        }

        return(new CStatus());
    }