Index: /Scheduling/branches/BMX4Support/RPCLogger.cs
===================================================================
--- /Scheduling/branches/BMX4Support/RPCLogger.cs	(revision 1195)
+++ /Scheduling/branches/BMX4Support/RPCLogger.cs	(revision 1195)
@@ -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/branches/BMX4Support/RPCLoggerView.Designer.cs
===================================================================
--- /Scheduling/branches/BMX4Support/RPCLoggerView.Designer.cs	(revision 1195)
+++ /Scheduling/branches/BMX4Support/RPCLoggerView.Designer.cs	(revision 1195)
@@ -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/branches/BMX4Support/RPCLoggerView.cs
===================================================================
--- /Scheduling/branches/BMX4Support/RPCLoggerView.cs	(revision 1195)
+++ /Scheduling/branches/BMX4Support/RPCLoggerView.cs	(revision 1195)
@@ -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/branches/BMX4Support/RPCLoggerView.resx
===================================================================
--- /Scheduling/branches/BMX4Support/RPCLoggerView.resx	(revision 1195)
+++ /Scheduling/branches/BMX4Support/RPCLoggerView.resx	(revision 1195)
@@ -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>
