Ignore:
Timestamp:
Mar 3, 2011, 4:44:18 AM (13 years ago)
Author:
Sam Habiel
Message:

DPatientLookup.cs: Usings Cleanup
DApptSearch: Extensive refactoring. Now uses new algorithm to find appointments. Now outputs CGAvailability
CGView: Appointments checked in now set the Checkin time on the appointment structure; changes to support DApptSearch modified output.
CGSchedLib: Extensive refactoring; only 2 methods remain: CreateAppointmentSchedule and CreateAvailabilitySchedule
CGDocument: SlotsAvailable uses a new algorithm
CGAVView: Uses CalendarGrid.TimesOverlap instead of the removed one in CGSchedLib
CGAVDocument: Uses CalendarGrid.TimesOverlap instead of the removed one in CGSchedLib; CreateAssignedSlotSchedule reassigned to CreateAvailabilitySchedule

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGSchedLib.cs

    r1095 r1097  
    11using System;
    22using System.Data;
    3 //using System.Data.OleDb;
    43using System.Collections;
    54using System.Diagnostics;
    65using System.Drawing;
    7 using IndianHealthService.BMXNet;
    86
    97namespace IndianHealthService.ClinicalScheduling
     
    2422        /// Gets appointments from VISTA to display in Grid
    2523        /// </summary>
    26         /// <param name="docManager"></param>
    27         /// <param name="saryResNames"></param>
    28         /// <param name="StartTime"></param>
    29         /// <param name="EndTime"></param>
     24        /// <param name="docManager">God Class</param>
     25        /// <param name="saryResNames">Resource Names Array</param>
     26        /// <param name="StartTime">Self Explanatory</param>
     27        /// <param name="EndTime">Self Explanatory</param>
    3028        /// <returns></returns>
    3129                public static DataTable CreateAppointmentSchedule(CGDocumentManager docManager, ArrayList saryResNames, DateTime StartTime, DateTime EndTime)
    3230                {
    33                         string sResName = "";
    34                         for  (int i = 0; i < saryResNames.Count; i++)
    35                         {
    36                                 sResName += saryResNames[i];
    37                                 if ((i+1) < saryResNames.Count)
    38                                         sResName += "|";
    39                         }
    40                        
    41                        
     31            string sResName = string.Join("|", saryResNames.ToArray());                 
    4232            string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
    4333            string sEnd = FMDateTime.Create(EndTime).FMDateString;
     
    4535                        DataTable dtRet = docManager.RPMSDataTable(sSql, "AppointmentSchedule");
    4636                        return dtRet;
    47                        
    4837                }
    4938
     
    5746        /// <param name="EndTime">Self-Explanatory</param>
    5847        /// <param name="saryApptTypes">Array of Access Type IDs</param>
    59         /// <param name="stType"></param>
    60         /// <param name="sSearchInfo"></param>
     48        /// <param name="stType">Not used</param>
     49        /// <param name="sSearchInfo">Specific Search Parameters</param>
    6150        /// <returns></returns>
    62                 public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager,
    63                         ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime,
    64                         ArrayList saryApptTypes,/**/ ScheduleType stType, string sSearchInfo)
    65                 {
    66                         DataTable rsOut;
    67                         rsOut = new DataTable("AvailabilitySchedule");
    68 
    69                         DataTable rsSlotSchedule;
    70                         DataTable rsApptSchedule;
    71                         DataTable rsTemp1;
    72 
    73                         int nSize = saryResourceNames.Count;
    74                         if (nSize == 0)
    75                         {
    76                                 return rsOut;
    77                         }
    78                        
    79                         string sResName;
     51        public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager,
     52            ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime,
     53            ArrayList saryApptTypes,/**/ ScheduleType stType, string sSearchInfo)
     54        {
     55            DataTable rsOut = new DataTable("AvailabilitySchedule");
     56            if (saryResourceNames.Count == 0) return rsOut;
     57            string sResNames = string.Join("|", saryResourceNames.ToArray());
     58            string sApptTypeIDs = string.Join("|", saryApptTypes.ToArray());
     59            string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
     60            string sEnd = FMDateTime.Create(EndTime).FMDateString;
     61            string sSql = "BSDX CREATE ASGND SLOT SCHED^" + sResNames + "^" + sStart + "^" + sEnd + "^" + sApptTypeIDs + "^" + sSearchInfo; //+ "^" + sSTType ;
     62            rsOut = docManager.RPMSDataTable(sSql, "AssignedSlotSchedule");
     63
     64            return rsOut;
     65        }
     66
     67            /*NOT USED ANYMORE
    8068            //TODO: Optimize: no need to keep looping through resources.
    8169            // for each resource
     
    8472                                sResName = saryResourceNames[i].ToString();
    8573                //Gets all the slots (or Availabities, or AV Blocks if you like)
    86                                 rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes,/**/ stType, sSearchInfo);
    87                                
     74                                rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes, stType, sSearchInfo);
     75                rsTemp1 = rsSlotSchedule;
     76
    8877                //if we have slots
    89                                 if (rsSlotSchedule.Rows.Count > 0 )
    90                                 {
     78                if (rsSlotSchedule.Rows.Count > 0 )
     79                {
    9180                    // Get appointment count to substract from the slots
    92                                         rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType);
     81                    rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType);
    9382
    9483                    // Perform the substraction
    95                                         rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName);
    96 
    97                                 }
     84                    rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName);
     85
     86                }
    9887                //otherwise, just return the slot schedule we have.
    99                                 else
    100                                 {
    101                                         rsTemp1 = rsSlotSchedule;
    102 
    103                                 }
     88                else
     89                {
     90                    rsTemp1 = rsSlotSchedule;
     91
     92                }
     93
    10494
    10595                // if only one resource was passed in, its availablility is what we want
     
    117107                        return rsOut;
    118108                }               
    119 
     109                */
    120110
    121111        /* NOT USED ANYMORE!!!
     
    281271        /// D00030START_TIME^D00030END_TIME^I00010SLOTS^T00030RESOURCE^T00010ACCESS_TYPE^T00250NOTE^I00030AVAILABILITYID
    282272        /// </returns>
    283                 public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime,
    284             DateTime EndTime, ArrayList rsaryApptTypeIDs, /**/ ScheduleType stType, string sSearchInfo)
     273                /*
     274         * public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime,
     275            DateTime EndTime, ArrayList rsaryApptTypeIDs, ScheduleType stType, string sSearchInfo)
    285276                {
    286277            //Appointment type ids is now always "" so that all appointment types are returned.
    287                         string sApptTypeIDs = "";
    288                        
    289             //flatten types by '|'
    290                         int nSize = rsaryApptTypeIDs.Count;  //nSize is used to decide where to put the '|' sent in the RPC as we flatten sApptTypeIDs
    291                         for (int i=0; i < nSize; i++)
    292                         {
    293                                 sApptTypeIDs += rsaryApptTypeIDs[i];
    294                                 if (i < (nSize-1))
    295                                         sApptTypeIDs += "|";
    296                         }       
    297        
     278            string sApptTypeIDs = string.Join("|", rsaryApptTypeIDs.ToArray());
    298279            string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
    299280            string sEnd = FMDateTime.Create(EndTime).FMDateString;
     
    303284            return dtRet;
    304285                }
    305 
     286        */
     287
     288        /*
    306289                public static DataTable CreateCopyTable()
    307290                {
     
    358341                        return dtCopy;
    359342                }
     343         */
    360344
    361345        /// <summary>
     
    368352        /// <param name="stType"></param>
    369353        /// <returns>DataTable with 4 columns: START_TIME, END_TIME, SLOTS, RESOURCE </returns>
    370                 public static DataTable CreateAppointmentSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType)
     354                /*
     355        public static DataTable CreateAppointmentSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType)
    371356                {
    372357            //Change Dates to FM Format
     
    424409                        ScheduleFromArray(cdtArray, StartTime, EndTime, ref ctbApptSchedule);
    425410
    426             /*So far, we have the following:
     411            So far, we have the following:
    427412             * dtRet -> List of Appointments Start and End times, one row per appointment
    428413             * cdtArray -> Linear 1 dimensional Array of dtRet Start and End times, sorted
     
    432417             *      2 appts as 10:10-10:30 and 10:20-10:40 get converted into 10:10-10:20,
    433418             *      10:20-10:30, 10:30-10:40).
    434             */
     419           
    435420
    436421            //Find number of TimeBlocks in ctbApptSchedule that overlap the TimeBlocks in ctbAppointments
     
    498483
    499484                }
    500 
     485        */
     486
     487        /*
    501488                public static int BlocksOverlap(CGAvailability rBlock, ArrayList rTBArray)
    502489                {
     
    542529                        return nCount;
    543530                }
     531        */
    544532
    545533                /// <summary>
     
    552540                /// <returns>true or false</returns>
    553541        /// <remarks>Draws 2 rectangles and sees if they overlap using minutes from 1980 as the start point</remarks>
    554                 public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
     542                /*
     543        public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
    555544                {
    556545                        Rectangle rect1 = new Rectangle();
     
    568557                        return bRet;
    569558                }
    570 
     559        */
     560
     561        /*
    571562                public static void ConsolidateBlocks(ArrayList rTBArray)
    572563                {
     
    607598                        }
    608599                        while (!((bDirty == false) || (rTBArray.Count == 1)));
    609                 }
     600                } */
    610601
    611602        /// <summary>
     
    616607        /// <param name="sResource"></param>
    617608        /// <returns></returns>
    618                 public static DataTable SubtractSlotsRS2(DataTable rsBlocks1, DataTable rsBlocks2, string sResource)
     609                /*
     610        public static DataTable SubtractSlotsRS2(DataTable rsBlocks1, DataTable rsBlocks2, string sResource)
    619611                {
    620612                        //Subtract slots in rsBlocks2 from rsBlocks1
     
    680672
    681673                }
    682 
     674         */
     675
     676        /*
    683677                public static DataTable UnionBlocks(DataTable rs1, DataTable rs2)
    684678                {
     
    714708                        return rsCopy;
    715709                }
    716 
     710        */
     711
     712        /*
    717713                public static DataTable IntersectBlocks(DataTable rs1, DataTable rs2)
    718714                {
     
    770766//                                                      rect2.Height = CGSchedLib.MinSince80(dEnd2) - rect2.Y;
    771767                                                        if (
    772                                                                 /*(rect2.IntersectsWith(rect1) == true)*/
     768                                                                /*(rect2.IntersectsWith(rect1) == true)
    773769                                                                (CGSchedLib.TimesOverlap(dStart1, dEnd1, dStart2, dEnd2) == true)
    774770                                                                &&
     
    797793                        return rsCopy;
    798794                }//end IntersectBlocks
    799 
     795        */
     796       
    800797        /// <summary>
    801798        /// Number of minutes since Jan 1 1980
     
    803800        /// <param name="d">Date to compare</param>
    804801        /// <returns>Minutes as integer</returns>
    805                 public static int MinSince80(DateTime d)
     802                /*
     803        public static int MinSince80(DateTime d)
    806804                {
    807805                        //Returns the total minutes between d and 1 Jan 1980
     
    814812                        return nMinutes;
    815813                }
    816 
     814        */
     815
     816        /*
    817817        /// <summary>
    818818        /// Converts an Array of Times like this:
     
    909909
    910910                }//end ScheduleFromArray
    911 
    912                 //long CResourceLink::SlotsInBlock(CTimeBlock &rTimeBlock, _RecordsetPtr rsBlock)
     911        */
     912               
     913        /*
     914        //long CResourceLink::SlotsInBlock(CTimeBlock &rTimeBlock, _RecordsetPtr rsBlock)
    913915                public static int SlotsInBlock(CGAvailability rTimeBlock, DataTable rsBlock)
    914916                {
     
    952954                        return nSlots;
    953955                }//end SlotsInBlock
    954 
     956        */
     957
     958        /*
    955959                public static string ClinicInBlock(CGAvailability rTimeBlock, DataTable rsBlock)
    956960                {
     
    991995                        return sClinic;
    992996                }//end ClinicInBlock
    993 
     997        */
     998
     999        /*
    9941000                public static bool ResourceRulesInBlock(CGAvailability rTimeBlock, DataTable rsBlock, ref string sResourceList, ref string sAccessRuleList, ref string sNote)
    9951001                {
     
    10591065                        return true;
    10601066                }//End ResourceRulesInBlock
     1067        */
    10611068
    10621069       
Note: See TracChangeset for help on using the changeset viewer.