Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from fpdf import FPDF
|
|
|
3 |
|
4 |
-
# Initial LLM-generated result (this would be dynamically generated in a real scenario)
|
5 |
llm_result = """
|
6 |
Diagnosis: Pneumonia
|
7 |
|
@@ -12,31 +12,38 @@ Prescription:
|
|
12 |
- Follow-up in 7 days if symptoms persist
|
13 |
"""
|
14 |
|
15 |
-
# Function to generate a PDF
|
16 |
def save_pdf(content):
|
17 |
pdf = FPDF()
|
18 |
pdf.add_page()
|
19 |
pdf.set_font("Arial", size=12)
|
20 |
pdf.multi_cell(0, 10, txt=content)
|
|
|
21 |
pdf_output_path = "prescription.pdf"
|
22 |
pdf.output(pdf_output_path)
|
23 |
-
|
|
|
|
|
24 |
|
25 |
# Streamlit app
|
26 |
def main():
|
27 |
st.title("Doctor's Assistance: Review and Edit Prescription")
|
28 |
|
29 |
st.write("## Review the LLM-generated prescription and make edits if necessary.")
|
30 |
-
|
31 |
-
# Display the LLM-generated result in a text area for editing
|
32 |
edited_text = st.text_area("Edit Prescription", value=llm_result, height=300)
|
33 |
|
34 |
-
# Button to save the prescription as PDF
|
35 |
if st.button("Save Prescription"):
|
36 |
-
if edited_text.strip():
|
37 |
-
save_pdf(edited_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
else:
|
39 |
st.error("Prescription content is empty. Please add details.")
|
40 |
|
41 |
if __name__ == "__main__":
|
42 |
-
main()
|
|
|
1 |
import streamlit as st
|
2 |
from fpdf import FPDF
|
3 |
+
import os
|
4 |
|
|
|
5 |
llm_result = """
|
6 |
Diagnosis: Pneumonia
|
7 |
|
|
|
12 |
- Follow-up in 7 days if symptoms persist
|
13 |
"""
|
14 |
|
|
|
15 |
def save_pdf(content):
|
16 |
pdf = FPDF()
|
17 |
pdf.add_page()
|
18 |
pdf.set_font("Arial", size=12)
|
19 |
pdf.multi_cell(0, 10, txt=content)
|
20 |
+
|
21 |
pdf_output_path = "prescription.pdf"
|
22 |
pdf.output(pdf_output_path)
|
23 |
+
|
24 |
+
# Return the path to download
|
25 |
+
return pdf_output_path
|
26 |
|
27 |
# Streamlit app
|
28 |
def main():
|
29 |
st.title("Doctor's Assistance: Review and Edit Prescription")
|
30 |
|
31 |
st.write("## Review the LLM-generated prescription and make edits if necessary.")
|
|
|
|
|
32 |
edited_text = st.text_area("Edit Prescription", value=llm_result, height=300)
|
33 |
|
|
|
34 |
if st.button("Save Prescription"):
|
35 |
+
if edited_text.strip():
|
36 |
+
pdf_file_path = save_pdf(edited_text)
|
37 |
+
st.success("Prescription saved!")
|
38 |
+
with open(pdf_file_path, "rb") as file:
|
39 |
+
st.download_button(
|
40 |
+
label="Download Prescription as PDF",
|
41 |
+
data=file,
|
42 |
+
file_name="prescription.pdf",
|
43 |
+
mime="application/pdf"
|
44 |
+
)
|
45 |
else:
|
46 |
st.error("Prescription content is empty. Please add details.")
|
47 |
|
48 |
if __name__ == "__main__":
|
49 |
+
main()
|