improve one click discharge paper
Browse files
app.py
CHANGED
@@ -12,13 +12,14 @@ from utils.callbackmanager import CallbackManager
|
|
12 |
from utils.meldrx import MeldRxAPI
|
13 |
from utils.prompts import system_instructions
|
14 |
from old.extractcode import extract_code_from_url
|
|
|
15 |
# Set up logging
|
16 |
logging.basicConfig(level=logging.INFO)
|
17 |
logger = logging.getLogger(__name__)
|
18 |
|
19 |
# Import PDF utilities
|
20 |
from utils.pdfutils import PDFGenerator, generate_discharge_summary
|
21 |
-
from utils.oneclick import generate_discharge_paper_one_click
|
22 |
# Import necessary libraries for new file types and AI analysis functions
|
23 |
import pydicom # For DICOM
|
24 |
import hl7 # For HL7
|
@@ -395,16 +396,19 @@ with gr.Blocks(theme=cyberpunk_theme) as demo: # Apply the theme here
|
|
395 |
)
|
396 |
|
397 |
with gr.Tab("One-Click Discharge Paper (AI)", elem_classes="cyberpunk-tab"):
|
398 |
-
gr.Markdown("<h2 style='color:#00FFFF; text-shadow: 0 0 3px #00FFFF;'>One-Click Medical Discharge
|
399 |
with gr.Row():
|
400 |
patient_id_input = gr.Textbox(label="Patient ID (Optional)", placeholder="Enter Patient ID")
|
401 |
first_name_input = gr.Textbox(label="First Name (Optional)", placeholder="Enter First Name")
|
402 |
last_name_input = gr.Textbox(label="Last Name (Optional)", placeholder="Enter Last Name")
|
403 |
-
|
404 |
-
"Generate Discharge
|
|
|
|
|
|
|
|
|
|
|
405 |
)
|
406 |
-
one_click_ai_pdf_status = gr.Textbox(label="Discharge Paper Generation Status (AI)")
|
407 |
-
one_click_ai_pdf_download = gr.File(label="Download Discharge Paper (AI)")
|
408 |
|
409 |
# Initialize MeldRxAPI (ensure client_id, client_secret, workspace_id are set in environment variables)
|
410 |
client_id = os.getenv("APPID")
|
@@ -413,10 +417,10 @@ with gr.Tab("One-Click Discharge Paper (AI)", elem_classes="cyberpunk-tab"):
|
|
413 |
redirect_uri = "https://multitransformer-discharge-guard.hf.space/callback"
|
414 |
meldrx_api = MeldRxAPI(client_id, client_secret, workspace_id, redirect_uri)
|
415 |
|
416 |
-
|
417 |
-
fn=lambda pid, fname, lname:
|
418 |
inputs=[patient_id_input, first_name_input, last_name_input],
|
419 |
-
outputs=
|
420 |
)
|
421 |
|
422 |
# Connect the patient data buttons
|
|
|
12 |
from utils.meldrx import MeldRxAPI
|
13 |
from utils.prompts import system_instructions
|
14 |
from old.extractcode import extract_code_from_url
|
15 |
+
from utils.generators import generate_pdf_from_meldrx, generate_ai_discharge_content, generate_pdf_from_meldrx_with_ai_content, extract_section, generate_pdf_from_form, generate_discharge_summary, generate_ai_discharge_content, analyze_dicom_file_with_ai, analyze_hl7_file_with_ai, analyze_cda_xml_file_with_ai, analyze_pdf_file_with_ai, analyze_csv_file_with_ai
|
16 |
# Set up logging
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
logger = logging.getLogger(__name__)
|
19 |
|
20 |
# Import PDF utilities
|
21 |
from utils.pdfutils import PDFGenerator, generate_discharge_summary
|
22 |
+
from utils.oneclick import generate_discharge_paper_one_click, generate_ai_discharge_summary_one_click
|
23 |
# Import necessary libraries for new file types and AI analysis functions
|
24 |
import pydicom # For DICOM
|
25 |
import hl7 # For HL7
|
|
|
396 |
)
|
397 |
|
398 |
with gr.Tab("One-Click Discharge Paper (AI)", elem_classes="cyberpunk-tab"):
|
399 |
+
gr.Markdown("<h2 style='color:#00FFFF; text-shadow: 0 0 3px #00FFFF;'>One-Click Medical Discharge Summary with AI Content</h2>")
|
400 |
with gr.Row():
|
401 |
patient_id_input = gr.Textbox(label="Patient ID (Optional)", placeholder="Enter Patient ID")
|
402 |
first_name_input = gr.Textbox(label="First Name (Optional)", placeholder="Enter First Name")
|
403 |
last_name_input = gr.Textbox(label="Last Name (Optional)", placeholder="Enter Last Name")
|
404 |
+
one_click_ai_button = gr.Button(
|
405 |
+
"Generate Discharge Summary with AI (One-Click)", elem_classes="cyberpunk-button"
|
406 |
+
)
|
407 |
+
one_click_ai_output = gr.Textbox(
|
408 |
+
label="AI-Generated Discharge Summary",
|
409 |
+
lines=20,
|
410 |
+
placeholder="Discharge summary will appear here..."
|
411 |
)
|
|
|
|
|
412 |
|
413 |
# Initialize MeldRxAPI (ensure client_id, client_secret, workspace_id are set in environment variables)
|
414 |
client_id = os.getenv("APPID")
|
|
|
417 |
redirect_uri = "https://multitransformer-discharge-guard.hf.space/callback"
|
418 |
meldrx_api = MeldRxAPI(client_id, client_secret, workspace_id, redirect_uri)
|
419 |
|
420 |
+
one_click_ai_button.click(
|
421 |
+
fn=lambda pid, fname, lname: generate_discharge_summary_one_click(meldrx_api, pid, fname, lname),
|
422 |
inputs=[patient_id_input, first_name_input, last_name_input],
|
423 |
+
outputs=one_click_ai_output,
|
424 |
)
|
425 |
|
426 |
# Connect the patient data buttons
|