def appointmentDate(date): result = False for appointment in State.getAppointmentList(): if appointment.date == date: result = True break return result
def getAppointmentStatus(appointment_id): result = False for appointment in State.getAppointmentList(): if appointment.id == appointment_id: result = True break return result
def updateAppointmentStatus(appointment_id, status, remark=""): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.id == appointment_id: appointment.status = status appointment.remark = remark appointmentList.append(appointment) break return appointmentList
def viewAppointmentsByDate(date): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.date == date: appointment_dict = vars(appointment) appointment_dict[ "timeslot_time"] = Appointment.__appointment_slot[ appointment.timeslot] appointmentList.append(appointment_dict) appointmentList.sort(key=lambda appointment: appointment["date"]) return appointmentList
def generateAppointmentSummaryByCustomerNRIC(customer_nric): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.customer_nric == customer_nric: appointment_dict = vars(appointment) appointment_dict[ "timeslot_time"] = Appointment.__appointment_slot[ appointment.timeslot] appointmentList.append(appointment_dict) appointmentList.sort(key=lambda appointment: appointment["date"]) return appointmentList
def cancelAppointment(appointment_id): cancelStatus = False currentDate = datetime.now() for appointment in State.getAppointmentList(): if appointment.id == int( appointment_id) and appointment.status == "Pending" and ( datetime.strptime(str(appointment.date), "%Y%m%d") - currentDate).days >= 1: appointment.cancel = True cancelStatus = True break return cancelStatus
def createAppointment(customer_name, customer_nric, dentist, treatment, date, timeslot): ableToCreate = True for appointment in State.getAppointmentList(): if appointment.date == date and appointment.timeslot == timeslot: ableToCreate = False break newAppointment = Appointment(customer_name, customer_nric, dentist, treatment, date, timeslot, State.getLogonUser()["user_id"]) State.addAppointment(newAppointment) return ableToCreate
def view7daysAppointmentCalendar(): appointmentList = [] for i in range(1, 7): currentDay = int( (date.today() + timedelta(days=i)).strftime("%Y%m%d")) for appointment in State.getAppointmentList(): if appointment.date == currentDay: appointment_dict = vars(appointment) appointment_dict[ "timeslot_time"] = Appointment.__appointment_slot[ appointment.timeslot] appointmentList.append(appointment_dict) appointmentList.sort(key=lambda appointment: appointment["date"]) return appointmentList
def __init__(self, customer_name, customer_nric, dentist, treatment, date, timeslot, user_id, status="Pending"): self.id = len(State.getAppointmentList()) + 1 self.customer_name = customer_name self.customer_nric = customer_nric self.dentist = dentist self.treatment = treatment self.date = date self.timeslot = timeslot self.user_id = user_id self.status = status self.remark = "" self.cancel = False
def viewAppointmentsStatus(user_id): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.user_id == user_id: appointment_dict = { "id": appointment.id, "date": appointment.date, "timeslot": Appointment.__appointment_slot[appointment.timeslot], "dentist": appointment.dentist, "treatment": appointment.treatment, "status": appointment.status } appointmentList.append(appointment_dict) appointmentList.sort(key=lambda appointment: appointment["date"]) return appointmentList
def viewTotalCustomersByTypes(): totalCustomersByTypes = { "Extractions": [], "Fillings": [], "Repairs": [], "Teeth Cleaning": [], "Denture": [] } returnData = [] for appointment in State.getAppointmentList(): if (appointment.user_id not in totalCustomersByTypes[appointment.treatment]): totalCustomersByTypes[appointment.treatment].append( appointment.user_id) for appointmentTypes in totalCustomersByTypes: returnData.append({ "typeOfTreatment": appointmentTypes, "customerCount": len(totalCustomersByTypes[appointmentTypes]) }) return returnData
def generateAppointmentSummaryByDentistTreatment(treatment): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.treatment == treatment: appointmentList.append(Appointment) return appointmentList