Tonic commited on
revert function
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ 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
|
| 23 |
# Import necessary libraries for new file types and AI analysis functions
|
| 24 |
import pydicom # For DICOM
|
| 25 |
import hl7 # For HL7
|
|
@@ -94,42 +94,42 @@ CALLBACK_MANAGER = CallbackManager(
|
|
| 94 |
# return f"Authentication successful! Access Token: {self.access_token[:10]}... (truncated)"
|
| 95 |
# return "Authentication failed. Please check the authorization code."
|
| 96 |
|
| 97 |
-
def generate_discharge_paper_one_click():
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
|
| 135 |
|
|
@@ -418,7 +418,7 @@ with gr.Tab("One-Click Discharge Paper (AI)", elem_classes="cyberpunk-tab"):
|
|
| 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:
|
| 422 |
inputs=[patient_id_input, first_name_input, last_name_input],
|
| 423 |
outputs=one_click_ai_output,
|
| 424 |
)
|
|
|
|
| 19 |
|
| 20 |
# Import PDF utilities
|
| 21 |
from utils.pdfutils import PDFGenerator, generate_discharge_summary
|
| 22 |
+
from utils.oneclick import generate_discharge_paper_one_click
|
| 23 |
# Import necessary libraries for new file types and AI analysis functions
|
| 24 |
import pydicom # For DICOM
|
| 25 |
import hl7 # For HL7
|
|
|
|
| 94 |
# return f"Authentication successful! Access Token: {self.access_token[:10]}... (truncated)"
|
| 95 |
# return "Authentication failed. Please check the authorization code."
|
| 96 |
|
| 97 |
+
# def generate_discharge_paper_one_click():
|
| 98 |
+
# """One-click function to fetch patient data and generate discharge paper with AI Content."""
|
| 99 |
+
# patient_data_str = CALLBACK_MANAGER.get_patient_data()
|
| 100 |
+
# if (
|
| 101 |
+
# patient_data_str.startswith("Not authenticated")
|
| 102 |
+
# or patient_data_str.startswith("Failed")
|
| 103 |
+
# or patient_data_str.startswith("Error")
|
| 104 |
+
# ):
|
| 105 |
+
# return None, patient_data_str # Return error message if authentication or data fetch fails
|
| 106 |
|
| 107 |
+
# try:
|
| 108 |
+
# patient_data = json.loads(patient_data_str)
|
| 109 |
|
| 110 |
+
# # --- AI Content Generation for Discharge Summary ---
|
| 111 |
+
# # This is a placeholder - Replace with actual AI call using InferenceClient and patient_data to generate content
|
| 112 |
+
# ai_generated_content = generate_ai_discharge_content(
|
| 113 |
+
# patient_data
|
| 114 |
+
# ) # Placeholder AI function
|
| 115 |
|
| 116 |
+
# if not ai_generated_content:
|
| 117 |
+
# return None, "Error: AI content generation failed."
|
| 118 |
|
| 119 |
+
# # --- PDF Generation with AI Content ---
|
| 120 |
+
# pdf_path, status_message = generate_pdf_from_meldrx_with_ai_content(
|
| 121 |
+
# patient_data, ai_generated_content
|
| 122 |
+
# ) # Function to generate PDF with AI content
|
| 123 |
|
| 124 |
+
# if pdf_path:
|
| 125 |
+
# return pdf_path, status_message
|
| 126 |
+
# else:
|
| 127 |
+
# return None, status_message # Return status message if PDF generation fails
|
| 128 |
|
| 129 |
+
# except json.JSONDecodeError:
|
| 130 |
+
# return None, "Error: Patient data is not in valid JSON format."
|
| 131 |
+
# except Exception as e:
|
| 132 |
+
# return None, f"Error during discharge paper generation: {str(e)}"
|
| 133 |
|
| 134 |
|
| 135 |
|
|
|
|
| 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_paper_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 |
)
|