Spaces:
Sleeping
Sleeping
File size: 4,595 Bytes
d49b521 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 136 137 138 |
import streamlit as st
from fpdf import FPDF
import datetime
import os
st.set_page_config(page_title="HouseMD - Clinical App", layout="wide")
# ------------------ USER ROLE HANDLING ------------------
roles = {
"doctor": "doctor123",
"reception": "reception123",
"pharmacy": "pharmacy123",
"lab": "lab123",
"radiology": "radiology123",
"biochem": "biochem123",
"pathology": "pathology123"
}
st.sidebar.title("HouseMD Login")
username = st.sidebar.selectbox("Select Role", list(roles.keys()))
password = st.sidebar.text_input("Enter Password", type="password")
if password != roles.get(username):
st.sidebar.warning("Enter correct password to continue.")
st.stop()
st.sidebar.success(f"Logged in as: {username.upper()}")
# ------------------ FUNCTIONS ------------------
def symptom_picker():
st.header("π©Ί Symptom-Based Trigger")
symptoms = ["Fever", "Burning urination", "Abdominal pain", "Cough", "Chest pain"]
selected = st.multiselect("Select presenting symptoms:", symptoms)
if selected:
st.info(f"Selected: {', '.join(selected)}")
st.success("Might be: UTI, Pneumonia, Gastroenteritis (Mock output)")
def history_taking():
st.header("π History Taking")
systems = {
"General": ["Fever", "Weight loss", "Fatigue"],
"GI": ["Abdominal pain", "Nausea", "Vomiting"],
"GU": ["Burning urination", "Frequency", "Flank pain"]
}
for system, questions in systems.items():
with st.expander(f"{system} History"):
for q in questions:
st.checkbox(q)
def test_suggestions():
st.header("π§ͺ Suggested Tests")
if st.button("Show Suggested Tests"):
tests = ["CBC", "Urine Routine", "RBS", "LFT"]
for t in tests:
st.checkbox(t)
def triage_tests():
st.header("π¨ Triage Diagnostic Workflow")
test = st.selectbox("Select Test", ["X-ray Chest", "CBC", "USG Abdomen"])
triage = st.radio("Triage Level", ["π’ Green", "π‘ Yellow", "π΄ Red"])
st.success(f"Test ordered: {test} with {triage} priority")
def prescription_builder():
st.header("π Prescription Generator")
name = st.text_input("Patient Name")
meds = st.text_area("Enter medicines and instructions")
if st.button("Generate PDF Rx"):
filename = f"{name}_rx.pdf"
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, f"Prescription for {name}", ln=True)
pdf.multi_cell(0, 10, meds)
pdf.output(filename)
with open(filename, "rb") as f:
st.download_button("Download Prescription PDF", f, file_name=filename)
os.remove(filename)
def reception_panel():
st.header("π§Ύ Reception - Patient Entry")
name = st.text_input("Patient Name")
age = st.number_input("Age", min_value=0, max_value=120)
complaint = st.text_input("Chief Complaint")
if st.button("Add to Queue"):
st.success(f"Added {name} to queue")
def pharmacy_panel():
st.header("π Pharmacy Panel")
st.table({"Patient": ["Aman"], "Medicines": ["Amoxicillin x5"], "Dispensed": ["β"]})
st.button("Mark as Dispensed")
def lab_panel():
st.header("π¬ Lab Dashboard")
st.table({"Patient": ["Ravi", "Neha"], "Test": ["CBC", "Urine"], "Status": ["Pending", "Pending"]})
st.button("Mark Sample Collected")
def radiology_panel():
st.header("π©» Radiology Panel")
file = st.file_uploader("Upload Radiology Report")
if file:
st.success("File uploaded.")
def admin_dashboard():
st.header("π Admin Dashboard")
st.metric("Todayβs OPD Revenue", "βΉ6,000")
st.metric("Pharmacy Income", "βΉ3,200")
st.metric("Lab Collections", "βΉ2,500")
# ------------------ UI ROUTING ------------------
if username == "doctor":
st.title("π₯ Doctor's Panel")
tabs = st.tabs(["Symptom Trigger", "History", "Tests", "Triage", "Prescription", "Admin"])
with tabs[0]: symptom_picker()
with tabs[1]: history_taking()
with tabs[2]: test_suggestions()
with tabs[3]: triage_tests()
with tabs[4]: prescription_builder()
with tabs[5]: admin_dashboard()
elif username == "reception":
st.title("π§Ύ Reception Desk")
reception_panel()
elif username == "pharmacy":
st.title("π Pharmacy Desk")
pharmacy_panel()
elif username == "lab":
st.title("π¬ Lab Technician Panel")
lab_panel()
elif username == "radiology":
st.title("π©» Radiology Panel")
radiology_panel()
else:
st.info("Panel for this role is coming soon.") |