Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -99,10 +99,22 @@ def main(audio, doctor_name, location):
|
|
99 |
|
100 |
return answers
|
101 |
|
102 |
-
def save_answers(
|
103 |
current_datetime = datetime.now().isoformat()
|
104 |
-
answers_dict = {
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
print("Saved answers:", answers_dict)
|
107 |
|
108 |
# Insert data into Supabase
|
@@ -178,7 +190,8 @@ with gr.Blocks() as demo:
|
|
178 |
with gr.Column():
|
179 |
doctor_name_display = gr.Textbox(label="Doctor’s Name", value="", interactive=False)
|
180 |
location_display = gr.Textbox(label="Location", value="", interactive=False)
|
181 |
-
|
|
|
182 |
with gr.Column():
|
183 |
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)]
|
184 |
dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
|
@@ -187,18 +200,18 @@ with gr.Blocks() as demo:
|
|
187 |
context = transcribe_audio(audio)
|
188 |
|
189 |
if "Error" in context:
|
190 |
-
return [context] * (len(oral_health_assessment_form) -
|
191 |
|
192 |
answers = fill_textboxes(context)
|
193 |
answers.insert(0, location) # Add location
|
194 |
answers.insert(0, doctor_name) # Add doctor name
|
195 |
|
196 |
-
return [doctor_name, location] + answers
|
197 |
|
198 |
-
transcribe_button.click(fn=update_textboxes, inputs=[audio_input, doctor_name_input, location_input], outputs=[doctor_name_display, location_display] + textboxes_left + textboxes_right)
|
199 |
submit_button = gr.Button("Submit", elem_id="submit_button")
|
200 |
output_html = gr.HTML(label="Submitted Answers")
|
201 |
-
submit_button.click(fn=save_answers, inputs=[doctor_name_display, location_display] + textboxes_left + textboxes_right + [dropdown_referred], outputs=output_html)
|
202 |
|
203 |
# Third tab for CSV download
|
204 |
with gr.Tab("Download CSV"):
|
|
|
99 |
|
100 |
return answers
|
101 |
|
102 |
+
def save_answers(doctor_name, location, patient_name, age, gender, chief_complaint, medical_history, dental_history, clinical_findings, treatment_plan, referred_to):
|
103 |
current_datetime = datetime.now().isoformat()
|
104 |
+
answers_dict = {
|
105 |
+
"Doctor’s Name": doctor_name,
|
106 |
+
"Location": location,
|
107 |
+
"Patient’s Name": patient_name,
|
108 |
+
"Age": age,
|
109 |
+
"Gender": gender,
|
110 |
+
"Chief complaint": chief_complaint,
|
111 |
+
"Medical history": medical_history,
|
112 |
+
"Dental history": dental_history,
|
113 |
+
"Clinical Findings": clinical_findings,
|
114 |
+
"Treatment plan": treatment_plan,
|
115 |
+
"Referred to": referred_to,
|
116 |
+
"Submission Date and Time": current_datetime
|
117 |
+
}
|
118 |
print("Saved answers:", answers_dict)
|
119 |
|
120 |
# Insert data into Supabase
|
|
|
190 |
with gr.Column():
|
191 |
doctor_name_display = gr.Textbox(label="Doctor’s Name", value="", interactive=False)
|
192 |
location_display = gr.Textbox(label="Location", value="", interactive=False)
|
193 |
+
patient_name_input = gr.Textbox(label="Patient’s Name", value="", interactive=True)
|
194 |
+
textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(3, len(oral_health_assessment_form)//2)]
|
195 |
with gr.Column():
|
196 |
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)]
|
197 |
dropdown_referred = gr.Dropdown(choices=["NONE","ORAL MEDICINE & RADIOLOGY", "PERIODONTICS", "ORAL SURGERY", "CONSERVATIVE AND ENDODONTICS", "PROSTHODONTICS", "PEDODONTICS", "ORTHODONTICS"], label="Referred to", interactive=True)
|
|
|
200 |
context = transcribe_audio(audio)
|
201 |
|
202 |
if "Error" in context:
|
203 |
+
return [context] * (len(oral_health_assessment_form) - 3) # Adjust for the number of fields
|
204 |
|
205 |
answers = fill_textboxes(context)
|
206 |
answers.insert(0, location) # Add location
|
207 |
answers.insert(0, doctor_name) # Add doctor name
|
208 |
|
209 |
+
return [doctor_name, location] + [""] + answers # Patient name is left empty
|
210 |
|
211 |
+
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)
|
212 |
submit_button = gr.Button("Submit", elem_id="submit_button")
|
213 |
output_html = gr.HTML(label="Submitted Answers")
|
214 |
+
submit_button.click(fn=save_answers, inputs=[doctor_name_display, location_display, patient_name_input] + textboxes_left + textboxes_right + [dropdown_referred], outputs=output_html)
|
215 |
|
216 |
# Third tab for CSV download
|
217 |
with gr.Tab("Download CSV"):
|