NikilDGr8 commited on
Commit
0161e86
1 Parent(s): 3c7d18a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -26
app.py CHANGED
@@ -159,36 +159,44 @@ def gradio_download():
159
  with gr.Blocks() as demo:
160
  gr.Markdown("# OHA Form Filler App")
161
 
162
- with gr.Tabs() as tabs:
163
- with gr.TabItem("Doctor Info"):
 
164
  doctor_name_input = gr.Textbox(label="Doctor's Name", interactive=True)
165
  location_input = gr.Textbox(label="Location", interactive=True)
166
- next_button = gr.Button("Next")
167
-
168
- with gr.TabItem("OHA Form"):
 
 
 
 
 
 
 
 
169
  audio_input = gr.Audio(type="filepath", label="Record your audio")
170
  transcribe_button = gr.Button("Transcribe and Generate Form")
171
-
172
- with gr.Row():
173
- with gr.Column():
174
- textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(2, len(oral_health_assessment_form)//2)]
175
- with gr.Column():
176
- textboxes_right = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(len(oral_health_assessment_form)//2, len(oral_health_assessment_form)-1)]
177
- dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
178
-
179
- submit_button = gr.Button("Submit")
180
- output_html = gr.HTML(label="Submitted Answers")
181
-
182
- transcribe_button.click(fn=main, inputs=[audio_input, doctor_name_input, location_input], outputs=textboxes_left + textboxes_right)
183
- submit_button.click(fn=save_answers, inputs=textboxes_left + textboxes_right + [dropdown_referred], outputs=output_html)
184
-
185
- with gr.TabItem("Download"):
186
- download_button = gr.Button("Download Table as CSV")
187
- download_csv_output = gr.File(label="Download CSV")
188
-
189
- download_button.click(fn=gradio_download, inputs=[], outputs=download_csv_output)
190
-
191
- next_button.click(fn=lambda: gr.set_active(tabs, 1), inputs=[], outputs=[])
192
 
193
  # Launch the app
194
  demo.launch()
 
159
  with gr.Blocks() as demo:
160
  gr.Markdown("# OHA Form Filler App")
161
 
162
+ # Default page for Doctor's Name and Location
163
+ with gr.Page(title="Doctor Info"):
164
+ with gr.Row():
165
  doctor_name_input = gr.Textbox(label="Doctor's Name", interactive=True)
166
  location_input = gr.Textbox(label="Location", interactive=True)
167
+ submit_info_button = gr.Button("Submit")
168
+ info_output = gr.HTML()
169
+
170
+ def handle_info_submission(doctor_name, location):
171
+ return f"Doctor: {doctor_name}, Location: {location}"
172
+
173
+ submit_info_button.click(fn=handle_info_submission, inputs=[doctor_name_input, location_input], outputs=info_output)
174
+
175
+ # Page for OHA Form
176
+ with gr.Page(title="OHA Form"):
177
+ with gr.Row():
178
  audio_input = gr.Audio(type="filepath", label="Record your audio")
179
  transcribe_button = gr.Button("Transcribe and Generate Form")
180
+
181
+ with gr.Row():
182
+ with gr.Column():
183
+ textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(2, len(oral_health_assessment_form)//2)]
184
+ with gr.Column():
185
+ textboxes_right = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(len(oral_health_assessment_form)//2, len(oral_health_assessment_form)-1)]
186
+ dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
187
+
188
+ submit_button = gr.Button("Submit")
189
+ output_html = gr.HTML(label="Submitted Answers")
190
+
191
+ transcribe_button.click(fn=main, inputs=[audio_input, doctor_name_input, location_input], outputs=textboxes_left + textboxes_right)
192
+ submit_button.click(fn=save_answers, inputs=textboxes_left + textboxes_right + [dropdown_referred], outputs=output_html)
193
+
194
+ # Page for downloading CSV
195
+ with gr.Page(title="Download CSV"):
196
+ download_button = gr.Button("Download Table as CSV")
197
+ download_csv_output = gr.File(label="Download CSV")
198
+
199
+ download_button.click(fn=gradio_download, inputs=[], outputs=download_csv_output)
 
200
 
201
  # Launch the app
202
  demo.launch()