Ejemplo n.º 1
0
 def past_appointment(self):
     from models.appointment import Appointment
     past_appointment = Appointment.select().where((
         Appointment.doctor == self) | (Appointment.patient == self))
     past_appointment_list = []
     for a in past_appointment:
         if a.end_datetime < datetime.now():
             if a.zoom_url:
                 link = a.zoom_url
             else:
                 link = None
             past_appointment_list.append({
                 "appointment_id":
                 a.id,
                 "doctor_name":
                 a.doctor.name,
                 "doctor_ic":
                 a.doctor.ic_number,
                 "patient_name":
                 a.patient.name,
                 "patient_ic":
                 a.patient.ic_number,
                 "start_time":
                 a.start_datetime.strftime("%Y-%m-%d %H:%M:%S"),
                 "end_time":
                 a.end_datetime.strftime("%Y-%m-%d %H:%M:%S"),
                 "zoom_url":
                 link
             })
     return past_appointment_list
Ejemplo n.º 2
0
def initialize():
    DATABASE.create_tables([User, Saloon, Appointment], safe=True)
    try:
        User.create(first_name="Felicia",
                    last_name="Mueni",
                    email="*****@*****.**")
    except IntegrityError:
        pass

    try:
        Saloon.create(name="Mrembo",
                      business_number="9897",
                      opening_time="10:00 am",
                      closing_time="5:00 pm",
                      description="Urembo services",
                      services="Manicure, Pedicure, Haircare",
                      user_id=1,
                      location="George Padimore Lane")
    except IntegrityError:
        pass
    try:
        no_appointments = Appointment.select().count()
        if no_appointments < 1:
            Appointment.create(user_id=1,
                               saloon_id=1,
                               services="Manicure, Pedicure",
                               time_appointment=datetime.datetime.now())

    except IntegrityError:
        pass
Ejemplo n.º 3
0
def list_appointments():
    appointments = Appointment.select()
    results = []
    for appointment in appointments:
        results.append({
            'user_id': appointment.user_id,
            'time_appointment': appointment.time_appointment,
            'saloon_id': appointment.saloon_id,
            'services': appointment.services
        })
    return jsonify(results)