Update pages/02_Workflow_UI.py
Browse files- pages/02_Workflow_UI.py +24 -9
pages/02_Workflow_UI.py
CHANGED
|
@@ -231,9 +231,10 @@ _case_summary_header(case)
|
|
| 231 |
tab_pcp, tab_spec = st.tabs(["PCP Referral", "Specialist Review"])
|
| 232 |
|
| 233 |
# ===== PCP Referral Tab =====
|
|
|
|
|
|
|
| 234 |
with tab_pcp:
|
| 235 |
is_draft = case.get("status") == "draft"
|
| 236 |
-
|
| 237 |
p = case.get("patient", {}) or {}
|
| 238 |
c = case.get("consult", {}) or {}
|
| 239 |
|
|
@@ -241,14 +242,23 @@ with tab_pcp:
|
|
| 241 |
with c1:
|
| 242 |
patient_name = st.text_input("Patient Name", value=p.get("name", ""), disabled=not is_draft, key=f"pt_name_{selected}")
|
| 243 |
consult_q = st.text_area("Consult Question", value=c.get("question", ""), height=80, disabled=not is_draft, key=f"q_{selected}")
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
with c2:
|
| 246 |
age = st.number_input("Age", min_value=0, max_value=120, value=int(p.get("age") or 0), disabled=not is_draft, key=f"age_{selected}")
|
| 247 |
-
sex = st.selectbox("Sex",
|
| 248 |
specialty = st.text_input("Specialty", value=c.get("specialty", "") or "", disabled=not is_draft, key=f"spec_{selected}")
|
| 249 |
with c3:
|
| 250 |
-
|
| 251 |
-
labs = st.text_area("Labs", value=c.get("labs", ""), height=
|
| 252 |
|
| 253 |
consent = bool(c.get("consent_obtained", False))
|
| 254 |
consent = st.checkbox("Patient consent obtained", value=consent, disabled=not is_draft, key=f"consent_{selected}")
|
|
@@ -256,8 +266,7 @@ with tab_pcp:
|
|
| 256 |
col = st.columns([1,1,6])[0]
|
| 257 |
with col:
|
| 258 |
if is_draft:
|
| 259 |
-
|
| 260 |
-
if submit_clicked:
|
| 261 |
if not consent:
|
| 262 |
st.error("Consent is required to submit.")
|
| 263 |
else:
|
|
@@ -266,8 +275,8 @@ with tab_pcp:
|
|
| 266 |
"consult": {
|
| 267 |
"specialty": specialty.strip(),
|
| 268 |
"question": consult_q.strip(),
|
| 269 |
-
"
|
| 270 |
-
"medications":
|
| 271 |
"labs": labs.strip(),
|
| 272 |
"consent_obtained": True,
|
| 273 |
},
|
|
@@ -279,6 +288,7 @@ with tab_pcp:
|
|
| 279 |
else:
|
| 280 |
st.info("Referral is not editable (status is In Review or Completed).")
|
| 281 |
|
|
|
|
| 282 |
# ===== Specialist Review Tab =====
|
| 283 |
with tab_spec:
|
| 284 |
status = case.get("status")
|
|
@@ -366,6 +376,11 @@ with tab_spec:
|
|
| 366 |
# Persist generated draft and mark unmodified so chips/guidelines show
|
| 367 |
store.update_case(selected, {"soap_draft": {"subjective": subj, "objective": obj, "assessment": assess, "plan": plan}, "explainability": {"manually_modified": False}})
|
| 368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
c1, c2 = st.columns(2)
|
| 370 |
with c1:
|
| 371 |
subj_new = st.text_area("Subjective", value=soap.get("subjective",""), height=140, disabled=read_only, key=f"subj_{selected}")
|
|
|
|
| 231 |
tab_pcp, tab_spec = st.tabs(["PCP Referral", "Specialist Review"])
|
| 232 |
|
| 233 |
# ===== PCP Referral Tab =====
|
| 234 |
+
# Inside the PCP Referral tab (replace your existing block):
|
| 235 |
+
|
| 236 |
with tab_pcp:
|
| 237 |
is_draft = case.get("status") == "draft"
|
|
|
|
| 238 |
p = case.get("patient", {}) or {}
|
| 239 |
c = case.get("consult", {}) or {}
|
| 240 |
|
|
|
|
| 242 |
with c1:
|
| 243 |
patient_name = st.text_input("Patient Name", value=p.get("name", ""), disabled=not is_draft, key=f"pt_name_{selected}")
|
| 244 |
consult_q = st.text_area("Consult Question", value=c.get("question", ""), height=80, disabled=not is_draft, key=f"q_{selected}")
|
| 245 |
+
clinical_summary = st.text_area(
|
| 246 |
+
"Clinical Summary",
|
| 247 |
+
value=c.get("summary", "") or c.get("history", ""),
|
| 248 |
+
height=160,
|
| 249 |
+
placeholder=("Example: 72yo man with NYHA class III HFrEF (EF 30%). "
|
| 250 |
+
"BP 110/70 HR 62. Echo: mild MR, no effusion. "
|
| 251 |
+
"BNP 230; here for med optimization."),
|
| 252 |
+
disabled=not is_draft,
|
| 253 |
+
key=f"summary_{selected}",
|
| 254 |
+
)
|
| 255 |
with c2:
|
| 256 |
age = st.number_input("Age", min_value=0, max_value=120, value=int(p.get("age") or 0), disabled=not is_draft, key=f"age_{selected}")
|
| 257 |
+
sex = st.selectbox("Sex", ["F", "M", "Other", ""], index=["F","M","Other",""].index(p.get("sex") or ""), disabled=not is_draft, key=f"sex_{selected}")
|
| 258 |
specialty = st.text_input("Specialty", value=c.get("specialty", "") or "", disabled=not is_draft, key=f"spec_{selected}")
|
| 259 |
with c3:
|
| 260 |
+
medications = st.text_area("Medications", value=c.get("medications", ""), height=100, disabled=not is_draft, key=f"meds_{selected}")
|
| 261 |
+
labs = st.text_area("Labs / Key Values", value=c.get("labs", ""), height=100, disabled=not is_draft, key=f"labs_{selected}")
|
| 262 |
|
| 263 |
consent = bool(c.get("consent_obtained", False))
|
| 264 |
consent = st.checkbox("Patient consent obtained", value=consent, disabled=not is_draft, key=f"consent_{selected}")
|
|
|
|
| 266 |
col = st.columns([1,1,6])[0]
|
| 267 |
with col:
|
| 268 |
if is_draft:
|
| 269 |
+
if st.button("Submit Referral", type="primary", use_container_width=True, key=f"submit_{selected}"):
|
|
|
|
| 270 |
if not consent:
|
| 271 |
st.error("Consent is required to submit.")
|
| 272 |
else:
|
|
|
|
| 275 |
"consult": {
|
| 276 |
"specialty": specialty.strip(),
|
| 277 |
"question": consult_q.strip(),
|
| 278 |
+
"summary": clinical_summary.strip(),
|
| 279 |
+
"medications": medications.strip(),
|
| 280 |
"labs": labs.strip(),
|
| 281 |
"consent_obtained": True,
|
| 282 |
},
|
|
|
|
| 288 |
else:
|
| 289 |
st.info("Referral is not editable (status is In Review or Completed).")
|
| 290 |
|
| 291 |
+
|
| 292 |
# ===== Specialist Review Tab =====
|
| 293 |
with tab_spec:
|
| 294 |
status = case.get("status")
|
|
|
|
| 376 |
# Persist generated draft and mark unmodified so chips/guidelines show
|
| 377 |
store.update_case(selected, {"soap_draft": {"subjective": subj, "objective": obj, "assessment": assess, "plan": plan}, "explainability": {"manually_modified": False}})
|
| 378 |
|
| 379 |
+
# Refresh case so UI shows the new SOAP fields immediately
|
| 380 |
+
case = _get_case(selected)
|
| 381 |
+
soap = case.get("soap_draft", {})
|
| 382 |
+
st.success("SOAP draft generated and saved. You can review it below.")
|
| 383 |
+
|
| 384 |
c1, c2 = st.columns(2)
|
| 385 |
with c1:
|
| 386 |
subj_new = st.text_area("Subjective", value=soap.get("subjective",""), height=140, disabled=read_only, key=f"subj_{selected}")
|