Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/AssemblyInfo.cs	(revision 1474)
@@ -28,5 +28,5 @@
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.6.1.*")]
+[assembly: AssemblyVersion("1.7.0.*")]
 
 //
@@ -58,4 +58,4 @@
 [assembly: AssemblyKeyFile("")]
 [assembly: AssemblyKeyName("")]
-[assembly: AssemblyFileVersionAttribute("1.6.1.0")]
+[assembly: AssemblyFileVersionAttribute("1.7.0.0")]
 [assembly: ComVisibleAttribute(false)]
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVView.cs	(revision 1474)
@@ -654,5 +654,5 @@
 //				sSql = "BSDX RAISE EVENT^" + sEvent + "^" + sParams + "^^";
 //				DataTable dtAppt =m_DocManager.RPMSDataTable(sSql, "RaiseEvent");
-				this.m_DocManager.ConnectInfo.RaiseEvent(sEvent, sParams, true);
+				CGDocumentManager.Current.RemoteSession.EventServices.TriggerEvent(sEvent, sParams, true);
 			}
 			catch (Exception ex)
@@ -809,5 +809,5 @@
 		{
 			calendarGrid1.CGToolTip.Active = false;
-			string sMsg = " this access block?";
+			string sMsg;
 			if (calendarGrid1.SelectedAppointments.AppointmentTable.Count > 1)
 				sMsg = " these access blocks?";
@@ -859,5 +859,5 @@
 			try
 			{
-				bool bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "+");
+				bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "+");
 				if (bLock == false)
 				{
@@ -872,5 +872,5 @@
 					return;
 				}
-				bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "-");
+                bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "-");
 			}
 			catch (Exception ex)
@@ -947,5 +947,5 @@
 		{
 			this.calendarGrid1.CloseGrid();
-			DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXRES(" + Document.ResourceID.ToString() + ")", "-");
+            CGDocumentManager.Current.RemoteSession.Lock("^BSDXRES(" + Document.ResourceID.ToString() + ")", "-");
 		}
 
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1474)
@@ -1,2 +1,8 @@
+/* Main Class...:
+ * Original Author: Horace Whitt
+ * Current Author and Maintainer: Sam Habiel
+ * License: LGPL. http://www.gnu.org/licenses/lgpl-2.1.html
+*/
+
 using System;
 using System.Windows.Forms;
@@ -6,4 +12,6 @@
 using System.Threading;
 using IndianHealthService.BMXNet;
+using IndianHealthService.BMXNet.WinForm;
+using IndianHealthService.BMXNet.WinForm.Configuration; //grrrr... too many namespaces here...
 using Mono.Options;
 using System.Runtime.InteropServices;
@@ -42,6 +50,4 @@
 		//M Connection member variables
 		private DataSet									m_dsGlobal = null;      // Holds all user data
-		private BMXNetConnectInfo						m_ConnectInfo = null;   // Connection to VISTA object
-        private BMXNetConnectInfo.BMXNetEventDelegate CDocMgrEventDelegate;     // Delegate to respond to messages from VISTA. Responds to event: BMXNetConnectInfo.BMXNetEvent
 
         //Custom Printing
@@ -51,14 +57,7 @@
         #region Properties
 
-        /// <summary>
-        /// Returns the document manager's BMXNetConnectInfo member
-        /// </summary>
-        public BMXNetConnectInfo ConnectInfo
-        {
-            get
-            {
-                return m_ConnectInfo;
-            }
-        }
+        public WinFramework WinFramework { get; private set; }  // Login Manager
+        public RemoteSession RemoteSession { get; private set; } // Data Sesssion against the RPMS/VISTA server
+        public RPCLogger RPCLogger { get; private set; }         // Logger for RPCs
 
         /// <summary>
@@ -153,7 +152,7 @@
 
         /// <summary>
-        /// Constructor. Does absolutely nothing at this point.
+        /// Private constructor for singleton instance.
         /// </summary>
-		public CGDocumentManager()
+		private CGDocumentManager()
 		{
         }
@@ -218,8 +217,19 @@
             opset.Parse(args);
             
-            //Init app
-            bool isEverythingOkay = _current.InitializeApp();
-
-            //if an error occurred, break out.
+            //Init app. Catch Login Exceptions if they happen.
+            bool isEverythingOkay = false;
+            try
+            {
+                isEverythingOkay = _current.InitializeApp();
+            }
+            catch (Exception ex)
+            {
+
+                MessageBox.Show("Booboo: An Error Happened: " + ex.Message);
+                return; // exit application
+            }
+            
+
+            //if something yucky happened, break out.
             if (!isEverythingOkay) return;
 
@@ -235,5 +245,5 @@
             view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText);
 
-            //Handle BMX Event
+            //Handle Message Queue
             Application.DoEvents();
 
@@ -295,28 +305,26 @@
 
         #region BMXNet Event Handler
-        private void CDocMgrEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
-		{
-			if (e.BMXEvent == "BSDX CALL WORKSTATIONS")
+        private void CDocMgrEventHandler(Object obj, RemoteEventArgs e)
+		{
+			if (e.EventType == "BSDX CALL WORKSTATIONS")
 			{
 				string sParam = "";
 				string sDelim="~";
-				sParam += this.m_ConnectInfo.UserName + sDelim;
+				sParam += this.RemoteSession.User.Name + sDelim;
 				sParam += this.m_sHandle + sDelim;
 				sParam += Application.ProductVersion + sDelim;
 				sParam += this._views.Count.ToString();
-				_current.m_ConnectInfo.RaiseEvent("BSDX WORKSTATION REPORT", sParam, true);
-			}
-			if (e.BMXEvent == "BSDX ADMIN MESSAGE")
-			{
-				string sMsg = e.BMXParam;
+				_current.RemoteSession.EventServices.TriggerEvent("BSDX WORKSTATION REPORT", sParam, true);
+			}
+			if (e.EventType == "BSDX ADMIN MESSAGE")
+			{
+				string sMsg = e.EventType;
 				ShowAdminMsgDelegate samd = new ShowAdminMsgDelegate(ShowAdminMsg);
-				//this.Invoke(samd, new object [] {sMsg});
                 samd.Invoke(sMsg);
 			}
-			if (e.BMXEvent == "BSDX ADMIN SHUTDOWN")
-			{
-				string sMsg = e.BMXParam;
+			if (e.EventType == "BSDX ADMIN SHUTDOWN")
+			{
+				string sMsg = e.Details;
 				CloseAllDelegate cad = new CloseAllDelegate(CloseAll);
-				//this.Invoke(cad, new object [] {sMsg});
                 cad.Invoke(sMsg);
 			}
@@ -353,22 +361,113 @@
         private bool InitializeApp(bool bReLogin)
 		{
-            //Set M connection info
-            m_ConnectInfo = new BMXNetConnectInfo(m_Encoding); // Encoding is "" unless passed in command line
-            _dal = new DAL(m_ConnectInfo);   // Data access layer
-            //m_ConnectInfo.bmxNetLib.StartLog();    //This line turns on logging of messages
+            //Note: There are 2 splashes -- one for being the parent of the log in forms
+            // the next is invoked async and updated async while the GUI is loading
+            // The reason is b/c an async form cannot be the parent of another that lies on the main thread
+
+            RPCLogger = new RPCLogger();
+
+            DSplash firstSplash = new DSplash();
+
+            firstSplash.Show();
             
-            //Create a delegate to process events raised by BMX.
-            CDocMgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(CDocMgrEventHandler);
+            /* IMPORTANT NOTE
+             * LOGIN CODE IS COPIED ALMOST VERBATIM FROM THE SCHEMABUILDER APPLICAITON;
+             * THE ONLY ONE I CAN FIND WHICH RELIES ON BMX 4 NEW WAYS WHICH I CAN'T FIGURE OUT
+             */
+            LoginProcess login;
+            this.WinFramework = WinFramework.CreateWithNetworkBroker(true, RPCLogger);
+            
+            if (bReLogin) // if logging in again...
+            {
+                this.WinFramework.LoadConnectionSpecs(LocalPersistentStore.CreateDefaultStorage(true), "BSDX");
+                login = this.WinFramework.CreateLoginProcess();
+                login.AttemptUserInputLogin("Clincal Scheduling Log-in", 3, true, firstSplash);
+                goto DoneTrying;
+            }
+
+            // If server,port,ac,vc are supplied on command line, then try to connect...
+            else if (!String.IsNullOrEmpty(m_Server) && m_Port != 0 && !String.IsNullOrEmpty(m_AccessCode) && !String.IsNullOrEmpty(m_VerifyCode))
+            {
+                RpmsConnectionSpec spec = new RpmsConnectionSpec();
+                spec.IsDefault = true;
+                spec.Name = "Command Line Server";
+                spec.Port = m_Port;
+                spec.Server = m_Server;
+                spec.UseWindowsAuthentication = false; //for now
+                spec.UseDefaultNamespace = true; //for now
+                login = this.WinFramework.CreateLoginProcess();
+                login.AutoSetDivisionToLastLookup = false;
+                login.AttemptAccessVerifyLogin(spec, m_AccessCode, m_VerifyCode);
+                goto DoneTrying;
+            }
+            
+            // if only server, port is supplied, then use these instead
+            else if (!String.IsNullOrEmpty(m_Server) && m_Port != 0)
+            {
+                RpmsConnectionSpec spec = new RpmsConnectionSpec();
+                spec.IsDefault = true;
+                spec.Name = "Command Line Server";
+                spec.Port = m_Port;
+                spec.Server = m_Server;
+                spec.UseWindowsAuthentication = false; //for now
+                spec.UseDefaultNamespace = true; //for now
+
+                RpmsConnectionSettings cxnSettings = new RpmsConnectionSettings
+                {
+                    CommandLineConnectionSpec = spec
+                };
+
+                this.WinFramework.ConnectionSettings = cxnSettings;
+
+                login = this.WinFramework.CreateLoginProcess();
+                login.AutoSetDivisionToLastLookup = false;
+                //test
+                //spec.UseWindowsAuthentication = true;
+                login.AttemptUserInputLogin("Clinical Scheduling Log-in", 3, false, firstSplash);
+                //login.AttemptWindowsAuthLogin();
+                //test
+                goto DoneTrying;
+            }
+
+            // if nothing is supplied, fall back on the original dialog
+            else
+            {
+                this.WinFramework.LoadConnectionSpecs(LocalPersistentStore.CreateDefaultStorage(true), "BSDX");
+                login = this.WinFramework.CreateLoginProcess();
+                login.AutoSetDivisionToLastLookup = false;
+                login.AttemptUserInputLogin("Clincal Scheduling Log-in", 3, true, firstSplash);
+
+                goto DoneTrying;
+            }
+
+DoneTrying:
+            if (!login.WasSuccessful)
+            {
+                return false;
+            }
+
+            LocalSession local = this.WinFramework.LocalSession;
+
+            if ((this.WinFramework.Context.User.Division == null) && !this.WinFramework.AttemptUserInputSetDivision("Set Initial Division", firstSplash))
+            {
+                return false;
+            }
+
+            
+
+            this.RemoteSession = this.WinFramework.PrimaryRemoteSession;
+
             //Tie delegate to Events generated by BMX.
-            m_ConnectInfo.BMXNetEvent += CDocMgrEventDelegate;
-            //Disable polling (But does this really work???? I don't see how it gets disabled)
-            m_ConnectInfo.EventPollingEnabled = false;
-
+            this.RemoteSession.EventServices.RpmsEvent += this.CDocMgrEventHandler;
+            //Disable polling
+            this.RemoteSession.EventServices.IsEventPollingEnabled = false;
+
+            //Second splash screens
             //Show a splash screen while initializing; define delegates to remote thread
-            DSplash m_ds = new DSplash();
-            DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
-            DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
-            DSplash.dProgressBarSet setMaxProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarMaxSet);
-            DSplash.dProgressBarSet setProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarValueSet);
+            DSplash secondSplash = new DSplash();
+            DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(secondSplash.SetStatus);
+            DSplash.dAny closeSplashDelegate = new DSplash.dAny(secondSplash.RemoteClose);
+            DSplash.dProgressBarSet setMaxProgressDelegate = new DSplash.dProgressBarSet(secondSplash.RemoteProgressBarMaxSet);
+            DSplash.dProgressBarSet setProgressDelegate = new DSplash.dProgressBarSet(secondSplash.RemoteProgressBarValueSet);
 
             //Start new thread for the Splash screen.
@@ -376,13 +475,16 @@
             threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
             threadSplash.Name = "Splash Thread";
-            threadSplash.Start(m_ds); // pass form as parameter.
+            threadSplash.Start(secondSplash);
+
+            firstSplash.Close(); // close temporary splash now that the new one is up and running
 
             //There are 21 steps to load the application. That's max for the progress bar.
             setMaxProgressDelegate(21);
+
+            // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
+            setStatusDelegate("Connecting to VISTA");
+
             
-            // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
-            
-            setStatusDelegate("Connecting to VISTA");
-            
+            /*
             //Try to connect using supplied values for Server and Port
             //Why am I doing this? The library BMX net uses prompts for access and verify code
@@ -462,7 +564,8 @@
                 }
 			}while (bRetry == true);
-            
-            //Printing
-
+            */
+
+            //Printing Custom DLL. Perfect place for code injection!!!
+            //*************************************************
             string DllLocation = string.Empty;
             System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Application.StartupPath + @"\Printing\");
@@ -495,5 +598,5 @@
                 this.m_PrintingObject = Creator.PrintFactory();
             }
-           
+           //************************************************
             
             //User Interface Culture (m_CultureName is set from the command line flag /culture)
@@ -512,4 +615,6 @@
             }
 
+            _dal = new DAL(RemoteSession);   // Data access layer
+            
             //Create global dataset
 			_current.m_dsGlobal = new DataSet("GlobalDataSet");
@@ -553,10 +658,12 @@
             setProgressDelegate(2);
             setStatusDelegate("Setting encoding...");
-
+            //PORT TODO: Set encoding
             if (m_Encoding == String.Empty)
             {
-                string utf8_server_support = m_ConnectInfo.bmxNetLib.TransmitRPC("BMX UTF-8", "");
+                string utf8_server_support = RemoteSession.TransmitRPC("BMX UTF-8", "");
+                
                 if (utf8_server_support == "1")
-                    m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
+                    RemoteSession.ConnectionEncoding = System.Text.UTF8Encoding.UTF8;
+                
             }
 			
@@ -565,5 +672,5 @@
             setProgressDelegate(3);
 			setStatusDelegate("Setting Application Context to BSDXRPC...");
-			m_ConnectInfo.AppContext = "BSDXRPC";
+			RemoteSession.AppContext = "BSDXRPC";
 
             //User Preferences Object
@@ -571,5 +678,5 @@
             setStatusDelegate("Getting User Preferences from the Server...");
 
-            _current.UserPreferences = new UserPreferences(); // Does the calling to do that...
+            _current.UserPreferences = new UserPreferences(); // Constructor Does the calling to do that...
             
             //Load global recordsets
@@ -583,5 +690,5 @@
             setProgressDelegate(6);
             setStatusDelegate(statusConst + " Schedule User");
-            DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
+            DataTable dtUser = _dal.GetUserInfo(RemoteSession.User.Duz);
             dtUser.TableName = "SchedulingUser";
             m_dsGlobal.Tables.Add(dtUser);
@@ -598,7 +705,5 @@
             setProgressDelegate(7);
             setStatusDelegate(statusConst + " Access Types");
-            DataTable dtAccessTypes = _dal.GetAccessTypes();
-            dtAccessTypes.TableName = "AccessTypes";
-            m_dsGlobal.Tables.Add(dtAccessTypes);
+            DataTable dtAccessTypes = _dal.GetAccessTypes(m_dsGlobal, "AccessTypes");
 
             //Get Access Groups
@@ -680,5 +785,5 @@
             //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
             sCommandText = "BSDX HOSPITAL LOCATION";
-            ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "HospitalLocation");
             Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
 
@@ -732,5 +837,5 @@
             setStatusDelegate(statusConst + " Providers");
             sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
-            ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
+            RemoteSession.TableFromSQL(sCommandText, m_dsGlobal, "Provider");
             Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
 
@@ -740,5 +845,5 @@
             setStatusDelegate(statusConst + " Holiday");
             sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE INTERNAL[DATE] > '" + FMDateTime.Create(DateTime.Today).DateOnly.FMDateString + "'";
-            ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
+            RemoteSession.TableFromSQL(sCommandText, m_dsGlobal, "HOLIDAY");
             Debug.Write("LoadingGlobalRecordsets -- Holidays loaded\n");
 
@@ -749,8 +854,8 @@
 
             setStatusDelegate("Setting Receive Timeout");
-            _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
+            _current.RemoteSession.ReceiveTimeout = 30000; //30-second timeout
 
 #if DEBUG
-            _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
+            _current.RemoteSession.ReceiveTimeout = 600000; //longer timeout for debugging
 #endif 
 			// Event Subsriptions
@@ -758,18 +863,20 @@
             //Table #16
             setProgressDelegate(18);
-            _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
+            _current.RemoteSession.EventServices.Subscribe("BSDX SCHEDULE");
 			//Table #17
             setProgressDelegate(19);
-            _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
+            _current.RemoteSession.EventServices.Subscribe("BSDX CALL WORKSTATIONS");
 			//Table #18
             setProgressDelegate(20);
-            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
+            _current.RemoteSession.EventServices.Subscribe("BSDX ADMIN MESSAGE");
 			//Table #19
             setProgressDelegate(21);
-            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
-
-			_current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
-			_current.m_ConnectInfo.EventPollingEnabled = true;
-			_current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
+            _current.RemoteSession.EventServices.Subscribe("BSDX ADMIN SHUTDOWN");
+
+			_current.RemoteSession.EventServices.EventPollingInterval = 5000; //in milliseconds
+			_current.RemoteSession.EventServices.IsEventPollingEnabled = true;
+			
+            //PORT TODO: No Autofire in BMX 4.0
+            //_current.RemoteSession.EventServices. = 12; //AutoFire every 12*5 seconds
 
             //Close Splash Screen
@@ -785,5 +892,5 @@
 		{
 			string sCommandText = "SELECT * FROM BSDX_ACCESS_GROUP";
-			ConnectInfo.RPMSDataTable(sCommandText, "AccessGroup", m_dsGlobal);
+			RemoteSession.TableFromSQL(sCommandText, m_dsGlobal, "AccessGroup");
 			Debug.Write("LoadGlobalRecordsets -- AccessGroups loaded\n");
 		}
@@ -792,5 +899,5 @@
 		{
 			string sCommandText = "BSDX GET ACCESS GROUP TYPES";
-			ConnectInfo.RPMSDataTable(sCommandText, "AccessGroupType", m_dsGlobal);
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "AccessGroupType");
 			Debug.Write("LoadGlobalRecordsets -- AccessGroupTypes loaded\n");
 		}
@@ -798,6 +905,6 @@
 		public void LoadBSDXResourcesTable()
 		{
-			string sCommandText = "BSDX RESOURCES^" + m_ConnectInfo.DUZ;
-			ConnectInfo.RPMSDataTable(sCommandText, "Resources", m_dsGlobal);
+			string sCommandText = "BSDX RESOURCES^" + RemoteSession.User.Duz;
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "Resources");
 			Debug.Write("LoadGlobalRecordsets -- Resources loaded\n");
 		}
@@ -809,6 +916,6 @@
 			//to which user has access
 			//Fields are: RESOURCE_GROUPID, RESOURCE_GROUP
-			string sCommandText = "BSDX RESOURCE GROUPS BY USER^" + m_ConnectInfo.DUZ;
-			ConnectInfo.RPMSDataTable(sCommandText, "ResourceGroup", m_dsGlobal);
+			string sCommandText = "BSDX RESOURCE GROUPS BY USER^" + RemoteSession.User.Duz;
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "ResourceGroup");
 			Debug.Write("LoadGlobalRecordsets -- ResourceGroup loaded\n");
 		}
@@ -821,6 +928,6 @@
 			//are returned.
 			//Fields are: RESOURCE_GROUPID, RESOURCE_GROUP, RESOURCE_GROUP_ITEMID, RESOURCE_NAME, RESOURCE_ID
-			string sCommandText = "BSDX GROUP RESOURCE^" + m_ConnectInfo.DUZ;
-			ConnectInfo.RPMSDataTable(sCommandText, "GroupResources", m_dsGlobal);
+			string sCommandText = "BSDX GROUP RESOURCE^" + RemoteSession.User.Duz;
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "GroupResources");
 			Debug.Write("LoadGlobalRecordsets -- GroupResources loaded\n");
 		}
@@ -831,5 +938,5 @@
 			//who possesses the BSDXZMENU security key.
 			string sCommandText = "BSDX SCHEDULE USER";
-			ConnectInfo.RPMSDataTable(sCommandText, "ScheduleUser", m_dsGlobal);
+            RemoteSession.TableFromCommand(sCommandText, m_dsGlobal, "ScheduleUser");
 			Debug.Write("LoadGlobalRecordsets -- ScheduleUser loaded\n");
 		}
@@ -850,8 +957,8 @@
             if (!bAllUsers)
             {
-                sCommandText += String.Format(" WHERE INTERNAL[USERNAME] = {0}", m_ConnectInfo.DUZ);
-            }
-
-			ConnectInfo.RPMSDataTable(sCommandText, "ResourceUser", m_dsGlobal);
+                sCommandText += String.Format(" WHERE INTERNAL[USERNAME] = {0}", RemoteSession.User.Duz);
+            }
+
+            RemoteSession.TableFromSQL(sCommandText, m_dsGlobal, "ResourceUser");
 			Debug.Write("LoadGlobalRecordsets -- ResourceUser loaded\n");
 		}
@@ -968,7 +1075,7 @@
 			if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
 			{
-				m_ConnectInfo.EventPollingEnabled = false;
-				m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
-				m_ConnectInfo.CloseConnection();
+				RemoteSession.EventServices.IsEventPollingEnabled = false;
+				RemoteSession.EventServices.Unsubscribe("BSDX SCHEDULE");
+                RemoteSession.Close();
 				Application.Exit();
 			}
@@ -983,5 +1090,5 @@
 			if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
 			{
-				m_ConnectInfo.bmxNetLib.CloseConnection();
+                RemoteSession.Close();
 				Application.Exit();
 			}
@@ -1123,7 +1230,7 @@
                 
                 //Used in Do loop
-                bool bRetry = true;
+                //bool bRetry = true;
 				
-                // Do Loop to deal with changing the server and the vagaries of user choices.
+                /*// Do Loop to deal with changing the server and the vagaries of user choices.
 				do
 				{
@@ -1134,5 +1241,6 @@
                         //so it can be re-used when BMX tries to log in again.
                         //Access and Verify code are prompted for in InitializeApp
-						m_ConnectInfo.ChangeServerInfo();
+                        LoginProcess login = this.WinFramework.CreateLoginProcess();
+                        login.AttemptUserInputLogin("ReLog-in", 3, true, null);
 						bRetry = false;
 					}
@@ -1157,5 +1265,6 @@
 					}
 				} while (bRetry == true);
-
+                */
+                
                 //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
                 bool isEverythingOkay = this.InitializeApp(true);
@@ -1194,5 +1303,8 @@
 		private void mnuRPMSLogin_Click(object sender, EventArgs e)
 		{
-			//Warn that changing login will close all schedules
+            mnuRPMSServer_Click(sender, e);
+            
+            /* v 1.7 to support BMX 4 -- commented out -- smh
+            //Warn that changing login will close all schedules
 			if (MessageBox.Show("Are you sure you want to close all schedules and login to VistA?", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
 				return;
@@ -1206,4 +1318,22 @@
 				CloseAll();
 				m_bExitOK = true;
+
+                LoginProcess login = this.WinFramework.CreateLoginProcess();
+                login.AttemptUserInputLogin("Clincal Scheduling", 3, true, null);
+                //m_ConnectInfo.bmxNetLib.StartLog();    //This line turns on logging of messages
+
+                if (!login.WasSuccessful)
+                {
+                    return;
+                }
+
+                LocalSession local = this.WinFramework.LocalSession;
+
+                if ((this.WinFramework.Context.User.Division == null) && !this.WinFramework.AttemptUserInputSetDivision("Set Initial Division", null))
+                {
+                    return;
+                }
+
+                this.RemoteSession = this.WinFramework.PrimaryRemoteSession;
 
                 //Parameter for initialize app tells it that this is a re-login and forces a new access and verify code.
@@ -1233,5 +1363,5 @@
 				throw ex;
 			}
-	
+	        */
 		}
 
@@ -1290,7 +1420,9 @@
 			{
 				//System.IntPtr pHandle = this.Handle;
-				RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(ConnectInfo.RPMSDataTable);
+				RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(RemoteSession.TableFromCommand);
 				//dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
-                dtOut = rdtd.Invoke(sSQL, sTableName);
+                dtOut = RemoteSession.TableFromCommand(sSQL);
+                dtOut.TableName = sTableName;
+
 			}
 
@@ -1307,5 +1439,8 @@
 		public void ChangeDivision(System.Windows.Forms.Form frmCaller)
 		{
-			this.ConnectInfo.ChangeDivision(frmCaller);
+            WinFramework.AttemptUserInputSetDivision("Change Division", frmCaller);
+
+            RemoteSession = WinFramework.PrimaryRemoteSession;
+
 			foreach (CGView v in _views.Keys)
 			{
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs	(revision 1474)
@@ -114,4 +114,5 @@
         private MenuItem sepApptMenu3;
         private MenuItem mnuReprintApptSlip;
+        private MenuItem mnuViewBrokerLog;
         private IContainer components;
 
@@ -132,9 +133,9 @@
 		public void InitializeDocView(string sText)
 		{
-			this.Text = this.DocManager.ConnectInfo.UserName;
+            this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
 			if (sText != null)
 				this.Text += " - " + sText;
-			if (DocManager.ConnectInfo.DivisionName != null)
-				this.Text += " - " + DocManager.ConnectInfo.DivisionName;
+            if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
+                this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
 		}
 
@@ -157,16 +158,12 @@
 
             // Set username and division up top
-            this.Text = this.DocManager.ConnectInfo.UserName;
+            this.Text = CGDocumentManager.Current.RemoteSession.User.Name;
 			if (sText != null)
 				this.Text += " - " + sText;
-			if (DocManager.ConnectInfo.DivisionName != null)
-				this.Text += " - " + DocManager.ConnectInfo.DivisionName;
-
-			this.m_ConnectInfo = m_DocManager.ConnectInfo;
-			m_bmxDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(BMXNetEventHandler);
-			m_ConnectInfo.BMXNetEvent += m_bmxDelegate;
-		}
-
-		private BMXNetConnectInfo.BMXNetEventDelegate m_bmxDelegate;
+			if (CGDocumentManager.Current.RemoteSession.User.Division.Name != null)
+                this.Text += " - " + CGDocumentManager.Current.RemoteSession.User.Division.Name;
+
+            CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent += BMXNetEventHandler;
+		}
 		
 
@@ -235,4 +232,5 @@
             this.mnuHelp = new System.Windows.Forms.MenuItem();
             this.mnuHelpAbout = new System.Windows.Forms.MenuItem();
+            this.mnuViewBrokerLog = new System.Windows.Forms.MenuItem();
             this.mnuTest = new System.Windows.Forms.MenuItem();
             this.mnuTest1 = new System.Windows.Forms.MenuItem();
@@ -680,5 +678,6 @@
             this.mnuHelp.Index = 3;
             this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.mnuHelpAbout});
+            this.mnuHelpAbout,
+            this.mnuViewBrokerLog});
             this.mnuHelp.Text = "&Help";
             // 
@@ -688,4 +687,10 @@
             this.mnuHelpAbout.Text = "&About";
             this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click);
+            // 
+            // mnuViewBrokerLog
+            // 
+            this.mnuViewBrokerLog.Index = 1;
+            this.mnuViewBrokerLog.Text = "&View Broker Log";
+            this.mnuViewBrokerLog.Click += new System.EventHandler(this.mnuViewBrokerLog_Click);
             // 
             // mnuTest
@@ -702,5 +707,4 @@
             this.mnuTest1.Index = 0;
             this.mnuTest1.Text = "Test1";
-            this.mnuTest1.Click += new System.EventHandler(this.mnuTest1_Click);
             // 
             // tvSchedules
@@ -712,5 +716,5 @@
             this.tvSchedules.Location = new System.Drawing.Point(0, 0);
             this.tvSchedules.Name = "tvSchedules";
-            this.tvSchedules.Size = new System.Drawing.Size(128, 392);
+            this.tvSchedules.Size = new System.Drawing.Size(128, 389);
             this.tvSchedules.Sorted = true;
             this.tvSchedules.TabIndex = 1;
@@ -781,5 +785,5 @@
             this.panelRight.Location = new System.Drawing.Point(996, 0);
             this.panelRight.Name = "panelRight";
-            this.panelRight.Size = new System.Drawing.Size(128, 392);
+            this.panelRight.Size = new System.Drawing.Size(128, 389);
             this.panelRight.TabIndex = 3;
             this.panelRight.Visible = false;
@@ -877,6 +881,141 @@
             this.panelCenter.Location = new System.Drawing.Point(136, 24);
             this.panelCenter.Name = "panelCenter";
-            this.panelCenter.Size = new System.Drawing.Size(857, 344);
+            this.panelCenter.Size = new System.Drawing.Size(857, 341);
             this.panelCenter.TabIndex = 7;
+            // 
+            // ctxCalendarGrid
+            // 
+            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+            this.ctxCalGridAdd,
+            this.ctxCalGridMkRadAppt,
+            this.ctxCalGridEdit,
+            this.ctxCalGridDelete,
+            this.ctxCalGridCancelRadAppt,
+            this.ctxCalGridCheckIn,
+            this.ctxCalGridUndoCheckin,
+            this.ctxCalGridSep1,
+            this.ctxCalGridNoShow,
+            this.ctxCalGridNoShowUndo,
+            this.ctxCalGridSep2,
+            this.ctxCalGridWalkin,
+            this.ctxCalGridSep3,
+            this.ctxCalGridReprintApptSlip});
+            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
+            // 
+            // ctxCalGridAdd
+            // 
+            this.ctxCalGridAdd.Index = 0;
+            this.ctxCalGridAdd.Text = "Add Appointment";
+            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
+            // 
+            // ctxCalGridMkRadAppt
+            // 
+            this.ctxCalGridMkRadAppt.Index = 1;
+            this.ctxCalGridMkRadAppt.Text = "Make Radiology Appointment";
+            this.ctxCalGridMkRadAppt.Click += new System.EventHandler(this.ctxCalGridMkRadAppt_Click);
+            // 
+            // ctxCalGridEdit
+            // 
+            this.ctxCalGridEdit.Index = 2;
+            this.ctxCalGridEdit.Text = "Edit Appointment";
+            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
+            // 
+            // ctxCalGridDelete
+            // 
+            this.ctxCalGridDelete.Index = 3;
+            this.ctxCalGridDelete.Text = "Cancel Appointment";
+            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
+            // 
+            // ctxCalGridCancelRadAppt
+            // 
+            this.ctxCalGridCancelRadAppt.Index = 4;
+            this.ctxCalGridCancelRadAppt.Text = "Cancel Radiology Appointment";
+            this.ctxCalGridCancelRadAppt.Click += new System.EventHandler(this.ctxCalGridCancelRadAppt_Click);
+            // 
+            // ctxCalGridCheckIn
+            // 
+            this.ctxCalGridCheckIn.Index = 5;
+            this.ctxCalGridCheckIn.Text = "Check In Patient";
+            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
+            // 
+            // ctxCalGridUndoCheckin
+            // 
+            this.ctxCalGridUndoCheckin.Index = 6;
+            this.ctxCalGridUndoCheckin.Text = "&Undo Check In";
+            this.ctxCalGridUndoCheckin.Click += new System.EventHandler(this.ctxCalGridUndoCheckin_Click);
+            // 
+            // ctxCalGridSep1
+            // 
+            this.ctxCalGridSep1.Index = 7;
+            this.ctxCalGridSep1.Text = "-";
+            // 
+            // ctxCalGridNoShow
+            // 
+            this.ctxCalGridNoShow.Index = 8;
+            this.ctxCalGridNoShow.Text = "Mark as No Show";
+            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
+            // 
+            // ctxCalGridNoShowUndo
+            // 
+            this.ctxCalGridNoShowUndo.Index = 9;
+            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
+            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
+            // 
+            // ctxCalGridSep2
+            // 
+            this.ctxCalGridSep2.Index = 10;
+            this.ctxCalGridSep2.Text = "-";
+            // 
+            // ctxCalGridWalkin
+            // 
+            this.ctxCalGridWalkin.Index = 11;
+            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
+            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
+            // 
+            // ctxCalGridSep3
+            // 
+            this.ctxCalGridSep3.Index = 12;
+            this.ctxCalGridSep3.Text = "-";
+            // 
+            // ctxCalGridReprintApptSlip
+            // 
+            this.ctxCalGridReprintApptSlip.Index = 13;
+            this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
+            this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
+            // 
+            // panelBottom
+            // 
+            this.panelBottom.Controls.Add(this.statusBar1);
+            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.panelBottom.Location = new System.Drawing.Point(136, 365);
+            this.panelBottom.Name = "panelBottom";
+            this.panelBottom.Size = new System.Drawing.Size(857, 24);
+            this.panelBottom.TabIndex = 8;
+            // 
+            // statusBar1
+            // 
+            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.statusBar1.Location = new System.Drawing.Point(0, 0);
+            this.statusBar1.Name = "statusBar1";
+            this.statusBar1.Size = new System.Drawing.Size(857, 24);
+            this.statusBar1.SizingGrip = false;
+            this.statusBar1.TabIndex = 0;
+            // 
+            // splitter1
+            // 
+            this.splitter1.Location = new System.Drawing.Point(128, 24);
+            this.splitter1.Name = "splitter1";
+            this.splitter1.Size = new System.Drawing.Size(8, 365);
+            this.splitter1.TabIndex = 9;
+            this.splitter1.TabStop = false;
+            // 
+            // splitter2
+            // 
+            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
+            this.splitter2.Location = new System.Drawing.Point(993, 24);
+            this.splitter2.Name = "splitter2";
+            this.splitter2.Size = new System.Drawing.Size(3, 365);
+            this.splitter2.TabIndex = 10;
+            this.splitter2.TabStop = false;
             // 
             // calendarGrid1
@@ -899,5 +1038,5 @@
             this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources")));
             this.calendarGrid1.SelectedAppointment = 0;
-            this.calendarGrid1.Size = new System.Drawing.Size(857, 344);
+            this.calendarGrid1.Size = new System.Drawing.Size(857, 341);
             this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0);
             this.calendarGrid1.TabIndex = 0;
@@ -909,143 +1048,8 @@
             this.calendarGrid1.MouseEnter += new System.EventHandler(this.calendarGrid1_MouseEnter);
             // 
-            // ctxCalendarGrid
-            // 
-            this.ctxCalendarGrid.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-            this.ctxCalGridAdd,
-            this.ctxCalGridMkRadAppt,
-            this.ctxCalGridEdit,
-            this.ctxCalGridDelete,
-            this.ctxCalGridCancelRadAppt,
-            this.ctxCalGridCheckIn,
-            this.ctxCalGridUndoCheckin,
-            this.ctxCalGridSep1,
-            this.ctxCalGridNoShow,
-            this.ctxCalGridNoShowUndo,
-            this.ctxCalGridSep2,
-            this.ctxCalGridWalkin,
-            this.ctxCalGridSep3,
-            this.ctxCalGridReprintApptSlip});
-            this.ctxCalendarGrid.Popup += new System.EventHandler(this.ctxCalendarGrid_Popup);
-            // 
-            // ctxCalGridAdd
-            // 
-            this.ctxCalGridAdd.Index = 0;
-            this.ctxCalGridAdd.Text = "Add Appointment";
-            this.ctxCalGridAdd.Click += new System.EventHandler(this.ctxCalGridAdd_Click);
-            // 
-            // ctxCalGridMkRadAppt
-            // 
-            this.ctxCalGridMkRadAppt.Index = 1;
-            this.ctxCalGridMkRadAppt.Text = "Make Radiology Appointment";
-            this.ctxCalGridMkRadAppt.Click += new System.EventHandler(this.ctxCalGridMkRadAppt_Click);
-            // 
-            // ctxCalGridEdit
-            // 
-            this.ctxCalGridEdit.Index = 2;
-            this.ctxCalGridEdit.Text = "Edit Appointment";
-            this.ctxCalGridEdit.Click += new System.EventHandler(this.ctxCalGridEdit_Click);
-            // 
-            // ctxCalGridDelete
-            // 
-            this.ctxCalGridDelete.Index = 3;
-            this.ctxCalGridDelete.Text = "Cancel Appointment";
-            this.ctxCalGridDelete.Click += new System.EventHandler(this.ctxCalGridDelete_Click);
-            // 
-            // ctxCalGridCancelRadAppt
-            // 
-            this.ctxCalGridCancelRadAppt.Index = 4;
-            this.ctxCalGridCancelRadAppt.Text = "Cancel Radiology Appointment";
-            this.ctxCalGridCancelRadAppt.Click += new System.EventHandler(this.ctxCalGridCancelRadAppt_Click);
-            // 
-            // ctxCalGridCheckIn
-            // 
-            this.ctxCalGridCheckIn.Index = 5;
-            this.ctxCalGridCheckIn.Text = "Check In Patient";
-            this.ctxCalGridCheckIn.Click += new System.EventHandler(this.ctxCalGridCheckIn_Click);
-            // 
-            // ctxCalGridUndoCheckin
-            // 
-            this.ctxCalGridUndoCheckin.Index = 6;
-            this.ctxCalGridUndoCheckin.Text = "&Undo Check In";
-            this.ctxCalGridUndoCheckin.Click += new System.EventHandler(this.ctxCalGridUndoCheckin_Click);
-            // 
-            // ctxCalGridSep1
-            // 
-            this.ctxCalGridSep1.Index = 7;
-            this.ctxCalGridSep1.Text = "-";
-            // 
-            // ctxCalGridNoShow
-            // 
-            this.ctxCalGridNoShow.Index = 8;
-            this.ctxCalGridNoShow.Text = "Mark as No Show";
-            this.ctxCalGridNoShow.Click += new System.EventHandler(this.ctxCalGridNoShow_Click);
-            // 
-            // ctxCalGridNoShowUndo
-            // 
-            this.ctxCalGridNoShowUndo.Index = 9;
-            this.ctxCalGridNoShowUndo.Text = "Undo NoShow";
-            this.ctxCalGridNoShowUndo.Click += new System.EventHandler(this.ctxCalGridNoShowUndo_Click);
-            // 
-            // ctxCalGridSep2
-            // 
-            this.ctxCalGridSep2.Index = 10;
-            this.ctxCalGridSep2.Text = "-";
-            // 
-            // ctxCalGridWalkin
-            // 
-            this.ctxCalGridWalkin.Index = 11;
-            this.ctxCalGridWalkin.Text = "Create Wal&k-In Appointment";
-            this.ctxCalGridWalkin.Click += new System.EventHandler(this.ctxCalGridWalkin_Click);
-            // 
-            // ctxCalGridSep3
-            // 
-            this.ctxCalGridSep3.Index = 12;
-            this.ctxCalGridSep3.Text = "-";
-            // 
-            // ctxCalGridReprintApptSlip
-            // 
-            this.ctxCalGridReprintApptSlip.Index = 13;
-            this.ctxCalGridReprintApptSlip.Text = "&Reprint Appointment Slip";
-            this.ctxCalGridReprintApptSlip.Click += new System.EventHandler(this.ctxCalGridReprintApptSlip_Click);
-            // 
-            // panelBottom
-            // 
-            this.panelBottom.Controls.Add(this.statusBar1);
-            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
-            this.panelBottom.Location = new System.Drawing.Point(136, 368);
-            this.panelBottom.Name = "panelBottom";
-            this.panelBottom.Size = new System.Drawing.Size(857, 24);
-            this.panelBottom.TabIndex = 8;
-            // 
-            // statusBar1
-            // 
-            this.statusBar1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.statusBar1.Location = new System.Drawing.Point(0, 0);
-            this.statusBar1.Name = "statusBar1";
-            this.statusBar1.Size = new System.Drawing.Size(857, 24);
-            this.statusBar1.SizingGrip = false;
-            this.statusBar1.TabIndex = 0;
-            // 
-            // splitter1
-            // 
-            this.splitter1.Location = new System.Drawing.Point(128, 24);
-            this.splitter1.Name = "splitter1";
-            this.splitter1.Size = new System.Drawing.Size(8, 368);
-            this.splitter1.TabIndex = 9;
-            this.splitter1.TabStop = false;
-            // 
-            // splitter2
-            // 
-            this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
-            this.splitter2.Location = new System.Drawing.Point(993, 24);
-            this.splitter2.Name = "splitter2";
-            this.splitter2.Size = new System.Drawing.Size(3, 368);
-            this.splitter2.TabIndex = 10;
-            this.splitter2.TabStop = false;
-            // 
             // CGView
             // 
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-            this.ClientSize = new System.Drawing.Size(1124, 392);
+            this.ClientSize = new System.Drawing.Size(1124, 389);
             this.Controls.Add(this.panelCenter);
             this.Controls.Add(this.panelBottom);
@@ -1086,6 +1090,4 @@
 		private Hashtable			m_htModifySchedule;
 		private Hashtable			m_htChangeAppts;
-		private BMXNetConnectInfo	m_ConnectInfo = null;
-		public BMXNetConnectInfo.BMXNetEventDelegate	BMXNetEvent;
 
 		#endregion Fields
@@ -1308,5 +1310,5 @@
 			DataTable dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
 			DataView dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
-			string sDuz = this.DocManager.ConnectInfo.DUZ;
+            string sDuz = CGDocumentManager.Current.RemoteSession.User.Duz;
 			bool bModSchedule = false;
 			DataRowView[] drvA = dv.FindRows(sResource);
@@ -1569,4 +1571,9 @@
         private bool IsThisARadiologyResource(string sResource)
         {
+            //smh - change in v 1.7... if the resource is not linked to a PIMS clinic, this method fails.
+            //This happens if there is just one resource that is not linked, which makes it impossible to
+            //make any appointments, because this method gets called at any time a menu is opened.
+            //So we change res.Field<int> to res.Field<int?> 
+           
             // see if resource is mapped to a Radiology Hospital Location.
             return (   //select all Hospital Locations which are radiology locations
@@ -1575,5 +1582,6 @@
                        //join this to the resources table using the foreign ID (plain jane relational join)
                        join res in CGDocumentManager.Current.GlobalDataSet.Tables["Resources"].AsEnumerable()
-                       on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int>("HOSPITAL_LOCATION_ID")
+                       //on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int>("HOSPITAL_LOCATION_ID") //change in 1.7
+                       on hl.Field<int>("HOSPITAL_LOCATION_ID") equals res.Field<int?>("HOSPITAL_LOCATION_ID")
                        //then filter this down to the resource that we have
                        where res.Field<string>("RESOURCE_NAME") == sResource
@@ -1766,5 +1774,5 @@
 					doc.ResourceID = Convert.ToInt32(sResourceID);
 
-					bool bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXRES(" + sResourceID + ")", "+");
+                    bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXRES(" + sResourceID + ")", "+");
 					if (bLock == false)
 					{
@@ -1939,7 +1947,5 @@
 			dt = this.DocManager.GlobalDataSet.Tables["ResourceUser"];
 			dv = new DataView(dt, "", "RESOURCENAME ASC", DataViewRowState.OriginalRows);
-
-            //dv.RowFilter = "USERNAME = '" + filte_name + "'";
-            dv.RowFilter = String.Format("USERNAME = '{0}'", this.DocManager.ConnectInfo.UserName.Replace("'", "''"));
+            dv.RowFilter = String.Format("USERNAME = '{0}'", CGDocumentManager.Current.RemoteSession.User.Name.Replace("'", "''"));
 
 			for (int j=0; j < dv.Count; j++)
@@ -2529,6 +2535,6 @@
 			{
                 string msg;
-                if (BMXNetLib.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
-                    msg = BMXNetLib.Piece(ex.Message, "~", 4);
+                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
+                    msg = M.Piece(ex.Message, "~", 4);
                 else
                     msg = ex.Message;
@@ -2640,6 +2646,6 @@
 			{   
                 string msg;
-                if (BMXNetLib.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
-                    msg = BMXNetLib.Piece(ex.Message, "~", 4);
+                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
+                    msg = M.Piece(ex.Message, "~", 4);
                 else
                     msg = ex.Message;
@@ -2748,6 +2754,6 @@
             {
                 string msg;
-                if (BMXNetLib.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
-                    msg = BMXNetLib.Piece(ex.Message, "~", 4);
+                if (M.Piece(ex.Message, "~", 1) == "-10") // -10 means that BSDXAPI reported an error.
+                    msg = M.Piece(ex.Message, "~", 4);
                 else
                     msg = ex.Message;
@@ -2771,5 +2777,5 @@
         /// <param name="e">BMXEvent Args: 
         /// e.BMXEvent is free text for Event Type; e.BMXParam is free text for Event Arguments</param>
-        private void BMXNetEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
+        private void BMXNetEventHandler(Object obj, RemoteEventArgs e)
         {
             try
@@ -2779,5 +2785,5 @@
 
                 // if event is Autofire event
-                if (e.BMXEvent == "BMXNet AutoFire")
+                if (e.EventType == "BMXNet AutoFire")
                 {
                     Debug.Write("CGView caught AutoFire event.\n");
@@ -2792,5 +2798,5 @@
 
                 // if event is BSDX SCHEDULE
-                else if (e.BMXEvent == "BSDX SCHEDULE")
+                else if (e.EventType == "BSDX SCHEDULE")
                 {
                     //See if any of the resources in the event argument matches BSDX Schedule.
@@ -2800,5 +2806,5 @@
                     {
                         sResourceName = m_Document.m_sResourcesArray[j].ToString();
-                        if (e.BMXParam == sResourceName)
+                        if (e.Details == sResourceName)
                         {
                             Debug.Write("CGView caught BSDX SCHEDULE event.\n");
@@ -2868,5 +2874,5 @@
             {
                 //Signal RPMS to raise an event
-                m_ConnectInfo.RaiseEvent(sEvent, sParams, false);
+                CGDocumentManager.Current.RemoteSession.EventServices.TriggerEvent(sEvent, sParams, false);
             }
             catch (Exception ex)
@@ -2914,5 +2920,5 @@
             try
             {
-                bool bLock = DocManager.ConnectInfo.Lock("^BSDXMGR", "+", "");
+                bool bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "+");
                 if (bLock == false)
                 {
@@ -2929,5 +2935,5 @@
                 m_DocManager.GlobalDataSet.Tables["ResourceUser"].Clear();
                 m_DocManager.LoadResourceUserTable(false);
-                bLock = DocManager.ConnectInfo.bmxNetLib.Lock("^BSDXMGR", "-");
+                bLock = CGDocumentManager.Current.RemoteSession.Lock("^BSDXMGR", "-");
             }
             catch (ApplicationException aex)
@@ -3195,47 +3201,9 @@
         }
 
-        /// <summary>
-        /// Useless code now... Good place to test something.
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-		private void mnuTest1_Click(object sender, System.EventArgs e)
-		{
-			ReaderWriterLock m_rwl = this.DocManager.ConnectInfo.bmxNetLib.BMXRWL;
+		private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+		{
 			try
 			{
-				m_rwl.AcquireWriterLock(50);
-				Debug.Write("\nTest Button 1 Acquired first lock\n");
-				m_rwl.AcquireWriterLock(50);
-				Debug.Write("Test Button 1 Acquired second lock\n");
-				this.DocManager.ViewRefresh();
-				Thread.Sleep(5000);
-				try
-				{
-				}
-				catch
-				{
-				}
-				finally
-				{
-					m_rwl.ReleaseWriterLock();
-					Debug.Write ("Test Button 1 released first lock.\n");
-					m_rwl.ReleaseWriterLock();
-					Debug.Write ("Test Button 1 released second lock.\n");
-				}
-
-				return;
-			}
-			catch (Exception ex)
-			{
-				Debug.Write("Test Button 1 exception: " + ex.Message + "\n");
-			}
-		}
-
-		private void CGView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
-		{
-			try
-			{
-				m_ConnectInfo.BMXNetEvent -= m_bmxDelegate;
+				CGDocumentManager.Current.RemoteSession.EventServices.RpmsEvent -= BMXNetEventHandler;
 				this.calendarGrid1.CloseGrid();
 			}
@@ -3966,4 +3934,10 @@
         }
 
+        private void mnuViewBrokerLog_Click(object sender, EventArgs e)
+        {
+            var view = new RPCLoggerView();
+            view.Show();
+        }
+
 
     }//End class
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj	(revision 1474)
@@ -110,4 +110,16 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="BMXNET40, Version=4.0.0.1, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>bin\Release\BMXNET40.dll</HintPath>
+    </Reference>
+    <Reference Include="BMXWIN40, Version=4.0.0.1, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>bin\Release\BMXWIN40.dll</HintPath>
+    </Reference>
+    <Reference Include="PrintPreview, Version=1.0.4570.15574, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>bin\Release\PrintPreview.dll</HintPath>
+    </Reference>
     <Reference Include="System">
       <Name>System</Name>
@@ -148,4 +160,11 @@
     <Compile Include="Provider.cs" />
     <Compile Include="RadiologyExam.cs" />
+    <Compile Include="RPCLogger.cs" />
+    <Compile Include="RPCLoggerView.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="RPCLoggerView.Designer.cs">
+      <DependentUpon>RPCLoggerView.cs</DependentUpon>
+    </Compile>
     <Compile Include="strings.ar.Designer.cs">
       <AutoGen>True</AutoGen>
@@ -431,4 +450,7 @@
     <EmbeddedResource Include="LoadingSplash.resx">
       <DependentUpon>LoadingSplash.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="RPCLoggerView.resx">
+      <DependentUpon>RPCLoggerView.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="strings.ar.resx">
@@ -478,14 +500,4 @@
     <Folder Include="Properties\" />
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\BMX2\BMXNet\BMXNet.csproj">
-      <Project>{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}</Project>
-      <Name>BMXNet</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\EnhancedPrintPreview\PrintPreview\PrintPreview.csproj">
-      <Project>{9E8D433B-EFD1-4253-BD2C-C4E0DB0BFD0E}</Project>
-      <Name>PrintPreview</Name>
-    </ProjectReference>
-  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1474)
@@ -37,5 +37,5 @@
     </RemoteDebugMachine>
     <StartAction>Project</StartAction>
-    <StartArguments>/s=10.0.1.13 /p=9261 /a=shabiel12 /v=catdog.22</StartArguments>
+    <StartArguments>/s=10.0.1.13 /p=9431 /a=shabiel12 /v=catdog.22</StartArguments>
     <StartPage>
     </StartPage>
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.sln
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.sln	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.sln	(revision 1474)
@@ -7,7 +7,7 @@
 	EndProjectSection
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrintPreview", "..\EnhancedPrintPreview\PrintPreview\PrintPreview.csproj", "{9E8D433B-EFD1-4253-BD2C-C4E0DB0BFD0E}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IndianHealthService.BMXNet", "..\BMX4\IndianHealthService.BMXNet\IndianHealthService.BMXNet.csproj", "{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMXNet", "..\..\BMX2\BMXNet\BMXNet.csproj", "{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IndianHealthService.BMXNet.WinForm", "..\BMX4\IndianHealthService.BMXNet.WinForm\IndianHealthService.BMXNet.WinForm.csproj", "{3B9011B5-59F4-4F6B-ADC7-54ADC6948F4D}"
 EndProject
 Global
@@ -29,4 +29,8 @@
 		{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3B9011B5-59F4-4F6B-ADC7-54ADC6948F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3B9011B5-59F4-4F6B-ADC7-54ADC6948F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3B9011B5-59F4-4F6B-ADC7-54ADC6948F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3B9011B5-59F4-4F6B-ADC7-54ADC6948F4D}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/DAL.cs	(revision 1474)
@@ -16,5 +16,5 @@
     public class DAL
     {
-        private BMXNetConnectInfo _thisConnection; // set in constructor
+        private RemoteSession _thisConnection; // set in constructor
         
         delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName); // for use in calling (Sync and Async)
@@ -25,5 +25,5 @@
         /// </summary>
         /// <param name="conn">The current connection to use</param>
-        public DAL(BMXNetConnectInfo conn)
+        public DAL(RemoteSession conn)
         {
             this._thisConnection = conn;
@@ -39,5 +39,5 @@
         {
             string cmd = String.Format("BMX VERSION INFO^{0}", nmsp);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -50,5 +50,5 @@
         {
             string cmd = String.Format("BSDX SCHEDULING USER INFO^{0}", DUZ);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -65,8 +65,8 @@
         /// BLUE (NJ3,0), [0;7]
         ///</returns>
-        public DataTable GetAccessTypes()
+        public DataTable GetAccessTypes(DataSet dataSetToTakeTable, string tablename)
         {
             string sCommandText = "SELECT * FROM BSDX_ACCESS_TYPE";
-            DataTable table = RPMSDataTable(sCommandText, "");
+            DataTable table = _thisConnection.TableFromSQL(sCommandText, dataSetToTakeTable, tablename);
             DataColumn dcKey = table.Columns["BMXIEN"];
             DataColumn[] dcKeys = new DataColumn[1];
@@ -93,5 +93,5 @@
             string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
             string cmd = String.Format("BSDX CLINIC LETTERS^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -107,5 +107,5 @@
         {
             string cmd = String.Format("BSDX RESOURCE LETTERS^{0}", sClinicList);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -126,5 +126,5 @@
             string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
             string cmd = String.Format("BSDX REBOOK CLINIC LIST^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -139,5 +139,5 @@
         {
             string cmd = String.Format("BSDX REBOOK LIST^{0}", sApptList);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -157,5 +157,5 @@
             string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
             string cmd = String.Format("BSDX CANCEL CLINIC LIST^{0}^{1}^{2}", sClinicList, sBegin, sEnd);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -173,5 +173,5 @@
             string sEnd = FMDateTime.Create(EndDate).DateOnly.FMDateString;
             string cmd = String.Format("BSDX CANCEL AV BY DATE^{0}^{1}^{2}", sResourceID, sBegin, sEnd);
-            return RPMSDataTable(cmd, "Cancelled");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -185,5 +185,5 @@
         {
             string cmd = string.Format("BSDX REMOVE CHECK-IN^{0}", ApptID);
-            return RPMSDataTable(cmd, "");
+            return _thisConnection.TableFromCommand(cmd);
         }
 
@@ -197,5 +197,5 @@
         {
             string cmd = string.Format("BSDX GET RAD EXAM FOR PT^{0}^{1}", DFN, SCIEN);
-            DataTable tbl = RPMSDataTable(cmd, "");
+            DataTable tbl = _thisConnection.TableFromCommand(cmd);
             return (from row in tbl.AsEnumerable()
                     select new RadiologyExam
@@ -218,5 +218,5 @@
         {
             string fmStartDate = FMDateTime.Create(dStart).FMDateString;
-            string result = _thisConnection.bmxNetLib.TransmitRPC("BSDX SCHEDULE RAD EXAM", string.Format("{0}^{1}^{2}", DFN, examIEN, fmStartDate));
+            string result = _thisConnection.TransmitRPC("BSDX SCHEDULE RAD EXAM", string.Format("{0}^{1}^{2}", DFN, examIEN, fmStartDate));
             return result == "1" ? true : false;
         }
@@ -230,5 +230,5 @@
         public bool CancelRadiologyExam(int DFN, int examIEN)
         {
-            string result = _thisConnection.bmxNetLib.TransmitRPC("BSDX HOLD RAD EXAM", string.Format("{0}^{1}", DFN, examIEN));
+            string result = _thisConnection.TransmitRPC("BSDX HOLD RAD EXAM", string.Format("{0}^{1}", DFN, examIEN));
             return result == "1" ? true : false;
         }
@@ -241,5 +241,5 @@
         public bool CanCancelRadExam(int examIEN)
         {
-            string result = _thisConnection.bmxNetLib.TransmitRPC("BSDX CAN HOLD RAD EXAM", examIEN.ToString());
+            string result = _thisConnection.TransmitRPC("BSDX CAN HOLD RAD EXAM", examIEN.ToString());
             return result == "1" ? true : false;
         }
@@ -256,10 +256,10 @@
             get
             {
-                string val = _thisConnection.bmxNetLib.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT RS");  //1 = true; 0 = false; "" = not set
+                string val = _thisConnection.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT RS");  //1 = true; 0 = false; "" = not set
                 return val == "1" ? true : false;
             }
             set
             {
-                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.bmxNetLib.TransmitRPC);
+                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.TransmitRPC);
                 // 0 = success; anything else is wrong. Not being tested here as its success is not critical to application use.
                 _asyncTransmitter.BeginInvoke("BSDX SET PARAM", String.Format("{0}^{1}", "BSDX AUTO PRINT RS", value ? "1" : "0"), null, null);
@@ -278,10 +278,10 @@
             get
             {
-                string val = _thisConnection.bmxNetLib.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT AS");  //1 = true; 0 = false; "" = not set
+                string val = _thisConnection.TransmitRPC("BSDX GET PARAM", "BSDX AUTO PRINT AS");  //1 = true; 0 = false; "" = not set
                 return val == "1" ? true : false;
             }
             set
             {
-                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.bmxNetLib.TransmitRPC);
+                TransmitRPCAsync _asyncTransmitter = new TransmitRPCAsync(_thisConnection.TransmitRPC);
                 // 0 = success; anything else is wrong. Not being tested here as its success is not critical to application use.
                 _asyncTransmitter.BeginInvoke("BSDX SET PARAM", String.Format("{0}^{1}", "BSDX AUTO PRINT AS", value ? "1" : "0"), null, null);
@@ -303,10 +303,7 @@
             DataTable dtOut;
 
-#if TRACE
-            DateTime sendTime = DateTime.Now;
-#endif
             try
             {
-                RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(_thisConnection.RPMSDataTable);
+                RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(_thisConnection.TableFromSQL);
                 dtOut = (DataTable)rdtd.Invoke(sSQL, sTableName);
             }
@@ -317,10 +314,4 @@
                 throw ex;
             }
-
-#if TRACE
-            DateTime receiveTime = DateTime.Now;
-            TimeSpan executionTime = receiveTime - sendTime;
-            Debug.Write("RPMSDataTable Execution Time: " + executionTime.Milliseconds + " ms.\n");
-#endif
 
             return dtOut;
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/DManagement.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/DManagement.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/DManagement.cs	(revision 1474)
@@ -140,7 +140,6 @@
 			this.m_dsGlobal = m_DocManager.GlobalDataSet;
 
-			MgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(MgrEventHandler);
-			m_DocManager.ConnectInfo.BMXNetEvent += MgrEventDelegate;
-			m_DocManager.ConnectInfo.SubscribeEvent("BSDX WORKSTATION REPORT");
+            m_DocManager.RemoteSession.EventServices.RpmsEvent += MgrEventHandler;
+			m_DocManager.RemoteSession.EventServices.Subscribe("BSDX WORKSTATION REPORT");
 			m_dtWSGrid = new DataTable("WSGrid");
 			m_dtWSGrid.Columns.Add("UserName", typeof(System.String));
@@ -1899,7 +1898,8 @@
             m_dsGlobal.Tables["AccessTypes"].Clear();
             m_dsGlobal.Tables["AccessGroupType"].Clear();
-            DataTable dt1 = m_DocManager.DAL.GetAccessTypes();
-            m_dsGlobal.Tables["AccessTypes"].Merge(dt1);
-            m_dsGlobal.Tables.Add(dt1);
+            //PORT TODO: This may fail.
+            DataTable dt1 = m_DocManager.DAL.GetAccessTypes(m_dsGlobal, "AccessTypes");
+            //m_dsGlobal.Tables["AccessTypes"].Merge(dt1); //smh -commented out for BMX4
+            //m_dsGlobal.Tables.Add(dt1);                  //smh -commented out for BMX4
             //Fix Groups
             //m_DocManager.LoadAccessTypesTable();
@@ -2329,15 +2329,14 @@
 		{
 			this.m_dtWSGrid.Clear();
-			this.m_DocManager.ConnectInfo.RaiseEvent("BSDX CALL WORKSTATIONS", "A", true);
-		}
-
-		private BMXNetConnectInfo.BMXNetEventDelegate	MgrEventDelegate;
+			this.m_DocManager.RemoteSession.EventServices.TriggerEvent("BSDX CALL WORKSTATIONS", "A", true);
+		}
+
 		delegate void UpdateWorkstationGridDelegate(string sParam);
 
-		private void MgrEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
+		private void MgrEventHandler(Object obj, RemoteEventArgs e)
 		{
 			try
 			{
-				if (e.BMXEvent == "BSDX WORKSTATION REPORT")
+				if (e.EventType == "BSDX WORKSTATION REPORT")
 				{
 					Debug.Write("DManagement Got Workstation Report\n");
@@ -2345,9 +2344,9 @@
                     if (this.InvokeRequired == true) //ensures that handle is created
                     {
-                        this.Invoke(uWSGd, new object[] { e.BMXParam });
+                        this.Invoke(uWSGd, new object[] { e.Details });
                     }
                     else
                     {
-                        UpdateWorkstationGrid(e.BMXParam);
+                        UpdateWorkstationGrid(e.Details);
                     }
 				}
@@ -2363,8 +2362,8 @@
 			string sDelim = "~";
 			DataRow dr = this.m_dtWSGrid.NewRow();
-			dr["UserName"] = BMXNetLib.Piece(sParam,sDelim,1);
-			dr["Handle"] = BMXNetLib.Piece(sParam,sDelim,2);
-			dr["Version"] = BMXNetLib.Piece(sParam,sDelim,3);		
-			dr["Views"] = BMXNetLib.Piece(sParam,sDelim,4);
+			dr["UserName"] = M.Piece(sParam,sDelim,1);
+			dr["Handle"] = M.Piece(sParam,sDelim,2);
+			dr["Version"] = M.Piece(sParam,sDelim,3);		
+			dr["Views"] = M.Piece(sParam,sDelim,4);
 			m_dtWSGrid.Rows.Add(dr);
 		}
@@ -2372,5 +2371,5 @@
 		private void DManagement_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 		{
-			m_DocManager.ConnectInfo.UnSubscribeEvent("BSDX WORKSTATION REPORT");
+			CGDocumentManager.Current.RemoteSession.EventServices.Unsubscribe("BSDX WORKSTATION REPORT");
 		}
 
@@ -2389,5 +2388,5 @@
 				return;
 
-			this.m_DocManager.ConnectInfo.RaiseEvent("BSDX ADMIN MESSAGE", sMessage, false);
+            this.m_DocManager.RemoteSession.EventServices.TriggerEvent("BSDX ADMIN MESSAGE", sMessage, false);
 		}
 
@@ -2398,5 +2397,5 @@
 				return;
 			}
-			this.m_DocManager.ConnectInfo.RaiseEvent("BSDX ADMIN SHUTDOWN", txtSendMessage.Text, false);
+            this.m_DocManager.RemoteSession.EventServices.TriggerEvent("BSDX ADMIN SHUTDOWN", txtSendMessage.Text, false);
         }
         #endregion Workstations
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs	(revision 1473)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs	(revision 1474)
@@ -217,5 +217,5 @@
             // Draw Header 
 
-            string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
+            string division = CGDocumentManager.Current.RemoteSession.User.Division.Name;
             int divisionStringHeight = (int)g.MeasureString(division.ToString(), fontBody, e.PageBounds.Width - (int)(10 * widthRatio) - HardMarginX).Height;
             
@@ -691,5 +691,5 @@
 
             // Draw Header
-            string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
+            string division = CGDocumentManager.Current.RemoteSession.User.Division.Name;
             int divisionStringHeight = (int)g.MeasureString(division.ToString(), fontBody, e.MarginBounds.Width).Height;
             Rectangle headerArea = new Rectangle()
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLogger.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLogger.cs	(revision 1474)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLogger.cs	(revision 1474)
@@ -0,0 +1,102 @@
+﻿/* Written by Sam Habiel in May 2011
+ * Licensed under LGPL */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using IndianHealthService.BMXNet;
+using System.Diagnostics;
+
+namespace IndianHealthService.ClinicalScheduling
+{
+    /// <summary>
+    /// Class to Log Calls to RPMS/VISTA back and forth. Implements BMXNet.[I]Log interaface.
+    /// Logger is implemented as a Queue Collection of class EventToLog
+    /// </summary>
+    public class RPCLogger: Log
+    {
+        /// <summary>
+        /// Max size of Log
+        /// </summary>
+        const int maxsize = 1000;
+
+        /// <summary>
+        /// Stop Watch to keep track of time between calls.
+        /// </summary>
+        Stopwatch _watch;
+
+        /// <summary>
+        /// ctor
+        /// </summary>
+        public RPCLogger()
+        {
+            _logger = new List<EventToLog>(maxsize);
+            _watch = new Stopwatch();
+            _watch.Start();
+        }
+
+        public bool IsLogging { get; set; }
+
+        //Event to notify interested controls that we have more data
+        public event EventHandler<EventToLog> HaveMoreData;
+
+        private List<EventToLog> _logger;
+        
+        public List<EventToLog> Logger
+        {
+        get { return _logger; } 
+        }
+
+        /// <summary>
+        /// Data Structure to Log
+        /// </summary>
+        public class EventToLog: EventArgs
+        {
+            public DateTime EventTime { get; set; }
+            public long ElapasedTime { get; set; }
+            public string Class { get; set; }
+            public string Category { get; set; }
+            public string Lines { get; set; }
+            public Exception Exception { get; set; }
+
+            public override string ToString()
+            {
+                return EventTime.TimeOfDay + "\t" + Category + "\t" + Class + "\t" + ElapasedTime + " ms";
+            }
+        }
+
+        /// <summary>
+        /// Chained to Below
+        /// </summary>
+        public void Log(string aClass, string aCategory, params string[] lines)
+        {
+            Log(aClass, aCategory, null, lines);
+        }
+
+        /// <summary>
+        /// Adds Log entry to queue object
+        /// </summary>
+        public void Log(string aClass, string aCategory, Exception anException, params string[] lines)
+        {
+            if (_logger.Count >= maxsize - 1) _logger.RemoveAt(_logger.Count - 1);
+
+            EventToLog _e = new EventToLog
+            {
+                EventTime = DateTime.Now,
+                Class = aClass,
+                Category = aCategory,
+                Lines = String.Join("\r\n", lines),
+                Exception = anException,
+                ElapasedTime = _watch.ElapsedMilliseconds
+            };
+
+            _logger.Add(_e);
+
+            _watch.Reset();
+            _watch.Start();
+
+            //Tell subscribers to this event that we want attention!!!!
+            if (HaveMoreData != null) HaveMoreData(this, _e);
+        }
+    }
+}
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.Designer.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.Designer.cs	(revision 1474)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.Designer.cs	(revision 1474)
@@ -0,0 +1,99 @@
+﻿namespace IndianHealthService.ClinicalScheduling
+{
+    partial class RPCLoggerView
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.lstRPCEvents = new System.Windows.Forms.ListBox();
+            this.txtRPCEvent = new System.Windows.Forms.TextBox();
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
+            this.splitContainer1.Panel1.SuspendLayout();
+            this.splitContainer1.Panel2.SuspendLayout();
+            this.splitContainer1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Name = "splitContainer1";
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.lstRPCEvents);
+            // 
+            // splitContainer1.Panel2
+            // 
+            this.splitContainer1.Panel2.Controls.Add(this.txtRPCEvent);
+            this.splitContainer1.Size = new System.Drawing.Size(894, 262);
+            this.splitContainer1.SplitterDistance = 342;
+            this.splitContainer1.TabIndex = 0;
+            // 
+            // lstRPCEvents
+            // 
+            this.lstRPCEvents.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstRPCEvents.FormattingEnabled = true;
+            this.lstRPCEvents.Location = new System.Drawing.Point(0, 0);
+            this.lstRPCEvents.Name = "lstRPCEvents";
+            this.lstRPCEvents.Size = new System.Drawing.Size(342, 262);
+            this.lstRPCEvents.TabIndex = 0;
+            this.lstRPCEvents.SelectedIndexChanged += new System.EventHandler(this.lstRPCEvents_SelectedIndexChanged);
+            // 
+            // txtRPCEvent
+            // 
+            this.txtRPCEvent.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.txtRPCEvent.Location = new System.Drawing.Point(0, 0);
+            this.txtRPCEvent.Multiline = true;
+            this.txtRPCEvent.Name = "txtRPCEvent";
+            this.txtRPCEvent.Size = new System.Drawing.Size(548, 262);
+            this.txtRPCEvent.TabIndex = 0;
+            // 
+            // RPCLoggerView
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(894, 262);
+            this.Controls.Add(this.splitContainer1);
+            this.Name = "RPCLoggerView";
+            this.Text = "BMX RPC Log View";
+            this.splitContainer1.Panel1.ResumeLayout(false);
+            this.splitContainer1.Panel2.ResumeLayout(false);
+            this.splitContainer1.Panel2.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
+            this.splitContainer1.ResumeLayout(false);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.SplitContainer splitContainer1;
+        private System.Windows.Forms.TextBox txtRPCEvent;
+        private System.Windows.Forms.ListBox lstRPCEvents;
+    }
+}
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.cs
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.cs	(revision 1474)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.cs	(revision 1474)
@@ -0,0 +1,60 @@
+﻿using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace IndianHealthService.ClinicalScheduling
+{
+    /// <summary>
+    /// This form displays the RPC Events found in RPCLogger
+    /// </summary>
+    public partial class RPCLoggerView : Form
+    {
+        public RPCLoggerView()
+        {
+            InitializeComponent();
+            lstRPCEvents.BeginUpdate();     // Stop redrawing
+            foreach (var eventItem in CGDocumentManager.Current.RPCLogger.Logger) lstRPCEvents.Items.Add(eventItem); // Add the stuff
+            lstRPCEvents.EndUpdate();       // Draw Again
+
+            //We are interested in event HaveMoreData. Each time it happens, it means we have an extra item we need to add.
+            CGDocumentManager.Current.RPCLogger.HaveMoreData += new EventHandler<RPCLogger.EventToLog>(RPCLogger_HaveMoreData);
+        }
+
+        // Dummmy delegate for the method below to use in this.Invoke
+        delegate void dAny(object s, RPCLogger.EventToLog e);
+
+        /// <summary>
+        /// Adds the new RPC event to Listbox
+        /// </summary>
+        /// <param name="sender">this is the RPCLogger Object. It's not used</param>
+        /// <param name="e">That's the custom logged event.</param>
+        void RPCLogger_HaveMoreData(object sender, RPCLogger.EventToLog e)
+        {
+            if (this.InvokeRequired)
+            {
+                dAny d = new dAny(this.RPCLogger_HaveMoreData);
+                this.Invoke(d, new object[] { sender, e });
+                return;
+            }
+
+            lstRPCEvents.Items.Add(e);
+        }
+
+        /// <summary>
+        /// Puts the text of the event in the text box
+        /// </summary>
+        /// <param name="sender">useless</param>
+        /// <param name="e">useless</param>
+        private void lstRPCEvents_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            RPCLogger.EventToLog l = lstRPCEvents.SelectedItem as RPCLogger.EventToLog;
+            if (l == null) return;
+            txtRPCEvent.Text = l.Lines + "\r\n" + l.Exception ?? ""; 
+        }
+    }
+}
Index: /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.resx
===================================================================
--- /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.resx	(revision 1474)
+++ /Scheduling/trunk/cs/bsdx0200GUISourceCode/RPCLoggerView.resx	(revision 1474)
@@ -0,0 +1,120 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
