NikilDGr8 commited on
Commit
d0a33ce
·
verified ·
1 Parent(s): 0cc644a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -31
app.py CHANGED
@@ -27,9 +27,9 @@ questions = [
27
 
28
  # Oral Health Assessment Form
29
  oral_health_assessment_form = [
30
- "Doctors Name",
31
  "Location",
32
- "Patients Name",
33
  "Age",
34
  "Gender",
35
  "Chief complaint",
@@ -84,18 +84,15 @@ def fill_textboxes(context: str) -> list:
84
 
85
  # Map answers to form fields in the correct order and return as a list
86
  return [
87
- answers[0] if len(answers) > 0 else "",
88
- answers[1] if len(answers) > 1 else "",
89
- answers[2] if len(answers) > 2 else "",
90
- answers[3] if len(answers) > 3 else "",
91
- answers[4] if len(answers) > 4 else "",
92
- answers[5] if len(answers) > 5 else "",
93
  "", # Referred to
94
- "", # Treatment plan
95
  "", # Calculus
96
  "", # Stains
97
- "", # Doctor’s Name
98
- "", # Location
99
  ]
100
 
101
  # Supabase configuration
@@ -105,22 +102,19 @@ def handle_transcription(audio: str, doctor_name: str, location: str) -> list:
105
  context = transcribe_audio(audio)
106
  if "Error" in context:
107
  # Fill all fields with the error message
108
- return [context] * len(textboxes_left + textboxes_right + [doctor_name_display, location_display])
109
 
110
  answers = fill_textboxes(context)
111
 
112
- # Insert Doctors Name and Location in the appropriate fields
113
- answers[-2] = doctor_name
114
- answers[-1] = location
115
-
116
- return answers + [""] * (14 - len(answers))
117
 
118
  def save_answers(doctor_name: str, location: str, patient_name: str, age: str, gender: str, chief_complaint: str, medical_history: str, dental_history: str, clinical_findings: str, treatment_plan: str, referred_to: str, calculus: str, stains: str) -> str:
119
  current_datetime = datetime.now().isoformat()
120
  answers_dict = {
121
- "Doctors Name": doctor_name,
122
  "Location": location,
123
- "Patients Name": patient_name,
124
  "Age": age,
125
  "Gender": gender,
126
  "Chief complaint": chief_complaint,
@@ -202,17 +196,17 @@ with gr.Blocks() as demo:
202
 
203
  with gr.Row(elem_id="textboxes_row"):
204
  with gr.Column():
205
- doctor_name_display = gr.Textbox(label="Doctors Name", value="", interactive=False)
206
  location_display = gr.Textbox(label="Location", value="", interactive=False)
207
- patient_name_input = gr.Textbox(label="Patients Name", value="", interactive=True)
208
- textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(3, len(oral_health_assessment_form)//2)]
209
  with gr.Column():
210
- 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)-3)]
211
- textboxes_right.append(gr.Textbox(label="Clinical Findings", interactive=True))
212
- textboxes_right.append(gr.Dropdown(choices=["NONE", "ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], value="NONE", label="Referred to", interactive=True))
213
- textboxes_right.append(gr.Dropdown(choices=["+", "++", "+++"], label="Calculus", interactive=True))
214
- textboxes_right.append(gr.Dropdown(choices=["-", "+", "++", "+++"], label="Stains", interactive=True))
215
- textboxes_right.append(gr.Dropdown(choices=["Scaling", "Filling", "Pulp therapy/RCT", "Extraction", "Medication", "Referral"], label="Treatment plan", interactive=True))
216
 
217
  oha_output = gr.Textbox(label="OHA Output", value="", interactive=False)
218
  save_button = gr.Button("Save to Supabase", elem_id="save_button", interactive=True)
@@ -221,13 +215,13 @@ with gr.Blocks() as demo:
221
  transcribe_button.click(
222
  fn=handle_transcription,
223
  inputs=[audio_input, doctor_name_input, location_input],
224
- outputs=textboxes_left + textboxes_right + [doctor_name_display, location_display]
225
  )
226
 
227
  # Save the form data to Supabase when the save button is clicked
228
  save_button.click(
229
  fn=save_answers,
230
- inputs=[doctor_name_input, location_input] + [patient_name_input] + textboxes_left + textboxes_right,
231
  outputs=[oha_output]
232
  )
233
 
@@ -238,4 +232,4 @@ with gr.Blocks() as demo:
238
  download_button.click(fn=gradio_download, inputs=[], outputs=download_output)
239
 
240
  # Launch the Gradio app
241
- demo.launch(share=True)
 
27
 
28
  # Oral Health Assessment Form
29
  oral_health_assessment_form = [
30
+ "Doctor's Name",
31
  "Location",
32
+ "Patient's Name",
33
  "Age",
34
  "Gender",
35
  "Chief complaint",
 
84
 
85
  # Map answers to form fields in the correct order and return as a list
86
  return [
87
+ answers[0] if len(answers) > 0 else "", # Age
88
+ answers[1] if len(answers) > 1 else "", # Gender
89
+ answers[2] if len(answers) > 2 else "", # Chief complaint
90
+ answers[3] if len(answers) > 3 else "", # Medical history
91
+ answers[4] if len(answers) > 4 else "", # Dental history
92
+ answers[5] if len(answers) > 5 else "", # Clinical Findings
93
  "", # Referred to
 
94
  "", # Calculus
95
  "", # Stains
 
 
96
  ]
97
 
98
  # Supabase configuration
 
102
  context = transcribe_audio(audio)
103
  if "Error" in context:
104
  # Fill all fields with the error message
105
+ return [context] * (len(textboxes_left) + len(textboxes_right) + 3) # +3 for doctor_name, location, and treatment_plan
106
 
107
  answers = fill_textboxes(context)
108
 
109
+ # Insert Doctor's Name and Location in the appropriate fields
110
+ return [doctor_name, location] + answers + [""] # Empty string for treatment_plan dropdown
 
 
 
111
 
112
  def save_answers(doctor_name: str, location: str, patient_name: str, age: str, gender: str, chief_complaint: str, medical_history: str, dental_history: str, clinical_findings: str, treatment_plan: str, referred_to: str, calculus: str, stains: str) -> str:
113
  current_datetime = datetime.now().isoformat()
114
  answers_dict = {
115
+ "Doctor's Name": doctor_name,
116
  "Location": location,
117
+ "Patient's Name": patient_name,
118
  "Age": age,
119
  "Gender": gender,
120
  "Chief complaint": chief_complaint,
 
196
 
197
  with gr.Row(elem_id="textboxes_row"):
198
  with gr.Column():
199
+ doctor_name_display = gr.Textbox(label="Doctor's Name", value="", interactive=False)
200
  location_display = gr.Textbox(label="Location", value="", interactive=False)
201
+ patient_name_input = gr.Textbox(label="Patient's Name", value="", interactive=True)
202
+ textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(3, 9)] # Age, Gender, Chief complaint, Medical history, Dental history, Clinical Findings
203
  with gr.Column():
204
+ textboxes_right = [
205
+ gr.Dropdown(choices=["NONE", "ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], value="NONE", label="Referred to", interactive=True),
206
+ gr.Dropdown(choices=["+", "++", "+++"], label="Calculus", interactive=True),
207
+ gr.Dropdown(choices=["-", "+", "++", "+++"], label="Stains", interactive=True),
208
+ ]
209
+ treatment_plan_dropdown = gr.Dropdown(choices=["Scaling", "Filling", "Pulp therapy/RCT", "Extraction", "Medication", "Referral"], label="Treatment plan", interactive=True)
210
 
211
  oha_output = gr.Textbox(label="OHA Output", value="", interactive=False)
212
  save_button = gr.Button("Save to Supabase", elem_id="save_button", interactive=True)
 
215
  transcribe_button.click(
216
  fn=handle_transcription,
217
  inputs=[audio_input, doctor_name_input, location_input],
218
+ outputs=[doctor_name_display, location_display] + textboxes_left + textboxes_right + [treatment_plan_dropdown]
219
  )
220
 
221
  # Save the form data to Supabase when the save button is clicked
222
  save_button.click(
223
  fn=save_answers,
224
+ inputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + [treatment_plan_dropdown] + textboxes_right,
225
  outputs=[oha_output]
226
  )
227
 
 
232
  download_button.click(fn=gradio_download, inputs=[], outputs=download_output)
233
 
234
  # Launch the Gradio app
235
+ demo.launch(share=True)