Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
8 |
+
Prescription:
|
9 |
+
- Amoxicillin 500 mg, twice daily for 7 days
|
10 |
+
- Paracetamol 500 mg, every 6 hours for fever
|
11 |
+
- Rest and hydration
|
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 |
+
st.success(f"Prescription saved as '{pdf_output_path}'")
|
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(): # Check if there's any content
|
37 |
+
save_pdf(edited_text)
|
38 |
+
else:
|
39 |
+
st.error("Prescription content is empty. Please add details.")
|
40 |
+
|
41 |
+
if __name__ == "__main__":
|
42 |
+
main()
|