def getCustomerDetailsByID(): full_name = "" nric = 0 user_id = State.getLogonUser()["user_id"] for user in State.getUserList(): if user.id == user_id: full_name = user.fullName nric = user.nric return full_name, nric
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 register(id, username, password, fullName, nric, gender, contactNumber, address, role="Customer"): newUser = User(id, username, password, fullName, nric, gender, contactNumber, address, role) State.addUser(newUser)
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 login(username, password): for user in State.getUserList(): if user.username == username: if user.password == password: State.logonUser(user.id, True, user.role) break else: State.logonUser(0, False, "") break else: State.logonUser(0, False, "") return State.getLogonUser()
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 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 mockAppointments(): State.addAppointment( Appointment ( customer_name = "Lee Kah Wei", customer_nric = "960411075647", dentist = "Dr. Ong", treatment = "Fillings", date = 20200815, timeslot = 1, status = "Complated", user_id = 4 ) ) State.addAppointment( Appointment ( customer_name = "Lee Kah Wei", customer_nric = "960411075647", dentist = "Dr. Stanley", treatment = "Fillings", date = 20200823, timeslot = 3, status = "Pending", user_id = 4 ) ) State.addAppointment( Appointment ( customer_name = "Lee Kah Wei", customer_nric = "960411075647", dentist = "Dr. Stanley", treatment = "Extractions", date = 20200820, timeslot = 2, status = "No-show", user_id = 4 ) ) State.addAppointment( Appointment ( customer_name = "Lee Min Er", customer_nric = "9604155689", dentist = "Dr. Stanley", treatment = "Extractions", date = 20200815, timeslot = 10, status = "Completed", user_id = 5 ) ) State.addAppointment( Appointment ( customer_name = "Lee Min Er", customer_nric = "9604155689", dentist = "Dr. Stanley", treatment = "Teeth Cleaning", date = 20200824, timeslot = 4, status = "Pending", user_id = 5 ) ) State.addAppointment( Appointment ( customer_name = "Lee Min Er", customer_nric = "9604155689", dentist = "Dr. Stanley", treatment = "Denture", date = 20200823, timeslot = 7, status = "Comfirmed", user_id = 5 ) ) State.addAppointment( Appointment ( customer_name = "Tan Yun Ching", customer_nric = "964123589646", dentist = "Dr. Stanley", treatment = "Denture", date = 20200815, timeslot = 8, status = "Completed", user_id = 6 ) ) State.addAppointment( Appointment ( customer_name = "Tan Yun Ching", customer_nric = "964123589646", dentist = "Dr. Ong", treatment = "Repairs", date = 20200825, timeslot = 13, status = "Confirmed", user_id = 6 ) ) State.addAppointment( Appointment ( customer_name = "Tan Yun Ching", customer_nric = "964123589646", dentist = "Dr. Ong", treatment = "Repairs", date = 20200823, timeslot = 13, status = "Pending", user_id = 6 ) ) State.addAppointment( Appointment ( customer_name = "Tan Yun Ching", customer_nric = "964123589646", dentist = "Dr. Stanley", treatment = "Denture", date = 20200806, timeslot = 13, status = "Rejected", user_id = 6 ) ) State.addAppointment( Appointment ( customer_name = "Koay Evon", customer_nric = "956321458523", dentist = "Dr. Ong", treatment = "Teeth Cleaning", date = 20200806, timeslot = 6, status = "Completed", user_id = 7 ) ) State.addAppointment( Appointment ( customer_name = "Koay Evon", customer_nric = "956321458523", dentist = "Dr. Stanley", treatment = "Teeth Cleaning", date = 20200822, timeslot = 6, status = "Pending", user_id = 7 ) ) State.addAppointment( Appointment ( customer_name = "Low Lee Yee", customer_nric = "95632555562", dentist = "Dr. Ong", treatment = "Fillings", date = 20200822, timeslot = 8, status = "Pending", user_id = 8 ) ) State.addAppointment( Appointment ( customer_name = "Low Lee Yee", customer_nric = "95632555562", dentist = "Dr. Ong", treatment = "Repairs", date = 20200806, timeslot = 8, status = "Completed", user_id = 8 ) )
def logout(): State.logonUser(0, False) return State.getLogonUser()
def mockUsers(): State.addUser( Dentist(id=1, username="******", password="******", fullName="Dr.Stanley", nric="990203075164", gender="Male", contactNumber="0125822587", address="26, Jalan Cantil, 16599,Penang, Malaysia")) State.addUser( Dentist(id=2, username="******", password="******", fullName="Dr.Ong", nric="893193891378", gender="Male", contactNumber="0164822695", address="2, Lorong Teratai Indah, 13400,Penang, Malaysia")) State.addUser( Nurse(id=3, username="******", password="******", fullName="Ms.Nurse", nric="850123856584", gender="Female", contactNumber="01265876436", address="13, Taman Kheng Tian, 13400,Penang, Malaysia")) State.addUser( Customer( id=4, username="******", password="******", fullName="Lee Kah Wei", nric="960411075647", gender="Male", contactNumber="0124912446", address= "50-6-10, Taman Sri Hijau, Jalan Van Praagh, 11600, Penang, Malaysia" )) State.addUser( Customer( id=5, username="******", password="******", fullName="Lee Min Er", nric="9604155689", gender="Female", contactNumber="0121235877", address= "49, Taman Cantik, Jalan Cantik, 15622, Penang, Malaysia")) State.addUser( Customer( id=6, username="******", password="******", fullName="Tan Yun Ching", nric="964123589646", gender="Female", contactNumber="0124555896", address="49, Taman Pondok, Jalan Yes, 45622, Penang, Malaysia") ) State.addUser( Customer( id=7, username="******", password="******", fullName="Koay Evon", nric="956321458523", gender="Female", contactNumber="0169852364", address= "9, Taman Hjiau 4, Jalan Tomato, 45996, Penang, Malaysia")) State.addUser( Customer(id=8, username="******", password="******", fullName="Low Lee Yee", nric="95632555562", gender="Male", contactNumber="0124545926", address="282, Taman Padini, 45622, Penang, Malaysia"))
def generateAppointmentSummaryByDentistTreatment(treatment): appointmentList = [] for appointment in State.getAppointmentList(): if appointment.treatment == treatment: appointmentList.append(Appointment) return appointmentList