File size: 2,936 Bytes
7083742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from interface.actions import *


def _start_application():
    with gr.Blocks() as app:
        gr.Markdown("## Agendamiento de citas")

        home_tab = gr.Tab('Home', visible=True)
        with home_tab:
            with gr.Row():
                schedule_button = gr.Button(value="Agendar Cita")
                search_button = gr.Button(value="Buscar Cita")

        schedule_tab = gr.Tab('Agendamientos', visible=False)
        with schedule_tab:
            gr.Markdown("## Agendar cita")
            identification = gr.Textbox(label="Identificación")
            name = gr.Textbox(label="Nombres")
            last_name = gr.Textbox(label="Apellidos")
            age = gr.Number(label="Edad")
            with gr.Row():
                available_dates = gr.State()
                day = gr.Dropdown(label='Fecha')
                hour = gr.Dropdown(label='Hora')
            with gr.Row():
                schedule_back_button = gr.Button(value="Volver")
                save_appointment_button = gr.Button(value="Agendar Cita")

        search_tab = gr.Tab('Buscar', visible=False)
        with search_tab:
            gr.Markdown("## Buscar cita")
            with gr.Row():
                date_dropdown = gr.Dropdown(label='Citas por', allow_custom_value=True)
                search_appointment_button = gr.Button(value="Buscar")
            appointments_df = gr.Dataframe(headers=['Cedula', 'Nombres', 'Hora'])
            search_back_button = gr.Button(value='Volver')

        # Start the appointment scheduling process
        schedule_button.click(
            make_appointment,
            None,
            [home_tab, schedule_tab, search_tab, available_dates, day, hour]
        )

        # Go back to the home tab
        schedule_back_button.click(
            get_back_home,
            None,
            [home_tab, schedule_tab, search_tab]
        )
        search_back_button.click(
            get_back_home,
            None,
            [home_tab, schedule_tab, search_tab]
        )

        # Update the available hours when the selected day changes when scheduling an appointment
        day.change(
            get_available_hours,
            [day, available_dates],
            [hour]
        )

        # Create the appointment
        save_appointment_button.click(
            create_appointment,
            [identification, name, last_name, age, day, hour],
            [home_tab, schedule_tab, search_tab]
        )

        # Start the search appointment process
        search_button.click(
            search_appointments_days,
            None,
            [home_tab, schedule_tab, search_tab, date_dropdown]
        )

        # Get all the appointments for the selected day
        search_appointment_button.click(
            search_appointments,
            date_dropdown,
            appointments_df
        )


    app.launch()

def init_application():
    _start_application()