NikilDGr8 commited on
Commit
51b3fe0
·
verified ·
1 Parent(s): 9ee86c8

dropdown for stains and calculus

Browse files
Files changed (1) hide show
  1. app.py +30 -15
app.py CHANGED
@@ -22,8 +22,8 @@ questions = [
22
  "What is the chief complaint regarding the patient's oral health?",
23
  "List the Medical history mentioned",
24
  "Give the Dental history in detail",
25
- "Please give all the clinical findings which were listed",
26
- "What treatment plan is recommended?"
27
  ]
28
 
29
  # List of form fields in the correct order
@@ -34,7 +34,7 @@ form_fields = [
34
  "Medical history",
35
  "Dental history",
36
  "Clinical Findings",
37
- "Treatment plan",
38
  "Referred to"
39
  ]
40
 
@@ -50,7 +50,9 @@ oral_health_assessment_form = [
50
  "Dental history",
51
  "Clinical Findings",
52
  "Treatment plan",
53
- "Referred to"
 
 
54
  ]
55
 
56
  # Function to generate answers for the questions
@@ -105,7 +107,6 @@ def fill_textboxes(context: str) -> dict:
105
  "Medical history": answers[3],
106
  "Dental history": answers[4],
107
  "Clinical Findings": answers[5],
108
- "Treatment plan": answers[6],
109
  "Referred to": ""
110
  }
111
 
@@ -117,15 +118,17 @@ def main(audio: str, doctor_name: str, location: str) -> list:
117
  context = transcribe_audio(audio)
118
 
119
  if "Error" in context:
120
- return [context] * (len(oral_health_assessment_form) - 2) # Adjust for the number of fields
121
 
122
  answers = fill_textboxes(context)
123
  answers_list = [doctor_name, location, ""] # Initial patient name field empty
124
  answers_list += [answers.get(field, "") for field in form_fields]
 
 
125
 
126
  return answers_list
127
 
128
- 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) -> str:
129
  current_datetime = datetime.now().isoformat()
130
  answers_dict = {
131
  "Doctor’s Name": doctor_name,
@@ -139,6 +142,8 @@ def save_answers(doctor_name: str, location: str, patient_name: str, age: str, g
139
  "Clinical Findings": clinical_findings,
140
  "Treatment plan": treatment_plan,
141
  "Referred to": referred_to,
 
 
142
  "Submission Date and Time": current_datetime
143
  }
144
  print("Saved answers:", answers_dict)
@@ -219,36 +224,46 @@ with gr.Blocks() as demo:
219
  patient_name_input = gr.Textbox(label="Patient’s Name", value="", interactive=True)
220
  textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(3, len(oral_health_assessment_form)//2)]
221
  with gr.Column():
222
- 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)]
223
  dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
 
 
 
224
 
225
  def enable_transcribe_button(audio_path: str):
226
  return gr.update(interactive=True)
227
 
228
  audio_input.change(fn=enable_transcribe_button, inputs=audio_input, outputs=transcribe_button)
229
 
 
230
  def update_textboxes(audio: str, doctor_name: str, location: str):
231
  context = transcribe_audio(audio)
232
 
233
  if "Error" in context:
234
- return [context] * (len(oral_health_assessment_form) - 3) # Adjust for the number of fields
235
 
236
  answers = fill_textboxes(context)
237
  answers_list = [doctor_name, location, ""] # Initial patient name field empty
238
  answers_list += [answers.get(field, "") for field in form_fields[:-1]] # Exclude "Referred to"
239
- answers_list.append(answers.get("Referred to", "")) # Ensure "Referred to" is included
240
-
241
  return answers_list
242
 
243
- transcribe_button.click(fn=update_textboxes, inputs=[audio_input, doctor_name_input, location_input], outputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right + [dropdown_referred])
 
 
 
 
244
 
245
  save_button = gr.Button("Save Form")
246
  save_output = gr.HTML(label="Save Output")
247
 
248
- def handle_submission(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):
249
- return save_answers(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to)
250
 
251
- save_button.click(fn=handle_submission, inputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right + [dropdown_referred], outputs=save_output)
 
 
 
 
252
 
253
  # Third tab for Save and Download
254
  with gr.Tab("Download Data"):
 
22
  "What is the chief complaint regarding the patient's oral health?",
23
  "List the Medical history mentioned",
24
  "Give the Dental history in detail",
25
+ "Please give all the clinical findings which were listed"
26
+ # "What treatment plan is recommended?" -- Removed as we are using a dropdown for this
27
  ]
28
 
29
  # List of form fields in the correct order
 
34
  "Medical history",
35
  "Dental history",
36
  "Clinical Findings",
37
+ # "Treatment plan", -- Removed
38
  "Referred to"
39
  ]
40
 
 
50
  "Dental history",
51
  "Clinical Findings",
52
  "Treatment plan",
53
+ "Referred to",
54
+ "Options",
55
+ "Stains"
56
  ]
57
 
58
  # Function to generate answers for the questions
 
107
  "Medical history": answers[3],
108
  "Dental history": answers[4],
109
  "Clinical Findings": answers[5],
 
110
  "Referred to": ""
111
  }
112
 
 
118
  context = transcribe_audio(audio)
119
 
120
  if "Error" in context:
121
+ return [context] * (len(oral_health_assessment_form) - 5) # Adjust for the number of fields
122
 
123
  answers = fill_textboxes(context)
124
  answers_list = [doctor_name, location, ""] # Initial patient name field empty
125
  answers_list += [answers.get(field, "") for field in form_fields]
126
+ answers_list.append("") # Default for "Options"
127
+ answers_list.append("") # Default for "Stains"
128
 
129
  return answers_list
130
 
131
+ 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, options: str, stains: str) -> str:
132
  current_datetime = datetime.now().isoformat()
133
  answers_dict = {
134
  "Doctor’s Name": doctor_name,
 
142
  "Clinical Findings": clinical_findings,
143
  "Treatment plan": treatment_plan,
144
  "Referred to": referred_to,
145
+ "Options": options,
146
+ "Stains": stains,
147
  "Submission Date and Time": current_datetime
148
  }
149
  print("Saved answers:", answers_dict)
 
224
  patient_name_input = gr.Textbox(label="Patient’s Name", value="", interactive=True)
225
  textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(3, len(oral_health_assessment_form)//2)]
226
  with gr.Column():
227
+ 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)-5)]
228
  dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
229
+ dropdown_options = gr.Dropdown(choices=["+", "++", "+++"], label="Options", interactive=True)
230
+ dropdown_stains = gr.Dropdown(choices=["+", "++", "+++"], label="Stains", interactive=True)
231
+ dropdown_treatment_plan = gr.Dropdown(choices=["Scaling", "Filling", "Pulp therapy/RCT", "Extraction", "Medication", "Referral"], label="Treatment plan", interactive=True)
232
 
233
  def enable_transcribe_button(audio_path: str):
234
  return gr.update(interactive=True)
235
 
236
  audio_input.change(fn=enable_transcribe_button, inputs=audio_input, outputs=transcribe_button)
237
 
238
+
239
  def update_textboxes(audio: str, doctor_name: str, location: str):
240
  context = transcribe_audio(audio)
241
 
242
  if "Error" in context:
243
+ return [context] * (len(oral_health_assessment_form) - 5) # Adjust for the number of fields
244
 
245
  answers = fill_textboxes(context)
246
  answers_list = [doctor_name, location, ""] # Initial patient name field empty
247
  answers_list += [answers.get(field, "") for field in form_fields[:-1]] # Exclude "Referred to"
 
 
248
  return answers_list
249
 
250
+ transcribe_button.click(
251
+ fn=update_textboxes,
252
+ inputs=[audio_input, doctor_name_input, location_input],
253
+ outputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right + [dropdown_referred, dropdown_treatment_plan, dropdown_options, dropdown_stains]
254
+ )
255
 
256
  save_button = gr.Button("Save Form")
257
  save_output = gr.HTML(label="Save Output")
258
 
259
+ def handle_submission(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, options: str, stains: str):
260
+ return save_answers(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to, options, stains)
261
 
262
+ save_button.click(
263
+ fn=handle_submission,
264
+ inputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right + [dropdown_referred, dropdown_treatment_plan, dropdown_options, dropdown_stains],
265
+ outputs=save_output
266
+ )
267
 
268
  # Third tab for Save and Download
269
  with gr.Tab("Download Data"):