Update pages/02_Workflow_UI.py
Browse files- pages/02_Workflow_UI.py +20 -1
pages/02_Workflow_UI.py
CHANGED
|
@@ -314,11 +314,21 @@ with tab_spec:
|
|
| 314 |
st.info("Submit the referral on the PCP tab to activate Specialist Review.")
|
| 315 |
st.stop()
|
| 316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
read_only = status == "completed"
|
| 318 |
|
| 319 |
st.subheader("SOAP Draft")
|
| 320 |
-
soap = case.get("soap_draft", {}) or {"subjective": "", "objective": "", "assessment": "", "plan": ""}
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
# Generate SOAP if needed
|
| 323 |
gen_needed = (status == "submitted") and (not any(soap.get(k, "").strip() for k in ("subjective", "objective", "assessment", "plan")))
|
| 324 |
if gen_needed and not read_only:
|
|
@@ -351,6 +361,8 @@ with tab_spec:
|
|
| 351 |
"soap_draft": {"subjective": subj.strip(), "objective": obj.strip(), "assessment": assess.strip(), "plan": plan.strip()},
|
| 352 |
"explainability": explain_patch,
|
| 353 |
})
|
|
|
|
|
|
|
| 354 |
st.rerun()
|
| 355 |
|
| 356 |
# Editable fields
|
|
@@ -383,6 +395,13 @@ with tab_spec:
|
|
| 383 |
|
| 384 |
stale = is_stale(assess_new, assess_hash0) or is_stale(plan_new, plan_hash0)
|
| 385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
if not stale and (normalize_text(assess_new + plan_new)):
|
| 387 |
# Use stored bullets if available; else compute and persist once
|
| 388 |
stored_points = (exp.get("guideline_rationale") or [])
|
|
|
|
| 314 |
st.info("Submit the referral on the PCP tab to activate Specialist Review.")
|
| 315 |
st.stop()
|
| 316 |
|
| 317 |
+
# Prevent guideline rationale or re-render during immediate SOAP rerun
|
| 318 |
+
if st.session_state.pop("_suppress_guidelines", False):
|
| 319 |
+
st.stop()
|
| 320 |
+
|
| 321 |
+
|
| 322 |
read_only = status == "completed"
|
| 323 |
|
| 324 |
st.subheader("SOAP Draft")
|
|
|
|
| 325 |
|
| 326 |
+
# Cache SOAP in session to avoid stale disk reads
|
| 327 |
+
st.session_state[f"soap_{selected}"] = case.get("soap_draft", {})
|
| 328 |
+
soap = st.session_state[f"soap_{selected}"]
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
|
| 332 |
# Generate SOAP if needed
|
| 333 |
gen_needed = (status == "submitted") and (not any(soap.get(k, "").strip() for k in ("subjective", "objective", "assessment", "plan")))
|
| 334 |
if gen_needed and not read_only:
|
|
|
|
| 361 |
"soap_draft": {"subjective": subj.strip(), "objective": obj.strip(), "assessment": assess.strip(), "plan": plan.strip()},
|
| 362 |
"explainability": explain_patch,
|
| 363 |
})
|
| 364 |
+
# Set flag so guideline rationale doesn't run on immediate rerun
|
| 365 |
+
st.session_state["_suppress_guidelines"] = True
|
| 366 |
st.rerun()
|
| 367 |
|
| 368 |
# Editable fields
|
|
|
|
| 395 |
|
| 396 |
stale = is_stale(assess_new, assess_hash0) or is_stale(plan_new, plan_hash0)
|
| 397 |
|
| 398 |
+
# Guard: skip guideline generation until SOAP fields exist
|
| 399 |
+
if not any((soap.get(k, "") or "").strip() for k in ("subjective", "objective", "assessment", "plan")):
|
| 400 |
+
st.info("Generate SOAP draft first to enable guideline rationale.")
|
| 401 |
+
st.stop()
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
|
| 405 |
if not stale and (normalize_text(assess_new + plan_new)):
|
| 406 |
# Use stored bullets if available; else compute and persist once
|
| 407 |
stored_points = (exp.get("guideline_rationale") or [])
|