Remove CGSchedLib.OutputArray everywhere. Used to be needed in VS 2003; not anymore as you can see tables now.
CalendarGrid: - Make MinSince80 and TimesOverlap static functions for use by other classes since they are done over and over again. CGAppointments: - Documentation updates CGAVDocument: - Removal of OutputArray CGDocument: - Refactored RefreshAvailabilitySchedule - AddAvailability will not call UpdateAllViews any more. View will be responsible for redrawing itself. - Removal of OutputArray CGDocumentManager: - Removal of OutputArray - Documentation updates CGSchedLib: Lots of Changes - Class now static (new .net 2.0 feature) - Removed OutputArray - Documentation Updates - Commented out now unused CreateAssignedTypeSchedule CGView: - OnUpdateScheduleCallback now has try catch when it this.Invokes the original form so that it won't crash if the form has been closed before it gets called.
This commit is contained in:
parent
ae035bbbd1
commit
23b1654177
|
@ -374,7 +374,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
ArrayList apptTypeIDs = new ArrayList();
|
||||
|
||||
rAppointmentSchedule = CGSchedLib.CreateAssignedSlotSchedule(m_DocManager, (string) m_sResourcesArray[0], this.m_dStartDate, this.m_dEndDate, apptTypeIDs,/* */ this.m_ScheduleType, "0");
|
||||
CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule");
|
||||
|
||||
foreach (DataRow r in rAppointmentSchedule.Rows)
|
||||
{
|
||||
nKeyID = Convert.ToInt32(r["AVAILABILITYID"].ToString());
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
/// <summary>
|
||||
/// This class was regenerated from Calendargrid.dll using Reflector.exe
|
||||
/// by Sam Habiel for WorldVista. The original source code is lost.
|
||||
/// Managers Appointment objects CGAppointment using an array list internally.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Really needs to be refactored to use generics
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class CGAppointments : IEnumerable, ICloneable
|
||||
{
|
||||
|
@ -57,6 +59,10 @@
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a deep copy of CGAppointments
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public object Clone()
|
||||
{
|
||||
CGAppointments newappts = new CGAppointments();
|
||||
|
|
|
@ -172,6 +172,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
|
||||
/// <summary>
|
||||
/// Update schedule based on info in RPMS
|
||||
/// <returns>Clears and repopluates m_appointments</returns>
|
||||
/// </summary>
|
||||
private bool RefreshDaysSchedule()
|
||||
{
|
||||
|
@ -199,15 +200,13 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
//Nice to know that it gets set here!!!
|
||||
m_dLastRefresh = DateTime.Now;
|
||||
|
||||
//Clear appointments associated with this document
|
||||
this.m_appointments.ClearAllAppointments();
|
||||
|
||||
// calls RPC to get appointments
|
||||
rAppointmentSchedule = CGSchedLib.CreateAppointmentSchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate);
|
||||
|
||||
// Datatable dumper into Debug Log (nice to know that this exists)
|
||||
CGSchedLib.OutputArray(rAppointmentSchedule, "rAppointmentSchedule");
|
||||
|
||||
|
||||
// loop through datatable: Create CGAppointment and add to CGAppointments
|
||||
foreach (DataRow r in rAppointmentSchedule.Rows)
|
||||
{
|
||||
|
||||
|
@ -421,19 +420,48 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
{
|
||||
try
|
||||
{
|
||||
if (this.m_DocManager.ConnectInfo.Connected == false)
|
||||
{
|
||||
m_DocManager.ConnectInfo.LoadConnectInfo();
|
||||
}
|
||||
|
||||
ArrayList saryApptTypes = new ArrayList();
|
||||
int nApptTypeID = 0;
|
||||
|
||||
|
||||
//Refresh Availability schedules
|
||||
DataTable rAvailabilitySchedule;
|
||||
rAvailabilitySchedule = CGSchedLib.CreateAvailabilitySchedule(m_DocManager, m_sResourcesArray, this.m_dStartDate, this.m_dEndDate, saryApptTypes,/**/ m_ScheduleType, "0");
|
||||
CGSchedLib.OutputArray(rAvailabilitySchedule, "rAvailabilitySchedule");
|
||||
|
||||
////NEW
|
||||
//NOTE: This lock makes sure that availabilities aren't queried for slots when the array is an intermediate
|
||||
//state. The other place that has this lock is SlotsAvailable function.
|
||||
lock (this.m_pAvArray)
|
||||
{
|
||||
m_pAvArray.Clear();
|
||||
foreach (DataRow rTemp in rAvailabilitySchedule.Rows)
|
||||
{
|
||||
DateTime dStart = (DateTime)rTemp["START_TIME"];
|
||||
DateTime dEnd = (DateTime)rTemp["END_TIME"];
|
||||
|
||||
//TODO: Fix this slots datatype problem
|
||||
string sSlots = rTemp["SLOTS"].ToString();
|
||||
int nSlots = Convert.ToInt16(sSlots);
|
||||
|
||||
string sResourceList = rTemp["RESOURCE"].ToString();
|
||||
string sAccessRuleList = rTemp["ACCESS_TYPE"].ToString();
|
||||
string sNote = rTemp["NOTE"].ToString();
|
||||
|
||||
int nApptTypeID;
|
||||
|
||||
if ((nSlots < -1000) || (sAccessRuleList == ""))
|
||||
{
|
||||
nApptTypeID = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nApptTypeID = Int32.Parse(rTemp["ACCESS_TYPE"].ToString());
|
||||
}
|
||||
|
||||
AddAvailability(dStart, dEnd, nApptTypeID, nSlots, sResourceList, sAccessRuleList, sNote);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
/* NOT USED
|
||||
//Refresh Type Schedule
|
||||
string sResourceName = "";
|
||||
DataTable rTypeSchedule = new DataTable(); ;
|
||||
|
@ -441,7 +469,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
{
|
||||
sResourceName = m_sResourcesArray[j].ToString();
|
||||
DataTable dtTemp = CGSchedLib.CreateAssignedTypeSchedule(m_DocManager, sResourceName, this.m_dStartDate, this.m_dEndDate, m_ScheduleType);
|
||||
CGSchedLib.OutputArray(dtTemp, "dtTemp");
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
rTypeSchedule = dtTemp;
|
||||
|
@ -451,7 +479,6 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
rTypeSchedule = CGSchedLib.UnionBlocks(rTypeSchedule, dtTemp);
|
||||
}
|
||||
}
|
||||
CGSchedLib.OutputArray(rTypeSchedule, "rTypeSchedule");
|
||||
|
||||
DateTime dStart;
|
||||
DateTime dEnd;
|
||||
|
@ -522,10 +549,11 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
}
|
||||
|
||||
|
||||
AddAvailability(dStart, dEnd, nApptTypeID, nSlots, false, sResourceList, sAccessRuleList, sNote);
|
||||
//AddAvailability(dStart, dEnd, nApptTypeID, nSlots, sResourceList, sAccessRuleList, sNote);
|
||||
}//end foreach datarow rTemp
|
||||
}//end lock
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -551,7 +579,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
/// <param name="sAccessRuleList"></param>
|
||||
/// <param name="sNote"></param>
|
||||
/// <returns></returns>
|
||||
public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, bool UpdateView, string sResourceList, string sAccessRuleList, string sNote)
|
||||
public int AddAvailability(DateTime StartTime, DateTime EndTime, int nType, int nSlots, string sResourceList, string sAccessRuleList, string sNote)
|
||||
{
|
||||
//adds it to the object array
|
||||
//Returns the index in the array
|
||||
|
@ -587,10 +615,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
|
||||
int nIndex = 0;
|
||||
nIndex = m_pAvArray.Add(pNewAv);
|
||||
if (UpdateView == true)
|
||||
{
|
||||
this.UpdateAllViews();
|
||||
}
|
||||
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
/// <remarks>
|
||||
/// Encoding decision is complex. This is the order of priority:
|
||||
/// - If the M DB runs in UTF-8, that's what we are going to use.
|
||||
/// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move forward.
|
||||
/// - If that's not so, /e sets the default encoding. If /e is a non-existent encoding, move to next step.
|
||||
/// - If /e is not supplied or is not recognized, the default encoding is the Windows default Encoding for the user.
|
||||
/// </remarks>
|
||||
[STAThread()]
|
||||
|
@ -605,7 +605,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
dr = new DataRelation("GroupResource", //Relation Name
|
||||
m_dsGlobal.Tables["ResourceGroup"].Columns["RESOURCE_GROUP"], //Parent
|
||||
m_dsGlobal.Tables["GroupResources"].Columns["RESOURCE_GROUP"]); //Child
|
||||
CGSchedLib.OutputArray(m_dsGlobal.Tables["GroupResources"], "GroupResources");
|
||||
|
||||
m_dsGlobal.Relations.Add(dr);
|
||||
|
||||
//HospitalLocation table
|
||||
|
|
|
@ -18,13 +18,8 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
/// CGSchedLib contains static functions that are called from throughout the
|
||||
/// scheduling application.
|
||||
/// </summary>
|
||||
public class CGSchedLib
|
||||
public static class CGSchedLib
|
||||
{
|
||||
public CGSchedLib()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets appointments from VISTA to display in Grid
|
||||
/// </summary>
|
||||
|
@ -52,30 +47,18 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
|
||||
}
|
||||
|
||||
public static void OutputArray(DataTable dt, string sName)
|
||||
{
|
||||
#if (DEBUG && OUTPUTARRAY)
|
||||
Debug.Write("\n " + sName + " OutputArray:\n");
|
||||
if (dt == null)
|
||||
return;
|
||||
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
Debug.Write(c.ToString());
|
||||
}
|
||||
Debug.Write("\n");
|
||||
foreach (DataRow r in dt.Rows)
|
||||
{
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
Debug.Write(r[c].ToString());
|
||||
}
|
||||
Debug.Write("\n");
|
||||
}
|
||||
Debug.Write("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all Availabilities and Appointments, then substracts Appointments from availabilities.
|
||||
/// </summary>
|
||||
/// <param name="docManager">God Class</param>
|
||||
/// <param name="saryResourceNames">Resource Array (ArrayList)</param>
|
||||
/// <param name="StartTime">Self-Explanatory</param>
|
||||
/// <param name="EndTime">Self-Explanatory</param>
|
||||
/// <param name="saryApptTypes">Array of Access Type IDs</param>
|
||||
/// <param name="stType"></param>
|
||||
/// <param name="sSearchInfo"></param>
|
||||
/// <returns></returns>
|
||||
public static DataTable CreateAvailabilitySchedule(CGDocumentManager docManager,
|
||||
ArrayList saryResourceNames, DateTime StartTime, DateTime EndTime,
|
||||
ArrayList saryApptTypes,/**/ ScheduleType stType, string sSearchInfo)
|
||||
|
@ -94,55 +77,54 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
}
|
||||
|
||||
string sResName;
|
||||
//TODO: Optimize: no need to keep looping through resources.
|
||||
// for each resource
|
||||
for (int i = 0; i < nSize; i++)
|
||||
{
|
||||
sResName = saryResourceNames[i].ToString();
|
||||
//Gets all the slots (or Availabities, if you like)
|
||||
//Gets all the slots (or Availabities, or AV Blocks if you like)
|
||||
rsSlotSchedule = CGSchedLib.CreateAssignedSlotSchedule(docManager, sResName, StartTime, EndTime, saryApptTypes,/**/ stType, sSearchInfo);
|
||||
OutputArray(rsSlotSchedule, "rsSlotSchedule");
|
||||
|
||||
//if we have slots
|
||||
if (rsSlotSchedule.Rows.Count > 0 )
|
||||
{
|
||||
// Get appointment count to substract from the slots
|
||||
rsApptSchedule = CGSchedLib.CreateAppointmentSlotSchedule(docManager, sResName, StartTime, EndTime, stType);
|
||||
OutputArray(rsApptSchedule, "rsApptSchedule");
|
||||
|
||||
// Perform the substraction
|
||||
rsTemp1 = CGSchedLib.SubtractSlotsRS2(rsSlotSchedule, rsApptSchedule, sResName);
|
||||
OutputArray(rsTemp1, "rsTemp1");
|
||||
|
||||
}
|
||||
//otherwise, just return the slot schedule we have.
|
||||
else
|
||||
{
|
||||
rsTemp1 = rsSlotSchedule;
|
||||
OutputArray(rsTemp1, "rsTemp1");
|
||||
|
||||
}
|
||||
|
||||
// if only one resource was passed in, its availablility is what we want
|
||||
if (i == 0)
|
||||
{
|
||||
rsOut = rsTemp1;
|
||||
OutputArray(rsOut, "rsOut");
|
||||
}
|
||||
|
||||
}
|
||||
// if more than one resource, merge them together
|
||||
else
|
||||
{
|
||||
rsOut = CGSchedLib.UnionBlocks(rsTemp1, rsOut);
|
||||
OutputArray(rsOut, "United rsOut");
|
||||
}
|
||||
}
|
||||
return rsOut;
|
||||
}
|
||||
|
||||
|
||||
/* NOT USED ANYMORE!!!
|
||||
public static DataTable CreateAssignedTypeSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ScheduleType stType)
|
||||
{
|
||||
|
||||
string sStart;
|
||||
string sEnd;
|
||||
//sStart = StartTime.ToString("M-d-yyyy");
|
||||
sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
//sEnd = EndTime.ToString("M-d-yyyy");
|
||||
sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString;
|
||||
// string sSource = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC");
|
||||
string sSql = "BSDX TYPE BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName ;//+ "^" + sSource;
|
||||
string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
string sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString;
|
||||
string sSql = "BSDX TYPE BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName;
|
||||
|
||||
DataTable rs = docManager.RPMSDataTable(sSql, "AssignedTypeSchedule");
|
||||
|
||||
|
@ -175,8 +157,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
rsCopy.Columns.Add(dCol);
|
||||
|
||||
dCol = new DataColumn();
|
||||
//dCol.DataType = Type.GetType("System.Int16");
|
||||
dCol.DataType = Type.GetType("System.Int32"); //MJL 11/17/2006
|
||||
dCol.DataType = Type.GetType("System.Int32");
|
||||
dCol.ColumnName = "AvailabilityID";
|
||||
dCol.ReadOnly = true;
|
||||
dCol.AllowDBNull = false;
|
||||
|
@ -195,11 +176,12 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
DateTime dLastEnd;
|
||||
DateTime dStart;
|
||||
DateTime dEnd;
|
||||
// DataRow r;
|
||||
DataRow rNew;
|
||||
DataRow rNew; //Temporary Holding place for first or last row
|
||||
|
||||
// Get Last Date from final row
|
||||
rNew = rs.Rows[rs.Rows.Count - 1];
|
||||
dLastEnd = (DateTime) rNew["EndTime"];
|
||||
// Get First Date from first row
|
||||
rNew = rs.Rows[0];
|
||||
dStart = (DateTime) rNew["StartTime"];
|
||||
|
||||
|
@ -209,6 +191,8 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
//if first block in vgetrows starts later than StartTime,
|
||||
// then pad with a new block
|
||||
|
||||
// if First Row time is later than the StartTime param (should always be true)
|
||||
// then make a new row whose time starts from StartTime and ends with dStart
|
||||
if (dStart > StartTime)
|
||||
{
|
||||
dEnd = dStart;
|
||||
|
@ -221,7 +205,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
rsCopy.Rows.Add(rNew);
|
||||
}
|
||||
|
||||
//if first block start time is < StartTime then trim
|
||||
//if first block start time is < StartTime then trim (shouldn't happen)
|
||||
if (dStart < StartTime)
|
||||
{
|
||||
rNew = rs.Rows[0];
|
||||
|
@ -232,6 +216,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
int nAppointmentTypeID;
|
||||
int nAvailabilityID;
|
||||
|
||||
//dStart holds the first date for the availabilities returned from RPMS
|
||||
dEnd = dStart;
|
||||
foreach (DataRow rEach in rs.Rows)
|
||||
{
|
||||
|
@ -247,10 +232,13 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
rsCopy.Rows.Add(rNew);
|
||||
}
|
||||
|
||||
//dEnd now EndTime for AV Block
|
||||
dEnd = (DateTime) rEach["EndTime"];
|
||||
|
||||
if (dEnd > EndTime)
|
||||
dEnd = EndTime;
|
||||
// if dEnd is greater than endime, set dEnd to be the same as EndTime.
|
||||
if (dEnd > EndTime) { dEnd = EndTime; }
|
||||
|
||||
|
||||
nAppointmentTypeID = (int) rEach["AppointmentTypeID"];
|
||||
nAvailabilityID = (int) rEach["AvailabilityID"];
|
||||
|
||||
|
@ -274,21 +262,32 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
rNew["ResourceName"] = sResourceName;
|
||||
rsCopy.Rows.Add(rNew);
|
||||
}
|
||||
OutputArray(rsCopy, "CreateAssignedTypeSchedule");
|
||||
|
||||
return rsCopy;
|
||||
}
|
||||
*/
|
||||
|
||||
public static DataTable CreateAssignedSlotSchedule(CGDocumentManager docManager, string sResourceName, DateTime StartTime, DateTime EndTime, ArrayList rsaryApptTypeIDs, /**/ ScheduleType stType, string sSearchInfo)
|
||||
/// <summary>
|
||||
/// Gets the Availability Slots from the Server
|
||||
/// </summary>
|
||||
/// <param name="docManager">God Class</param>
|
||||
/// <param name="sResourceName">Resource for which to get slots</param>
|
||||
/// <param name="StartTime"></param>
|
||||
/// <param name="EndTime"></param>
|
||||
/// <param name="rsaryApptTypeIDs">Access Type IDs to retrieve</param>
|
||||
/// <param name="stType">Not used</param>
|
||||
/// <param name="sSearchInfo">If performing a slot search (i.e. for empty appointments), has search info here. Used by Find Appointments</param>
|
||||
/// <returns>DataTable with the following Columns:
|
||||
/// 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)
|
||||
{
|
||||
|
||||
//Appointment type ids is now always "" so that all appointment types are returned.
|
||||
//Appointment type ids is now always "" so that all appointment types are returned.
|
||||
string sApptTypeIDs = "";
|
||||
|
||||
//The following code block is not used now, but keep for possible later use:
|
||||
//Unpack the Appointment Type IDs
|
||||
/*
|
||||
*/
|
||||
int nSize = rsaryApptTypeIDs.Count;
|
||||
//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];
|
||||
|
@ -296,22 +295,12 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
sApptTypeIDs += "|";
|
||||
}
|
||||
|
||||
string sStart;
|
||||
string sEnd;
|
||||
//sStart = StartTime.ToString("M-d-yyyy"); smh
|
||||
sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
//sEnd = EndTime.ToString("M-d-yyyy@H:mm"); smh
|
||||
sEnd = FMDateTime.Create(EndTime).FMDateString;
|
||||
string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
string sEnd = FMDateTime.Create(EndTime).FMDateString;
|
||||
string sSql = "BSDX CREATE ASGND SLOT SCHED^" + sResourceName + "^" + sStart + "^" + sEnd + "^" + sApptTypeIDs + "^" + sSearchInfo; //+ "^" + sSTType ;
|
||||
|
||||
DataTable dtRet = docManager.RPMSDataTable(sSql, "AssignedSlotSchedule");
|
||||
|
||||
if (sResourceName == "")
|
||||
{
|
||||
return dtRet;
|
||||
}
|
||||
|
||||
return dtRet;
|
||||
return dtRet;
|
||||
}
|
||||
|
||||
public static DataTable CreateCopyTable()
|
||||
|
@ -369,47 +358,57 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
return dtCopy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This gets a datatable which shows the appointments between start and end time, one row per appointment
|
||||
/// </summary>
|
||||
/// <param name="docManager"></param>
|
||||
/// <param name="sResourceName"></param>
|
||||
/// <param name="StartTime"></param>
|
||||
/// <param name="EndTime"></param>
|
||||
/// <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)
|
||||
{
|
||||
|
||||
|
||||
string sStart;
|
||||
string sEnd;
|
||||
//sStart = StartTime.ToString("M-d-yyyy");
|
||||
sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
//sEnd = EndTime.ToString("M-d-yyyy");
|
||||
sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString;
|
||||
|
||||
string sSTType = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC");
|
||||
//Change Dates to FM Format
|
||||
string sStart = FMDateTime.Create(StartTime).DateOnly.FMDateString;
|
||||
string sEnd = FMDateTime.Create(EndTime).DateOnly.FMDateString;
|
||||
|
||||
string sSTType = (stType == ScheduleType.Resource ? "ST_RESOURCE" : "ST_CLINIC");
|
||||
string sSql = "BSDX APPT BLOCKS OVERLAP^" + sStart + "^" + sEnd + "^" + sResourceName ;//+ "^" + sSTType;
|
||||
|
||||
//This gets you a table with 2 columns containing start and end time for each appt
|
||||
//Each appt gets its own row
|
||||
DataTable dtRet = docManager.RPMSDataTable(sSql, "AppointmentSlotSchedule");
|
||||
|
||||
if (dtRet.Rows.Count < 1)
|
||||
return dtRet;
|
||||
|
||||
//Create CDateTimeArray & load records from rsOut
|
||||
int nRC;
|
||||
nRC = dtRet.Rows.Count;
|
||||
int nRC = dtRet.Rows.Count; // nRC is row count from Appointments table just retrieved
|
||||
ArrayList cdtArray = new ArrayList();
|
||||
cdtArray.Capacity = (nRC * 2);
|
||||
cdtArray.Capacity = (nRC * 2); //new ArrayList has capacity double that of appointment table
|
||||
DateTime v;
|
||||
int i = 0;
|
||||
|
||||
foreach (DataRow r in dtRet.Rows)
|
||||
//for each row in the Appointment Table, ArrayList cdtArray gets 2 entries: Start and End times
|
||||
foreach (DataRow r in dtRet.Rows)
|
||||
{
|
||||
v = (DateTime) r[dtRet.Columns["START_TIME"]];
|
||||
cdtArray.Add(v);
|
||||
v = (DateTime) r[dtRet.Columns["END_TIME"]];
|
||||
cdtArray.Add(v);
|
||||
}
|
||||
|
||||
//Sort start and end times (for use in ScheduleFromArray method)
|
||||
cdtArray.Sort();
|
||||
|
||||
//Create a CTimeBlockArray and load it from rsOut
|
||||
|
||||
//Now, create a new ArrayList with the size of the appointment table to hold availabilities
|
||||
ArrayList ctbAppointments = new ArrayList(nRC);
|
||||
CGAvailability cTB;
|
||||
i = 0;
|
||||
//For each appointment, create an availability
|
||||
foreach (DataRow r in dtRet.Rows)
|
||||
{
|
||||
cTB = new CGAvailability();
|
||||
|
@ -420,17 +419,29 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
|
||||
//Create a TimeBlock Array from the data in the DateTime array
|
||||
ArrayList ctbApptSchedule = new ArrayList();
|
||||
|
||||
//Convert Appointments to Availabilities, where all appointments become squeezed together.
|
||||
ScheduleFromArray(cdtArray, StartTime, EndTime, ref ctbApptSchedule);
|
||||
|
||||
//Find number of TimeBlocks in ctbApptSchedule that
|
||||
//overlap the TimeBlocks in ctbAppointments
|
||||
|
||||
/*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
|
||||
* ctbAppointments -> Arraylist of dtRet as Availabilities
|
||||
* ctbApptSchedule -> Arraylist of dtRet as Availabilities with no overlapping boundaries
|
||||
* (overlaps in appointments get converted into availabilties themselves: so
|
||||
* 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
|
||||
ArrayList ctbApptSchedule2 = new ArrayList();
|
||||
CGAvailability cTB2;
|
||||
int nSlots = 0;
|
||||
for (i=0; i< ctbApptSchedule.Count; i++)
|
||||
for (i=0; i< ctbApptSchedule.Count; i++) //for each non-overlapping appts as availabilities
|
||||
{
|
||||
cTB = (CGAvailability) ctbApptSchedule[i];
|
||||
nSlots = BlocksOverlap(cTB, ctbAppointments);
|
||||
//How many times does the non-overlapping part show up in an appointment slot?
|
||||
nSlots = BlocksOverlap(cTB, ctbAppointments);
|
||||
cTB2 = new CGAvailability();
|
||||
cTB2.Create(cTB.StartTime, cTB.EndTime, nSlots);
|
||||
ctbApptSchedule2.Add(cTB2);
|
||||
|
@ -531,7 +542,15 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
return nCount;
|
||||
}
|
||||
|
||||
//BOOL CResourceLink::TimesOverlap(COleDateTime dStart1, COleDateTime dEnd1, COleDateTime dStart2, COleDateTime dEnd2)
|
||||
/// <summary>
|
||||
/// Does an appointment overlap with another appointment in the same day?
|
||||
/// </summary>
|
||||
/// <param name="dStart1">Start Time of First Appt</param>
|
||||
/// <param name="dEnd1">End Time of First Appt</param>
|
||||
/// <param name="dStart2">Start Time of Second Appt</param>
|
||||
/// <param name="dEnd2">End Time of Second Appt</param>
|
||||
/// <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)
|
||||
{
|
||||
Rectangle rect1 = new Rectangle();
|
||||
|
@ -666,8 +685,6 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
//Test input tables
|
||||
Debug.Assert(rs1 != null);
|
||||
Debug.Assert(rs2 != null);
|
||||
CGSchedLib.OutputArray(rs1, "UnionBlocks rs1");
|
||||
CGSchedLib.OutputArray(rs2, "UnionBlocks rs2");
|
||||
|
||||
DataTable rsCopy;
|
||||
DataRow dr;
|
||||
|
@ -797,7 +814,19 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
return nMinutes;
|
||||
}
|
||||
|
||||
public static void ScheduleFromArray(ArrayList cdtArray, DateTime dStartTime, DateTime dEndTime, ref ArrayList rTBArray)
|
||||
/// <summary>
|
||||
/// Converts an Array of Times like this:
|
||||
/// 10:00 10:00 10:20 10:20 10:30 10:30 10:30 10:40
|
||||
/// To an array of availabilities like this:
|
||||
/// 12:00-10:00 10:00-10:20 10:20-10:30 10:30-10:40
|
||||
/// Where the 12:00 comes from the start time
|
||||
/// </summary>
|
||||
/// <param name="cdtArray">ArrayList containing start and end times of Appointments combmined and sorted</param>
|
||||
/// <param name="dStartTime">Start Time for Schedule</param>
|
||||
/// <param name="dEndTime">End Time for Schedule</param>
|
||||
/// <param name="rTBArray">Output of Availabilities: Pass Empty</param>
|
||||
public static void ScheduleFromArray(ArrayList cdtArray, DateTime dStartTime, DateTime dEndTime,
|
||||
ref ArrayList rTBArray)
|
||||
{
|
||||
int j = 0;
|
||||
CGAvailability cTB;
|
||||
|
@ -811,12 +840,18 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
//If StartTime passed in, then adjust for it
|
||||
if (dStartTime.Ticks > 0)
|
||||
{
|
||||
if ((DateTime) cdtArray[0] > dStartTime)
|
||||
// if first Array Entry greater than start time, then create an availability
|
||||
// with the start time as dStartTime, and end time as the first array entry, and 0 slots
|
||||
// then add this to the output array
|
||||
if ((DateTime) cdtArray[0] > dStartTime)
|
||||
{
|
||||
cTB = new CGAvailability();
|
||||
cTB.Create(dStartTime, (DateTime) cdtArray[0], 0);
|
||||
rTBArray.Add(cTB);
|
||||
}
|
||||
|
||||
// if first Array Entry less than start time (shouldn't happen),
|
||||
// convert all input array's times less than the start time to all be the start time
|
||||
if ((DateTime) cdtArray[0] < dStartTime)
|
||||
{
|
||||
for (j = 0; j < cdtArray.Count; j++)
|
||||
|
@ -828,6 +863,8 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
}
|
||||
|
||||
//Trim the end if necessary
|
||||
//If end time is passed, set all the times in the original array greater
|
||||
//than the end time to be the end time (Shouldn't happen).
|
||||
if (dEndTime.Ticks > 0)
|
||||
{
|
||||
for (j = 0; j < cdtArray.Count; j++)
|
||||
|
@ -838,30 +875,34 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
}
|
||||
|
||||
//build the schedule in rTBArray
|
||||
DateTime dTemp = new DateTime();
|
||||
DateTime dTemp = new DateTime(); //hold previous appt time.
|
||||
DateTime dStart;
|
||||
DateTime dEnd;
|
||||
int k = 0;
|
||||
for (j = 0; j < (cdtArray.Count -1); j++) //TODO: why minus 1?
|
||||
//for each time in appointment array
|
||||
for (j = 0; j < (cdtArray.Count -1); j++) // -1 b/c k below starts with j+1.
|
||||
{
|
||||
if ((DateTime) cdtArray[j] != dTemp)
|
||||
{
|
||||
dStart =(DateTime) cdtArray[j];
|
||||
dTemp = dStart;
|
||||
|
||||
//for each time in appointment array, starting with the next one
|
||||
for (k = j+1; k < cdtArray.Count; k++)
|
||||
{
|
||||
dEnd = new DateTime();
|
||||
if ((DateTime) cdtArray[k] != dStart)
|
||||
if ((DateTime) cdtArray[k] != dStart) //if the next time isn't the same
|
||||
{
|
||||
dEnd = (DateTime) cdtArray[k];
|
||||
dEnd = (DateTime) cdtArray[k]; // set the end to be the next time
|
||||
}
|
||||
if (dEnd.Ticks > 0)
|
||||
if (dEnd.Ticks > 0) //make a new availability and add it to the output array.
|
||||
{
|
||||
cTB = new CGAvailability();
|
||||
cTB.Create(dStart, dEnd, 0);
|
||||
rTBArray.Add(cTB);
|
||||
break;
|
||||
}
|
||||
// if the end time is still empty, loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2328,11 +2328,17 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
/// <remarks>Calls UpdateArrays via this.Invoke to make sure that the grid is redrawn on the UI thread</remarks>
|
||||
private void OnUpdateScheduleCallback(IAsyncResult itfAR)
|
||||
{
|
||||
// if the view meanwhile closed, just return
|
||||
if (this == null) return;
|
||||
|
||||
OnUpdateScheduleDelegate d = new OnUpdateScheduleDelegate(UpdateArrays);
|
||||
this.Invoke(d);
|
||||
|
||||
//try catch just in case that the view closed in the meantime.
|
||||
try
|
||||
{
|
||||
this.Invoke(d);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -798,7 +798,7 @@
|
|||
DateTime time2 = this.GetTimeFromCell(endCell).AddMinutes((double) this.m_nTimeScale);
|
||||
foreach (CGAvailability availability in this.m_pAvArray)
|
||||
{
|
||||
if (this.TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
||||
if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
||||
{
|
||||
nAccessTypeID = availability.AvailabilityType;
|
||||
break;
|
||||
|
@ -841,7 +841,7 @@
|
|||
DateTime time2 = this.GetTimeFromCell(cell2).AddMinutes((double) this.m_nTimeScale);
|
||||
foreach (CGAvailability availability in this.m_pAvArray)
|
||||
{
|
||||
if (this.TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
||||
if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
||||
{
|
||||
nAccessTypeID = availability.AvailabilityType;
|
||||
break;
|
||||
|
@ -893,7 +893,7 @@
|
|||
|
||||
}
|
||||
|
||||
private int MinSince80(DateTime d)
|
||||
private static int MinSince80(DateTime d)
|
||||
{
|
||||
DateTime time = new DateTime(1980, 1, 1, 0, 0, 0);
|
||||
TimeSpan span = (TimeSpan) (d - time);
|
||||
|
@ -1152,7 +1152,15 @@
|
|||
base.Invalidate();
|
||||
}
|
||||
|
||||
private bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
|
||||
/// <summary>
|
||||
/// Do 2 time ranges overlap each other?
|
||||
/// </summary>
|
||||
/// <param name="dStart1">First Start Time</param>
|
||||
/// <param name="dEnd1">First End Time</param>
|
||||
/// <param name="dStart2">Second Start Time</param>
|
||||
/// <param name="dEnd2">Second End Time</param>
|
||||
/// <returns>True or False</returns>
|
||||
public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
|
||||
{
|
||||
long ticks = dEnd1.Ticks - dStart1.Ticks;
|
||||
TimeSpan ts = new TimeSpan(ticks);
|
||||
|
@ -1164,10 +1172,10 @@
|
|||
rectangle2.X = 0;
|
||||
rect.Width = 1;
|
||||
rectangle2.Width = 1;
|
||||
rect.Y = this.MinSince80(dStart1);
|
||||
rect.Height = this.MinSince80(dEnd1) - rect.Y;
|
||||
rectangle2.Y = this.MinSince80(dStart2);
|
||||
rectangle2.Height = this.MinSince80(dEnd2) - rectangle2.Y;
|
||||
rect.Y = MinSince80(dStart1);
|
||||
rect.Height = MinSince80(dEnd1) - rect.Y;
|
||||
rectangle2.Y = MinSince80(dStart2);
|
||||
rectangle2.Height = MinSince80(dEnd2) - rectangle2.Y;
|
||||
return rectangle2.IntersectsWith(rect);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<RemoteDebugMachine>
|
||||
</RemoteDebugMachine>
|
||||
<StartAction>Project</StartAction>
|
||||
<StartArguments>/s=172.16.16.108 /p=9250 /a=abeer12 /v=abc,4321</StartArguments>
|
||||
<StartArguments>/s=192.168.56.101 /p=9260 /a=shabiel12 /v=catdog.77</StartArguments>
|
||||
<StartPage>
|
||||
</StartPage>
|
||||
<StartProgram>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\IEExec.exe</StartProgram>
|
||||
|
|
|
@ -10,12 +10,12 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8C05C4F7-FE81-479F-87A0-44E04C7F6E0F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DE8E4CC9-4F3A-4E32-8DFE-EE5692E8FC45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{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
|
||||
EndGlobalSection
|
||||
|
|
Binary file not shown.
|
@ -96,7 +96,6 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
|
||||
//Build AccessGroup table containing *active* AccessTypes and their Groups
|
||||
m_dtTypes = m_dsGlobal.Tables["AccessGroupType"];
|
||||
CGSchedLib.OutputArray(m_dtTypes, "Access Group Type");
|
||||
//Create a view that is filterable on Access Group
|
||||
m_dvTypes = new DataView(m_dtTypes);
|
||||
m_dvTypes.RowFilter = "ACCESS_GROUP = '" + this.cboAccessTypeFilter.Text + "'";
|
||||
|
@ -656,7 +655,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
string sDOW;
|
||||
int nAccessTypeID;
|
||||
string sAccessType;
|
||||
CGSchedLib.OutputArray(m_dtResult, "Result Grid");
|
||||
|
||||
foreach (DataRow dr in m_dtResult.Rows)
|
||||
{
|
||||
dt = (DateTime) dr["START_TIME"];
|
||||
|
@ -673,7 +672,7 @@ namespace IndianHealthService.ClinicalScheduling
|
|||
}
|
||||
}
|
||||
}
|
||||
CGSchedLib.OutputArray(m_dtResult, "Result Grid");
|
||||
|
||||
|
||||
m_dvResult = new DataView(m_dtResult);
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue