use FlexiBook.ump;

class Appointment{
  sm{
    Booked{
      
      updateAppointment(TimeSlot TS, Boolean isChange, BookableService newService, Boolean isAdd, ComboItem opService) [upToOneDayDifference() & timeSlotAvailable()] /{
        doUpdateAppointment(TS, isChange, newService, isAdd, opService);
      }->Booked;
      
      cancelAppointment(Customer c) [upToOneDayDifference()]/{
        doCancelAppointment(c);
      }->Final;
      
      startAppointment() [isWithinAppTimeSlot()]/{
        doStartAppointment();
    }->InProgress;
      
    }
    
    InProgress{
      updateAppointment(TimeSlot TS, Boolean isChange, BookableService newService, Boolean isAdd, ComboItem opService) [sameStartTime()]/{
        doUpdateAppointment(TS, isChange, newService, isAdd, opService);
      }-> InProgress;
      
      endAppointment()[isDone() || noShow()]/{
        doEndAppointment();
    }->Final;
    }
    
  }
  
  private void doCancelAppointment(Customer c){
  
  }
  
   private void doUpdateAppointment(TimeSlot TS, Boolean isChange, BookableService newService, Boolean isAdd, ComboItem opService){
	   
	   this.setTimeSlot(TS);
	   if(isChange != null && isChange.equals(Boolean.TRUE)) {    
		   this.setBookableService(newService);
		   return;
	   }
	   
	   ServiceCombo combo = (ServiceCombo) this.getBookableService();
	   if(isAdd.equals(Boolean.TRUE)) {
		  combo.addService(opService);
	   }
	   else {
		  combo.removeService(opService);
	   }
  }
  
  private void doStartAppointment(){
  }
  
  private void doEndAppointment(){
  }
  
  private boolean isDone(){
  return true;
  }
  
  private boolean noShow(){
  return true;
  }
  
  private boolean isWithinAppTimeSlot(){
  return true;
  }
  
  private boolean upToOneDayDifference(){
  return true;
  }
  
  private boolean sameStartTime(){
  return true;
  }
  
  private boolean timeSlotAvailable(){
  return true;
  }
   
  
}
