Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -120,16 +120,19 @@ def fill_textboxes(context: str) -> dict:
|
|
120 |
supabase: Client = create_client(url, key)
|
121 |
|
122 |
# Main Gradio app function
|
123 |
-
def main(audio: str, doctor_name: str, location: str) ->
|
124 |
context = transcribe_audio(audio)
|
125 |
|
126 |
if "Error" in context:
|
127 |
-
return
|
128 |
|
129 |
answers = fill_textboxes(context)
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
133 |
|
134 |
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:
|
135 |
current_datetime = datetime.now().isoformat()
|
@@ -239,11 +242,27 @@ with gr.Blocks() as demo:
|
|
239 |
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))
|
240 |
textboxes_right.append(gr.Dropdown(choices=["+", "++", "+++"], label="Calculus", interactive=True))
|
241 |
textboxes_right.append(gr.Dropdown(choices=["-", "+", "++", "+++"], label="Stains", interactive=True))
|
242 |
-
textboxes_right.append(gr.Dropdown(choices=["Scaling", "Filling", "Pulp therapy/RCT", "Extraction", "Medication"], label="Treatment plan", interactive=True))
|
|
|
243 |
oha_output = gr.Textbox(label="OHA Output", value="", interactive=False)
|
244 |
save_button = gr.Button("Save to Supabase", elem_id="save_button", interactive=True)
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
with gr.Tab("Download Data"):
|
249 |
download_button = gr.Button("Download CSV")
|
|
|
120 |
supabase: Client = create_client(url, key)
|
121 |
|
122 |
# Main Gradio app function
|
123 |
+
def main(audio: str, doctor_name: str, location: str) -> dict:
|
124 |
context = transcribe_audio(audio)
|
125 |
|
126 |
if "Error" in context:
|
127 |
+
return {field: context for field in form_fields} # Adjust for the number of fields
|
128 |
|
129 |
answers = fill_textboxes(context)
|
130 |
+
# Fill in the textboxes with the generated answers
|
131 |
+
answers.update({
|
132 |
+
"Doctor’s Name": doctor_name,
|
133 |
+
"Location": location
|
134 |
+
})
|
135 |
+
return answers
|
136 |
|
137 |
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:
|
138 |
current_datetime = datetime.now().isoformat()
|
|
|
242 |
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))
|
243 |
textboxes_right.append(gr.Dropdown(choices=["+", "++", "+++"], label="Calculus", interactive=True))
|
244 |
textboxes_right.append(gr.Dropdown(choices=["-", "+", "++", "+++"], label="Stains", interactive=True))
|
245 |
+
textboxes_right.append(gr.Dropdown(choices=["Scaling", "Filling", "Pulp therapy/RCT", "Extraction", "Medication", "Referral"], label="Treatment plan", interactive=True))
|
246 |
+
|
247 |
oha_output = gr.Textbox(label="OHA Output", value="", interactive=False)
|
248 |
save_button = gr.Button("Save to Supabase", elem_id="save_button", interactive=True)
|
249 |
+
|
250 |
+
def handle_transcription(audio, doctor_name, location):
|
251 |
+
context = transcribe_audio(audio)
|
252 |
+
if "Error" in context:
|
253 |
+
return {field: context for field in form_fields} # Return error message for all fields
|
254 |
+
answers = fill_textboxes(context)
|
255 |
+
answers.update({
|
256 |
+
"Doctor’s Name": doctor_name,
|
257 |
+
"Location": location
|
258 |
+
})
|
259 |
+
return answers
|
260 |
+
|
261 |
+
def save_to_supabase(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to, calculus, stains):
|
262 |
+
return save_answers(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to, calculus, stains)
|
263 |
+
|
264 |
+
transcribe_button.click(fn=handle_transcription, inputs=[audio_input, doctor_name_display, location_display], outputs=textboxes_left + textboxes_right + [oha_output])
|
265 |
+
save_button.click(fn=save_to_supabase, inputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right, outputs=oha_output)
|
266 |
|
267 |
with gr.Tab("Download Data"):
|
268 |
download_button = gr.Button("Download CSV")
|