/// <summary> /// US:1882 Check to see if we have a valid MDWS connection /// </summary> /// <returns></returns> public CStatus CheckMDWSConnection() { //performing a simple operation in MDWS //to make sure we are still connected. CStatus status = new CStatus(); //todo: forcing a disconnect for testing //GetMDWSSOAPClient().disconnect(); CMDWSOps ops = new CMDWSOps(this); long lCount = 0; status = ops.GetMDWSSecurityKeys(UserID, false, out lCount); if (!status.Status) { long lUserID = 0; EmrSvcSoapClient mdwsSOAPClient = null; status = ops.MDWSLogin(MDWSUID.ToString(), MDWSPWD.ToString(), SiteID, out lUserID, out mdwsSOAPClient); } return(status); }
/// <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()); }
/// <summary> /// US:834 gets a connection to the vappct oracle database and MDWS /// </summary> /// <param name="data"></param> /// <param name="mdwsSOAPClient"></param> /// <returns></returns> public CStatus GetConnections(out CCommDBConn conn, out CData data, out EmrSvcSoapClient mdwsSOAPClient) { //connect to the oracle db and MDWS data = null; mdwsSOAPClient = null; conn = new CCommDBConn(); CStatus status = conn.Connect(out data, out mdwsSOAPClient); if (!status.Status) { //write the start event to the event table WriteEvent(data, "Connect", status.StatusComment); return(status); } return(status); }
/// <summary> /// US:840 /// helper to determine if MDWS is valid /// </summary> /// <returns></returns> public CStatus IsMDWSValid() { //check the connection to MDWS, will attempt to reconnect //if necessary CAppUser appUser = new CAppUser(this); //get the users security keys, this is how we test the connection UserSecurityKeyArray usk = GetMDWSSOAPClient().getUserSecurityKeys(appUser.UserID.ToString()); if (usk != null && usk.fault != null) { long lUserID = 0; EmrSvcSoapClient mdwsSOAPClient = null; CStatus status = MDWSLogin( appUser.MDWSUID.ToString(), appUser.MDWSPWD.ToString(), appUser.SiteID, out lUserID, out mdwsSOAPClient); if (!status.Status) { return(status); } } /*todo: debug * else * { * string strkeys = String.Empty; * foreach (UserSecurityKeyTO to in usk.keys) * { * strkeys += to.name + "\r\n"; * } * * strkeys += ""; * }*/ return(new CStatus()); }
/// <summary> /// gets the soap client so we can talk to mdws /// </summary> /// <returns></returns> EmrSvcSoapClient GetMDWSSOAPClient() { //this is used from communicator also and we //have no "Session" in communicator if (WebSession != null) { if (WebSession["EmrSvcSoapClient"] == null) { m_EmrSvcSoapClient = new EmrSvcSoapClient("EmrSvcSoap"); WebSession["EmrSvcSoapClient"] = m_EmrSvcSoapClient; } return((EmrSvcSoapClient)WebSession["EmrSvcSoapClient"]); } else { if (m_EmrSvcSoapClient == null) { m_EmrSvcSoapClient = new EmrSvcSoapClient("EmrSvcSoap"); } return(m_EmrSvcSoapClient); } }
/// <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); }
/// <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); }
/// <summary> /// US:840 US:1882 US:836 US:866 /// login to the checklist tool /// </summary> /// <param name="strUID"></param> /// <param name="strPWD"></param> /// <returns></returns> public CStatus Login(string strUID, string strPWD, long lSiteID) { //status CStatus status = new CStatus(); long lUserID = 0; LoggedIn = false; //login to mdws if we are connecting to mdws if (MDWSTransfer) { EmrSvcSoapClient mdwsSOAPClient = null; CMDWSOps ops = new CMDWSOps(this); status = ops.MDWSLogin( strUID, strPWD, lSiteID, out lUserID, out mdwsSOAPClient); if (status.Status) { //create the session record UserID = lUserID; CUserData ud = new CUserData(this); string strFXSessionID = String.Empty; status = ud.CreateFXSession(out strFXSessionID); if (!status.Status) { return(status); } //load the rest of the user data status = LoadUserData(lUserID); if (!status.Status) { return(status); } //we are loged in at this point LoggedIn = true; //cache the encrypted login credentials so that we can re-login if //we timeout from MDWS. MDWSUID = strUID; MDWSPWD = strPWD; SiteID = lSiteID; } return(status); } //simple login long lRoleID = 0; DataSet ds = null; CUserData cud = new CUserData(this); status = cud.GetLoginUserDS( strUID, strPWD, out ds, out lUserID, out lRoleID); if (status.Status) { //create the session record UserID = lUserID; CUserData ud = new CUserData(this); string strFXSessionID = String.Empty; status = ud.CreateFXSession(out strFXSessionID); if (!status.Status) { return(status); } //load the rest of the user date status = LoadUserData(lUserID); if (!status.Status) { return(status); } //we are loged in at this point LoggedIn = true; } return(status); }
/// <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()); }
/// <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); }