Spaces:
Runtime error
Runtime error
Deploy full Medyx app from medyx-ddp branch (Docker Streamlit)
Browse files- .streamlit/config.toml +3 -3
- scripts/deploy_hf_space.py +1 -1
- ui/app.py +215 -120
.streamlit/config.toml
CHANGED
|
@@ -6,8 +6,8 @@ enableXsrfProtection = false
|
|
| 6 |
[browser]
|
| 7 |
gatherUsageStats = false
|
| 8 |
|
|
|
|
|
|
|
| 9 |
[theme]
|
| 10 |
-
primaryColor = "#
|
| 11 |
-
backgroundColor = "#FFFFFF"
|
| 12 |
-
secondaryBackgroundColor = "#F5F7FA"
|
| 13 |
font = "sans serif"
|
|
|
|
| 6 |
[browser]
|
| 7 |
gatherUsageStats = false
|
| 8 |
|
| 9 |
+
# No fixed background colours here so the app honours the user's
|
| 10 |
+
# Light / Dark / "Use system setting" choice (custom CSS adapts to both).
|
| 11 |
[theme]
|
| 12 |
+
primaryColor = "#0e7c86"
|
|
|
|
|
|
|
| 13 |
font = "sans serif"
|
scripts/deploy_hf_space.py
CHANGED
|
@@ -101,7 +101,7 @@ def main() -> str:
|
|
| 101 |
"requirements-hf.txt",
|
| 102 |
"requirements.txt", # always generated from requirements-hf.txt below
|
| 103 |
}
|
| 104 |
-
skip_suffixes = (".docx", ".tex")
|
| 105 |
|
| 106 |
for item in ROOT.iterdir():
|
| 107 |
if item.name in skip_dirs or item.name in skip_files:
|
|
|
|
| 101 |
"requirements-hf.txt",
|
| 102 |
"requirements.txt", # always generated from requirements-hf.txt below
|
| 103 |
}
|
| 104 |
+
skip_suffixes = (".docx", ".tex", ".pptx", ".ppt")
|
| 105 |
|
| 106 |
for item in ROOT.iterdir():
|
| 107 |
if item.name in skip_dirs or item.name in skip_files:
|
ui/app.py
CHANGED
|
@@ -89,30 +89,57 @@ st.set_page_config(
|
|
| 89 |
initial_sidebar_state="auto", # collapsed on mobile, expanded on desktop
|
| 90 |
)
|
| 91 |
|
| 92 |
-
# Custom CSS β modern healthcare interface,
|
| 93 |
st.markdown("""
|
| 94 |
<style>
|
| 95 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
|
| 96 |
|
|
|
|
| 97 |
:root {
|
| 98 |
-
--
|
| 99 |
-
--
|
| 100 |
-
--
|
| 101 |
-
--
|
| 102 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
html, body, [class*="css"], .stMarkdown, .stTextInput, .stTextArea, button {
|
| 106 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 107 |
}
|
| 108 |
|
|
|
|
| 109 |
.stApp {
|
| 110 |
-
background:
|
| 111 |
-
radial-gradient(
|
| 112 |
-
radial-gradient(
|
| 113 |
-
|
| 114 |
}
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
/* ββ Hero header βββββββββββββββββββββββββββββββββββββββ */
|
| 117 |
.medyx-hero {
|
| 118 |
background: linear-gradient(120deg, #0e7c86 0%, #11657a 45%, #1E88E5 100%);
|
|
@@ -133,60 +160,86 @@ st.markdown("""
|
|
| 133 |
border-radius: 50%;
|
| 134 |
}
|
| 135 |
.medyx-hero h1 {
|
| 136 |
-
font-size: 2.3rem;
|
| 137 |
-
|
| 138 |
-
letter-spacing: -0.5px;
|
| 139 |
-
margin: 0;
|
| 140 |
-
display: flex; align-items: center; gap: 0.6rem;
|
| 141 |
}
|
| 142 |
.medyx-hero p {
|
| 143 |
-
font-size: 1.02rem;
|
| 144 |
-
|
| 145 |
-
opacity: 0.92;
|
| 146 |
-
margin: 0.35rem 0 0 0;
|
| 147 |
-
max-width: 640px;
|
| 148 |
}
|
| 149 |
.medyx-pills { margin-top: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
| 150 |
.medyx-pill {
|
| 151 |
background: rgba(255,255,255,0.16);
|
| 152 |
border: 1px solid rgba(255,255,255,0.28);
|
| 153 |
-
padding: 0.28rem 0.7rem;
|
| 154 |
-
|
| 155 |
-
font-size: 0.78rem;
|
| 156 |
-
font-weight: 500;
|
| 157 |
-
backdrop-filter: blur(6px);
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
/* ββ Section cards βββββββββββββββββββββββββββββββββββββ */
|
| 161 |
-
.section-card {
|
| 162 |
-
background: #ffffff;
|
| 163 |
-
border: 1px solid #e6edf2;
|
| 164 |
-
border-radius: 0.9rem;
|
| 165 |
-
padding: 1.25rem 1.4rem;
|
| 166 |
-
box-shadow: 0 6px 20px -14px rgba(15,34,51,0.25);
|
| 167 |
-
margin-bottom: 1rem;
|
| 168 |
}
|
| 169 |
|
| 170 |
-
/* ββ Status pills (sidebar) ββ
|
| 171 |
.status-row {
|
| 172 |
display: flex; align-items: center; gap: 0.55rem;
|
| 173 |
-
padding: 0.5rem 0.7rem;
|
| 174 |
-
|
| 175 |
-
margin-bottom: 0.45rem;
|
| 176 |
-
font-size: 0.88rem;
|
| 177 |
-
font-weight: 500;
|
| 178 |
border: 1px solid transparent;
|
| 179 |
}
|
| 180 |
-
.status-ok { background:
|
| 181 |
-
.status-warn { background:
|
| 182 |
-
.status-off { background:
|
| 183 |
-
.status-dot {
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
/* ββ Diagnosis impression box ββββββββββββββββββββββββββ */
|
| 192 |
.severity-normal { background: linear-gradient(135deg,#e8f5e9,#f3fbf4); border-left: 6px solid #4CAF50; }
|
|
@@ -195,50 +248,56 @@ st.markdown("""
|
|
| 195 |
.severity-severe { background: linear-gradient(135deg,#ffebee,#fff6f7); border-left: 6px solid #f44336; }
|
| 196 |
.severity-critical { background: linear-gradient(135deg,#ffe0e3,#fff1f2); border-left: 6px solid #b71c1c; }
|
| 197 |
.diagnosis-box {
|
| 198 |
-
padding: 1.5rem 1.6rem;
|
| 199 |
-
border-radius: 0.8rem;
|
| 200 |
-
margin: 0.6rem 0 0.4rem 0;
|
| 201 |
box-shadow: 0 8px 24px -16px rgba(15,34,51,0.4);
|
| 202 |
}
|
| 203 |
-
.diagnosis-box h2 { color:
|
| 204 |
|
| 205 |
-
/* ββ Ranked differential
|
| 206 |
.ddx-row {
|
| 207 |
-
display: flex; align-items: center; gap: 0.
|
| 208 |
-
background:
|
| 209 |
-
border:
|
| 210 |
-
|
| 211 |
-
padding: 0.7rem 1rem;
|
| 212 |
-
margin-bottom: 0.5rem;
|
| 213 |
-
box-shadow: 0 4px 14px -12px rgba(15,34,51,0.3);
|
| 214 |
}
|
|
|
|
|
|
|
| 215 |
.ddx-rank {
|
| 216 |
-
width:
|
| 217 |
-
color: #fff; font-weight:
|
| 218 |
display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
|
|
|
|
| 219 |
}
|
| 220 |
-
.ddx-
|
|
|
|
|
|
|
| 221 |
|
| 222 |
.expert-discussion {
|
| 223 |
-
background: #0f2233;
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
font-family: 'SFMono-Regular', Consolas, monospace;
|
| 228 |
-
font-size: 0.84rem;
|
| 229 |
-
white-space: pre-wrap;
|
| 230 |
-
max-height: 500px;
|
| 231 |
-
overflow-y: auto;
|
| 232 |
border: 1px solid rgba(255,255,255,0.06);
|
| 233 |
}
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
/* Primary button polish */
|
| 236 |
.stButton > button[kind="primary"] {
|
| 237 |
-
background: linear-gradient(120deg, #0e7c86, #1E88E5);
|
| 238 |
-
|
| 239 |
-
font-weight: 600;
|
| 240 |
-
letter-spacing: 0.2px;
|
| 241 |
-
padding: 0.6rem 1rem;
|
| 242 |
box-shadow: 0 10px 24px -12px rgba(30,136,229,0.6);
|
| 243 |
}
|
| 244 |
.stButton > button[kind="primary"]:hover { filter: brightness(1.06); }
|
|
@@ -255,16 +314,13 @@ st.markdown("""
|
|
| 255 |
.medyx-hero { padding: 1.2rem 1.2rem; }
|
| 256 |
.medyx-hero h1 { font-size: 1.45rem; }
|
| 257 |
.medyx-hero p { font-size: 0.85rem; }
|
| 258 |
-
|
|
|
|
| 259 |
[data-testid="stHorizontalBlock"] { flex-direction: column !important; }
|
| 260 |
[data-testid="stHorizontalBlock"] > [data-testid="column"] {
|
| 261 |
-
width: 100% !important;
|
| 262 |
-
flex: 1 1 100% !important;
|
| 263 |
-
min-width: 0 !important;
|
| 264 |
}
|
| 265 |
[data-testid="stButton"] > button { width: 100%; }
|
| 266 |
-
[data-testid="stMetricLabel"] { font-size: 0.7rem !important; }
|
| 267 |
-
[data-testid="stMetricValue"] { font-size: 1.1rem !important; }
|
| 268 |
.block-container { padding: 1rem 0.75rem !important; }
|
| 269 |
.diagnosis-box { padding: 1rem; }
|
| 270 |
.expert-discussion { font-size: 0.75rem; max-height: 260px; }
|
|
@@ -656,14 +712,22 @@ def render_report(report, case_id: str = "", log_text: str = "") -> None:
|
|
| 656 |
"knowledge-graph context, and image review."
|
| 657 |
)
|
| 658 |
rank_colours = ["#0e7c86", "#c47a00", "#b03030"]
|
|
|
|
| 659 |
for entry in dr[:3]:
|
| 660 |
rk = int(entry.get("rank", 0) or 0)
|
| 661 |
dn = str(entry.get("disease", "Unknown"))
|
| 662 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
st.markdown(
|
| 664 |
-
f'<div class="ddx-row">'
|
| 665 |
-
f'<span class="ddx-rank" style="background:{
|
|
|
|
| 666 |
f'<span class="ddx-name">{dn}</span>'
|
|
|
|
|
|
|
| 667 |
f"</div>",
|
| 668 |
unsafe_allow_html=True,
|
| 669 |
)
|
|
@@ -908,8 +972,6 @@ def main():
|
|
| 908 |
|
| 909 |
with meta_box.container():
|
| 910 |
if patient_history:
|
| 911 |
-
st.markdown("##### π€ AI Intake β inferred case metadata")
|
| 912 |
-
|
| 913 |
# Compute what will actually be used (same merge logic as Run Diagnosis)
|
| 914 |
_conf_now = (inferred.confidence or "low").lower()
|
| 915 |
_imod = (inferred.modality or "").strip()
|
|
@@ -923,36 +985,63 @@ def main():
|
|
| 923 |
(visual_region or _ireg) if (_ireg_unknown or _conf_now == "low") else _ireg
|
| 924 |
)
|
| 925 |
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
with c3:
|
| 935 |
-
_reg_label = _display_reg or "β"
|
| 936 |
-
_reg_delta = f"text: {_ireg}" if _display_reg != _ireg and _ireg else None
|
| 937 |
-
st.metric("Region", _reg_label, delta=_reg_delta,
|
| 938 |
-
delta_color="off" if _reg_delta else "normal")
|
| 939 |
-
with c4:
|
| 940 |
-
st.metric("Specialist", inferred.specialist)
|
| 941 |
-
|
| 942 |
-
if inferred.reasoning:
|
| 943 |
-
st.caption(f"Reasoning: {inferred.reasoning}")
|
| 944 |
-
if inferred.parse_error:
|
| 945 |
-
st.warning(f"Parse note: {inferred.parse_error}")
|
| 946 |
-
conf_colour = {"high": "green", "medium": "orange", "low": "red"}.get(
|
| 947 |
-
inferred.confidence, "gray"
|
| 948 |
)
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 955 |
)
|
|
|
|
|
|
|
| 956 |
|
| 957 |
else:
|
| 958 |
st.info("Enter patient history above β the AI will infer modality, organ, and specialist.")
|
|
@@ -961,9 +1050,15 @@ def main():
|
|
| 961 |
st.subheader("πΌοΈ Image Preview")
|
| 962 |
if uploaded_files:
|
| 963 |
for f in uploaded_files[:6]:
|
| 964 |
-
st.image(f, caption=f
|
| 965 |
else:
|
| 966 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
|
| 968 |
st.divider()
|
| 969 |
|
|
|
|
| 89 |
initial_sidebar_state="auto", # collapsed on mobile, expanded on desktop
|
| 90 |
)
|
| 91 |
|
| 92 |
+
# Custom CSS β modern healthcare interface, light + dark adaptive, responsive
|
| 93 |
st.markdown("""
|
| 94 |
<style>
|
| 95 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
|
| 96 |
|
| 97 |
+
/* ββ Theme tokens (light defaults) βββββββββββββββββββββ */
|
| 98 |
:root {
|
| 99 |
+
--teal: #0e7c86;
|
| 100 |
+
--blue: #1E88E5;
|
| 101 |
+
--ink: #0f2233;
|
| 102 |
+
--muted: #5b6b72;
|
| 103 |
+
--card-bg: #ffffff;
|
| 104 |
+
--card-border: #e7edf2;
|
| 105 |
+
--card-shadow: 0 6px 20px -14px rgba(15,34,51,0.28);
|
| 106 |
+
--chip-bg: #eef4f7;
|
| 107 |
+
--chip-border: #d8e3ea;
|
| 108 |
+
--hairline: rgba(15,34,51,0.08);
|
| 109 |
+
}
|
| 110 |
+
/* ββ Dark theme (follows OS / Streamlit auto) ββββββββββ */
|
| 111 |
+
@media (prefers-color-scheme: dark) {
|
| 112 |
+
:root {
|
| 113 |
+
--ink: #eaf1f6;
|
| 114 |
+
--muted: #9fb2c0;
|
| 115 |
+
--card-bg: #161f29;
|
| 116 |
+
--card-border: #29333d;
|
| 117 |
+
--card-shadow: 0 10px 26px -14px rgba(0,0,0,0.65);
|
| 118 |
+
--chip-bg: #1c2731;
|
| 119 |
+
--chip-border: #2c3742;
|
| 120 |
+
--hairline: rgba(255,255,255,0.10);
|
| 121 |
+
}
|
| 122 |
}
|
| 123 |
|
| 124 |
html, body, [class*="css"], .stMarkdown, .stTextInput, .stTextArea, button {
|
| 125 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 126 |
}
|
| 127 |
|
| 128 |
+
/* Translucent ambient gradient β lets Streamlit's own light/dark bg show through */
|
| 129 |
.stApp {
|
| 130 |
+
background-image:
|
| 131 |
+
radial-gradient(1100px 560px at 10% -10%, rgba(14,124,134,0.10), transparent 60%),
|
| 132 |
+
radial-gradient(900px 480px at 100% 0%, rgba(30,136,229,0.08), transparent 55%);
|
| 133 |
+
background-attachment: fixed;
|
| 134 |
}
|
| 135 |
|
| 136 |
+
/* Hide Streamlit default chrome (deploy button, footer, colour bar) */
|
| 137 |
+
[data-testid="stAppDeployButton"] { display: none !important; }
|
| 138 |
+
[data-testid="stDecoration"] { display: none !important; }
|
| 139 |
+
header[data-testid="stHeader"] { background: transparent !important; }
|
| 140 |
+
footer { visibility: hidden !important; height: 0 !important; }
|
| 141 |
+
#MainMenu { /* keep menu so users can switch Light/Dark theme */ }
|
| 142 |
+
|
| 143 |
/* ββ Hero header βββββββββββββββββββββββββββββββββββββββ */
|
| 144 |
.medyx-hero {
|
| 145 |
background: linear-gradient(120deg, #0e7c86 0%, #11657a 45%, #1E88E5 100%);
|
|
|
|
| 160 |
border-radius: 50%;
|
| 161 |
}
|
| 162 |
.medyx-hero h1 {
|
| 163 |
+
font-size: 2.3rem; font-weight: 800; letter-spacing: -0.5px; margin: 0;
|
| 164 |
+
display: flex; align-items: center; gap: 0.6rem; color: #fff;
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
.medyx-hero p {
|
| 167 |
+
font-size: 1.02rem; font-weight: 400; opacity: 0.92;
|
| 168 |
+
margin: 0.35rem 0 0 0; max-width: 640px; color: #eaf6ff;
|
|
|
|
|
|
|
|
|
|
| 169 |
}
|
| 170 |
.medyx-pills { margin-top: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
| 171 |
.medyx-pill {
|
| 172 |
background: rgba(255,255,255,0.16);
|
| 173 |
border: 1px solid rgba(255,255,255,0.28);
|
| 174 |
+
padding: 0.28rem 0.7rem; border-radius: 999px;
|
| 175 |
+
font-size: 0.78rem; font-weight: 500; backdrop-filter: blur(6px);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
}
|
| 177 |
|
| 178 |
+
/* ββ Status pills (sidebar) β translucent, theme-safe ββ */
|
| 179 |
.status-row {
|
| 180 |
display: flex; align-items: center; gap: 0.55rem;
|
| 181 |
+
padding: 0.5rem 0.7rem; border-radius: 0.6rem;
|
| 182 |
+
margin-bottom: 0.45rem; font-size: 0.88rem; font-weight: 600;
|
|
|
|
|
|
|
|
|
|
| 183 |
border: 1px solid transparent;
|
| 184 |
}
|
| 185 |
+
.status-ok { background: rgba(22,163,90,0.14); color: #16a35a; border-color: rgba(22,163,90,0.30); }
|
| 186 |
+
.status-warn { background: rgba(245,158,11,0.15); color: #d98300; border-color: rgba(245,158,11,0.32); }
|
| 187 |
+
.status-off { background: rgba(120,135,148,0.16);color: #8794a0; border-color: rgba(120,135,148,0.30); }
|
| 188 |
+
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
|
| 189 |
+
.dot-ok { background: #16a35a; } .dot-warn { background: #f59e0b; } .dot-off { background: #9aa7b0; }
|
| 190 |
+
|
| 191 |
+
/* ββ Routing flow (AI intake) ββββββββββββββββββββββββββ */
|
| 192 |
+
.route-wrap {
|
| 193 |
+
background: var(--card-bg);
|
| 194 |
+
border: 1px solid var(--card-border);
|
| 195 |
+
border-radius: 1rem; padding: 1.1rem 1.2rem 1.2rem 1.2rem;
|
| 196 |
+
box-shadow: var(--card-shadow); margin: 0.3rem 0 0.6rem 0;
|
| 197 |
+
}
|
| 198 |
+
.route-title {
|
| 199 |
+
display: flex; align-items: center; gap: 0.5rem;
|
| 200 |
+
font-weight: 700; color: var(--ink); font-size: 0.98rem; margin-bottom: 0.9rem;
|
| 201 |
+
}
|
| 202 |
+
.route-flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.5rem; }
|
| 203 |
+
.route-card {
|
| 204 |
+
flex: 1 1 0; min-width: 110px;
|
| 205 |
+
background: var(--chip-bg); border: 1px solid var(--chip-border);
|
| 206 |
+
border-radius: 0.8rem; padding: 0.7rem 0.85rem; position: relative;
|
| 207 |
+
}
|
| 208 |
+
.route-card .rc-label {
|
| 209 |
+
font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
|
| 210 |
+
color: var(--muted); font-weight: 700; margin-bottom: 0.2rem;
|
| 211 |
+
}
|
| 212 |
+
.route-card .rc-value { font-size: 1.05rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
|
| 213 |
+
.route-card .rc-sub { font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem; }
|
| 214 |
+
.route-card.accent {
|
| 215 |
+
background: linear-gradient(135deg, rgba(14,124,134,0.14), rgba(30,136,229,0.12));
|
| 216 |
+
border-color: rgba(14,124,134,0.35);
|
| 217 |
+
}
|
| 218 |
+
.route-card.accent .rc-value { color: var(--teal); }
|
| 219 |
+
.route-arrow { display: flex; align-items: center; color: var(--muted); font-size: 1.1rem; padding: 0 0.1rem; }
|
| 220 |
+
.route-foot {
|
| 221 |
+
display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
|
| 222 |
+
margin-top: 0.85rem;
|
| 223 |
+
}
|
| 224 |
+
.conf-badge {
|
| 225 |
+
font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 999px;
|
| 226 |
+
letter-spacing: 0.03em;
|
| 227 |
+
}
|
| 228 |
+
.conf-high { background: rgba(22,163,90,0.16); color: #16a35a; }
|
| 229 |
+
.conf-medium { background: rgba(245,158,11,0.18); color: #d98300; }
|
| 230 |
+
.conf-low { background: rgba(244,67,54,0.16); color: #e0564b; }
|
| 231 |
+
.route-note {
|
| 232 |
+
font-size: 0.8rem; color: var(--muted); margin-top: 0.6rem; line-height: 1.45;
|
| 233 |
+
border-left: 3px solid var(--chip-border); padding-left: 0.7rem;
|
| 234 |
}
|
| 235 |
+
|
| 236 |
+
/* ββ Image preview βββββββββββββββββββββββββββββββββββββ */
|
| 237 |
+
.preview-empty {
|
| 238 |
+
border: 1.5px dashed var(--card-border); border-radius: 1rem;
|
| 239 |
+
background: var(--chip-bg); color: var(--muted);
|
| 240 |
+
padding: 2.4rem 1rem; text-align: center; font-size: 0.9rem;
|
| 241 |
+
}
|
| 242 |
+
.preview-empty .pe-icon { font-size: 2rem; display:block; margin-bottom: 0.4rem; opacity: 0.8; }
|
| 243 |
|
| 244 |
/* ββ Diagnosis impression box ββββββββββββββββββββββββββ */
|
| 245 |
.severity-normal { background: linear-gradient(135deg,#e8f5e9,#f3fbf4); border-left: 6px solid #4CAF50; }
|
|
|
|
| 248 |
.severity-severe { background: linear-gradient(135deg,#ffebee,#fff6f7); border-left: 6px solid #f44336; }
|
| 249 |
.severity-critical { background: linear-gradient(135deg,#ffe0e3,#fff1f2); border-left: 6px solid #b71c1c; }
|
| 250 |
.diagnosis-box {
|
| 251 |
+
padding: 1.5rem 1.6rem; border-radius: 0.8rem; margin: 0.6rem 0 0.4rem 0;
|
|
|
|
|
|
|
| 252 |
box-shadow: 0 8px 24px -16px rgba(15,34,51,0.4);
|
| 253 |
}
|
| 254 |
+
.diagnosis-box h2, .diagnosis-box p, .diagnosis-box div { color: #16263a !important; }
|
| 255 |
|
| 256 |
+
/* ββ Ranked differential β clinical result cards βββββββ */
|
| 257 |
.ddx-row {
|
| 258 |
+
display: flex; align-items: center; gap: 0.85rem;
|
| 259 |
+
background: var(--card-bg); border: 1px solid var(--card-border);
|
| 260 |
+
border-radius: 0.85rem; padding: 0.8rem 1rem; margin-bottom: 0.55rem;
|
| 261 |
+
box-shadow: var(--card-shadow); transition: transform .12s ease;
|
|
|
|
|
|
|
|
|
|
| 262 |
}
|
| 263 |
+
.ddx-row:hover { transform: translateX(2px); }
|
| 264 |
+
.ddx-row.primary { border-color: rgba(14,124,134,0.45); background: linear-gradient(135deg, rgba(14,124,134,0.08), transparent 70%); }
|
| 265 |
.ddx-rank {
|
| 266 |
+
width: 34px; height: 34px; border-radius: 10px;
|
| 267 |
+
color: #fff; font-weight: 800; font-size: 0.95rem;
|
| 268 |
display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
|
| 269 |
+
box-shadow: 0 4px 10px -4px rgba(0,0,0,0.35);
|
| 270 |
}
|
| 271 |
+
.ddx-main { display: flex; flex-direction: column; }
|
| 272 |
+
.ddx-name { font-weight: 700; color: var(--ink); font-size: 1.02rem; line-height: 1.2; }
|
| 273 |
+
.ddx-tag { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
|
| 274 |
|
| 275 |
.expert-discussion {
|
| 276 |
+
background: #0f2233; color: #d7e3ec !important;
|
| 277 |
+
padding: 1rem 1.1rem; border-radius: 0.7rem;
|
| 278 |
+
font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.84rem;
|
| 279 |
+
white-space: pre-wrap; max-height: 500px; overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
border: 1px solid rgba(255,255,255,0.06);
|
| 281 |
}
|
| 282 |
|
| 283 |
+
/* ββ Tabs β styled, no bland default βββββββββββββββββββ */
|
| 284 |
+
.stTabs [data-baseweb="tab-list"] {
|
| 285 |
+
gap: 0.35rem; border-bottom: 1px solid var(--hairline); padding-bottom: 0.1rem;
|
| 286 |
+
}
|
| 287 |
+
.stTabs [data-baseweb="tab"] {
|
| 288 |
+
height: auto; padding: 0.45rem 0.9rem; border-radius: 0.6rem 0.6rem 0 0;
|
| 289 |
+
font-weight: 600; font-size: 0.88rem; color: var(--muted);
|
| 290 |
+
}
|
| 291 |
+
.stTabs [aria-selected="true"] {
|
| 292 |
+
color: var(--teal) !important;
|
| 293 |
+
background: linear-gradient(135deg, rgba(14,124,134,0.12), rgba(30,136,229,0.10));
|
| 294 |
+
}
|
| 295 |
+
.stTabs [data-baseweb="tab-highlight"] { background: var(--teal); }
|
| 296 |
+
|
| 297 |
/* Primary button polish */
|
| 298 |
.stButton > button[kind="primary"] {
|
| 299 |
+
background: linear-gradient(120deg, #0e7c86, #1E88E5); border: none;
|
| 300 |
+
font-weight: 600; letter-spacing: 0.2px; padding: 0.6rem 1rem;
|
|
|
|
|
|
|
|
|
|
| 301 |
box-shadow: 0 10px 24px -12px rgba(30,136,229,0.6);
|
| 302 |
}
|
| 303 |
.stButton > button[kind="primary"]:hover { filter: brightness(1.06); }
|
|
|
|
| 314 |
.medyx-hero { padding: 1.2rem 1.2rem; }
|
| 315 |
.medyx-hero h1 { font-size: 1.45rem; }
|
| 316 |
.medyx-hero p { font-size: 0.85rem; }
|
| 317 |
+
.route-flow { flex-direction: column; }
|
| 318 |
+
.route-arrow { transform: rotate(90deg); justify-content: center; }
|
| 319 |
[data-testid="stHorizontalBlock"] { flex-direction: column !important; }
|
| 320 |
[data-testid="stHorizontalBlock"] > [data-testid="column"] {
|
| 321 |
+
width: 100% !important; flex: 1 1 100% !important; min-width: 0 !important;
|
|
|
|
|
|
|
| 322 |
}
|
| 323 |
[data-testid="stButton"] > button { width: 100%; }
|
|
|
|
|
|
|
| 324 |
.block-container { padding: 1rem 0.75rem !important; }
|
| 325 |
.diagnosis-box { padding: 1rem; }
|
| 326 |
.expert-discussion { font-size: 0.75rem; max-height: 260px; }
|
|
|
|
| 712 |
"knowledge-graph context, and image review."
|
| 713 |
)
|
| 714 |
rank_colours = ["#0e7c86", "#c47a00", "#b03030"]
|
| 715 |
+
rank_tags = ["Most likely", "Alternative", "Alternative"]
|
| 716 |
for entry in dr[:3]:
|
| 717 |
rk = int(entry.get("rank", 0) or 0)
|
| 718 |
dn = str(entry.get("disease", "Unknown"))
|
| 719 |
+
idx = min(max(rk - 1, 0), 2)
|
| 720 |
+
colour = rank_colours[idx]
|
| 721 |
+
grad = f"linear-gradient(135deg,{colour},{colour}cc)"
|
| 722 |
+
primary_cls = " primary" if rk == 1 else ""
|
| 723 |
+
tag = rank_tags[idx]
|
| 724 |
st.markdown(
|
| 725 |
+
f'<div class="ddx-row{primary_cls}">'
|
| 726 |
+
f'<span class="ddx-rank" style="background:{grad};">{rk or "β’"}</span>'
|
| 727 |
+
f'<span class="ddx-main">'
|
| 728 |
f'<span class="ddx-name">{dn}</span>'
|
| 729 |
+
f'<span class="ddx-tag">{tag}</span>'
|
| 730 |
+
f"</span>"
|
| 731 |
f"</div>",
|
| 732 |
unsafe_allow_html=True,
|
| 733 |
)
|
|
|
|
| 972 |
|
| 973 |
with meta_box.container():
|
| 974 |
if patient_history:
|
|
|
|
|
|
|
| 975 |
# Compute what will actually be used (same merge logic as Run Diagnosis)
|
| 976 |
_conf_now = (inferred.confidence or "low").lower()
|
| 977 |
_imod = (inferred.modality or "").strip()
|
|
|
|
| 985 |
(visual_region or _ireg) if (_ireg_unknown or _conf_now == "low") else _ireg
|
| 986 |
)
|
| 987 |
|
| 988 |
+
import html as _html
|
| 989 |
+
|
| 990 |
+
_age_val = str(inferred.age) if inferred.age else "β"
|
| 991 |
+
_mod_val = _html.escape(_display_mod or "β")
|
| 992 |
+
_reg_val = _html.escape((_display_reg or "β").title())
|
| 993 |
+
_spec_val = _html.escape(inferred.specialist or "β")
|
| 994 |
+
_mod_sub = (
|
| 995 |
+
"from image scan" if (_display_mod != _imod and _imod) else " "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 996 |
)
|
| 997 |
+
_reg_sub = (
|
| 998 |
+
"from image scan" if (_display_reg != _ireg and _ireg) else " "
|
| 999 |
+
)
|
| 1000 |
+
_conf = (inferred.confidence or "low").lower()
|
| 1001 |
+
_conf_cls = {"high": "conf-high", "medium": "conf-medium"}.get(_conf, "conf-low")
|
| 1002 |
+
|
| 1003 |
+
st.markdown(
|
| 1004 |
+
f"""
|
| 1005 |
+
<div class="route-wrap">
|
| 1006 |
+
<div class="route-title">π€ AI Intake β case routing</div>
|
| 1007 |
+
<div class="route-flow">
|
| 1008 |
+
<div class="route-card">
|
| 1009 |
+
<div class="rc-label">Patient age</div>
|
| 1010 |
+
<div class="rc-value">{_age_val}</div>
|
| 1011 |
+
<div class="rc-sub"> </div>
|
| 1012 |
+
</div>
|
| 1013 |
+
<div class="route-arrow">β</div>
|
| 1014 |
+
<div class="route-card">
|
| 1015 |
+
<div class="rc-label">Modality</div>
|
| 1016 |
+
<div class="rc-value">{_mod_val}</div>
|
| 1017 |
+
<div class="rc-sub">{_mod_sub}</div>
|
| 1018 |
+
</div>
|
| 1019 |
+
<div class="route-arrow">β</div>
|
| 1020 |
+
<div class="route-card">
|
| 1021 |
+
<div class="rc-label">Region</div>
|
| 1022 |
+
<div class="rc-value">{_reg_val}</div>
|
| 1023 |
+
<div class="rc-sub">{_reg_sub}</div>
|
| 1024 |
+
</div>
|
| 1025 |
+
<div class="route-arrow">β</div>
|
| 1026 |
+
<div class="route-card accent">
|
| 1027 |
+
<div class="rc-label">Routed to</div>
|
| 1028 |
+
<div class="rc-value">{_spec_val}</div>
|
| 1029 |
+
<div class="rc-sub">specialist</div>
|
| 1030 |
+
</div>
|
| 1031 |
+
</div>
|
| 1032 |
+
<div class="route-foot">
|
| 1033 |
+
<span class="conf-badge {_conf_cls}">CONFIDENCE: {_conf.upper()}</span>
|
| 1034 |
+
<span style="font-size:0.78rem;color:var(--muted);">
|
| 1035 |
+
Edit the history above to re-infer.
|
| 1036 |
+
</span>
|
| 1037 |
+
</div>
|
| 1038 |
+
{f'<div class="route-note">{_html.escape(inferred.reasoning)}</div>' if inferred.reasoning else ''}
|
| 1039 |
+
</div>
|
| 1040 |
+
""",
|
| 1041 |
+
unsafe_allow_html=True,
|
| 1042 |
)
|
| 1043 |
+
if inferred.parse_error:
|
| 1044 |
+
st.warning(f"Parse note: {inferred.parse_error}")
|
| 1045 |
|
| 1046 |
else:
|
| 1047 |
st.info("Enter patient history above β the AI will infer modality, organ, and specialist.")
|
|
|
|
| 1050 |
st.subheader("πΌοΈ Image Preview")
|
| 1051 |
if uploaded_files:
|
| 1052 |
for f in uploaded_files[:6]:
|
| 1053 |
+
st.image(f, caption=f.name, use_container_width=True)
|
| 1054 |
else:
|
| 1055 |
+
st.markdown(
|
| 1056 |
+
'<div class="preview-empty">'
|
| 1057 |
+
'<span class="pe-icon">π©»</span>'
|
| 1058 |
+
'Upload a scan to preview it here'
|
| 1059 |
+
'</div>',
|
| 1060 |
+
unsafe_allow_html=True,
|
| 1061 |
+
)
|
| 1062 |
|
| 1063 |
st.divider()
|
| 1064 |
|