File size: 1,442 Bytes
5520e13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gradio as gr
import os
import plotly.graph_objects as go

patient_info = {"id": "", "description": ""}
qa_count = 0
patient_number = 0

def normalize_path(path):
    return os.path.normpath(path).replace('\\', '/')
    
def reset_patient():
    global patient_info, qa_count, patient_number
    patient_info = {"id": "", "description": ""}
    qa_count = 0
    patient_number += 1
    return (
        "",  # patient_desc
        gr.update(value=""),  # qa_desc
        gr.update(visible=True),  # patient_input
        gr.update(visible=False),  # qa_interface
        gr.update(visible=False),  # change_patient_btn
        "",  # question_input
        "",  # answer_output
        None,  # image_output
        go.Figure()  # graph_output (empty Plotly figure)
    )

def set_patient(patient_description):
    global patient_info, qa_count
    patient_info["description"] = patient_description
    qa_count = 0
    return (
        f"Patient Description: {patient_description}",
        gr.update(visible=True),
        gr.update(visible=False),
        "",  # question_input
        "",  # answer_output
        None,  # image_output
        go.Figure(),  # graph_output (empty Plotly figure)
        gr.update(visible=True),  # ask_another_question_btn
        gr.update(visible=True)  # change_patient_btn
    )

def ask_another_question():
    return "", "", None, go.Figure(), gr.update(visible=True), gr.update(visible=False)