|
|
import gradio as gr |
|
|
|
|
|
from utility import * |
|
|
from application import * |
|
|
from features import init_app_data, add_device, remove_device, get_device |
|
|
|
|
|
def reset(): |
|
|
return ( |
|
|
gr.Textbox.update(value=""), |
|
|
gr.Textbox.update(value=""), |
|
|
gr.File.update(value=None), |
|
|
gr.TextArea.update(value=""), |
|
|
gr.TextArea.update(value=""), |
|
|
gr.TextArea.update(value=""), |
|
|
gr.Markdown.update(value="") |
|
|
) |
|
|
|
|
|
def refresh(): |
|
|
init_app_data() |
|
|
''' |
|
|
refresh the literature report. |
|
|
''' |
|
|
print([d["device_name"] for d in app_data["devices"]]) |
|
|
return create_md_tables(app_data["devices"]), gr.Dropdown.update(choices=[d["device_name"] for d in app_data["devices"]]) |
|
|
|
|
|
with gr.Blocks() as device_page: |
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
gr.Markdown("## Devices") |
|
|
gr.HTML("<hr>") |
|
|
select_device = gr.Dropdown( |
|
|
choices=[d["device_name"] for d in app_data["devices"]], |
|
|
|
|
|
value=None, |
|
|
label="Select Device", |
|
|
interactive=True |
|
|
) |
|
|
gr.HTML("<hr>") |
|
|
device_name = gr.Textbox(lines=1, label="Subject Device Name") |
|
|
device_type = gr.Textbox(lines=1, label="Subject Device Type") |
|
|
|
|
|
upload_instruction = gr.File(label="Upload IFU(Instruction For Use)") |
|
|
|
|
|
intended_use = gr.TextArea(lines=5, label="Intended Use") |
|
|
indications = gr.TextArea(lines=5, label="Indication") |
|
|
contraindications = gr.TextArea(lines=5, label="Contraindication") |
|
|
|
|
|
with gr.Row(): |
|
|
btn_get = gr.Button("Get",variant="primary") |
|
|
btn_add = gr.Button("Add",variant="primary") |
|
|
btn_reset = gr.Button("Reset",variant="stop") |
|
|
|
|
|
gr.Markdown("## Device Details") |
|
|
details = gr.Markdown("") |
|
|
|
|
|
btn_reset.click( |
|
|
fn=reset, |
|
|
outputs=[ |
|
|
device_name, |
|
|
device_type, |
|
|
upload_instruction, |
|
|
intended_use, |
|
|
indications, |
|
|
contraindications, |
|
|
details |
|
|
]) |
|
|
|
|
|
btn_add.click( |
|
|
fn=add_device, |
|
|
inputs=[ |
|
|
device_name, |
|
|
device_type, |
|
|
upload_instruction, |
|
|
intended_use, |
|
|
indications, |
|
|
contraindications |
|
|
], |
|
|
outputs=[ |
|
|
details |
|
|
] |
|
|
) |
|
|
|
|
|
btn_get.click( |
|
|
fn=get_device, |
|
|
inputs=[select_device], |
|
|
outputs=[ |
|
|
device_name, |
|
|
device_type, |
|
|
intended_use, |
|
|
indications, |
|
|
contraindications, |
|
|
details |
|
|
] |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Column(scale=2): |
|
|
gr.Markdown("## Devices List") |
|
|
btn_refresh = gr.Button(value="Refresh",variant="primary") |
|
|
gr.HTML("<hr>") |
|
|
|
|
|
device_list = gr.Markdown("") |
|
|
|
|
|
btn_refresh.click( |
|
|
fn=refresh, |
|
|
outputs=[ |
|
|
device_list, |
|
|
select_device |
|
|
] |
|
|
) |