|
import streamlit as st |
|
from interm import generate_clinical_content, generate_summary, generate_soap_note, fetch_pubmed_articles, save_as_text, save_as_pdf |
|
|
|
|
|
st.set_page_config(page_title="Clinical AI Assistant", page_icon="π©Ί", layout="wide") |
|
|
|
st.title("π©Ί AI-Powered Clinical Intelligence Assistant") |
|
st.write("AI-driven **clinical research, medical documentation, and PubMed insights**.") |
|
|
|
|
|
tabs = st.tabs(["π Clinical Content", "π Research Summaries", "π©Ί SOAP Notes", "π PubMed Research", "π Medical Reports"]) |
|
|
|
|
|
with tabs[0]: |
|
st.header("Generate Medical Articles & Patient Education") |
|
|
|
prompt = st.text_area("Enter a Medical Topic (e.g., AI in Radiology, Hypertension Management):") |
|
target_audience = st.selectbox("Select Audience:", ["Clinicians", "Patients", "Researchers"]) |
|
|
|
if st.button("Generate Content"): |
|
if prompt: |
|
with st.spinner("Generating medical content..."): |
|
result = generate_clinical_content(prompt, target_audience) |
|
st.session_state["medical_content"] = result |
|
st.subheader("Generated Medical Content") |
|
st.write(result) |
|
else: |
|
st.warning("Please enter a medical topic.") |
|
|
|
|
|
with tabs[1]: |
|
st.header("Summarize Clinical Trials & Medical Research") |
|
|
|
if "medical_content" in st.session_state: |
|
if st.button("Generate Summary"): |
|
with st.spinner("Summarizing medical research..."): |
|
summary = generate_summary(st.session_state["medical_content"]) |
|
st.session_state["research_summary"] = summary |
|
st.subheader("Clinical Summary") |
|
st.markdown(summary) |
|
else: |
|
st.warning("Generate content in Tab 1 first.") |
|
|
|
|
|
with tabs[2]: |
|
st.header("Generate SOAP Notes for Patient Consultations") |
|
|
|
symptoms = st.text_area("Enter Symptoms (e.g., fever, cough, chest pain):") |
|
patient_history = st.text_area("Brief Patient History:") |
|
|
|
if st.button("Generate SOAP Note"): |
|
if symptoms: |
|
with st.spinner("Generating SOAP Note..."): |
|
soap_note = generate_soap_note(symptoms, patient_history) |
|
st.session_state["soap_note"] = soap_note |
|
st.subheader("Generated SOAP Note") |
|
st.code(soap_note, language="text") |
|
else: |
|
st.warning("Please enter patient symptoms.") |
|
|
|
|
|
with tabs[3]: |
|
st.header("Fetch Latest Research from PubMed") |
|
|
|
query = st.text_input("Enter a medical keyword (e.g., COVID-19, AI in Oncology, Diabetes):") |
|
|
|
if st.button("Fetch PubMed Articles"): |
|
if query: |
|
with st.spinner("Retrieving PubMed articles..."): |
|
articles = fetch_pubmed_articles(query) |
|
st.session_state["pubmed_results"] = articles |
|
for article in articles: |
|
st.subheader(article["title"]) |
|
st.write(f"**Authors:** {article['authors']}") |
|
st.write(f"**Abstract:** {article['abstract']}") |
|
st.write(f"[Read More]({article['url']})") |
|
else: |
|
st.warning("Please enter a medical topic.") |
|
|
|
|
|
with tabs[4]: |
|
st.header("Download Clinical Reports") |
|
|
|
if "soap_note" in st.session_state: |
|
report_content = st.session_state["soap_note"] |
|
text_file_path, text_filename = save_as_text(report_content, "Medical_Report.txt") |
|
pdf_file_path, pdf_filename = save_as_pdf(report_content, "Medical_Report.pdf") |
|
|
|
with open(text_file_path, "rb") as file: |
|
st.download_button("Download Report as TXT", data=file, file_name=text_filename, mime="text/plain") |
|
|
|
with open(pdf_file_path, "rb") as file: |
|
st.download_button("Download Report as PDF", data=file, file_name=pdf_filename, mime="application/pdf") |
|
|