Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGSchedLib.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGSchedLib.cs	(revision 1095)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGSchedLib.cs	(revision 1097)
@@ -1,9 +1,7 @@
 using System;
 using System.Data;
-//using System.Data.OleDb;
 using System.Collections;
 using System.Diagnostics;
 using System.Drawing;
-using IndianHealthService.BMXNet;
 
 namespace IndianHealthService.ClinicalScheduling
@@ -24,20 +22,12 @@
         /// Gets appointments from VISTA to display in Grid
         /// </summary>
-        /// <param name="docManager"></param>
-        /// <param name="saryResNames"></param>
-        /// <param name="StartTime"></param>
-        /// <param name="EndTime"></param>
+        /// <param name="docManager">God Class</param>
+        /// <param name="saryResNames">Resource Names Array</param>
+        /// <param name="StartTime">Self Explanatory</param>
+        /// <param name="EndTime">Self Explanatory</param>
         /// <returns></returns>
 		public static DataTable CreateAppointmentSchedule(CGDocumentManager docManager, ArrayList saryResNames, DateTime StartTime, DateTime EndTime)
 		{
-			string sResName = "";
-			for  (int i = 0; i < saryResNames.Count; i++)
-			{
-				sResName += saryResNames[i];
-				if ((i+1) < saryResNames.Count)
-					sResName += "|";
-			}
-			
-			
+            string sResName = string.Join("|", saryResNames.ToArray());			
             string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
             string sEnd = FMDateTime.Create(EndTime).FMDateString;
@@ -45,5 +35,4 @@
 			DataTable dtRet = docManager.RPMSDataTable(sSql, "AppointmentSchedule");
 			return dtRet;
-			
 		}
 
@@ -57,25 +46,24 @@
         /// <param name="EndTime">Self-Explanatory</param>
         /// <param name="saryApptTypes">Array of Access Type IDs</param>
-        /// <param name="stType"></param>
-        /// <param name="sSearchInfo"></param>
+        /// <param name="stType">Not used</param>
+        /// <param name="sSearchInfo">Specific Search Parameters</param>
         /// <returns></returns>
-		public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager, 
-			ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime, 
-			ArrayList saryApptTypes,/**/ ScheduleType stType, string sSearchInfo) 
-		{
-			DataTable rsOut;
-			rsOut = new DataTable("AvailabilitySchedule");
-
-			DataTable rsSlotSchedule;
-			DataTable rsApptSchedule;
-			DataTable rsTemp1;
-
-			int nSize = saryResourceNames.Count;
-			if (nSize == 0) 
-			{
-				return rsOut;
-			}
-			
-			string sResName;
+        public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager,
+            ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime,
+            ArrayList saryApptTypes,/**/ ScheduleType stType, string sSearchInfo)
+        {
+            DataTable rsOut = new DataTable("AvailabilitySchedule");
+            if (saryResourceNames.Count == 0) return rsOut;
+            string sResNames = string.Join("|", saryResourceNames.ToArray());
+            string sApptTypeIDs = string.Join("|", saryApptTypes.ToArray());
+            string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
+            string sEnd = FMDateTime.Create(EndTime).FMDateString;
+            string sSql = "BSDX CREATE ASGND SLOT SCHED^" + sResNames + "^" + sStart + "^" + sEnd + "^" + sApptTypeIDs + "^" + sSearchInfo; //+ "^" + sSTType ;
+            rsOut = docManager.RPMSDataTable(sSql, "AssignedSlotSchedule");
+
+            return rsOut;
+        }
+
+            /*NOT USED ANYMORE
             //TODO: Optimize: no need to keep looping through resources.
             // for each resource
@@ -84,22 +72,24 @@
 				sResName = saryResourceNames[i].ToString();
                 //Gets all the slots (or Availabities, or AV Blocks if you like)
-				rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes,/**/ stType, sSearchInfo);
-				
+				rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes, stType, sSearchInfo);
+                rsTemp1 = rsSlotSchedule;
+
                 //if we have slots
-				if (rsSlotSchedule.Rows.Count > 0 ) 
-				{
+                if (rsSlotSchedule.Rows.Count > 0 ) 
+                {
                     // Get appointment count to substract from the slots
-					rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType);
+                    rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType);
 
                     // Perform the substraction
-					rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName);
-
-				}
+                    rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName);
+
+                }
                 //otherwise, just return the slot schedule we have.
-				else 
-				{
-					rsTemp1 = rsSlotSchedule;
-
-				}
+                else 
+                {
+                    rsTemp1 = rsSlotSchedule;
+
+                }
+
 
                 // if only one resource was passed in, its availablility is what we want
@@ -117,5 +107,5 @@
 			return rsOut;
 		}		
-
+                */
 
         /* NOT USED ANYMORE!!!
@@ -281,19 +271,10 @@
         /// D00030START_TIME^D00030END_TIME^I00010SLOTS^T00030RESOURCE^T00010ACCESS_TYPE^T00250NOTE^I00030AVAILABILITYID
         /// </returns>
-		public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, 
-            DateTime EndTime, ArrayList rsaryApptTypeIDs, /**/ ScheduleType stType, string sSearchInfo) 
+		/*
+         * public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, 
+            DateTime EndTime, ArrayList rsaryApptTypeIDs, ScheduleType stType, string sSearchInfo) 
 		{
             //Appointment type ids is now always "" so that all appointment types are returned.
-			string sApptTypeIDs = "";
-			
-            //flatten types by '|'
-			int nSize = rsaryApptTypeIDs.Count;  //nSize is used to decide where to put the '|' sent in the RPC as we flatten sApptTypeIDs
-			for (int i=0; i < nSize; i++) 
-			{
-				sApptTypeIDs += rsaryApptTypeIDs[i];
-				if (i < (nSize-1))
-					sApptTypeIDs += "|";
-			}	
-	
+            string sApptTypeIDs = string.Join("|", rsaryApptTypeIDs.ToArray());
             string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
             string sEnd = FMDateTime.Create(EndTime).FMDateString;
@@ -303,5 +284,7 @@
             return dtRet;
 		}
-
+        */
+
+        /*
 		public static DataTable CreateCopyTable()
 		{
@@ -358,4 +341,5 @@
 			return dtCopy;
 		}
+         */
 
         /// <summary>
@@ -368,5 +352,6 @@
         /// <param name="stType"></param>
         /// <returns>DataTable with 4 columns: START_TIME, END_TIME, SLOTS, RESOURCE </returns>
-		public static DataTable CreateAppointmentSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType)
+		/*
+        public static DataTable CreateAppointmentSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType)
 		{
             //Change Dates to FM Format
@@ -424,5 +409,5 @@
 			ScheduleFromArray(cdtArray, StartTime, EndTime, ref ctbApptSchedule);
 
-            /*So far, we have the following:
+            So far, we have the following:
              * dtRet -> List of Appointments Start and End times, one row per appointment
              * cdtArray -> Linear 1 dimensional Array of dtRet Start and End times, sorted
@@ -432,5 +417,5 @@
              *      2 appts as 10:10-10:30 and 10:20-10:40 get converted into 10:10-10:20,
              *      10:20-10:30, 10:30-10:40).
-            */
+            
 
             //Find number of TimeBlocks in ctbApptSchedule that overlap the TimeBlocks in ctbAppointments
@@ -498,5 +483,7 @@
 
 		}
-
+        */
+
+        /*
 		public static int BlocksOverlap(CGAvailability rBlock, ArrayList rTBArray)
 		{
@@ -542,4 +529,5 @@
 			return nCount;
 		}
+        */
 
 		/// <summary>
@@ -552,5 +540,6 @@
 		/// <returns>true or false</returns>
         /// <remarks>Draws 2 rectangles and sees if they overlap using minutes from 1980 as the start point</remarks>
-		public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
+		/*
+        public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
 		{
 			Rectangle rect1 = new Rectangle();
@@ -568,5 +557,7 @@
 			return bRet;
 		}
-
+        */
+
+        /*
 		public static void ConsolidateBlocks(ArrayList rTBArray)
 		{
@@ -607,5 +598,5 @@
 			}
 			while (!((bDirty == false) || (rTBArray.Count == 1)));
-		}
+		} */
 
         /// <summary>
@@ -616,5 +607,6 @@
         /// <param name="sResource"></param>
         /// <returns></returns>
-		public static DataTable SubtractSlotsRS2(DataTable rsBlocks1, DataTable rsBlocks2, string sResource)
+		/*
+        public static DataTable SubtractSlotsRS2(DataTable rsBlocks1, DataTable rsBlocks2, string sResource)
 		{
 			//Subtract slots in rsBlocks2 from rsBlocks1
@@ -680,5 +672,7 @@
 
 		}
-
+         */
+
+        /*
 		public static DataTable UnionBlocks(DataTable rs1, DataTable rs2)
 		{
@@ -714,5 +708,7 @@
 			return rsCopy;
 		}
-
+        */
+
+        /*
 		public static DataTable IntersectBlocks(DataTable rs1, DataTable rs2)
 		{
@@ -770,5 +766,5 @@
 //							rect2.Height = CGSchedLib.MinSince80(dEnd2) - rect2.Y;
 							if (
-								/*(rect2.IntersectsWith(rect1) == true)*/
+								/*(rect2.IntersectsWith(rect1) == true)
 								(CGSchedLib.TimesOverlap(dStart1, dEnd1, dStart2, dEnd2) == true)
 								&& 
@@ -797,5 +793,6 @@
 			return rsCopy;
 		}//end IntersectBlocks
-
+        */
+        
         /// <summary>
         /// Number of minutes since Jan 1 1980
@@ -803,5 +800,6 @@
         /// <param name="d">Date to compare</param>
         /// <returns>Minutes as integer</returns>
-		public static int MinSince80(DateTime d)
+		/*
+        public static int MinSince80(DateTime d)
 		{
 			//Returns the total minutes between d and 1 Jan 1980
@@ -814,5 +812,7 @@
 			return nMinutes;
 		}
-
+        */
+
+        /*
         /// <summary>
         /// Converts an Array of Times like this:
@@ -909,6 +909,8 @@
 
 		}//end ScheduleFromArray
-
-		//long CResourceLink::SlotsInBlock(CTimeBlock &rTimeBlock, _RecordsetPtr rsBlock)
+        */
+		
+        /*
+        //long CResourceLink::SlotsInBlock(CTimeBlock &rTimeBlock, _RecordsetPtr rsBlock)
 		public static int SlotsInBlock(CGAvailability rTimeBlock, DataTable rsBlock)
 		{
@@ -952,5 +954,7 @@
 			return nSlots;
 		}//end SlotsInBlock
-
+        */
+
+        /*
 		public static string ClinicInBlock(CGAvailability rTimeBlock, DataTable rsBlock)
 		{
@@ -991,5 +995,7 @@
 			return sClinic;
 		}//end ClinicInBlock
-
+        */
+
+        /*
 		public static bool ResourceRulesInBlock(CGAvailability rTimeBlock, DataTable rsBlock, ref string sResourceList, ref string sAccessRuleList, ref string sNote)
 		{
@@ -1059,4 +1065,5 @@
 			return true;
 		}//End ResourceRulesInBlock
+        */
 
 	
