GetAppointmentsForPeriod() question

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
mopensoft
Posts: 146
Joined: Tue Dec 04, 2012 3:33 pm
Location: Melbourne, Australia
Contact:

GetAppointmentsForPeriod() question

Post by mopensoft » Thu Sep 05, 2013 7:19 pm

I was a bit confuse with this function as it always give me empty list result:

Code: Select all

   public static List<Appointment> GetAppointmentsForPeriod(DateTime start,DateTime end) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<List<Appointment>>(MethodBase.GetCurrentMethod(),start,end);
			}
			string command="SELECT * FROM appointment WHERE ";
			command+="AptDateTime >= "+POut.DateT(start.Date);//to check to see if an appointment scheduled beforehand overlaps this time segment
			command+="AND AptDateTime <= "+POut.DateT(end);
			List<Appointment> retVal = Crud.AppointmentCrud.TableToList(Db.GetTable(command));
			for(int i=retVal.Count-1;i>=0;i--) {
				if(retVal[i].AptDateTime.AddMinutes(retVal[i].Pattern.Length*PrefC.GetInt(PrefName.AppointmentTimeIncrement))>start) {
					retVal.RemoveAt(i);
				}
			}
			return retVal;
		}
I think the checking condition may be the problem as it's always true. It should be "end" rather than "start", shouldn't it?

Cheers
M

User avatar
jsalmon
Posts: 1553
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: GetAppointmentsForPeriod() question

Post by jsalmon » Thu Sep 05, 2013 10:39 pm

I agree this method does not look complete. I see that it is not referenced anywhere. I looked at the history of the file and noticed when it was written it never got used. This leads me further to believe that it is not a completed method. You might try the method GetForPeriodList(). That will essentially give you the same results you would get from GetAppointmentsForPeriod(), the main difference being that unscheduled and planned appointments are excluded.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
mopensoft
Posts: 146
Joined: Tue Dec 04, 2012 3:33 pm
Location: Melbourne, Australia
Contact:

Re: GetAppointmentsForPeriod() question

Post by mopensoft » Fri Sep 06, 2013 6:16 am

I rewrote the function in my plugin so it's ok now. Will try GetAppointmentsForPeriod(). Thanks. Minh

Post Reply