NikilDGr8 commited on
Commit
09c32d0
1 Parent(s): 0161e86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -34
app.py CHANGED
@@ -159,44 +159,38 @@ def gradio_download():
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()
 
159
  with gr.Blocks() as demo:
160
  gr.Markdown("# OHA Form Filler App")
161
 
162
+ with gr.Tabs() as tabs:
163
+ # Default tab for Doctor's Name and Location
164
+ with gr.Tab("Doctor Info"):
165
  doctor_name_input = gr.Textbox(label="Doctor's Name", interactive=True)
166
  location_input = gr.Textbox(label="Location", interactive=True)
167
+ submit_button = gr.Button("Submit")
168
+ info_output = gr.HTML(label="Submitted Info")
169
+
170
+ submit_button.click(fn=lambda name, loc: f"Doctor's Name: {name}<br>Location: {loc}", inputs=[doctor_name_input, location_input], outputs=info_output)
 
 
 
 
 
 
 
 
 
171
 
172
+ # Second tab for OHA Form
173
+ with gr.Tab("OHA Form"):
174
+ audio_input = gr.Audio(type="filepath", label="Record your audio", elem_id="audio_input")
175
+ transcribe_button = gr.Button("Transcribe and Generate Form", elem_id="transcribe_button")
176
+
177
+ with gr.Row(elem_id="textboxes_row"):
178
+ with gr.Column():
179
+ textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(2, len(oral_health_assessment_form)//2)]
180
+ with gr.Column():
181
+ 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)]
182
+ dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
183
+
184
+ transcribe_button.click(fn=main, inputs=[audio_input, doctor_name_input, location_input], outputs=textboxes_left + textboxes_right)
185
+ submit_button = gr.Button("Submit", elem_id="submit_button")
186
+ output_html = gr.HTML(label="Submitted Answers")
187
+ submit_button.click(fn=save_answers, inputs=textboxes_left + textboxes_right + [dropdown_referred], outputs=output_html)
188
 
189
+ # Third tab for CSV download
190
+ with gr.Tab("Download CSV"):
191
+ download_button = gr.Button("Download Table as CSV")
192
+ download_csv_output = gr.File(label="Download CSV")
193
+ download_button.click(fn=gradio_download, inputs=[], outputs=download_csv_output)
 
 
 
 
 
 
 
194
 
195
  # Launch the app
196
  demo.launch()