Spaces:
Sleeping
Sleeping
Hackathon Builder commited on
Commit ·
80a559b
1
Parent(s): 3024450
ER Danger Pattern Specialist: Condition-First Priority Engine and Action Mapping
Browse files- backend/main.py +26 -24
- frontend/dist/assets/{index-B9EjTr1w.js → index-DC0otKNt.js} +0 -0
- frontend/dist/index.html +1 -1
- frontend/src/BriefPanel.jsx +88 -157
backend/main.py
CHANGED
|
@@ -93,10 +93,9 @@ def _gemini(prompt: str, retries: int = 4, override_key: str = None) -> Optional
|
|
| 93 |
|
| 94 |
# ── Agent 1: Triage ───────────────────────────────────────────────────────────
|
| 95 |
def agent_triage(record: Dict, override_key: str = None) -> Dict:
|
| 96 |
-
prompt = f"""You are
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
If INR is high AND there is a bleed history, flag as EXTREME HEMORRHAGE RISK.
|
| 100 |
|
| 101 |
PATIENT DATA:
|
| 102 |
{json.dumps(record, indent=2)}
|
|
@@ -104,12 +103,16 @@ PATIENT DATA:
|
|
| 104 |
Return ONLY raw JSON:
|
| 105 |
{{
|
| 106 |
"severity": 1,
|
| 107 |
-
"
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
}}"""
|
| 114 |
r = _gemini(prompt)
|
| 115 |
if r:
|
|
@@ -234,28 +237,27 @@ Return ONLY raw JSON:
|
|
| 234 |
# ── Agent 5: Action Protocol ──────────────────────────────────────────────────
|
| 235 |
def agent_action_protocol(record: Dict, triage: Dict, contraindication: Dict,
|
| 236 |
labs: Dict, differentials: Dict, override_key: str = None) -> Dict:
|
| 237 |
-
prompt = f"""You are the
|
| 238 |
-
|
|
|
|
| 239 |
|
| 240 |
-
TRIAGE: {json.dumps(triage)}
|
| 241 |
SAFETY: {json.dumps(contraindication)}
|
| 242 |
LABS: {json.dumps(labs)}
|
| 243 |
DIFFERENTIALS: {json.dumps(differentials)}
|
| 244 |
-
PATIENT: Age {record.get('age')}, {record.get('gender')}
|
| 245 |
|
| 246 |
Return ONLY raw JSON:
|
| 247 |
{{
|
| 248 |
-
"
|
| 249 |
-
"
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
| 253 |
],
|
| 254 |
-
"
|
| 255 |
-
"
|
| 256 |
-
|
| 257 |
-
"Prioritize reversal of the most immediate life-threat"
|
| 258 |
-
]
|
| 259 |
}}"""
|
| 260 |
r = _gemini(prompt)
|
| 261 |
if r:
|
|
|
|
| 93 |
|
| 94 |
# ── Agent 1: Triage ───────────────────────────────────────────────────────────
|
| 95 |
def agent_triage(record: Dict, override_key: str = None) -> Dict:
|
| 96 |
+
prompt = f"""You are an ER Danger Pattern Specialist. Analyze the patient for 'Time-to-Collapse' risks.
|
| 97 |
+
REASONING CHAIN: Finding → Physiological Danger → Risk of Collapse → Urgency.
|
| 98 |
+
Example: Glucose 48 → Severe Hypoglycemia → risk of Seizure/Coma → IMMEDIATE.
|
|
|
|
| 99 |
|
| 100 |
PATIENT DATA:
|
| 101 |
{json.dumps(record, indent=2)}
|
|
|
|
| 103 |
Return ONLY raw JSON:
|
| 104 |
{{
|
| 105 |
"severity": 1,
|
| 106 |
+
"critical_risks": [
|
| 107 |
+
{{
|
| 108 |
+
"condition": "Condition Name",
|
| 109 |
+
"evidence": "Value/Symptom",
|
| 110 |
+
"danger": "Risk of [Death/Collapse/Organ Failure]",
|
| 111 |
+
"urgency": "IMMEDIATE | HIGH"
|
| 112 |
+
}}
|
| 113 |
+
],
|
| 114 |
+
"chief_complaint": "Physiological status summary",
|
| 115 |
+
"agent_reasoning": ["Analyze vitals for physiological decompensation", "Evaluate history for high-risk instability"]
|
| 116 |
}}"""
|
| 117 |
r = _gemini(prompt)
|
| 118 |
if r:
|
|
|
|
| 237 |
# ── Agent 5: Action Protocol ──────────────────────────────────────────────────
|
| 238 |
def agent_action_protocol(record: Dict, triage: Dict, contraindication: Dict,
|
| 239 |
labs: Dict, differentials: Dict, override_key: str = None) -> Dict:
|
| 240 |
+
prompt = f"""You are the ED Attending. Implement 'Diagnosis-Driven Action Mapping'.
|
| 241 |
+
For every critical risk identified by the team, map a specific life-saving intervention.
|
| 242 |
+
Example: Hypoglycemia → Glucose correction. Sepsis → Antibiotics + Fluids.
|
| 243 |
|
| 244 |
+
TRIAGE/RISKS: {json.dumps(triage)}
|
| 245 |
SAFETY: {json.dumps(contraindication)}
|
| 246 |
LABS: {json.dumps(labs)}
|
| 247 |
DIFFERENTIALS: {json.dumps(differentials)}
|
|
|
|
| 248 |
|
| 249 |
Return ONLY raw JSON:
|
| 250 |
{{
|
| 251 |
+
"primary_directive": "The single most urgent life-saving priority",
|
| 252 |
+
"action_mapping": [
|
| 253 |
+
{{
|
| 254 |
+
"condition": "Risk factor",
|
| 255 |
+
"action": "Specific life-saving intervention"
|
| 256 |
+
}}
|
| 257 |
],
|
| 258 |
+
"monitoring": ["Specific parameter and frequency"],
|
| 259 |
+
"clinical_summary": "ER-style synthesis: Age/Gender presenting with [Pattern] requiring [Priority].",
|
| 260 |
+
"agent_reasoning": ["Synthesize danger patterns into action mapping", "Prioritize physiological stabilization"]
|
|
|
|
|
|
|
| 261 |
}}"""
|
| 262 |
r = _gemini(prompt)
|
| 263 |
if r:
|
frontend/dist/assets/{index-B9EjTr1w.js → index-DC0otKNt.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 9 |
<title>CodeBlue Context</title>
|
| 10 |
-
<script type="module" crossorigin src="/assets/index-
|
| 11 |
<link rel="stylesheet" crossorigin href="/assets/index-DKXwe-v6.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
|
|
|
| 7 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 8 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 9 |
<title>CodeBlue Context</title>
|
| 10 |
+
<script type="module" crossorigin src="/assets/index-DC0otKNt.js"></script>
|
| 11 |
<link rel="stylesheet" crossorigin href="/assets/index-DKXwe-v6.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
frontend/src/BriefPanel.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
// BriefPanel.jsx — Right column: Emergency Brief + Treatment Checker
|
| 2 |
import { useState } from 'react';
|
| 3 |
-
import { ShieldAlert, FlaskConical, Stethoscope, ListChecks, AlertTriangle, Clock, Send, CheckCircle, XCircle, AlertCircle } from 'lucide-react';
|
| 4 |
|
| 5 |
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
| 6 |
|
|
@@ -140,23 +140,14 @@ export function BriefPanel({ data, patient }) {
|
|
| 140 |
);
|
| 141 |
}
|
| 142 |
|
| 143 |
-
const { agents,
|
| 144 |
const triage = agents?.triage || {};
|
| 145 |
-
const contra = agents?.contraindication || {};
|
| 146 |
-
const labs = agents?.labs || {};
|
| 147 |
-
const diff = agents?.differentials || {};
|
| 148 |
const action = agents?.action_protocol || {};
|
| 149 |
-
const snap = deterministic?.snapshot || '';
|
| 150 |
-
const risks = deterministic?.risks || [];
|
| 151 |
-
const vitals = deterministic?.vitals || {};
|
| 152 |
-
|
| 153 |
-
const severityColor = triage.severity <= 2 ? 'var(--red-critical)' : triage.severity === 3 ? 'var(--amber-warning)' : 'var(--green-safe)';
|
| 154 |
|
| 155 |
return (
|
| 156 |
-
<div style={{ display: 'flex', flexDirection: 'column',
|
| 157 |
-
{
|
| 158 |
-
|
| 159 |
-
<span style={{ fontWeight: 700, fontSize: 13, color: 'var(--text-secondary)', textTransform: 'uppercase', letterSpacing: '0.05em' }}>
|
| 160 |
Emergency Brief
|
| 161 |
</span>
|
| 162 |
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 10, color: 'var(--text-tertiary)' }}>
|
|
@@ -185,7 +176,7 @@ export function BriefPanel({ data, patient }) {
|
|
| 185 |
</div>
|
| 186 |
|
| 187 |
{/* Primary Clinical Directive */}
|
| 188 |
-
{action.
|
| 189 |
<div className="fade-up directive-banner" style={{
|
| 190 |
padding: '16px 20px', borderRadius: 14, marginBottom: 20,
|
| 191 |
boxShadow: '0 12px 32px rgba(2, 132, 199, 0.3)',
|
|
@@ -196,170 +187,110 @@ export function BriefPanel({ data, patient }) {
|
|
| 196 |
<Zap size={12} fill="white" /> IMMEDIATE CRITICAL DIRECTIVE
|
| 197 |
</div>
|
| 198 |
<div style={{ fontSize: 18, fontWeight: 900, lineHeight: 1.2, letterSpacing: '-0.01em' }}>
|
| 199 |
-
{action.
|
| 200 |
</div>
|
| 201 |
</div>
|
| 202 |
)}
|
| 203 |
|
| 204 |
-
{/*
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
{(triage.time_critical_flags?.length > 0 || triage.do_not_delay?.length > 0) && (
|
| 225 |
-
<Section title="Immediate Threats" icon={<ShieldAlert size={14}/>} accent="var(--red-critical)">
|
| 226 |
-
<div className="pulse-critical" style={{ borderRadius: 8, padding: 4 }}>
|
| 227 |
-
{(triage.time_critical_flags || []).map((f, i) => <AlertBox key={i} text={f} severity="critical" />)}
|
| 228 |
</div>
|
| 229 |
-
|
| 230 |
-
</Section>
|
| 231 |
)}
|
| 232 |
|
| 233 |
-
{/*
|
| 234 |
-
{
|
| 235 |
-
<
|
| 236 |
-
{
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
)}
|
| 247 |
|
| 248 |
-
{/*
|
| 249 |
-
{action.
|
| 250 |
-
<
|
| 251 |
<div style={{
|
| 252 |
-
|
| 253 |
-
|
| 254 |
}}>
|
| 255 |
-
|
| 256 |
-
{action.agent_reasoning.map((r, i) => (
|
| 257 |
-
<p key={i} style={{ marginBottom: 4, display: 'flex', gap: 6 }}>
|
| 258 |
-
<span style={{ color: 'var(--purple-ai)' }}>•</span> {r}
|
| 259 |
-
</p>
|
| 260 |
-
))}
|
| 261 |
</div>
|
| 262 |
-
</
|
| 263 |
)}
|
| 264 |
|
| 265 |
-
{/*
|
| 266 |
-
{
|
| 267 |
-
<
|
| 268 |
-
|
| 269 |
-
<div key={i} style={{ marginBottom: 8, padding: '6px 10px', borderRadius: 7, background: 'rgba(255,45,85,0.08)', border: '1px solid rgba(255,45,85,0.2)' }}>
|
| 270 |
-
<div style={{ fontSize: 12, fontWeight: 700, color: 'var(--red-critical)', fontFamily: 'var(--font-mono)' }}>{l.name}: {l.value}</div>
|
| 271 |
-
<div style={{ fontSize: 11, color: 'var(--text-secondary)', marginTop: 2 }}>{l.significance}</div>
|
| 272 |
-
{l.immediate_action && <div style={{ fontSize: 11, color: 'var(--amber-warning)', marginTop: 2 }}>→ {l.immediate_action}</div>}
|
| 273 |
-
</div>
|
| 274 |
-
))}
|
| 275 |
-
{(labs.abnormal_labs || []).map((l, i) => (
|
| 276 |
-
<div key={i} style={{ marginBottom: 6, padding: '5px 10px', borderRadius: 7, background: 'rgba(255,159,10,0.07)', border: '1px solid rgba(255,159,10,0.2)' }}>
|
| 277 |
-
<span style={{ fontFamily: 'var(--font-mono)', fontSize: 12, fontWeight: 600, color: 'var(--amber-warning)' }}>{l.name}: {l.value}</span>
|
| 278 |
-
<span style={{ fontSize: 11, color: 'var(--text-secondary)', marginLeft: 8 }}>{l.significance}</span>
|
| 279 |
-
</div>
|
| 280 |
-
))}
|
| 281 |
-
</Section>
|
| 282 |
-
)}
|
| 283 |
|
| 284 |
-
{/*
|
| 285 |
-
{
|
| 286 |
-
<
|
| 287 |
-
<div style={{
|
| 288 |
-
|
| 289 |
-
<div key={k} style={{ padding: '5px 8px', borderRadius: 6, background: 'var(--bg-card)', border: '1px solid var(--border-subtle)' }}>
|
| 290 |
-
<div style={{ fontSize: 10, color: 'var(--text-tertiary)', textTransform: 'uppercase', letterSpacing: '0.04em' }}>{k}</div>
|
| 291 |
-
<div style={{ fontSize: 14, fontWeight: 700, fontFamily: 'var(--font-mono)', color: 'var(--text-primary)' }}>{String(v)}</div>
|
| 292 |
-
</div>
|
| 293 |
-
))}
|
| 294 |
</div>
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
<Section title="Differential Diagnosis" icon={<Stethoscope size={12}/>} accent="var(--blue-accent)">
|
| 301 |
-
{(diff.differentials || []).map((d, i) => (
|
| 302 |
-
<div key={i} style={{ marginBottom: 8, display: 'flex', gap: 8, alignItems: 'flex-start' }}>
|
| 303 |
-
<span style={{ fontSize: 16, fontWeight: 900, color: 'var(--text-tertiary)', minWidth: 20 }}>{i + 1}</span>
|
| 304 |
-
<div>
|
| 305 |
-
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 2 }}>
|
| 306 |
-
<span style={{ fontSize: 12, fontWeight: 700, color: 'var(--text-primary)' }}>{d.diagnosis}</span>
|
| 307 |
-
<span className={`badge ${d.likelihood === 'HIGH' ? 'badge-critical' : d.likelihood === 'MODERATE' ? 'badge-moderate' : 'badge-stable'}`} style={{ fontSize: 9 }}>
|
| 308 |
-
{d.likelihood}
|
| 309 |
-
</span>
|
| 310 |
-
{d.must_rule_out && <span style={{ fontSize: 9, color: 'var(--red-critical)', fontWeight: 700 }}>MUST RULE OUT</span>}
|
| 311 |
-
</div>
|
| 312 |
-
{(d.supporting_evidence || []).map((e, j) => (
|
| 313 |
-
<p key={j} style={{ fontSize: 10, color: 'var(--text-secondary)', marginBottom: 1 }}>· {e}</p>
|
| 314 |
-
))}
|
| 315 |
</div>
|
| 316 |
-
|
| 317 |
-
))}
|
| 318 |
-
{diff.key_diagnostic_question && (
|
| 319 |
-
<div style={{ marginTop: 8, padding: '6px 10px', borderRadius: 7, background: 'rgba(10,132,255,0.08)', border: '1px solid rgba(10,132,255,0.2)', fontSize: 11, color: 'var(--blue-accent)' }}>
|
| 320 |
-
Key question: {diff.key_diagnostic_question}
|
| 321 |
-
</div>
|
| 322 |
-
)}
|
| 323 |
-
</Section>
|
| 324 |
-
)}
|
| 325 |
-
|
| 326 |
-
{/* Action Protocol */}
|
| 327 |
-
{action.immediate_actions?.length > 0 && (
|
| 328 |
-
<Section title="Action Protocol" icon={<ListChecks size={12}/>} accent="var(--green-safe)">
|
| 329 |
-
{(action.immediate_actions || []).map((a, i) => (
|
| 330 |
-
<div key={i} style={{ display: 'flex', gap: 8, marginBottom: 6, alignItems: 'flex-start' }}>
|
| 331 |
-
<span style={{ width: 20, height: 20, borderRadius: 5, background: 'var(--green-safe)', color: '#000', fontSize: 11, fontWeight: 800, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>{i + 1}</span>
|
| 332 |
-
<span style={{ fontSize: 12, color: 'var(--text-primary)', lineHeight: 1.5 }}>{a}</span>
|
| 333 |
-
</div>
|
| 334 |
-
))}
|
| 335 |
-
{(action.drugs_to_avoid || []).length > 0 && (
|
| 336 |
-
<div style={{ marginTop: 8 }}>
|
| 337 |
-
{action.drugs_to_avoid.map((d, i) => (
|
| 338 |
-
<p key={i} style={{ fontSize: 11, color: 'var(--red-critical)', marginBottom: 3 }}>✕ AVOID: {d.drug} — {d.reason}</p>
|
| 339 |
-
))}
|
| 340 |
-
</div>
|
| 341 |
-
)}
|
| 342 |
-
{action.disposition && (
|
| 343 |
-
<div style={{ marginTop: 10, padding: '6px 12px', borderRadius: 7, background: 'rgba(10,132,255,0.1)', border: '1px solid rgba(10,132,255,0.3)', fontSize: 12, fontWeight: 700, color: 'var(--blue-accent)' }}>
|
| 344 |
-
Disposition: {action.disposition.replace('_', ' ')}
|
| 345 |
-
</div>
|
| 346 |
-
)}
|
| 347 |
-
</Section>
|
| 348 |
-
)}
|
| 349 |
-
|
| 350 |
-
{/* Snapshot text */}
|
| 351 |
-
{snap && (
|
| 352 |
-
<div className="fade-up" style={{ padding: 14, borderRadius: 10, background: 'var(--bg-surface)', border: '1px solid var(--border-default)', marginBottom: 14 }}>
|
| 353 |
-
<div style={{ fontSize: 10, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.06em', color: 'var(--text-tertiary)', marginBottom: 6 }}>
|
| 354 |
-
Clinical Summary
|
| 355 |
</div>
|
| 356 |
-
<p style={{ fontSize: 12, color: 'var(--text-primary)', lineHeight: 1.7, whiteSpace: 'pre-wrap' }}>{snap}</p>
|
| 357 |
</div>
|
| 358 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|
| 360 |
-
|
| 361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
</div>
|
|
|
|
| 363 |
</div>
|
| 364 |
);
|
| 365 |
}
|
|
|
|
| 1 |
// BriefPanel.jsx — Right column: Emergency Brief + Treatment Checker
|
| 2 |
import { useState } from 'react';
|
| 3 |
+
import { ShieldAlert, FlaskConical, Stethoscope, ListChecks, AlertTriangle, Clock, Send, CheckCircle, XCircle, AlertCircle, Zap, FileText, Activity, Shield } from 'lucide-react';
|
| 4 |
|
| 5 |
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
| 6 |
|
|
|
|
| 140 |
);
|
| 141 |
}
|
| 142 |
|
| 143 |
+
const { agents, meta } = data;
|
| 144 |
const triage = agents?.triage || {};
|
|
|
|
|
|
|
|
|
|
| 145 |
const action = agents?.action_protocol || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
return (
|
| 148 |
+
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', background: 'var(--bg-base)' }}>
|
| 149 |
+
<div style={{ padding: '14px 16px', borderBottom: '1px solid var(--border-subtle)', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
| 150 |
+
<span style={{ fontWeight: 800, fontSize: 13, letterSpacing: '0.05em', color: 'var(--text-primary)', textTransform: 'uppercase' }}>
|
|
|
|
| 151 |
Emergency Brief
|
| 152 |
</span>
|
| 153 |
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 10, color: 'var(--text-tertiary)' }}>
|
|
|
|
| 176 |
</div>
|
| 177 |
|
| 178 |
{/* Primary Clinical Directive */}
|
| 179 |
+
{action.primary_directive && (
|
| 180 |
<div className="fade-up directive-banner" style={{
|
| 181 |
padding: '16px 20px', borderRadius: 14, marginBottom: 20,
|
| 182 |
boxShadow: '0 12px 32px rgba(2, 132, 199, 0.3)',
|
|
|
|
| 187 |
<Zap size={12} fill="white" /> IMMEDIATE CRITICAL DIRECTIVE
|
| 188 |
</div>
|
| 189 |
<div style={{ fontSize: 18, fontWeight: 900, lineHeight: 1.2, letterSpacing: '-0.01em' }}>
|
| 190 |
+
{action.primary_directive}
|
| 191 |
</div>
|
| 192 |
</div>
|
| 193 |
)}
|
| 194 |
|
| 195 |
+
{/* Immediate Critical Risks (Condition-First) */}
|
| 196 |
+
{triage.critical_risks?.length > 0 && (
|
| 197 |
+
<SectionBlock title="Immediate Critical Risks" icon={<ShieldAlert size={14}/>} accent="var(--red-critical)">
|
| 198 |
+
<div className="pulse-critical" style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
| 199 |
+
{triage.critical_risks.map((r, i) => (
|
| 200 |
+
<div key={i} style={{
|
| 201 |
+
background: 'rgba(239, 68, 68, 0.08)', border: '1px solid rgba(239, 68, 68, 0.2)',
|
| 202 |
+
borderRadius: 10, padding: '10px 14px'
|
| 203 |
+
}}>
|
| 204 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }}>
|
| 205 |
+
<AlertTriangle size={14} color="var(--red-critical)" />
|
| 206 |
+
<span style={{ fontWeight: 800, fontSize: 12, color: 'var(--red-critical)' }}>
|
| 207 |
+
{r.condition} ({r.evidence})
|
| 208 |
+
</span>
|
| 209 |
+
</div>
|
| 210 |
+
<div style={{ fontSize: 11, color: 'var(--text-secondary)', marginLeft: 22 }}>
|
| 211 |
+
→ risk of <span style={{ fontWeight: 700, color: 'var(--text-primary)' }}>{r.danger}</span>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
</div>
|
| 216 |
+
</SectionBlock>
|
|
|
|
| 217 |
)}
|
| 218 |
|
| 219 |
+
{/* Diagnosis-Driven Action Mapping */}
|
| 220 |
+
{action.action_mapping?.length > 0 && (
|
| 221 |
+
<SectionBlock title="Immediate Action Protocol" icon={<Zap size={14}/>} accent="var(--blue-accent)">
|
| 222 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
| 223 |
+
{action.action_mapping.map((m, i) => (
|
| 224 |
+
<div key={i} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
|
| 225 |
+
<div style={{
|
| 226 |
+
width: 20, height: 20, borderRadius: '50%', background: 'var(--blue-accent)',
|
| 227 |
+
display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff',
|
| 228 |
+
fontSize: 10, fontWeight: 900, flexShrink: 0, marginTop: 2
|
| 229 |
+
}}>
|
| 230 |
+
{i + 1}
|
| 231 |
+
</div>
|
| 232 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
| 233 |
+
<div style={{ fontSize: 12, fontWeight: 700, color: 'var(--text-primary)' }}>{m.action}</div>
|
| 234 |
+
<div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>Target: {m.condition}</div>
|
| 235 |
+
</div>
|
| 236 |
+
</div>
|
| 237 |
+
))}
|
| 238 |
+
{action.monitoring?.map((mon, i) => (
|
| 239 |
+
<div key={`mon-${i}`} style={{ fontSize: 11, color: 'var(--text-secondary)', display: 'flex', alignItems: 'center', gap: 6, marginTop: 4 }}>
|
| 240 |
+
<div style={{ width: 4, height: 4, borderRadius: '50%', background: 'var(--blue-accent)' }} />
|
| 241 |
+
{mon}
|
| 242 |
+
</div>
|
| 243 |
+
))}
|
| 244 |
+
</div>
|
| 245 |
+
</SectionBlock>
|
| 246 |
)}
|
| 247 |
|
| 248 |
+
{/* Clinical Summary */}
|
| 249 |
+
{action.clinical_summary && (
|
| 250 |
+
<SectionBlock title="Clinical Synthesis" icon={<FileText size={14}/>} accent="var(--purple-ai)">
|
| 251 |
<div style={{
|
| 252 |
+
fontSize: 12, lineHeight: 1.6, color: 'var(--text-secondary)', fontStyle: 'italic',
|
| 253 |
+
background: 'var(--bg-surface)', padding: '12px 14px', borderRadius: 10, border: '1px solid var(--border-subtle)'
|
| 254 |
}}>
|
| 255 |
+
"{action.clinical_summary}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
</div>
|
| 257 |
+
</SectionBlock>
|
| 258 |
)}
|
| 259 |
|
| 260 |
+
{/* Safety Checker */}
|
| 261 |
+
<div style={{ marginTop: 20 }}>
|
| 262 |
+
<TreatmentChecker patientId={patient?.id} />
|
| 263 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
+
{/* Expert Correlation Log */}
|
| 266 |
+
{action.agent_reasoning && (
|
| 267 |
+
<div style={{ marginTop: 24, paddingTop: 16, borderTop: '1px solid var(--border-subtle)' }}>
|
| 268 |
+
<div style={{ fontSize: 10, fontWeight: 800, color: 'var(--text-tertiary)', textTransform: 'uppercase', marginBottom: 10, display: 'flex', alignItems: 'center', gap: 6 }}>
|
| 269 |
+
<Zap size={10} /> Agent Reasoning Pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
</div>
|
| 271 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
| 272 |
+
{action.agent_reasoning.map((r, i) => (
|
| 273 |
+
<div key={i} style={{ fontSize: 10, color: 'var(--text-tertiary)', display: 'flex', gap: 8 }}>
|
| 274 |
+
<span style={{ color: 'var(--purple-ai)' }}>▶</span>
|
| 275 |
+
<span>{r}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
</div>
|
| 277 |
+
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
</div>
|
|
|
|
| 279 |
</div>
|
| 280 |
)}
|
| 281 |
+
</div>
|
| 282 |
+
</div>
|
| 283 |
+
);
|
| 284 |
+
}
|
| 285 |
|
| 286 |
+
function SectionBlock({ title, icon, children, accent = 'var(--blue-accent)' }) {
|
| 287 |
+
return (
|
| 288 |
+
<div style={{ marginBottom: 24 }}>
|
| 289 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12, borderBottom: `1px solid ${accent}20`, paddingBottom: 6 }}>
|
| 290 |
+
<div style={{ color: accent }}>{icon}</div>
|
| 291 |
+
<span style={{ fontSize: 11, fontWeight: 900, textTransform: 'uppercase', letterSpacing: '0.08em', color: 'var(--text-primary)' }}>{title}</span>
|
| 292 |
</div>
|
| 293 |
+
{children}
|
| 294 |
</div>
|
| 295 |
);
|
| 296 |
}
|