diff --git a/README.md b/README.md index f69d06d274fdfd38171a2abafd1655189f86ddc1..7d423e287937db60a7f96bee3a23f3f14eaacdb7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ ---- -license: apache-2.0 -title: MediAssist v14.3 — Chat + RAG + PDF -sdk: streamlit -colorFrom: purple -colorTo: indigo -short_description: The MedicalAI system combines **ClinicalBERT**, **RAG retrie ---- \ No newline at end of file +# MediAssist v14.4 — Stable (Router-powered) +- Uses HF Router text-generation endpoint (default: GPT-OSS-120B) +- Robust chat handler with non-JSON and 404 handling +- RAG with unique IDs to prevent Chroma DuplicateIDError +- OPD + Citations + PDF export +- Diagnostics page for quick endpoint tests + +## HF Space Setup +1. Create Space (SDK: Streamlit) and upload this ZIP. +2. Settings → Secrets: `HF_API_TOKEN` +3. Settings → Variables (optional): + - `HF_CHAT_ENDPOINT` = https://router.huggingface.co/hf-inference/text-generation/openai/gpt-oss-120b +4. Sidebar → Seed / Refresh RAG Index (once) +5. Chat, generate OPD, and export PDF. + +Generated: 2025-12-06 diff --git a/app.py b/app.py index 897d4f7f82d9a615c62566e08fb1735593aa0a1e..54f1595bc1f3524af32d3489903dfee59a57feba 100644 --- a/app.py +++ b/app.py @@ -1,47 +1,48 @@ -import os, json, time, streamlit as st +import os, json, streamlit as st from backend.rag_engine import get_embedder, get_chroma, retrieve, seed_index from backend.soap_generator import compose_soap from backend.pdf_utils import generate_pdf from backend.chat_endpoint import chat from utils.constants import DOCS_DIR, RETRIEVAL_K_DEFAULT -st.set_page_config(page_title="MediAssist v14.3 — Clinical AI", page_icon="🩺", layout="wide") +st.set_page_config(page_title="MediAssist v14.4 — Clinical AI (Stable)", page_icon="🩺", layout="wide") @st.cache_resource(show_spinner=False) def _embedder(): return get_embedder() - @st.cache_resource(show_spinner=False) def _col(): return get_chroma()[1] with st.sidebar: st.subheader("Controls") if st.button("Seed / Refresh RAG Index"): - with st.spinner("Indexing..."): + with st.spinner("Indexing guidelines..."): n = seed_index(_col(), _embedder(), DOCS_DIR) - st.success(f"Indexed {n} chunks from {DOCS_DIR}") - st.caption("Upload .txt/.md to data/guidelines// then reseed.") + st.success(f"Indexed {n} chunks.") + st.caption("Upload .txt/.md into data/guidelines// and reseed.") -st.title("🩺 MediAssist v14.3 — Clinical AI for Doctors") -st.caption("Chat + RAG + PDF · Uses HF Endpoint (set HF_API_TOKEN & HF_CHAT_ENDPOINT).") +st.title("🩺 MediAssist v14.4 — Clinical AI (Stable)") +st.caption("HF Router endpoint + RAG + PDF.") narrative = st.text_area("Patient narrative", height=140, placeholder="e.g., 10 days period delay, nausea, mild cramps") k = st.slider("🔍 Results to retrieve", 1, 10, RETRIEVAL_K_DEFAULT) -col1, col2 = st.columns(2) +c1, c2 = st.columns(2) if st.button("🧾 Generate OPD + Citations"): with st.spinner("Composing..."): items = retrieve(_col(), _embedder(), narrative, k=k) soap = compose_soap(narrative, items) - with col1: + with c1: st.subheader("SOAP JSON") st.code(json.dumps(soap, indent=2), language="json") - with col2: + with c2: st.subheader("Citations") - if not items: st.info("No citations retrieved.") - for i,it in enumerate(items,1): - st.markdown(f"**{i}. {it['title']}** \n`{it['source']}` \n> {it['text'][:400]}...") - st.divider() + if not items: + st.info("No citations retrieved.") + else: + for idx,it in enumerate(items,1): + st.markdown(f"**{idx}. {it['title']}** \n`{it['source']}` \n> {it['text'][:400]}...") + st.divider() st.markdown("---") st.subheader("💬 AI Chat") diff --git a/backend/chat_endpoint.py b/backend/chat_endpoint.py index 7206c80fb8b48a7365f881b9913852ce8b37fa62..917aafbd0af8508875cd3c62f81a57844891a6e6 100644 --- a/backend/chat_endpoint.py +++ b/backend/chat_endpoint.py @@ -9,86 +9,45 @@ def _headers(): tok = os.getenv("HF_API_TOKEN") return {"Authorization": f"Bearer {tok}","Content-Type":"application/json"} if tok else {} - def chat(user_message: str, mode: str = "patient"): url = active_chat_endpoint() headers = _headers() if not headers: return "⚠ Add HF_API_TOKEN in Settings → Secrets." - system = AI_GYNO_PERSONA_V2 + ( - "\nUse simple, reassuring language." if mode=="patient" - else "\nUse clinical language, differentials, and red flags." - ) - - payload = { - "inputs": [ - {"role": "system", "content": system}, - {"role": "user", "content": user_message} - ], - "parameters": { - "max_new_tokens": 400, - "temperature": 0.2, - "return_full_text": False - } - } - - try: - r = requests.post(url, headers=headers, json=payload, timeout=60) - except Exception as e: - return f"⚠ Network error: {str(e)}" + system = AI_GYNO_PERSONA_V2 + ("\nUse simple, supportive language." if mode=='patient' else "\nProvide differentials, initial workup, and red flags.") + prompt = f"""{system} - # --- SAFER PARSER --- - txt = r.text +Patient narrative: +{user_message} - # HTML → clear signal model is loading or wrong - if "" + return f"⚠ Non-JSON response:\n{text[:1000]}" + except Exception as e: + time.sleep(BACKOFF_SECONDS_DEFAULT * attempt) + return "❌ Endpoint unavailable after retries." diff --git a/backend/rag_engine.py b/backend/rag_engine.py index dcfcd9ec5700cec8ea2849820e1bfbc689bf8ed3..cf0cb04c4f1baec4cd6a31fe8dccb0153aa0ab52 100644 --- a/backend/rag_engine.py +++ b/backend/rag_engine.py @@ -27,6 +27,7 @@ def seed_index(col, model, root_folder: str) -> int: ids, docs, metas = [], [], [] for p in sorted(paths): title = os.path.splitext(os.path.basename(p))[0] + rel = os.path.relpath(p, DOCS_DIR).replace(os.sep, "_") # guarantee uniqueness try: with open(p, "r", encoding="utf-8") as f: txt = f.read() @@ -34,7 +35,7 @@ def seed_index(col, model, root_folder: str) -> int: continue chunks = splitter.split_text(txt) for i, ch in enumerate(chunks): - ids.append(f"{title}-{i}") + ids.append(f"{rel}-{i}") docs.append(ch) metas.append({"title": title, "source": p}) if not docs: diff --git a/backend/soap_generator.py b/backend/soap_generator.py index 4c7aa31959e4b0335cb3cec8208388601e61d497..ff9b56b144ccdf74f55f75515d4074046ecca455 100644 --- a/backend/soap_generator.py +++ b/backend/soap_generator.py @@ -5,12 +5,12 @@ def compose_soap(narrative: str, retrieved: List[Dict]) -> Dict: assessment, plan = [], ["Safety-net advice and red-flag education.", "Follow-up in 3–7 days or earlier if worse."] if any(k in text for k in ["bleed","spotting","period","menorrhagia","aub"]): assessment.append("Abnormal uterine bleeding — structural vs hormonal.") - plan.append("Urine pregnancy test if appropriate; CBC; pelvic US if indicated.") + plan.append("Urine pregnancy test; CBC; pelvic ultrasound if indicated.") if any(k in text for k in ["pelvic pain","cramp","lower abdominal pain"]): - assessment.append("Pelvic pain — rule out infection/cyst/endometriosis.") + assessment.append("Pelvic pain — r/o infection/cyst/endometriosis.") plan.append("Trial NSAIDs; pelvic exam/US if persistent.") if any(k in text for k in ["chest pain","shortness of breath","sob"]): - assessment.append("Chest pain — consider ACS/PE; triage red flags immediately.") + assessment.append("Chest pain — consider ACS/PE; triage immediately if red flags.") plan.append("ECG, vitals; urgent review if high risk.") if any(k in text for k in ["knee pain","joint","sprain","swelling","injury"]): assessment.append("MSK complaint — ortho evaluation.") diff --git a/data/guidelines/internal_med/001_Hypertension.txt b/data/guidelines/internal_med/001_Hypertension.txt new file mode 100644 index 0000000000000000000000000000000000000000..203fb8433d30ca361c96ed7ab1ef919de264b45b --- /dev/null +++ b/data/guidelines/internal_med/001_Hypertension.txt @@ -0,0 +1,6 @@ +Title: Chest Pain — Internal Medicine Guideline (1) +Summary: Evidence-aligned triage and management for chest pain in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/002_Hypertension.txt b/data/guidelines/internal_med/002_Hypertension.txt new file mode 100644 index 0000000000000000000000000000000000000000..8c103eaf59b772f6037df3783b64de83b110e0af --- /dev/null +++ b/data/guidelines/internal_med/002_Hypertension.txt @@ -0,0 +1,6 @@ +Title: Asthma — Internal Medicine Guideline (2) +Summary: Evidence-aligned triage and management for asthma in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/003_Fever_of_Unknown_Origin.txt b/data/guidelines/internal_med/003_Fever_of_Unknown_Origin.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea19bd3832a23edfb39a1add98ca455d3a0b6651 --- /dev/null +++ b/data/guidelines/internal_med/003_Fever_of_Unknown_Origin.txt @@ -0,0 +1,6 @@ +Title: Asthma — Internal Medicine Guideline (3) +Summary: Evidence-aligned triage and management for asthma in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/004_Asthma.txt b/data/guidelines/internal_med/004_Asthma.txt new file mode 100644 index 0000000000000000000000000000000000000000..34457c683207e8a939120370fb42c3805c9a294a --- /dev/null +++ b/data/guidelines/internal_med/004_Asthma.txt @@ -0,0 +1,6 @@ +Title: Fever of Unknown Origin — Internal Medicine Guideline (4) +Summary: Evidence-aligned triage and management for fever of unknown origin in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/005_Fever_of_Unknown_Origin.txt b/data/guidelines/internal_med/005_Fever_of_Unknown_Origin.txt new file mode 100644 index 0000000000000000000000000000000000000000..3f606113106f722f194e6536b6464041f7c36ce9 --- /dev/null +++ b/data/guidelines/internal_med/005_Fever_of_Unknown_Origin.txt @@ -0,0 +1,6 @@ +Title: Hypertension — Internal Medicine Guideline (5) +Summary: Evidence-aligned triage and management for hypertension in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/006_COPD_Exacerbation.txt b/data/guidelines/internal_med/006_COPD_Exacerbation.txt new file mode 100644 index 0000000000000000000000000000000000000000..287efc17400b724cf447e2df8ec9ab582b5df65a --- /dev/null +++ b/data/guidelines/internal_med/006_COPD_Exacerbation.txt @@ -0,0 +1,6 @@ +Title: UTI — Internal Medicine Guideline (6) +Summary: Evidence-aligned triage and management for uti in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/007_Asthma.txt b/data/guidelines/internal_med/007_Asthma.txt new file mode 100644 index 0000000000000000000000000000000000000000..2630cbb0c1d473a24a51983b7091a354f5639aaf --- /dev/null +++ b/data/guidelines/internal_med/007_Asthma.txt @@ -0,0 +1,6 @@ +Title: UTI — Internal Medicine Guideline (7) +Summary: Evidence-aligned triage and management for uti in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/008_Thyroid_Dysfunction.txt b/data/guidelines/internal_med/008_Thyroid_Dysfunction.txt new file mode 100644 index 0000000000000000000000000000000000000000..5c126406eb76d21b5057c59eb2520613cc4df9d2 --- /dev/null +++ b/data/guidelines/internal_med/008_Thyroid_Dysfunction.txt @@ -0,0 +1,6 @@ +Title: COPD Exacerbation — Internal Medicine Guideline (8) +Summary: Evidence-aligned triage and management for copd exacerbation in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/009_Diabetes_Mellitus.txt b/data/guidelines/internal_med/009_Diabetes_Mellitus.txt new file mode 100644 index 0000000000000000000000000000000000000000..8d34ae2b887f50edd1e16b7ece155413ec764852 --- /dev/null +++ b/data/guidelines/internal_med/009_Diabetes_Mellitus.txt @@ -0,0 +1,6 @@ +Title: Anemia — Internal Medicine Guideline (9) +Summary: Evidence-aligned triage and management for anemia in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/010_Thyroid_Dysfunction.txt b/data/guidelines/internal_med/010_Thyroid_Dysfunction.txt new file mode 100644 index 0000000000000000000000000000000000000000..c87d8244a4fb88149dce8145fce273697b4f0fe8 --- /dev/null +++ b/data/guidelines/internal_med/010_Thyroid_Dysfunction.txt @@ -0,0 +1,6 @@ +Title: Diabetes Mellitus — Internal Medicine Guideline (10) +Summary: Evidence-aligned triage and management for diabetes mellitus in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/011_Fever_of_Unknown_Origin.txt b/data/guidelines/internal_med/011_Fever_of_Unknown_Origin.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e4dcce8a3103f4732ffe169297aa5fbcae7ed70 --- /dev/null +++ b/data/guidelines/internal_med/011_Fever_of_Unknown_Origin.txt @@ -0,0 +1,6 @@ +Title: AKI — Internal Medicine Guideline (11) +Summary: Evidence-aligned triage and management for aki in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/012_Diabetes_Mellitus.txt b/data/guidelines/internal_med/012_Diabetes_Mellitus.txt new file mode 100644 index 0000000000000000000000000000000000000000..974471a84a5070eaf26bbd8b5d435f7bcbf1e386 --- /dev/null +++ b/data/guidelines/internal_med/012_Diabetes_Mellitus.txt @@ -0,0 +1,6 @@ +Title: AKI — Internal Medicine Guideline (12) +Summary: Evidence-aligned triage and management for aki in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/013_UTI.txt b/data/guidelines/internal_med/013_UTI.txt new file mode 100644 index 0000000000000000000000000000000000000000..3922f669c18410ac0dc410dc6635ba3974285b3a --- /dev/null +++ b/data/guidelines/internal_med/013_UTI.txt @@ -0,0 +1,6 @@ +Title: Diabetes Mellitus — Internal Medicine Guideline (13) +Summary: Evidence-aligned triage and management for diabetes mellitus in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/014_Asthma.txt b/data/guidelines/internal_med/014_Asthma.txt new file mode 100644 index 0000000000000000000000000000000000000000..affb53cccb89cff58a62392726ed7f3de19bbe20 --- /dev/null +++ b/data/guidelines/internal_med/014_Asthma.txt @@ -0,0 +1,6 @@ +Title: Diabetes Mellitus — Internal Medicine Guideline (14) +Summary: Evidence-aligned triage and management for diabetes mellitus in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/015_UTI.txt b/data/guidelines/internal_med/015_UTI.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ba27c480188c71aca4672a8b8d335b15633e1b5 --- /dev/null +++ b/data/guidelines/internal_med/015_UTI.txt @@ -0,0 +1,6 @@ +Title: AKI — Internal Medicine Guideline (15) +Summary: Evidence-aligned triage and management for aki in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/016_Anemia.txt b/data/guidelines/internal_med/016_Anemia.txt index 829a217024e1f5940584cd3319c76e67bb8a3e8c..ab118b37d702fc2535e2d604f23e8c01d06e586a 100644 --- a/data/guidelines/internal_med/016_Anemia.txt +++ b/data/guidelines/internal_med/016_Anemia.txt @@ -1,34 +1,6 @@ -Title: Anemia — Internal Medicine Guideline (16) - -Clinical Summary: -Evidence-aligned approach to anemia in Internal Medicine. Prioritize red flags, history, and targeted exam; use testing judiciously. - -Symptoms: -- Pattern, onset, severity, modifiers -- Associated: fever, weight loss, bleeding, dyspnea -- Risks: comorbidities, medications, family history - -Differentials: -- Common -- Less common -- Must-not-miss (red flag) - -Investigations: -- First-line labs -- Imaging when indicated -- Decision thresholds - -Management: -- Conservative measures -- Pharmacologic options -- Escalation criteria - -Red Flags: -- Syncope, severe pain, hemodynamic instability -- New neurologic deficits -- Rapid progression or systemic toxicity - -Follow-Up: -- Time-bounded review -- Safety-net advice -- When to return earlier \ No newline at end of file +Title: Asthma — Internal Medicine Guideline (16) +Summary: Evidence-aligned triage and management for asthma in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/017_COPD_Exacerbation.txt b/data/guidelines/internal_med/017_COPD_Exacerbation.txt new file mode 100644 index 0000000000000000000000000000000000000000..e3c368686eea2ad7c6af72307aa8b121c9558720 --- /dev/null +++ b/data/guidelines/internal_med/017_COPD_Exacerbation.txt @@ -0,0 +1,6 @@ +Title: Thyroid Dysfunction — Internal Medicine Guideline (17) +Summary: Evidence-aligned triage and management for thyroid dysfunction in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/018_COPD_Exacerbation.txt b/data/guidelines/internal_med/018_COPD_Exacerbation.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ee50a9797500f9ffd14701c70bf307b60c07eae --- /dev/null +++ b/data/guidelines/internal_med/018_COPD_Exacerbation.txt @@ -0,0 +1,6 @@ +Title: Asthma — Internal Medicine Guideline (18) +Summary: Evidence-aligned triage and management for asthma in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/019_Asthma.txt b/data/guidelines/internal_med/019_Asthma.txt index 025d02b6583f8f9d71b70b385d44b1a6dde3a58c..8fa5931bda024689c42d3a0e26310531c38856bf 100644 --- a/data/guidelines/internal_med/019_Asthma.txt +++ b/data/guidelines/internal_med/019_Asthma.txt @@ -1,34 +1,6 @@ Title: Hypertension — Internal Medicine Guideline (19) - -Clinical Summary: -Evidence-aligned approach to hypertension in Internal Medicine. Prioritize red flags, history, and targeted exam; use testing judiciously. - -Symptoms: -- Pattern, onset, severity, modifiers -- Associated: fever, weight loss, bleeding, dyspnea -- Risks: comorbidities, medications, family history - -Differentials: -- Common -- Less common -- Must-not-miss (red flag) - -Investigations: -- First-line labs -- Imaging when indicated -- Decision thresholds - -Management: -- Conservative measures -- Pharmacologic options -- Escalation criteria - -Red Flags: -- Syncope, severe pain, hemodynamic instability -- New neurologic deficits -- Rapid progression or systemic toxicity - -Follow-Up: -- Time-bounded review -- Safety-net advice -- When to return earlier \ No newline at end of file +Summary: Evidence-aligned triage and management for hypertension in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/internal_med/020_Fever_of_Unknown_Origin.txt b/data/guidelines/internal_med/020_Fever_of_Unknown_Origin.txt new file mode 100644 index 0000000000000000000000000000000000000000..d724a32182af5cafd32999b47a85455aafd52105 --- /dev/null +++ b/data/guidelines/internal_med/020_Fever_of_Unknown_Origin.txt @@ -0,0 +1,6 @@ +Title: UTI — Internal Medicine Guideline (20) +Summary: Evidence-aligned triage and management for uti in Internal Medicine. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/001_AUB.txt b/data/guidelines/obgyn/001_AUB.txt index 77e46282adc9b1abdc5541f028bfb29d9b31e5c4..cc037d58fd1863ca9a4c92c6594e67b6552a32d6 100644 --- a/data/guidelines/obgyn/001_AUB.txt +++ b/data/guidelines/obgyn/001_AUB.txt @@ -1,34 +1,6 @@ -Title: Infertility Workup — OBGYN Guideline (1) - -Clinical Summary: -Evidence-aligned approach to infertility workup in OBGYN. Prioritize red flags, history, and targeted exam; use testing judiciously. - -Symptoms: -- Pattern, onset, severity, modifiers -- Associated: fever, weight loss, bleeding, dyspnea -- Risks: comorbidities, medications, family history - -Differentials: -- Common -- Less common -- Must-not-miss (red flag) - -Investigations: -- First-line labs -- Imaging when indicated -- Decision thresholds - -Management: -- Conservative measures -- Pharmacologic options -- Escalation criteria - -Red Flags: -- Syncope, severe pain, hemodynamic instability -- New neurologic deficits -- Rapid progression or systemic toxicity - -Follow-Up: -- Time-bounded review -- Safety-net advice -- When to return earlier \ No newline at end of file +Title: Antenatal Care — OBGYN Guideline (1) +Summary: Evidence-aligned triage and management for antenatal care in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/002_Fibroids.txt b/data/guidelines/obgyn/002_Fibroids.txt new file mode 100644 index 0000000000000000000000000000000000000000..b4cfaa54c7d955e1c511c0393d22214d7a38cd25 --- /dev/null +++ b/data/guidelines/obgyn/002_Fibroids.txt @@ -0,0 +1,6 @@ +Title: Antenatal Care — OBGYN Guideline (2) +Summary: Evidence-aligned triage and management for antenatal care in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/003_PCOS.txt b/data/guidelines/obgyn/003_PCOS.txt new file mode 100644 index 0000000000000000000000000000000000000000..9707b80b4cc57e23a96abb73a0e237c5c8ba5650 --- /dev/null +++ b/data/guidelines/obgyn/003_PCOS.txt @@ -0,0 +1,6 @@ +Title: Fibroids — OBGYN Guideline (3) +Summary: Evidence-aligned triage and management for fibroids in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/004_Antenatal_Care.txt b/data/guidelines/obgyn/004_Antenatal_Care.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f8d327474e4a030a9bb683a05ed764e9fd2db0d --- /dev/null +++ b/data/guidelines/obgyn/004_Antenatal_Care.txt @@ -0,0 +1,6 @@ +Title: Ectopic Pregnancy — OBGYN Guideline (4) +Summary: Evidence-aligned triage and management for ectopic pregnancy in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/005_Endometriosis.txt b/data/guidelines/obgyn/005_Endometriosis.txt new file mode 100644 index 0000000000000000000000000000000000000000..4361461ab2075d562cfbcc3bf75e78fa287b2844 --- /dev/null +++ b/data/guidelines/obgyn/005_Endometriosis.txt @@ -0,0 +1,6 @@ +Title: Endometriosis — OBGYN Guideline (5) +Summary: Evidence-aligned triage and management for endometriosis in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/006_Miscarriage.txt b/data/guidelines/obgyn/006_Miscarriage.txt new file mode 100644 index 0000000000000000000000000000000000000000..4534fa571d16e6a9c90a321ff378312d2b6a0b3f --- /dev/null +++ b/data/guidelines/obgyn/006_Miscarriage.txt @@ -0,0 +1,6 @@ +Title: Antenatal Care — OBGYN Guideline (6) +Summary: Evidence-aligned triage and management for antenatal care in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/007_Dysmenorrhea.txt b/data/guidelines/obgyn/007_Dysmenorrhea.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f93892b4ac559334b0bea5b3da0c8e1e9eb58de --- /dev/null +++ b/data/guidelines/obgyn/007_Dysmenorrhea.txt @@ -0,0 +1,6 @@ +Title: AUB — OBGYN Guideline (7) +Summary: Evidence-aligned triage and management for aub in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/008_Infertility_Workup.txt b/data/guidelines/obgyn/008_Infertility_Workup.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c00d4b521f23ce60121f983dbfd3bff68e17faf --- /dev/null +++ b/data/guidelines/obgyn/008_Infertility_Workup.txt @@ -0,0 +1,6 @@ +Title: PCOS — OBGYN Guideline (8) +Summary: Evidence-aligned triage and management for pcos in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/009_Infertility_Workup.txt b/data/guidelines/obgyn/009_Infertility_Workup.txt new file mode 100644 index 0000000000000000000000000000000000000000..782e5382489483c27c87bc11a0ece84a1fd1b07f --- /dev/null +++ b/data/guidelines/obgyn/009_Infertility_Workup.txt @@ -0,0 +1,6 @@ +Title: Infertility Workup — OBGYN Guideline (9) +Summary: Evidence-aligned triage and management for infertility workup in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/010_Miscarriage.txt b/data/guidelines/obgyn/010_Miscarriage.txt new file mode 100644 index 0000000000000000000000000000000000000000..3941cca275382131d3255a22b860425a220738c8 --- /dev/null +++ b/data/guidelines/obgyn/010_Miscarriage.txt @@ -0,0 +1,6 @@ +Title: PCOS — OBGYN Guideline (10) +Summary: Evidence-aligned triage and management for pcos in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/011_Fibroids.txt b/data/guidelines/obgyn/011_Fibroids.txt new file mode 100644 index 0000000000000000000000000000000000000000..4a31e4ff57c8d3e439204c58cb525bf8128918f8 --- /dev/null +++ b/data/guidelines/obgyn/011_Fibroids.txt @@ -0,0 +1,6 @@ +Title: Ectopic Pregnancy — OBGYN Guideline (11) +Summary: Evidence-aligned triage and management for ectopic pregnancy in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/012_Dysmenorrhea.txt b/data/guidelines/obgyn/012_Dysmenorrhea.txt new file mode 100644 index 0000000000000000000000000000000000000000..022d0010e86738318678f07d825845ad3d8b0258 --- /dev/null +++ b/data/guidelines/obgyn/012_Dysmenorrhea.txt @@ -0,0 +1,6 @@ +Title: Infertility Workup — OBGYN Guideline (12) +Summary: Evidence-aligned triage and management for infertility workup in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/013_Antenatal_Care.txt b/data/guidelines/obgyn/013_Antenatal_Care.txt new file mode 100644 index 0000000000000000000000000000000000000000..8642dbad57b9083d3d951e843d4ef2029e878ac3 --- /dev/null +++ b/data/guidelines/obgyn/013_Antenatal_Care.txt @@ -0,0 +1,6 @@ +Title: Dysmenorrhea — OBGYN Guideline (13) +Summary: Evidence-aligned triage and management for dysmenorrhea in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/014_Adenomyosis.txt b/data/guidelines/obgyn/014_Adenomyosis.txt new file mode 100644 index 0000000000000000000000000000000000000000..e6cdeb408b0e4e8986a267e19abb5fccc164bf7d --- /dev/null +++ b/data/guidelines/obgyn/014_Adenomyosis.txt @@ -0,0 +1,6 @@ +Title: Antenatal Care — OBGYN Guideline (14) +Summary: Evidence-aligned triage and management for antenatal care in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/015_Infertility_Workup.txt b/data/guidelines/obgyn/015_Infertility_Workup.txt new file mode 100644 index 0000000000000000000000000000000000000000..c8c04e883ebc72c49131b9dcfd175f829c315f39 --- /dev/null +++ b/data/guidelines/obgyn/015_Infertility_Workup.txt @@ -0,0 +1,6 @@ +Title: Endometriosis — OBGYN Guideline (15) +Summary: Evidence-aligned triage and management for endometriosis in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/016_Ectopic_Pregnancy.txt b/data/guidelines/obgyn/016_Ectopic_Pregnancy.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1012b7f352d5d680a46e634b110026c8f378b88 --- /dev/null +++ b/data/guidelines/obgyn/016_Ectopic_Pregnancy.txt @@ -0,0 +1,6 @@ +Title: Endometriosis — OBGYN Guideline (16) +Summary: Evidence-aligned triage and management for endometriosis in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/017_Endometriosis.txt b/data/guidelines/obgyn/017_Endometriosis.txt new file mode 100644 index 0000000000000000000000000000000000000000..10baa70d7618495f4a6fafdb64eeca0fbe6f72fa --- /dev/null +++ b/data/guidelines/obgyn/017_Endometriosis.txt @@ -0,0 +1,6 @@ +Title: Antenatal Care — OBGYN Guideline (17) +Summary: Evidence-aligned triage and management for antenatal care in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/018_Miscarriage.txt b/data/guidelines/obgyn/018_Miscarriage.txt new file mode 100644 index 0000000000000000000000000000000000000000..061206a5938fe29e6a78356bae1d63802f920985 --- /dev/null +++ b/data/guidelines/obgyn/018_Miscarriage.txt @@ -0,0 +1,6 @@ +Title: Infertility Workup — OBGYN Guideline (18) +Summary: Evidence-aligned triage and management for infertility workup in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/019_AUB.txt b/data/guidelines/obgyn/019_AUB.txt new file mode 100644 index 0000000000000000000000000000000000000000..5e70ee0d2a0f8c89285d7503bafdc88636ed32a3 --- /dev/null +++ b/data/guidelines/obgyn/019_AUB.txt @@ -0,0 +1,6 @@ +Title: Miscarriage — OBGYN Guideline (19) +Summary: Evidence-aligned triage and management for miscarriage in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/obgyn/020_Adenomyosis.txt b/data/guidelines/obgyn/020_Adenomyosis.txt new file mode 100644 index 0000000000000000000000000000000000000000..c99b141945bcd8587cc76721d755f2b6ee59cd05 --- /dev/null +++ b/data/guidelines/obgyn/020_Adenomyosis.txt @@ -0,0 +1,6 @@ +Title: AUB — OBGYN Guideline (20) +Summary: Evidence-aligned triage and management for aub in OBGYN. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/001_ACL_Injury.txt b/data/guidelines/orthopedics/001_ACL_Injury.txt new file mode 100644 index 0000000000000000000000000000000000000000..096bdbd0f391fd4de56674dc3b4c4ed63a43d728 --- /dev/null +++ b/data/guidelines/orthopedics/001_ACL_Injury.txt @@ -0,0 +1,6 @@ +Title: Hip Fracture — Orthopedics Guideline (1) +Summary: Evidence-aligned triage and management for hip fracture in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/002_Rotator_Cuff_Tear.txt b/data/guidelines/orthopedics/002_Rotator_Cuff_Tear.txt new file mode 100644 index 0000000000000000000000000000000000000000..33603435dbff2a39a2483c1772cb84071d272975 --- /dev/null +++ b/data/guidelines/orthopedics/002_Rotator_Cuff_Tear.txt @@ -0,0 +1,6 @@ +Title: Rotator Cuff Tear — Orthopedics Guideline (2) +Summary: Evidence-aligned triage and management for rotator cuff tear in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/003_Frozen_Shoulder.txt b/data/guidelines/orthopedics/003_Frozen_Shoulder.txt new file mode 100644 index 0000000000000000000000000000000000000000..6563e888b57dcce7c16ce74349f5c824c145f1db --- /dev/null +++ b/data/guidelines/orthopedics/003_Frozen_Shoulder.txt @@ -0,0 +1,6 @@ +Title: Frozen Shoulder — Orthopedics Guideline (3) +Summary: Evidence-aligned triage and management for frozen shoulder in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/004_Low_Back_Pain.txt b/data/guidelines/orthopedics/004_Low_Back_Pain.txt new file mode 100644 index 0000000000000000000000000000000000000000..86c7609ecbc2f4ea7f794dbcb76da59299c1eae3 --- /dev/null +++ b/data/guidelines/orthopedics/004_Low_Back_Pain.txt @@ -0,0 +1,6 @@ +Title: Cervical Spondylosis — Orthopedics Guideline (4) +Summary: Evidence-aligned triage and management for cervical spondylosis in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/005_Knee_Osteoarthritis.txt b/data/guidelines/orthopedics/005_Knee_Osteoarthritis.txt new file mode 100644 index 0000000000000000000000000000000000000000..232fc67c489a72fb01c776f2943b3007c7e4196a --- /dev/null +++ b/data/guidelines/orthopedics/005_Knee_Osteoarthritis.txt @@ -0,0 +1,6 @@ +Title: Knee Osteoarthritis — Orthopedics Guideline (5) +Summary: Evidence-aligned triage and management for knee osteoarthritis in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/006_Hip_Fracture.txt b/data/guidelines/orthopedics/006_Hip_Fracture.txt new file mode 100644 index 0000000000000000000000000000000000000000..d1eab7d2a95725f22d88131c2a3946ff98919c2a --- /dev/null +++ b/data/guidelines/orthopedics/006_Hip_Fracture.txt @@ -0,0 +1,6 @@ +Title: ACL Injury — Orthopedics Guideline (6) +Summary: Evidence-aligned triage and management for acl injury in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/007_Knee_Osteoarthritis.txt b/data/guidelines/orthopedics/007_Knee_Osteoarthritis.txt new file mode 100644 index 0000000000000000000000000000000000000000..0d98679fe48c0a3782aafac81471468fe4d9f95e --- /dev/null +++ b/data/guidelines/orthopedics/007_Knee_Osteoarthritis.txt @@ -0,0 +1,6 @@ +Title: Hip Fracture — Orthopedics Guideline (7) +Summary: Evidence-aligned triage and management for hip fracture in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/008_Frozen_Shoulder.txt b/data/guidelines/orthopedics/008_Frozen_Shoulder.txt new file mode 100644 index 0000000000000000000000000000000000000000..61418d1ad93be99a111910d0df2486c5667dda57 --- /dev/null +++ b/data/guidelines/orthopedics/008_Frozen_Shoulder.txt @@ -0,0 +1,6 @@ +Title: Cervical Spondylosis — Orthopedics Guideline (8) +Summary: Evidence-aligned triage and management for cervical spondylosis in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/009_Hip_Fracture.txt b/data/guidelines/orthopedics/009_Hip_Fracture.txt new file mode 100644 index 0000000000000000000000000000000000000000..cb185fe2c386815b69dda545ffb4d66e4cda2faf --- /dev/null +++ b/data/guidelines/orthopedics/009_Hip_Fracture.txt @@ -0,0 +1,6 @@ +Title: ACL Injury — Orthopedics Guideline (9) +Summary: Evidence-aligned triage and management for acl injury in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/010_Ankle_Sprain.txt b/data/guidelines/orthopedics/010_Ankle_Sprain.txt new file mode 100644 index 0000000000000000000000000000000000000000..0a2f602fb174808199786b98a27c5579e5e986ee --- /dev/null +++ b/data/guidelines/orthopedics/010_Ankle_Sprain.txt @@ -0,0 +1,6 @@ +Title: Rotator Cuff Tear — Orthopedics Guideline (10) +Summary: Evidence-aligned triage and management for rotator cuff tear in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/011_Rotator_Cuff_Tear.txt b/data/guidelines/orthopedics/011_Rotator_Cuff_Tear.txt new file mode 100644 index 0000000000000000000000000000000000000000..c6bafe188b043f443400583ba0069d0f4be1d4e9 --- /dev/null +++ b/data/guidelines/orthopedics/011_Rotator_Cuff_Tear.txt @@ -0,0 +1,6 @@ +Title: Hip Fracture — Orthopedics Guideline (11) +Summary: Evidence-aligned triage and management for hip fracture in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/012_Low_Back_Pain.txt b/data/guidelines/orthopedics/012_Low_Back_Pain.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1265f0a7489a2a0dd35399f5319d4fb56a8ae99 --- /dev/null +++ b/data/guidelines/orthopedics/012_Low_Back_Pain.txt @@ -0,0 +1,6 @@ +Title: ACL Injury — Orthopedics Guideline (12) +Summary: Evidence-aligned triage and management for acl injury in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/013_Low_Back_Pain.txt b/data/guidelines/orthopedics/013_Low_Back_Pain.txt new file mode 100644 index 0000000000000000000000000000000000000000..dc1f67955f4958585e32f2a1f5c19521b93827fb --- /dev/null +++ b/data/guidelines/orthopedics/013_Low_Back_Pain.txt @@ -0,0 +1,6 @@ +Title: Ankle Sprain — Orthopedics Guideline (13) +Summary: Evidence-aligned triage and management for ankle sprain in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/014_Knee_Osteoarthritis.txt b/data/guidelines/orthopedics/014_Knee_Osteoarthritis.txt new file mode 100644 index 0000000000000000000000000000000000000000..d2f8c6156716442e092e7e6fe787ff941fb2a61a --- /dev/null +++ b/data/guidelines/orthopedics/014_Knee_Osteoarthritis.txt @@ -0,0 +1,6 @@ +Title: Rotator Cuff Tear — Orthopedics Guideline (14) +Summary: Evidence-aligned triage and management for rotator cuff tear in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/015_Cervical_Spondylosis.txt b/data/guidelines/orthopedics/015_Cervical_Spondylosis.txt index 46bc1988c48823e581d4855d32d58a7b37c9b1cf..7ae775be5b12311e4b5a5e746f603fe42473bd06 100644 --- a/data/guidelines/orthopedics/015_Cervical_Spondylosis.txt +++ b/data/guidelines/orthopedics/015_Cervical_Spondylosis.txt @@ -1,34 +1,6 @@ -Title: Knee Osteoarthritis — Orthopedics Guideline (15) - -Clinical Summary: -Evidence-aligned approach to knee osteoarthritis in Orthopedics. Prioritize red flags, history, and targeted exam; use testing judiciously. - -Symptoms: -- Pattern, onset, severity, modifiers -- Associated: fever, weight loss, bleeding, dyspnea -- Risks: comorbidities, medications, family history - -Differentials: -- Common -- Less common -- Must-not-miss (red flag) - -Investigations: -- First-line labs -- Imaging when indicated -- Decision thresholds - -Management: -- Conservative measures -- Pharmacologic options -- Escalation criteria - -Red Flags: -- Syncope, severe pain, hemodynamic instability -- New neurologic deficits -- Rapid progression or systemic toxicity - -Follow-Up: -- Time-bounded review -- Safety-net advice -- When to return earlier \ No newline at end of file +Title: Hip Fracture — Orthopedics Guideline (15) +Summary: Evidence-aligned triage and management for hip fracture in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/016_Rotator_Cuff_Tear.txt b/data/guidelines/orthopedics/016_Rotator_Cuff_Tear.txt new file mode 100644 index 0000000000000000000000000000000000000000..4078b467f5ff09beb1f6f13ac895cde14967df32 --- /dev/null +++ b/data/guidelines/orthopedics/016_Rotator_Cuff_Tear.txt @@ -0,0 +1,6 @@ +Title: Frozen Shoulder — Orthopedics Guideline (16) +Summary: Evidence-aligned triage and management for frozen shoulder in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/017_Plantar_Fasciitis.txt b/data/guidelines/orthopedics/017_Plantar_Fasciitis.txt new file mode 100644 index 0000000000000000000000000000000000000000..7da26ba920bae580f0d945a19f827ef901181ff8 --- /dev/null +++ b/data/guidelines/orthopedics/017_Plantar_Fasciitis.txt @@ -0,0 +1,6 @@ +Title: ACL Injury — Orthopedics Guideline (17) +Summary: Evidence-aligned triage and management for acl injury in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/018_ACL_Injury.txt b/data/guidelines/orthopedics/018_ACL_Injury.txt new file mode 100644 index 0000000000000000000000000000000000000000..d68c2ccd892c6a611a51e2bf183adf4504540ef4 --- /dev/null +++ b/data/guidelines/orthopedics/018_ACL_Injury.txt @@ -0,0 +1,6 @@ +Title: Knee Osteoarthritis — Orthopedics Guideline (18) +Summary: Evidence-aligned triage and management for knee osteoarthritis in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/019_Ankle_Sprain.txt b/data/guidelines/orthopedics/019_Ankle_Sprain.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6126b59b0cb7abb47d412da01189fce9e88a040 --- /dev/null +++ b/data/guidelines/orthopedics/019_Ankle_Sprain.txt @@ -0,0 +1,6 @@ +Title: Rotator Cuff Tear — Orthopedics Guideline (19) +Summary: Evidence-aligned triage and management for rotator cuff tear in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/data/guidelines/orthopedics/020_Rotator_Cuff_Tear.txt b/data/guidelines/orthopedics/020_Rotator_Cuff_Tear.txt new file mode 100644 index 0000000000000000000000000000000000000000..5662d765a915609bf89b1a74318330ac320ed94a --- /dev/null +++ b/data/guidelines/orthopedics/020_Rotator_Cuff_Tear.txt @@ -0,0 +1,6 @@ +Title: Hip Fracture — Orthopedics Guideline (20) +Summary: Evidence-aligned triage and management for hip fracture in Orthopedics. +Red Flags: syncope, severe pain, hemodynamic instability. +Workup: history, focused exam, first-line tests, targeted imaging. +Management: conservative → pharmacologic → escalation when needed. +Follow-Up: safety-net advice; return if worse. \ No newline at end of file diff --git a/pages/1_Diagnostics.py b/pages/1_Diagnostics.py index 283025e7ff0e508f6b16dd1e124cdb7a540c57de..69854dcf755ada3a8239bc41e7bd8637bca1e621 100644 --- a/pages/1_Diagnostics.py +++ b/pages/1_Diagnostics.py @@ -1,13 +1,12 @@ import streamlit as st, os, json, requests st.set_page_config(page_title="Diagnostics", page_icon="🧪", layout="wide") -st.title("🧪 Endpoint Diagnostics") -st.write("Quickly test your endpoint/token and inspect raw responses.") -endpoint = st.text_input("Endpoint", os.getenv("HF_CHAT_ENDPOINT") or os.getenv("CHAT_ENDPOINT") or "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-1B-Instruct") +st.title("🧪 Endpoint Diagnostics (Router)") +endpoint = st.text_input("Endpoint", os.getenv("HF_CHAT_ENDPOINT") or "https://router.huggingface.co/hf-inference/text-generation/openai/gpt-oss-120b") token = st.text_input("HF API Token (optional; else use env)", os.getenv("HF_API_TOKEN") or "", type="password") -prompt = st.text_area("Prompt", "ping") +prompt = st.text_area("Prompt", "hello from MediAssist") if st.button("Ping"): try: - r = requests.post(endpoint, headers={"Authorization": f"Bearer {token or os.getenv('HF_API_TOKEN')}","Content-Type":"application/json"}, json={"inputs":[{"role":"user","content":prompt}]}, timeout=60) + r = requests.post(endpoint, headers={"Authorization": f"Bearer {token or os.getenv('HF_API_TOKEN')}","Content-Type":"application/json"}, json={"inputs": prompt, "parameters":{"max_new_tokens":50}}, timeout=60) st.subheader("Status / headers") st.code(f"{r.status_code}\n{dict(r.headers)}") try: diff --git a/utils/constants.py b/utils/constants.py index 1b5329a8931a6b468d43bf67434559a74ab399c2..d143241de30e0aa729d5336eb5d114f3c482ca12 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -4,9 +4,9 @@ COLLECTION = "med_guidelines_multispeciality" EMB_MODEL_NAME = "medicalai/ClinicalBERT" RETRIEVAL_K_DEFAULT = 5 -# Default endpoints (override in HF Space variables) -CHAT_ENDPOINT_DEFAULT = " https://router.huggingface.co/models/meta-llama/Llama-3.2-1B-Instruct" -TEXTGEN_ENDPOINT_DEFAULT = " https://router.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1" +# Default chat endpoint (router, text-generation) +CHAT_ENDPOINT_DEFAULT = "https://router.huggingface.co/hf-inference/text-generation/openai/gpt-oss-120b" + REQUEST_TIMEOUT_SECONDS_DEFAULT = 60 RETRIES_DEFAULT = 6 BACKOFF_SECONDS_DEFAULT = 3 diff --git a/utils/persona.py b/utils/persona.py index 85ff382fec0b1beb75d730bccbb9b0d70f5a2ae8..51c939d25baa12ce72d01f421628845023188b29 100644 --- a/utils/persona.py +++ b/utils/persona.py @@ -1,9 +1,7 @@ AI_GYNO_PERSONA_V2 = """ You are MediAssist Clinical AI (AIgyno Persona v2). -- Assist doctors (OBGYN, Internal Medicine, Orthopedics) with safe reasoning. -- Use simple language with patients; use clinical language with doctors. -- Ask 3–6 targeted follow-up questions when info is insufficient. -- Provide differentials and next steps. Do not give definitive diagnoses. -- Always include red flags and escalation criteria. Cite context if available. -- Final decisions rest with the doctor. +- Assist doctors across OBGYN, Internal Medicine, Orthopedics. +- Be safe, clear, and ask 3–6 targeted follow-ups if needed. +- Provide differentials, initial workup, red flags, and next steps. +- Never give definitive diagnosis; final decisions rest with the doctor. """