Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,21 +120,33 @@ def fill_textboxes(context: str) -> dict:
|
|
| 120 |
supabase: Client = create_client(url, key)
|
| 121 |
|
| 122 |
# Main Gradio app function
|
| 123 |
-
def
|
| 124 |
context = transcribe_audio(audio)
|
| 125 |
-
|
| 126 |
if "Error" in context:
|
| 127 |
-
return {field: context for field in form_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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,
|
| 138 |
current_datetime = datetime.now().isoformat()
|
| 139 |
answers_dict = {
|
| 140 |
"Doctor’s Name": doctor_name,
|
|
@@ -148,7 +160,7 @@ def save_answers(doctor_name: str, location: str, patient_name: str, age: str, g
|
|
| 148 |
"Clinical Findings": clinical_findings,
|
| 149 |
"Treatment plan": treatment_plan,
|
| 150 |
"Referred to": referred_to,
|
| 151 |
-
"Calculus":
|
| 152 |
"Stains": stains,
|
| 153 |
"Submission Date and Time": current_datetime
|
| 154 |
}
|
|
@@ -250,13 +262,30 @@ with gr.Blocks() as demo:
|
|
| 250 |
def handle_transcription(audio, doctor_name, location):
|
| 251 |
context = transcribe_audio(audio)
|
| 252 |
if "Error" in context:
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
| 255 |
answers.update({
|
| 256 |
"Doctor’s Name": doctor_name,
|
| 257 |
"Location": location
|
| 258 |
})
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
|
|
| 120 |
supabase: Client = create_client(url, key)
|
| 121 |
|
| 122 |
# Main Gradio app function
|
| 123 |
+
def handle_transcription(audio: str, doctor_name: str, location: str) -> dict:
|
| 124 |
context = transcribe_audio(audio)
|
|
|
|
| 125 |
if "Error" in context:
|
| 126 |
+
return {field: context for field in form_fields}
|
| 127 |
|
| 128 |
answers = fill_textboxes(context)
|
|
|
|
| 129 |
answers.update({
|
| 130 |
"Doctor’s Name": doctor_name,
|
| 131 |
"Location": location
|
| 132 |
})
|
| 133 |
+
|
| 134 |
+
return {
|
| 135 |
+
"Age": answers.get("Age", ""),
|
| 136 |
+
"Gender": answers.get("Gender", ""),
|
| 137 |
+
"Chief complaint": answers.get("Chief complaint", ""),
|
| 138 |
+
"Medical history": answers.get("Medical history", ""),
|
| 139 |
+
"Dental history": answers.get("Dental history", ""),
|
| 140 |
+
"Clinical Findings": answers.get("Clinical Findings", ""),
|
| 141 |
+
"Referred to": answers.get("Referred to", ""),
|
| 142 |
+
"Treatment plan": answers.get("Treatment plan", ""),
|
| 143 |
+
"Calculus": answers.get("Calculus", ""),
|
| 144 |
+
"Stains": answers.get("Stains", ""),
|
| 145 |
+
"Doctor’s Name": doctor_name,
|
| 146 |
+
"Location": location
|
| 147 |
+
}
|
| 148 |
|
| 149 |
+
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:
|
| 150 |
current_datetime = datetime.now().isoformat()
|
| 151 |
answers_dict = {
|
| 152 |
"Doctor’s Name": doctor_name,
|
|
|
|
| 160 |
"Clinical Findings": clinical_findings,
|
| 161 |
"Treatment plan": treatment_plan,
|
| 162 |
"Referred to": referred_to,
|
| 163 |
+
"Calculus": calculus,
|
| 164 |
"Stains": stains,
|
| 165 |
"Submission Date and Time": current_datetime
|
| 166 |
}
|
|
|
|
| 262 |
def handle_transcription(audio, doctor_name, location):
|
| 263 |
context = transcribe_audio(audio)
|
| 264 |
if "Error" in context:
|
| 265 |
+
# Return error message for all fields
|
| 266 |
+
return [context] * len(textboxes_left + textboxes_right) + [context]
|
| 267 |
+
|
| 268 |
+
answers = handle_transcription(audio, doctor_name, location)
|
| 269 |
answers.update({
|
| 270 |
"Doctor’s Name": doctor_name,
|
| 271 |
"Location": location
|
| 272 |
})
|
| 273 |
+
|
| 274 |
+
# Return the answers in the order of textboxes and dropdowns
|
| 275 |
+
return [
|
| 276 |
+
answers.get("Age", ""),
|
| 277 |
+
answers.get("Gender", ""),
|
| 278 |
+
answers.get("Chief complaint", ""),
|
| 279 |
+
answers.get("Medical history", ""),
|
| 280 |
+
answers.get("Dental history", ""),
|
| 281 |
+
answers.get("Clinical Findings", ""),
|
| 282 |
+
answers.get("Referred to", ""),
|
| 283 |
+
answers.get("Treatment plan", ""),
|
| 284 |
+
answers.get("Calculus", ""),
|
| 285 |
+
answers.get("Stains", ""),
|
| 286 |
+
doctor_name,
|
| 287 |
+
location
|
| 288 |
+
]
|
| 289 |
|
| 290 |
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):
|
| 291 |
return save_answers(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to, calculus, stains)
|