File size: 3,368 Bytes
476d5b6
 
 
 
d903482
 
 
ef80389
 
 
d903482
f7804d0
d903482
d31afa8
f7804d0
d903482
 
476d5b6
f7804d0
82b9d78
 
 
 
 
 
498a219
82b9d78
 
498a219
 
 
 
 
fdccd1a
498a219
 
82b9d78
 
 
fdccd1a
 
476d5b6
82b9d78
 
 
f7804d0
82b9d78
 
 
 
 
 
 
 
476d5b6
82b9d78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498a219
82b9d78
 
 
 
 
 
 
 
 
d903482
82b9d78
 
 
 
 
e61d4b7
82b9d78
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import gradio as gr

from utility import *
from application import *
from features import *

def reset():
    '''
    reset gradio input and output features in this page.
    '''
    return (
        gr.Radio.update(value=anatomic_domains[-1]),
        gr.Files.update(value=None),
        gr.TextArea.update(value=""),
        gr.Markdown.update(value=""),
        gr.Markdown.update(value="")
    )

# complete user interfaces
@terminal_print
def init_study_page():
    with gr.Blocks() as study_page:
        # user control panel
        with gr.Row(equal_height=False):
            with gr.Column():
                gr.Markdown("## Settings")
                gr.HTML("<hr>")
                domain = gr.Radio(label="Anatomical Region",choices=anatomic_domains,value=default_region)
                select_ifu = gr.Dropdown(label="Select an IFU",choices=app_data["devices"].keys(),value=list(app_data["devices"].keys())[0])
                
            with gr.Column():
                gr.Markdown("## Upload")
                gr.HTML("<hr>")
                upload_study = gr.File(label="Upload a clinical study report",type="file",file_count="single")
                input_study = gr.TextArea(label="Or paste a clinical study report content",placeholder="Paste content here...",lines=5)

                with gr.Row():
                    btn_reset = gr.Button(value="Reset",variant="stop")
                    btn_add_study = gr.Button(value="Add",variant="primary")
                
                

        gr.HTML("<hr>")
        with gr.Row():
            gr.Markdown("## Literature Report")

        gr.HTML("<hr>")
        with gr.Row(equal_height=False):
            with gr.Column():
                dropdown = gr.Dropdown(label="Select a literature report",choices=app_data["articles"].keys())
            with gr.Column():
                with gr.Row():
                    btn_get_article = gr.Button(value="Get",variant="primary")
                    btn_refresh = gr.Button(value="Refresh",variant="primary")

        gr.HTML("<hr>")
        # extraction outcome panel
        with gr.Row(equal_height=False):
            with gr.Column():
                overview = gr.Markdown("")
            with gr.Column():
                # tables = gr.Markdown("")
                detail_views = gr.Markdown("")
                
        # control element definition
        btn_get_article.click(
            get_existing_article,
            inputs=[
                dropdown,
            ],
            outputs=[
                overview,
                detail_views,
            ]
        )

        btn_reset.click(
            reset,
            outputs=[
                domain,
                upload_study,
                input_study,
                overview,
                detail_views,
            ]
        )

        btn_add_study.click(
            process_study,
            inputs=[
                domain,
                select_ifu,
                upload_study,
                input_study,
            ],
            outputs=[
                overview,
                detail_views,
                # tables
            ],
        )

        btn_refresh.click(
            refresh,
            outputs=[
                overview,
                detail_views,
                dropdown
            ],
        )
    return study_page