[614] | 1 | using System;
|
---|
| 2 | using System.Windows.Forms;
|
---|
| 3 | using System.Collections;
|
---|
| 4 | using System.Data;
|
---|
| 5 | using System.Diagnostics;
|
---|
| 6 | using IndianHealthService.BMXNet;
|
---|
[772] | 7 | using Mono.Options;
|
---|
[788] | 8 | using System.Runtime.InteropServices;
|
---|
[614] | 9 |
|
---|
| 10 | namespace IndianHealthService.ClinicalScheduling
|
---|
| 11 | {
|
---|
| 12 | /// <summary>
|
---|
| 13 | /// Summary description for DocumentManager.
|
---|
| 14 | /// </summary>
|
---|
| 15 | public class CGDocumentManager : System.Windows.Forms.Form
|
---|
| 16 | {
|
---|
| 17 | #region Member Variables
|
---|
| 18 |
|
---|
| 19 | private static CGDocumentManager _current;
|
---|
| 20 | private Hashtable _views = new Hashtable();
|
---|
| 21 | private Hashtable m_AVViews = new Hashtable();
|
---|
[620] | 22 | private string m_sWindowText = "Clinical Scheduling"; //Default Window Text
|
---|
[614] | 23 | private bool m_bSchedManager;
|
---|
| 24 | private bool m_bExitOK = true;
|
---|
| 25 | public string m_sHandle = "0";
|
---|
[772] | 26 | private string m_AccessCode="";
|
---|
| 27 | private string m_VerifyCode="";
|
---|
| 28 | private string m_Server="";
|
---|
| 29 | private int m_Port=0;
|
---|
[614] | 30 |
|
---|
| 31 | //M Connection member variables
|
---|
| 32 | private DataSet m_dsGlobal = null;
|
---|
| 33 | private System.ComponentModel.IContainer components = null;
|
---|
| 34 | private BMXNetConnectInfo m_ConnectInfo = null;
|
---|
| 35 | private BMXNetConnectInfo.BMXNetEventDelegate CDocMgrEventDelegate;
|
---|
| 36 |
|
---|
| 37 | #endregion
|
---|
| 38 |
|
---|
| 39 | public CGDocumentManager()
|
---|
| 40 | {
|
---|
| 41 | InitializeComponent();
|
---|
| 42 | m_ConnectInfo = new BMXNetConnectInfo();
|
---|
| 43 | //m_ConnectInfo.bmxNetLib.StartLog(); //This line turns on logging of messages
|
---|
| 44 | m_bSchedManager = false;
|
---|
| 45 | CDocMgrEventDelegate = new BMXNetConnectInfo.BMXNetEventDelegate(CDocMgrEventHandler);
|
---|
| 46 | m_ConnectInfo.BMXNetEvent += CDocMgrEventDelegate;
|
---|
| 47 | m_ConnectInfo.EventPollingEnabled = false;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | #region BMXNet Event Handler
|
---|
| 51 | private void CDocMgrEventHandler(Object obj, BMXNet.BMXNetEventArgs e)
|
---|
| 52 | {
|
---|
| 53 | if (e.BMXEvent == "BSDX CALL WORKSTATIONS")
|
---|
| 54 | {
|
---|
| 55 | string sParam = "";
|
---|
| 56 | string sDelim="~";
|
---|
| 57 | sParam += this.m_ConnectInfo.UserName + sDelim;
|
---|
| 58 | sParam += this.m_sHandle + sDelim;
|
---|
| 59 | sParam += Application.ProductVersion + sDelim;
|
---|
| 60 | sParam += this._views.Count.ToString();
|
---|
| 61 | _current.m_ConnectInfo.RaiseEvent("BSDX WORKSTATION REPORT", sParam, true);
|
---|
| 62 | }
|
---|
| 63 | if (e.BMXEvent == "BSDX ADMIN MESSAGE")
|
---|
| 64 | {
|
---|
| 65 | string sMsg = e.BMXParam;
|
---|
| 66 | ShowAdminMsgDelegate samd = new ShowAdminMsgDelegate(ShowAdminMsg);
|
---|
| 67 | this.Invoke(samd, new object [] {sMsg});
|
---|
| 68 | }
|
---|
| 69 | if (e.BMXEvent == "BSDX ADMIN SHUTDOWN")
|
---|
| 70 | {
|
---|
| 71 | string sMsg = e.BMXParam;
|
---|
| 72 | CloseAllDelegate cad = new CloseAllDelegate(CloseAll);
|
---|
| 73 | this.Invoke(cad, new object [] {sMsg});
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | delegate void ShowAdminMsgDelegate(string sMsg);
|
---|
| 78 |
|
---|
| 79 | private void ShowAdminMsg(string sMsg)
|
---|
| 80 | {
|
---|
| 81 | MessageBox.Show(sMsg, "Message from Scheduling Administrator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | #endregion BMXNet Event Handler
|
---|
| 85 |
|
---|
| 86 | #region Properties
|
---|
| 87 |
|
---|
| 88 | /// <summary>
|
---|
| 89 | /// Returns the document manager's BMXNetConnectInfo member
|
---|
| 90 | /// </summary>
|
---|
| 91 | public BMXNetConnectInfo ConnectInfo
|
---|
| 92 | {
|
---|
| 93 | get
|
---|
| 94 | {
|
---|
| 95 | return m_ConnectInfo;
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /// <summary>
|
---|
| 100 | /// True if the current user holds the BSDXZMGR or XUPROGMODE keys in RPMS
|
---|
| 101 | /// </summary>
|
---|
| 102 | public bool ScheduleManager
|
---|
| 103 | {
|
---|
| 104 | get
|
---|
| 105 | {
|
---|
| 106 | return m_bSchedManager;
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | /// <summary>
|
---|
| 111 | /// Holds the user and division
|
---|
| 112 | /// </summary>
|
---|
| 113 | public string WindowText
|
---|
| 114 | {
|
---|
| 115 | get
|
---|
| 116 | {
|
---|
| 117 | return m_sWindowText;
|
---|
| 118 | }
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /// <summary>
|
---|
| 122 | /// This dataset contains tables used by the entire application
|
---|
| 123 | /// </summary>
|
---|
| 124 | public DataSet GlobalDataSet
|
---|
| 125 | {
|
---|
| 126 | get
|
---|
| 127 | {
|
---|
| 128 | return m_dsGlobal;
|
---|
| 129 | }
|
---|
| 130 | set
|
---|
| 131 | {
|
---|
| 132 | m_dsGlobal = value;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 | //public BMXNetConnection ADOConnection
|
---|
| 136 | //{
|
---|
| 137 | // get
|
---|
| 138 | // {
|
---|
| 139 | // return m_ADOConnection;
|
---|
| 140 | // }
|
---|
| 141 | //}
|
---|
| 142 |
|
---|
| 143 | /// <summary>
|
---|
| 144 | /// Returns the single CGDocumentManager object
|
---|
| 145 | /// </summary>
|
---|
| 146 | public static CGDocumentManager Current
|
---|
| 147 | {
|
---|
| 148 | get
|
---|
| 149 | {
|
---|
| 150 | return _current;
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /// <summary>
|
---|
| 155 | /// Returns the list of currently opened documents
|
---|
| 156 | /// </summary>
|
---|
| 157 | public Hashtable Views
|
---|
| 158 | {
|
---|
| 159 | get
|
---|
| 160 | {
|
---|
| 161 | return _views;
|
---|
| 162 | }
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | /// <summary>
|
---|
| 166 | /// Returns the list of currently opened CGAVViews
|
---|
| 167 | /// </summary>
|
---|
| 168 | public Hashtable AvailabilityViews
|
---|
| 169 | {
|
---|
| 170 | get
|
---|
| 171 | {
|
---|
| 172 | return this.m_AVViews;
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | #endregion
|
---|
| 178 |
|
---|
| 179 | #region Methods & Events
|
---|
| 180 | /// <summary>
|
---|
| 181 | /// Clean up any resources being used.
|
---|
| 182 | /// </summary>
|
---|
| 183 | protected override void Dispose( bool disposing )
|
---|
| 184 | {
|
---|
| 185 | if( disposing )
|
---|
| 186 | {
|
---|
| 187 | if (m_ConnectInfo != null)
|
---|
| 188 | {
|
---|
| 189 | m_ConnectInfo.EventPollingEnabled = false;
|
---|
| 190 | m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
|
---|
| 191 | m_ConnectInfo.UnSubscribeEvent("BSDX CALL WORKSTATIONS");
|
---|
| 192 | m_ConnectInfo.CloseConnection();
|
---|
| 193 | }
|
---|
| 194 | if (components != null)
|
---|
| 195 | {
|
---|
| 196 | components.Dispose();
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
| 199 | base.Dispose( disposing );
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | private void InitializeComponent()
|
---|
| 204 | {
|
---|
| 205 | //
|
---|
| 206 | // CGDocumentManager
|
---|
| 207 | //
|
---|
| 208 | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
---|
| 209 | this.ClientSize = new System.Drawing.Size(292, 266);
|
---|
| 210 | this.Name = "CGDocumentManager";
|
---|
| 211 |
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 | private DSplash m_ds;
|
---|
| 216 | public void StartSplash()
|
---|
| 217 | {
|
---|
| 218 | m_ds = new DSplash();
|
---|
| 219 | m_ds.ShowDialog();
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | private void InitializeApp()
|
---|
| 223 | {
|
---|
| 224 | InitializeApp(false);
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | private void InitializeApp(bool bReLogin)
|
---|
| 228 | {
|
---|
| 229 | try
|
---|
| 230 | {
|
---|
| 231 | //Set M connection info
|
---|
| 232 | //Show a splash screen while initializing
|
---|
| 233 | m_ds = new DSplash();
|
---|
| 234 | m_ds.Show(this);
|
---|
| 235 | m_ds.SetStatus("Loading Configuration Settings...");
|
---|
| 236 | m_ds.Refresh();
|
---|
| 237 | this.Activate();
|
---|
| 238 | System.Configuration.ConfigurationManager.GetSection("appSettings");
|
---|
[627] | 239 | m_ds.SetStatus("Connecting to VistA Server...");
|
---|
[614] | 240 | m_ds.Refresh();
|
---|
| 241 | bool bRetry = true;
|
---|
| 242 | do
|
---|
| 243 | {
|
---|
| 244 | try
|
---|
| 245 | {
|
---|
| 246 | if (bReLogin == true)
|
---|
| 247 | {
|
---|
| 248 | //Prompt for Access and Verify codes
|
---|
| 249 | _current.m_ConnectInfo.LoadConnectInfo("", "");
|
---|
| 250 | }
|
---|
| 251 | else
|
---|
| 252 | {
|
---|
[772] | 253 | if (m_Server != String.Empty && m_Port != 0 && m_AccessCode != String.Empty
|
---|
| 254 | && m_VerifyCode != String.Empty)
|
---|
| 255 | m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, m_AccessCode, m_VerifyCode);
|
---|
| 256 | else if (m_Server != String.Empty && m_Port != 0)
|
---|
[788] | 257 | m_ConnectInfo.LoadConnectInfo(m_Server, m_Port, "", "");
|
---|
[772] | 258 | else
|
---|
[788] | 259 | m_ConnectInfo.LoadConnectInfo();
|
---|
[772] | 260 | }
|
---|
[614] | 261 | bRetry = false;
|
---|
| 262 | }
|
---|
| 263 | catch (Exception ex)
|
---|
| 264 | {
|
---|
| 265 | m_ds.Close();
|
---|
[627] | 266 | if (MessageBox.Show("Unable to connect to VistA. " + ex.Message , "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
|
---|
[614] | 267 | {
|
---|
| 268 | bRetry = true;
|
---|
| 269 | _current.m_ConnectInfo.ChangeServerInfo();
|
---|
| 270 | }
|
---|
| 271 | else
|
---|
| 272 | {
|
---|
| 273 | bRetry = false;
|
---|
| 274 | throw ex;
|
---|
| 275 | }
|
---|
| 276 | }
|
---|
| 277 | }while (bRetry == true);
|
---|
| 278 |
|
---|
| 279 | //Create global dataset
|
---|
| 280 | _current.m_dsGlobal = new DataSet("GlobalDataSet");
|
---|
| 281 |
|
---|
| 282 | //Version info
|
---|
| 283 | m_ds.SetStatus("Getting Version Info...");
|
---|
| 284 | m_ds.Refresh();
|
---|
| 285 | String sCmd = "BMX VERSION INFO^BSDX^";
|
---|
| 286 | this.m_ConnectInfo.RPMSDataTable(sCmd, "VersionInfo", m_dsGlobal);
|
---|
| 287 |
|
---|
| 288 | //Keep the following commented code for future use:
|
---|
| 289 | //How to extract the version numbers:
|
---|
| 290 | //DataTable dtVersion = m_dsGlobal.Tables["VersionInfo"];
|
---|
| 291 | //Debug.Assert(dtVersion.Rows.Count == 1);
|
---|
| 292 | //DataRow rVersion = dtVersion.Rows[0];
|
---|
| 293 | //string sMajor = rVersion["MAJOR_VERSION"].ToString();
|
---|
| 294 | //string sMinor = rVersion["MINOR_VERSION"].ToString();
|
---|
| 295 | //string sBuild = rVersion["BUILD"].ToString();
|
---|
| 296 | //decimal fBuild = Convert.ToDecimal(sBuild);
|
---|
| 297 |
|
---|
| 298 | //Set application context
|
---|
[772] | 299 | m_ds.SetStatus("Setting Application Context to BSDXRPC...");
|
---|
[614] | 300 | m_ds.Refresh();
|
---|
| 301 | m_ConnectInfo.AppContext = "BSDXRPC";
|
---|
| 302 |
|
---|
| 303 | //Load global recordsets
|
---|
[627] | 304 | m_ds.SetStatus("Loading VistA data tables...");
|
---|
[614] | 305 | m_ds.Refresh();
|
---|
| 306 | if (_current.LoadGlobalRecordsets() == false)
|
---|
| 307 | {
|
---|
[627] | 308 | MessageBox.Show("Unable to create VistA recordsets"); //TODO Improve this message
|
---|
[614] | 309 | m_ds.Close();
|
---|
| 310 | return;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | System.IntPtr pHandle = this.Handle;
|
---|
| 314 | System.IntPtr pConnHandle = this.ConnectInfo.Handle;
|
---|
| 315 | this.m_sHandle = pHandle.ToString();
|
---|
| 316 |
|
---|
| 317 | _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
|
---|
| 318 |
|
---|
| 319 | #if DEBUG
|
---|
| 320 | _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
|
---|
| 321 | #endif
|
---|
| 322 | _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
|
---|
| 323 | _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
|
---|
| 324 | _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
|
---|
| 325 | _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
|
---|
| 326 |
|
---|
| 327 | _current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
|
---|
| 328 | _current.m_ConnectInfo.EventPollingEnabled = true;
|
---|
| 329 | _current.m_ConnectInfo.AutoFire = 12; //AutoFire every 12*5 seconds
|
---|
| 330 |
|
---|
| 331 | m_ds.Close();
|
---|
| 332 | }
|
---|
| 333 | catch (Exception ex)
|
---|
| 334 | {
|
---|
| 335 | m_ds.Close();
|
---|
| 336 | Debug.Write(ex.Message);
|
---|
| 337 | MessageBox.Show(ex.Message + ex.StackTrace, "Clinical Scheduling Error -- Closing Application");
|
---|
| 338 | throw ex;
|
---|
| 339 | }
|
---|
| 340 | }
|
---|
| 341 |
|
---|
[788] | 342 | //To write to the console
|
---|
| 343 | [DllImport("kernel32.dll")]
|
---|
| 344 | static extern bool AttachConsole(int dwProcessId);
|
---|
| 345 | private const int ATTACH_PARENT_PROCESS = -1;
|
---|
| 346 |
|
---|
| 347 | [STAThread()]
|
---|
| 348 | static void Main(string[] args)
|
---|
[614] | 349 | {
|
---|
[788] | 350 | #if DEBUG
|
---|
| 351 | // Print console messages to console if launched from console
|
---|
| 352 | AttachConsole(ATTACH_PARENT_PROCESS);
|
---|
| 353 | #endif
|
---|
[614] | 354 | try
|
---|
[788] | 355 | {
|
---|
[772] | 356 | //Store the current manager
|
---|
[614] | 357 | _current = new CGDocumentManager();
|
---|
[772] | 358 |
|
---|
[788] | 359 | //Get command line options; store in private variables
|
---|
| 360 | var opset = new OptionSet () {
|
---|
| 361 | { "s=", s => _current.m_Server = s },
|
---|
| 362 | { "p=", p => _current.m_Port = int.Parse(p) },
|
---|
| 363 | { "a=", a => _current.m_AccessCode = a },
|
---|
| 364 | { "v=", v => _current.m_VerifyCode = v }
|
---|
[772] | 365 | };
|
---|
[614] | 366 |
|
---|
[772] | 367 | opset.Parse(args);
|
---|
| 368 |
|
---|
[614] | 369 | try
|
---|
| 370 | {
|
---|
| 371 | _current.InitializeApp();
|
---|
| 372 | }
|
---|
| 373 | catch (Exception ex)
|
---|
| 374 | {
|
---|
| 375 | Debug.Write(ex.Message);
|
---|
| 376 | return;
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 | //Create the first empty document
|
---|
| 380 | CGDocument doc = new CGDocument();
|
---|
| 381 | doc.DocManager = _current;
|
---|
| 382 | doc.OnNewDocument();
|
---|
| 383 | Application.DoEvents();
|
---|
| 384 |
|
---|
| 385 | //Run the application
|
---|
| 386 | Application.Run();
|
---|
| 387 | }
|
---|
| 388 | catch (Exception ex)
|
---|
| 389 | {
|
---|
| 390 | Debug.Write(ex.Message);
|
---|
| 391 | MessageBox.Show(ex.Message + ex.StackTrace, "CGDocumentManager.Main(): Clinical Scheduling Error -- Closing Application");
|
---|
| 392 | return;
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | public void LoadAccessTypesTable()
|
---|
| 397 | {
|
---|
| 398 | string sCommandText = "SELECT * FROM BSDX_ACCESS_TYPE";
|
---|
| 399 | ConnectInfo.RPMSDataTable(sCommandText, "AccessTypes", m_dsGlobal);
|
---|
| 400 | Debug.Write("LoadGlobalRecordsets -- AccessTypes loaded\n");
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | public void LoadAccessGroupsTable()
|
---|
| 404 | {
|
---|
| 405 | string sCommandText = "SELECT * FROM BSDX_ACCESS_GROUP";
|
---|
| 406 | ConnectInfo.RPMSDataTable(sCommandText, "AccessGroup", m_dsGlobal);
|
---|
| 407 | Debug.Write("LoadGlobalRecordsets -- AccessGroups loaded\n");
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | public void LoadAccessGroupTypesTable()
|
---|
| 411 | {
|
---|
| 412 | string sCommandText = "BSDX GET ACCESS GROUP TYPES";
|
---|
| 413 | ConnectInfo.RPMSDataTable(sCommandText, "AccessGroupType", m_dsGlobal);
|
---|
| 414 | Debug.Write("LoadGlobalRecordsets -- AccessGroupTypes loaded\n");
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | public void LoadClinicSetupTable()
|
---|
| 418 | {
|
---|
| 419 | string sCommandText = "BSDX CLINIC SETUP";
|
---|
| 420 | ConnectInfo.RPMSDataTable(sCommandText, "ClinicSetupParameters", m_dsGlobal);
|
---|
| 421 | Debug.Write("LoadGlobalRecordsets -- ClinicSetupParameters loaded\n");
|
---|
| 422 | }
|
---|
| 423 |
|
---|
| 424 | public void LoadBSDXResourcesTable()
|
---|
| 425 | {
|
---|
| 426 | string sCommandText = "BSDX RESOURCES^" + m_ConnectInfo.DUZ;
|
---|
| 427 | ConnectInfo.RPMSDataTable(sCommandText, "Resources", m_dsGlobal);
|
---|
| 428 | Debug.Write("LoadGlobalRecordsets -- Resources loaded\n");
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | public void LoadResourceGroupTable()
|
---|
| 432 | {
|
---|
| 433 | //ResourceGroup Table (Resource Groups by User)
|
---|
| 434 | //Table "ResourceGroup" contains all resource group names
|
---|
| 435 | //to which user has access
|
---|
| 436 | //Fields are: RESOURCE_GROUPID, RESOURCE_GROUP
|
---|
| 437 | string sCommandText = "BSDX RESOURCE GROUPS BY USER^" + m_ConnectInfo.DUZ;
|
---|
| 438 | ConnectInfo.RPMSDataTable(sCommandText, "ResourceGroup", m_dsGlobal);
|
---|
| 439 | Debug.Write("LoadGlobalRecordsets -- ResourceGroup loaded\n");
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | public void LoadGroupResourcesTable()
|
---|
| 443 | {
|
---|
| 444 | //Table "GroupResources" contains all active GROUP/RESOURCE combinations
|
---|
| 445 | //to which user has access based on entries in BSDX RESOURCE USER file
|
---|
| 446 | //If user has BSDXZMGR or XUPROGMODE keys, then ALL Group/Resource combinstions
|
---|
| 447 | //are returned.
|
---|
| 448 | //Fields are: RESOURCE_GROUPID, RESOURCE_GROUP, RESOURCE_GROUP_ITEMID, RESOURCE_NAME, RESOURCE_ID
|
---|
| 449 | string sCommandText = "BSDX GROUP RESOURCE^" + m_ConnectInfo.DUZ;
|
---|
| 450 | ConnectInfo.RPMSDataTable(sCommandText, "GroupResources", m_dsGlobal);
|
---|
| 451 | Debug.Write("LoadGlobalRecordsets -- GroupResources loaded\n");
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | public void LoadScheduleUserTable()
|
---|
| 455 | {
|
---|
| 456 | //Table "ScheduleUser" contains an entry for each user in File 200 (NEW PERSON)
|
---|
| 457 | //who possesses the BSDXZMENU security key.
|
---|
| 458 | string sCommandText = "BSDX SCHEDULE USER";
|
---|
| 459 | ConnectInfo.RPMSDataTable(sCommandText, "ScheduleUser", m_dsGlobal);
|
---|
| 460 | Debug.Write("LoadGlobalRecordsets -- ScheduleUser loaded\n");
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | public void LoadResourceUserTable()
|
---|
| 464 | {
|
---|
| 465 | //Table "ResourceUser" duplicates the BSDX RESOURCE USER File.
|
---|
| 466 | //NOTE: Column names are RESOURCEUSER_ID, RESOURCEID,
|
---|
| 467 | // OVERBOOK, MODIFY_SCHEDULE, USERID, USERID1
|
---|
| 468 | //string sCommandText = "SELECT BMXIEN RESOURCEUSER_ID, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, USERNAME USERID, INTERNAL[USERNAME] FROM BSDX_RESOURCE_USER";
|
---|
| 469 | LoadResourceUserTable(false);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | public void LoadResourceUserTable(bool bAllUsers)
|
---|
| 473 | {
|
---|
| 474 | string sCommandText = "SELECT BMXIEN RESOURCEUSER_ID, RESOURCENAME, INTERNAL[RESOURCENAME] RESOURCEID, OVERBOOK, MODIFY_SCHEDULE, MODIFY_APPOINTMENTS, USERNAME, INTERNAL[USERNAME] USERID FROM BSDX_RESOURCE_USER";
|
---|
| 475 | ConnectInfo.RPMSDataTable(sCommandText, "ResourceUser", m_dsGlobal);
|
---|
| 476 | Debug.Write("LoadGlobalRecordsets -- ResourceUser loaded\n");
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | private bool LoadGlobalRecordsets()
|
---|
| 480 | {
|
---|
| 481 | //Schedule User Info
|
---|
| 482 | string sCommandText = "BSDX SCHEDULING USER INFO^" + m_ConnectInfo.DUZ;
|
---|
| 483 | DataTable dtUser = ConnectInfo.RPMSDataTable(sCommandText, "SchedulingUser", m_dsGlobal);
|
---|
| 484 |
|
---|
| 485 | Debug.Assert(dtUser.Rows.Count == 1);
|
---|
| 486 | DataRow rUser = dtUser.Rows[0];
|
---|
| 487 | Object oUser = rUser["MANAGER"];
|
---|
| 488 | string sUser = oUser.ToString();
|
---|
| 489 | m_bSchedManager = (sUser == "YES")?true:false;
|
---|
| 490 |
|
---|
| 491 | //AccessTypes
|
---|
| 492 | LoadAccessTypesTable();
|
---|
| 493 |
|
---|
| 494 | //Build Primary Key for AccessTypes table
|
---|
| 495 | DataTable dtTypes = m_dsGlobal.Tables["AccessTypes"];
|
---|
| 496 | DataColumn dcKey = dtTypes.Columns["BMXIEN"];
|
---|
| 497 | DataColumn[] dcKeys = new DataColumn[1];
|
---|
| 498 | dcKeys[0] = dcKey;
|
---|
| 499 | dtTypes.PrimaryKey = dcKeys;
|
---|
| 500 |
|
---|
| 501 | //AccessGroups
|
---|
| 502 | LoadAccessGroupsTable();
|
---|
| 503 |
|
---|
| 504 | //Build Primary Key for AccessGroup table
|
---|
| 505 | DataTable dtGroups = m_dsGlobal.Tables["AccessGroup"];
|
---|
| 506 | dcKey = dtGroups.Columns["ACCESS_GROUP"];
|
---|
| 507 | dcKeys = new DataColumn[1];
|
---|
| 508 | dcKeys[0] = dcKey;
|
---|
| 509 | dtGroups.PrimaryKey = dcKeys;
|
---|
| 510 |
|
---|
| 511 | //AccessGroupType
|
---|
| 512 | LoadAccessGroupTypesTable();
|
---|
| 513 |
|
---|
| 514 | //Build Primary Key for AccessGroupType table
|
---|
| 515 | DataTable dtAGTypes = m_dsGlobal.Tables["AccessGroupType"];
|
---|
| 516 | DataColumn dcGTKey = dtAGTypes.Columns["ACCESS_GROUP_TYPEID"];
|
---|
| 517 | DataColumn[] dcGTKeys = new DataColumn[1];
|
---|
| 518 | dcGTKeys[0] = dcGTKey;
|
---|
| 519 | dtAGTypes.PrimaryKey = dcGTKeys;
|
---|
| 520 |
|
---|
| 521 | //Build Data Relationship between AccessGroupType and AccessTypes tables
|
---|
| 522 | DataRelation dr = new DataRelation("AccessGroupType", //Relation Name
|
---|
| 523 | m_dsGlobal.Tables["AccessGroup"].Columns["BMXIEN"], //Parent
|
---|
| 524 | m_dsGlobal.Tables["AccessGroupType"].Columns["ACCESS_GROUP_ID"]); //Child
|
---|
| 525 | m_dsGlobal.Relations.Add(dr);
|
---|
| 526 |
|
---|
| 527 | //ResourceGroup Table (Resource Groups by User)
|
---|
| 528 | LoadResourceGroupTable();
|
---|
| 529 |
|
---|
| 530 | //Resources by user
|
---|
| 531 | LoadBSDXResourcesTable();
|
---|
| 532 |
|
---|
| 533 | //Build Primary Key for Resources table
|
---|
| 534 | DataColumn[] dc = new DataColumn[1];
|
---|
| 535 | dc[0] = m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"];
|
---|
| 536 | m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
|
---|
| 537 |
|
---|
| 538 | //GroupResources table
|
---|
| 539 | LoadGroupResourcesTable();
|
---|
| 540 |
|
---|
| 541 | //Build Primary Key for ResourceGroup table
|
---|
| 542 | dc = new DataColumn[1];
|
---|
| 543 | dc[0] = m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"];
|
---|
| 544 | m_dsGlobal.Tables["ResourceGroup"].PrimaryKey = dc;
|
---|
| 545 |
|
---|
| 546 | //Build Data Relationships between ResourceGroup and GroupResources tables
|
---|
| 547 | dr = new DataRelation("GroupResource", //Relation Name
|
---|
| 548 | m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"], //Parent
|
---|
| 549 | m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child
|
---|
| 550 | CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
|
---|
| 551 | m_dsGlobal.Relations.Add(dr);
|
---|
| 552 |
|
---|
| 553 | //HospitalLocation table
|
---|
| 554 | //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
|
---|
| 555 | sCommandText = "BSDX HOSPITAL LOCATION";
|
---|
| 556 | ConnectInfo.RPMSDataTable(sCommandText, "HospitalLocation", m_dsGlobal);
|
---|
| 557 | Debug.Write("LoadGlobalRecordsets -- HospitalLocation loaded\n");
|
---|
| 558 |
|
---|
| 559 | //Build Primary Key for HospitalLocation table
|
---|
| 560 | dc = new DataColumn[1];
|
---|
| 561 | DataTable dtTemp = m_dsGlobal.Tables["HospitalLocation"];
|
---|
| 562 | dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
|
---|
| 563 | m_dsGlobal.Tables["HospitalLocation"].PrimaryKey = dc;
|
---|
| 564 |
|
---|
| 565 | LoadClinicSetupTable();
|
---|
| 566 |
|
---|
| 567 | //Build Primary Key for ClinicSetupParameters table
|
---|
| 568 | dc = new DataColumn[1];
|
---|
| 569 | dtTemp = m_dsGlobal.Tables["ClinicSetupParameters"];
|
---|
| 570 | dc[0] = dtTemp.Columns["HOSPITAL_LOCATION_ID"];
|
---|
| 571 | m_dsGlobal.Tables["ClinicSetupParameters"].PrimaryKey = dc;
|
---|
| 572 |
|
---|
| 573 | //Build Data Relationships between ClinicSetupParameters and HospitalLocation tables
|
---|
| 574 | dr = new DataRelation("HospitalLocationClinic", //Relation Name
|
---|
| 575 | m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"], //Parent
|
---|
| 576 | m_dsGlobal.Tables["ClinicSetupParameters"].Columns["HOSPITAL_LOCATION_ID"], false); //Child
|
---|
| 577 | m_dsGlobal.Relations.Add(dr);
|
---|
| 578 |
|
---|
| 579 | dtTemp.Columns.Add("PROVIDER", System.Type.GetType("System.String"), "Parent.DEFAULT_PROVIDER");
|
---|
| 580 | dtTemp.Columns.Add("CLINIC_STOP", System.Type.GetType("System.String"), "Parent.STOP_CODE_NUMBER");
|
---|
| 581 | dtTemp.Columns.Add("INACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.INACTIVATE_DATE");
|
---|
| 582 | dtTemp.Columns.Add("REACTIVATE_DATE", System.Type.GetType("System.String"), "Parent.REACTIVATE_DATE");
|
---|
| 583 |
|
---|
| 584 | //Build Data Relationships between Resources and HospitalLocation tables
|
---|
| 585 | dr = new DataRelation("HospitalLocationResource", //Relation Name
|
---|
| 586 | m_dsGlobal.Tables["HospitalLocation"].Columns["HOSPITAL_LOCATION_ID"], //Parent
|
---|
| 587 | m_dsGlobal.Tables["Resources"].Columns["HOSPITAL_LOCATION_ID"], false); //Child
|
---|
| 588 | m_dsGlobal.Relations.Add(dr);
|
---|
| 589 |
|
---|
| 590 | //Build ScheduleUser table
|
---|
| 591 | this.LoadScheduleUserTable();
|
---|
| 592 |
|
---|
| 593 | //Build Primary Key for ScheduleUser table
|
---|
| 594 | dc = new DataColumn[1];
|
---|
| 595 | dtTemp = m_dsGlobal.Tables["ScheduleUser"];
|
---|
| 596 | dc[0] = dtTemp.Columns["USERID"];
|
---|
| 597 | m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
|
---|
| 598 |
|
---|
| 599 | //Build ResourceUser table
|
---|
| 600 | this.LoadResourceUserTable();
|
---|
| 601 |
|
---|
| 602 | //Build Primary Key for ResourceUser table
|
---|
| 603 | dc = new DataColumn[1];
|
---|
| 604 | dtTemp = m_dsGlobal.Tables["ResourceUser"];
|
---|
| 605 | dc[0] = dtTemp.Columns["RESOURCEUSER_ID"];
|
---|
| 606 | m_dsGlobal.Tables["ResourceUser"].PrimaryKey = dc;
|
---|
| 607 |
|
---|
| 608 | //Create relation between BSDX Resource and BSDX Resource User tables
|
---|
| 609 | dr = new DataRelation("ResourceUser", //Relation Name
|
---|
| 610 | m_dsGlobal.Tables["Resources"].Columns["RESOURCEID"], //Parent
|
---|
| 611 | m_dsGlobal.Tables["ResourceUser"].Columns["RESOURCEID"]); //Child
|
---|
| 612 | m_dsGlobal.Relations.Add(dr);
|
---|
| 613 |
|
---|
| 614 | //Build active provider table
|
---|
| 615 | sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND INTERNAL[PROVIDER_CLASS] > 0";
|
---|
| 616 | ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
|
---|
| 617 | Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
|
---|
| 618 |
|
---|
| 619 | //Build the CLINIC_STOP table
|
---|
| 620 | // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
|
---|
| 621 | sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
|
---|
| 622 | ConnectInfo.RPMSDataTable(sCommandText, "ClinicStop", m_dsGlobal);
|
---|
| 623 | Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
|
---|
| 624 |
|
---|
| 625 | //Build the HOLIDAY table
|
---|
| 626 | sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
|
---|
| 627 | ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
|
---|
| 628 |
|
---|
| 629 | //Save the xml schema
|
---|
| 630 | //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
|
---|
| 631 |
|
---|
| 632 | return true;
|
---|
| 633 | }
|
---|
| 634 |
|
---|
| 635 | public void RegisterDocumentView(CGDocument doc, CGView view)
|
---|
| 636 | {
|
---|
| 637 | //Store the view in the list of views
|
---|
| 638 | this.Views.Add(view, doc);
|
---|
| 639 |
|
---|
| 640 | //Hook into the view's 'closed' event
|
---|
| 641 | view.Closed += new EventHandler(ViewClosed);
|
---|
| 642 |
|
---|
| 643 | //Hook into the view's mnuRPMSServer.Click event
|
---|
| 644 | view.mnuRPMSServer.Click += new EventHandler(mnuRPMSServer_Click);
|
---|
| 645 |
|
---|
| 646 | //Hook into the view's mnuRPMSLogin.Click event
|
---|
| 647 | view.mnuRPMSLogin.Click += new EventHandler(mnuRPMSLogin_Click);
|
---|
| 648 |
|
---|
| 649 | }
|
---|
| 650 |
|
---|
| 651 | public void RegisterAVDocumentView(CGAVDocument doc, CGAVView view)
|
---|
| 652 | {
|
---|
| 653 | //Store the view in the list of views
|
---|
| 654 | this.AvailabilityViews.Add(view, doc);
|
---|
| 655 |
|
---|
| 656 | //Hook into the view's 'closed' event
|
---|
| 657 | view.Closed += new EventHandler(AVViewClosed);
|
---|
| 658 | }
|
---|
| 659 |
|
---|
| 660 | public CGAVView GetAVViewByResource(ArrayList sResourceArray)
|
---|
| 661 | {
|
---|
| 662 | if (sResourceArray == null)
|
---|
| 663 | return null;
|
---|
| 664 |
|
---|
| 665 | bool bEqual = true;
|
---|
| 666 | foreach (CGAVView v in m_AVViews.Keys)
|
---|
| 667 | {
|
---|
| 668 | CGAVDocument d = v.Document;
|
---|
| 669 |
|
---|
| 670 | bEqual = false;
|
---|
| 671 | if (d.Resources.Count == sResourceArray.Count)
|
---|
| 672 | {
|
---|
| 673 | bEqual = true;
|
---|
| 674 | for (int j = 0; j < sResourceArray.Count; j++)
|
---|
| 675 | {
|
---|
| 676 | if (sResourceArray.Contains(d.Resources[j]) == false)
|
---|
| 677 | {
|
---|
| 678 | bEqual = false;
|
---|
| 679 | break;
|
---|
| 680 | }
|
---|
| 681 | if (d.Resources.Contains(sResourceArray[j]) == false)
|
---|
| 682 | {
|
---|
| 683 | bEqual = false;
|
---|
| 684 | break;
|
---|
| 685 | }
|
---|
| 686 | }
|
---|
| 687 | if (bEqual == true)
|
---|
| 688 | return v;
|
---|
| 689 | }
|
---|
| 690 | }
|
---|
| 691 | return null;
|
---|
| 692 | }
|
---|
| 693 | /// <summary>
|
---|
| 694 | /// Return the first view having a resource array matching sResourceArray
|
---|
| 695 | /// </summary>
|
---|
| 696 | /// <param name="sResourceArray"></param>
|
---|
| 697 | /// <returns></returns>
|
---|
| 698 | public CGView GetViewByResource(ArrayList sResourceArray)
|
---|
| 699 | {
|
---|
| 700 | if (sResourceArray == null)
|
---|
| 701 | return null;
|
---|
| 702 |
|
---|
| 703 | bool bEqual = true;
|
---|
| 704 | foreach (CGView v in _views.Keys)
|
---|
| 705 | {
|
---|
| 706 | CGDocument d = v.Document;
|
---|
| 707 |
|
---|
| 708 | bEqual = false;
|
---|
| 709 | if (d.Resources.Count == sResourceArray.Count)
|
---|
| 710 | {
|
---|
| 711 | bEqual = true;
|
---|
| 712 | for (int j = 0; j < sResourceArray.Count; j++)
|
---|
| 713 | {
|
---|
| 714 | if (sResourceArray.Contains(d.Resources[j]) == false)
|
---|
| 715 | {
|
---|
| 716 | bEqual = false;
|
---|
| 717 | break;
|
---|
| 718 | }
|
---|
| 719 | if (d.Resources.Contains(sResourceArray[j]) == false)
|
---|
| 720 | {
|
---|
| 721 | bEqual = false;
|
---|
| 722 | break;
|
---|
| 723 | }
|
---|
| 724 | }
|
---|
| 725 | if (bEqual == true)
|
---|
| 726 | return v;
|
---|
| 727 | }
|
---|
| 728 | }
|
---|
| 729 | return null;
|
---|
| 730 | }
|
---|
| 731 |
|
---|
| 732 | private void ViewClosed(object sender, EventArgs e)
|
---|
| 733 | {
|
---|
| 734 | //Remove the sender from our document list
|
---|
| 735 | Views.Remove(sender);
|
---|
| 736 |
|
---|
| 737 | //If no documents left, then close RPMS connection & exit the application
|
---|
| 738 | if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
|
---|
| 739 | {
|
---|
| 740 | m_ConnectInfo.EventPollingEnabled = false;
|
---|
| 741 | m_ConnectInfo.UnSubscribeEvent("BSDX SCHEDULE");
|
---|
| 742 | m_ConnectInfo.CloseConnection();
|
---|
| 743 | Application.Exit();
|
---|
| 744 | }
|
---|
| 745 | }
|
---|
| 746 |
|
---|
| 747 | private void AVViewClosed(object sender, EventArgs e)
|
---|
| 748 | {
|
---|
| 749 | //Remove the sender from our document list
|
---|
| 750 | this.AvailabilityViews.Remove(sender);
|
---|
| 751 |
|
---|
| 752 | //If no documents left, then close RPMS connection & exit the application
|
---|
| 753 | if ((Views.Count == 0)&&(this.AvailabilityViews.Count == 0)&&(m_bExitOK == true))
|
---|
| 754 | {
|
---|
| 755 | m_ConnectInfo.bmxNetLib.CloseConnection();
|
---|
| 756 | Application.Exit();
|
---|
| 757 | }
|
---|
| 758 | }
|
---|
| 759 |
|
---|
| 760 | private void KeepAlive()
|
---|
| 761 | {
|
---|
| 762 | foreach (CGView v in _views.Keys)
|
---|
| 763 | {
|
---|
| 764 | CGDocument d = v.Document;
|
---|
| 765 | DateTime dNow = DateTime.Now;
|
---|
| 766 | DateTime dLast = d.LastRefreshed;
|
---|
| 767 | TimeSpan tsDiff = dNow - dLast;
|
---|
| 768 | if (tsDiff.Seconds > 180)
|
---|
| 769 | {
|
---|
| 770 | for (int j = 0; j < d.Resources.Count; j++)
|
---|
| 771 | {
|
---|
| 772 | v.RaiseRPMSEvent("SCHEDULE-" + d.Resources[j].ToString(), "");
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 | break;
|
---|
| 776 | }
|
---|
| 777 | }
|
---|
| 778 | }
|
---|
| 779 |
|
---|
| 780 | /// <summary>
|
---|
| 781 | /// Propogate availability updates to all sRresource's doc/views
|
---|
| 782 | /// </summary>
|
---|
| 783 | public void UpdateViews(string sResource, string sOldResource)
|
---|
| 784 | {
|
---|
| 785 | if (sResource == null)
|
---|
| 786 | return;
|
---|
| 787 | foreach (CGView v in _views.Keys)
|
---|
| 788 | {
|
---|
| 789 | CGDocument d = v.Document;
|
---|
| 790 | for (int j = 0; j < d.Resources.Count; j++)
|
---|
| 791 | {
|
---|
| 792 | if ((sResource == "") || (sResource == ((string) d.Resources[j])) || (sOldResource == ((string) d.Resources[j])))
|
---|
| 793 | {
|
---|
| 794 | d.RefreshDocument();
|
---|
| 795 | break;
|
---|
| 796 | }
|
---|
| 797 | }
|
---|
| 798 | v.UpdateTree();
|
---|
| 799 | }
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 | /// <summary>
|
---|
| 803 | /// Propogate availability updates to all doc/views
|
---|
| 804 | /// </summary>
|
---|
| 805 | public void UpdateViews()
|
---|
| 806 | {
|
---|
| 807 | UpdateViews("","");
|
---|
| 808 | foreach (CGView v in _views.Keys)
|
---|
| 809 | {
|
---|
| 810 | v.UpdateTree();
|
---|
| 811 | }
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | /// <summary>
|
---|
| 815 | /// Calls each view associated with document Doc and closes it.
|
---|
| 816 | /// </summary>
|
---|
| 817 | public void CloseAllViews(CGDocument doc)
|
---|
| 818 | {
|
---|
| 819 | //iterate through all views and call update.
|
---|
| 820 | Hashtable h = CGDocumentManager.Current.Views;
|
---|
| 821 |
|
---|
| 822 | CGDocument d;
|
---|
| 823 | int nTempCount = h.Count;
|
---|
| 824 | do
|
---|
| 825 | {
|
---|
| 826 | nTempCount = h.Count;
|
---|
| 827 | foreach (CGView v in h.Keys)
|
---|
| 828 | {
|
---|
| 829 | d = (CGDocument) h[v];
|
---|
| 830 | if (d == doc)
|
---|
| 831 | {
|
---|
| 832 | v.Close();
|
---|
| 833 | break;
|
---|
| 834 | }
|
---|
| 835 | }
|
---|
| 836 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 | /// <summary>
|
---|
| 840 | /// Calls each view associated with Availability Doc and closes it.
|
---|
| 841 | /// </summary>
|
---|
| 842 | public void CloseAllViews(CGAVDocument doc)
|
---|
| 843 | {
|
---|
| 844 | //iterate through all views and call update.
|
---|
| 845 | Hashtable h = CGDocumentManager.Current.AvailabilityViews;
|
---|
| 846 |
|
---|
| 847 | CGAVDocument d;
|
---|
| 848 | int nTempCount = h.Count;
|
---|
| 849 | do
|
---|
| 850 | {
|
---|
| 851 | nTempCount = h.Count;
|
---|
| 852 | foreach (CGAVView v in h.Keys)
|
---|
| 853 | {
|
---|
| 854 | d = (CGAVDocument) h[v];
|
---|
| 855 | if (d == doc)
|
---|
| 856 | {
|
---|
| 857 | v.Close();
|
---|
| 858 | break;
|
---|
| 859 | }
|
---|
| 860 | }
|
---|
| 861 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 862 |
|
---|
| 863 |
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | private void mnuRPMSServer_Click(object sender, EventArgs e)
|
---|
| 867 | {
|
---|
| 868 | //Warn that changing servers will close all schedules
|
---|
[627] | 869 | if (MessageBox.Show("Are you sure you want to close all schedules and connect to a different VistA server?", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
---|
[614] | 870 | return;
|
---|
| 871 |
|
---|
| 872 | //Reconnect to RPMS and recreate all global recordsets
|
---|
| 873 | try
|
---|
| 874 | {
|
---|
| 875 | m_bExitOK = false;
|
---|
| 876 | bool bRetry = true;
|
---|
| 877 | BMXNetConnectInfo tmpInfo;
|
---|
| 878 | do
|
---|
| 879 | {
|
---|
| 880 | tmpInfo = m_ConnectInfo;
|
---|
| 881 | try
|
---|
| 882 | {
|
---|
| 883 | tmpInfo.ChangeServerInfo();
|
---|
| 884 | bRetry = false;
|
---|
| 885 | }
|
---|
| 886 | catch (Exception ex)
|
---|
| 887 | {
|
---|
| 888 | if (ex.Message == "User cancelled.")
|
---|
| 889 | {
|
---|
| 890 | bRetry = false;
|
---|
| 891 | return;
|
---|
| 892 | }
|
---|
[627] | 893 | if (MessageBox.Show("Unable to connect to VistA. " + ex.Message , "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
|
---|
[614] | 894 | {
|
---|
| 895 | bRetry = true;
|
---|
| 896 | }
|
---|
| 897 | else
|
---|
| 898 | {
|
---|
| 899 | bRetry = false;
|
---|
| 900 | return;
|
---|
| 901 | }
|
---|
| 902 | }
|
---|
| 903 | } while (bRetry == true);
|
---|
| 904 |
|
---|
| 905 | CloseAll();
|
---|
| 906 | m_bExitOK = true;
|
---|
| 907 | m_ConnectInfo = tmpInfo;
|
---|
| 908 |
|
---|
| 909 | this.InitializeApp();
|
---|
| 910 |
|
---|
| 911 | //Create a new document
|
---|
| 912 | CGDocument doc = new CGDocument();
|
---|
| 913 | doc.DocManager = _current;
|
---|
| 914 | doc.OnNewDocument();
|
---|
| 915 |
|
---|
| 916 | }
|
---|
| 917 | catch (Exception ex)
|
---|
| 918 | {
|
---|
| 919 | throw ex;
|
---|
| 920 | }
|
---|
| 921 |
|
---|
| 922 | }
|
---|
| 923 |
|
---|
| 924 | private void mnuRPMSLogin_Click(object sender, EventArgs e)
|
---|
| 925 | {
|
---|
| 926 | //Warn that changing login will close all schedules
|
---|
[627] | 927 | if (MessageBox.Show("Are you sure you want to close all schedules and login to VistA?", "Clinical Scheduling", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
---|
[614] | 928 | return;
|
---|
| 929 |
|
---|
| 930 | //Reconnect to RPMS and recreate all global recordsets
|
---|
| 931 | try
|
---|
| 932 | {
|
---|
| 933 | m_bExitOK = false;
|
---|
| 934 | CloseAll();
|
---|
| 935 | m_bExitOK = true;
|
---|
| 936 | _current.m_ConnectInfo = new BMXNet.BMXNetConnectInfo();
|
---|
| 937 | this.InitializeApp(true);
|
---|
| 938 | //Create a new document
|
---|
| 939 | CGDocument doc = new CGDocument();
|
---|
| 940 | doc.DocManager = _current;
|
---|
| 941 | doc.OnNewDocument();
|
---|
| 942 | }
|
---|
| 943 | catch (Exception ex)
|
---|
| 944 | {
|
---|
| 945 | throw ex;
|
---|
| 946 | }
|
---|
| 947 |
|
---|
| 948 | }
|
---|
| 949 |
|
---|
| 950 | delegate void CloseAllDelegate(string sMsg);
|
---|
| 951 |
|
---|
| 952 | private void CloseAll(string sMsg)
|
---|
| 953 | {
|
---|
| 954 | if (sMsg == "")
|
---|
| 955 | {
|
---|
| 956 | sMsg = "Scheduling System Shutting Down Immediately for Maintenance.";
|
---|
| 957 | }
|
---|
| 958 |
|
---|
[620] | 959 | MessageBox.Show(sMsg, "Clinical Scheduling Administrator -- System Shutdown Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
---|
[614] | 960 |
|
---|
| 961 | CloseAll();
|
---|
| 962 | }
|
---|
| 963 |
|
---|
| 964 | private void CloseAll()
|
---|
| 965 | {
|
---|
| 966 | //Close all documents, views and connections
|
---|
| 967 | Hashtable h = CGDocumentManager.Current.Views;
|
---|
| 968 | int nTempCount = h.Count;
|
---|
| 969 | do
|
---|
| 970 | {
|
---|
| 971 | nTempCount = h.Count;
|
---|
| 972 | foreach (CGView v in h.Keys)
|
---|
| 973 | {
|
---|
| 974 | v.Close();
|
---|
| 975 | break;
|
---|
| 976 | }
|
---|
| 977 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 978 |
|
---|
| 979 | h = CGDocumentManager.Current.AvailabilityViews;
|
---|
| 980 | nTempCount = h.Count;
|
---|
| 981 | do
|
---|
| 982 | {
|
---|
| 983 | nTempCount = h.Count;
|
---|
| 984 | foreach (CGAVView v in h.Keys)
|
---|
| 985 | {
|
---|
| 986 | v.Close();
|
---|
| 987 | break;
|
---|
| 988 | }
|
---|
| 989 | } while ((h.Count > 0) && (nTempCount != h.Count));
|
---|
| 990 |
|
---|
| 991 | }
|
---|
| 992 |
|
---|
| 993 | delegate DataTable RPMSDataTableDelegate(string CommandString, string TableName);
|
---|
| 994 |
|
---|
| 995 | public DataTable RPMSDataTable(string sSQL, string sTableName)
|
---|
| 996 | {
|
---|
| 997 | //Retrieves a recordset from RPMS
|
---|
| 998 | string sErrorMessage = "";
|
---|
| 999 | try
|
---|
| 1000 | {
|
---|
| 1001 | System.IntPtr pHandle = this.Handle;
|
---|
| 1002 | DataTable dtOut;
|
---|
| 1003 | RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(ConnectInfo.RPMSDataTable);
|
---|
| 1004 | dtOut = (DataTable) this.Invoke(rdtd, new object[] {sSQL, sTableName});
|
---|
| 1005 | return dtOut;
|
---|
| 1006 | }
|
---|
| 1007 | catch (Exception ex)
|
---|
| 1008 | {
|
---|
| 1009 | sErrorMessage = "CGDocumentManager.RPMSDataTable error: " + ex.Message;
|
---|
| 1010 | throw ex;
|
---|
| 1011 | }
|
---|
| 1012 | }
|
---|
| 1013 |
|
---|
| 1014 | public void ChangeDivision(System.Windows.Forms.Form frmCaller)
|
---|
| 1015 | {
|
---|
| 1016 | this.ConnectInfo.ChangeDivision(frmCaller);
|
---|
| 1017 | foreach (CGView v in _views.Keys)
|
---|
| 1018 | {
|
---|
| 1019 | v.InitializeDocView(v.Document.DocName);
|
---|
| 1020 | v.Document.RefreshDocument();
|
---|
| 1021 | }
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
| 1024 | public void ViewRefresh()
|
---|
| 1025 | {
|
---|
| 1026 | foreach (CGView v in _views.Keys)
|
---|
| 1027 | {
|
---|
| 1028 | try
|
---|
| 1029 | {
|
---|
| 1030 | v.Document.RefreshDocument();
|
---|
| 1031 | }
|
---|
| 1032 | catch (Exception ex)
|
---|
| 1033 | {
|
---|
| 1034 | Debug.Write("CGDocumentManager.ViewRefresh Exception: " + ex.Message + "\n");
|
---|
| 1035 | }
|
---|
| 1036 | finally
|
---|
| 1037 | {
|
---|
| 1038 | }
|
---|
| 1039 | }
|
---|
| 1040 | Debug.Write("DocManager refreshed all views.\n");
|
---|
| 1041 | }
|
---|
| 1042 |
|
---|
| 1043 | #endregion Methods & Events
|
---|
| 1044 |
|
---|
| 1045 | }
|
---|
| 1046 | }
|
---|