#!/usr/bin/env python3 """ Paper-Native Clinical PICO & Entity Parser for UnsolvedMedical v3.0.0. Transforms raw peer-reviewed medical paper titles and metadata into: 1. Complete, non-truncated, grammatically clean clinical topics (`clean_topic`) 2. Paper-verified `condition_or_health_state` and `population` (eliminating cross-condition chimeras when a paper addresses a condition outside the 20 sub-domain defaults) 3. Paper-specific `intervention_exposure_test_or_predictor` (`name`, `kind`, `details`) 4. Paper-specific `comparator_or_reference` 5. 100 natural clinical research question formulations (5 distinct structural variants x 20 question types) with distinct `statement`, concise `clean_statement`, and patient-accessible `plain_language_statement`. """ import html import re SUBTITLE_BOILERPLATE_RE = re.compile( r"\s*[:–—-]\s*(a |an |the )?(systematic review|meta-analysis|narrative review|scoping review|" r"literature review|umbrella review|comprehensive review|integrative review|minireview|mini-review|" r"review of|updated review|critical review|overview of|retrospective|prospective|multicenter|" r"multi-center|single-center|single center|randomized|randomised|phase [i1234v/]+|pilot study|" r"cohort study|cross-sectional|observational study|clinical trial|real-world|secondary analysis|" r"post-hoc|post hoc|sub-study|substudy|preliminary|comparative study|mendelian randomization|" r"network meta-analysis|pooled analysis|propensity score|outcomes from|results from|insights from|" r"findings from|lessons from|experience from|report from|evidence-based|consensus statement|" r"position paper|clinical practice guideline|expert consensus|multidisciplinary|" r"international delphi|delphi consensus|national survey|cross-sectional survey).*$", re.I, ) PREFIX_BOILERPLATE_RE = re.compile( r"^(a |an |the )?(systematic review and meta-analysis of|systematic review of|meta-analysis of|" r"narrative review of|scoping review of|comprehensive review of|clinical overview of|overview of|" r"update on|updates in|current perspectives on|emerging role of|advances in|new insights into|" r"recent advances in|state of the art in|clinical management of|management of|current state of|" r"exploring the|understanding the|investigating the|evaluating the|assessing the|" r"reassessing the role of|reassessing|role of|the role of|development of a|development of|" r"predictive value of|prognostic value of|diagnostic value of|clinical utility of|" r"clinical significance of|significance of|expert consensus on the|expert consensus on|" r"consensus statement on|international consensus on|diagnosis and monitoring of|diagnosis and management of|" r"diagnosis and treatment of|prevention and treatment of|efficacy and safety of|effectiveness and safety of|" r"efficacy of|effectiveness of|impact of the|impact of|effect of|effects of|" r"influence of|the influence of|association between|association of|relationship between)\s+", re.I, ) DANGLING_TAIL_RE = re.compile( r"\s+\b(a|an|the|in|of|for|with|without|and|or|by|to|from|on|at|among|between|after|before|" r"during|under|into|via|versus|vs|through|across|within|towards|toward|against|upon|using|" r"including|following|regarding|concerning|based|associated|related|compared|comparing|" r"as|such|whether|while|when|where|who|which|that|whose|undergoing|receiving|treated|" r"diagnosed|presenting|living|incorporating|combining|targeting|evaluating|assessing|" r"predicting|preventing|managing|early|late|acute|chronic|severe|moderate|mild|advanced|" r"metastatic|primary|secondary|novel|new|current|emerging|clinical|human|pediatric|adult|" r"older|elderly|high-risk|low-risk|refractory|relapsed|recurrent)\b[:;,\-–—.]*$", re.I, ) # Non-distinctive modifier words that must NOT trigger a specific sub-domain disease match on their own GENERIC_CONDITION_MODIFIERS = { "with", "without", "from", "after", "before", "during", "early", "stage", "late", "acute", "chronic", "severe", "moderate", "mild", "advanced", "metastatic", "unresectable", "resectable", "borderline", "locally", "localized", "high", "risk", "low", "relapsed", "relapsing", "refractory", "recurrent", "first", "second", "line", "complete", "remission", "positive", "negative", "wildtype", "proficient", "deficient", "dependent", "resistant", "progressing", "associated", "related", "induced", "mediated", "primary", "secondary", "adult", "adults", "children", "pediatric", "neonatal", "adolescent", "older", "elderly", "maternal", "pregnant", "postpartum", "patients", "patient", "care", "health", "management", "treatment", "therapy", "disease", "diseases", "syndrome", "syndromes", "disorder", "disorders", "condition", "conditions", "infection", "infections", "cancer", "carcinoma", "adenocarcinoma", "malignancy", "tumor", "tumors", "cell", "small", "large", "diffuse", "factor", "inhibitors", "inhibitor", "mutations", "driver", "pathway", "inhibition", "targetable", "neutralizing", "viii", "active", "grade", "serous", "chemoimmunotherapy", "blockade", "allogeneic", "hsct", "transplant", "transfusion", "long", "term", "short", "type", "types", "form", "forms", "rate", "rates", "systemic", "idiopathic", "hereditary", "familial", "congenital", "acquired", "uncomplicated", "complicated", "stanford", "persistent", "paroxysmal", "sustained", "protracted", "maintenance", "discontinuation", "withdrawal", "postoperative", "perioperative", "preoperative", "intensive", "critical", "critically", "emergency", "outpatient", "inpatient", "community", "hospital", "surgical", "medical", "clinical", "human", "cohort", "onset", "status", "loss", "pain", "failure", "injury", } # Broad umbrella disease nouns that require at least one accompanying qualifier token when present in base_cond_name UMBRELLA_DISEASE_NOUNS = { "amyloidosis", "dissection", "aneurysm", "stenosis", "regurgitation", "insufficiency", "cardiomyopathy", "neuropathy", "nephropathy", "retinopathy", "hepatitis", "cirrhosis", "fibrosis", "arthritis", "vasculitis", "colitis", "epilepsy", "dementia", "depression", "anemia", "thrombocytopenia", "hypertension", "diabetes", "asthma", "stroke", "hemorrhage", "infarction", "thrombosis", "embolism", "leukemia", "lymphoma", "myeloma", "sarcoma", "melanoma", "glioma", "pneumonia", "meningitis", "encephalitis", "endocarditis", "myocarditis", "pancreatitis", "sepsis", "glaucoma", "uveitis", "dermatitis", "psoriasis", "alopecia", "lupus", "myositis", "osteoporosis", "osteoarthritis", "fracture", "fractures", "infertility", "dystrophy", "hemophilia", "thalassemia", } # Explicit comparison pattern: " versus/vs./compared with " EXPLICIT_COMP_RE = re.compile( r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{3,75}?)\s+" r"(?:versus|vs\.?|compared with|compared to)\s+" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{4,75}?)" r"(?:\s+(?:in|for|among|after|during|with|on|to)\b|$)", re.I, ) # "Role/Efficacy/Safety/Value/Impact of in/for/on " OF_PATTERN_RE = re.compile( r"^(?:the\s+)?(?:role|efficacy|effectiveness|safety|impact|effects?|influence|value|utility|feasibility|" r"performance|accuracy|use|application|addition|combination|integration|implementation|" r"optimization|evaluation|assessment|association|relationship|correlation|" r"predictive value|prognostic value|diagnostic value|diagnostic accuracy|clinical utility|" r"clinical significance|significance|therapeutic potential|mechanisms?|pathogenesis|determinants|predictors|biomarkers|" r"reassessing the role|development|genetics)\s+of\s+(?:a\s+|an\s+|the\s+)?" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{5,90}?)" r"(?:\s+(?:in|for|among|on|to guide|after|during|with)\s+(?P[A-Za-z0-9].+))?$", re.I, ) # " for/in the treatment/management/diagnosis/prediction/prevention of " FOR_ACTION_RE = re.compile( r"^(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{5,85}?)\s+" r"(?:for|in|to guide)\s+(?:the\s+)?(?:treatment|management|prevention|diagnosis|early detection|" r"prediction|prognosis|risk stratification|monitoring|rehabilitation|mitigation|control|adjuvant|neoadjuvant)\s*(?:of\s+)?" r"(?P[A-Za-z0-9].+)$", re.I, ) # " and in " AND_IN_RE = re.compile( r"^(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{5,75}?)\s+and\s+" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{4,70}?)\s+" r"(?:in|among|after|during)\s+(?P[A-Za-z0-9].+)$", re.I, ) # Participial/Gerund lead: "Targeting/Predicting/De-escalating in " GERUND_RE = re.compile( r"^(?:targeting|inhibiting|modulating|predicting|stratifying|monitoring|optimizing|" r"de-escalating|reassessing|mapping|decoding|unraveling|evaluating|comparing|enhancing|" r"preventing|overcoming|identifying|quantifying|characterizing)\s+(?:the\s+|a\s+|an\s+)?" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{5,85}?)" r"(?:\s+(?:in|for|among|after|during|with|to)\s+(?P[A-Za-z0-9].+))?$", re.I, ) # Extract condition phrase after "in patients with ", "in ", "of ", "for " COND_PREP_RE = re.compile( r"\b(?:in patients with|among patients with|in adults with|in children with|in women with|in men with|in individuals with|" r"in the management of|in the treatment of|for the treatment of|in|among)\s+" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{6,95})$", re.I, ) def _balance_parens(text: str) -> str: t = text.strip() while t.startswith("(") and t.endswith(")") and t[1:-1].count("(") == t[1:-1].count(")"): t = t[1:-1].strip() if t.count("(") > t.count(")"): last_open = t.rfind("(") if len(t) - last_open <= 15: t = t + ")" else: t = t[:last_open].strip() elif t.count(")") > t.count("("): t = t.replace(")", "").strip() return t def clean_complete_topic(raw_title: str) -> str: """ Extract a complete, self-contained clinical topic phrase from a peer-reviewed paper title without mid-phrase truncation or dangling prepositions/adjectives. """ t = html.unescape(raw_title or "") t = re.sub(r"<[^>]+>", "", t).strip() t = re.sub(r"\s+", " ", t).rstrip(".:;?-–— ") t = SUBTITLE_BOILERPLATE_RE.sub("", t).strip() if ":" in t: p0, p1 = [p.strip() for p in t.split(":", 1)] if p0.lower() in {"research review", "clinical review", "special report", "consensus statement", "clinical practice guideline", "original article", "review article"} and len(p1) >= 24: t = p1 elif len(p0) >= 28: t = p0 elif len(p1) >= 28 and not SUBTITLE_BOILERPLATE_RE.search(": " + p1): t = f"{p0} ({p1})" if len(p0) + len(p1) < 120 else p1 t = re.sub( r"^(a |an |the )?(systematic review and meta-analysis of|systematic review of|meta-analysis of|" r"narrative review of|scoping review of|comprehensive review of|clinical overview of|overview of|" r"update on|updates in|current perspectives on)\s+", "", t, flags=re.I, ).strip() if len(t) > 215: clause_break = re.search(r"[,;–—]\s+", t[110:]) if clause_break: t = t[: 110 + clause_break.start()].strip() else: t = t[:210].rsplit(" ", 1)[0].strip() t = _balance_parens(t) t = re.sub(r"[:;,\-–—/]+\s*$", "", t).strip() while True: new_t = DANGLING_TAIL_RE.sub("", t).strip() new_t = re.sub(r"[:;,\-–—/]+\s*$", "", new_t).strip() if new_t == t or len(new_t) < 22: break t = new_t t = _balance_parens(t) if t and t[0].islower(): t = t[0].upper() + t[1:] return t def _clean_extracted_entity(phrase: str) -> str: p = phrase.strip(" ,:;.-–—") p = PREFIX_BOILERPLATE_RE.sub("", p).strip(" ,:;.-–—") p = re.sub(r"\s+\b(patients|individuals|adults|children|subjects|cases)\s*$", "", p, flags=re.I).strip() while True: np = DANGLING_TAIL_RE.sub("", p).strip(" ,:;.-–—") if np == p or len(np) < 8: break p = np p = _balance_parens(p) if p and p[0].islower(): p = p[0].upper() + p[1:] return p def _distinctive_condition_words(cond_name: str) -> list[str]: return [ w.lower() for w in re.findall(r"[A-Za-z0-9]{3,}", cond_name) if len(w) >= 4 and w.lower() not in GENERIC_CONDITION_MODIFIERS ] def _extract_condition_from_paper(clean_topic: str, cat_display_name: str) -> str | None: """Extract a paper-native disease/condition phrase from clean_topic when it differs from the sub-domain default.""" trimmed_topic = re.sub(r"\s+in the (?:era|context|setting|wake|presence) of\s+[A-Za-z0-9\s,\-/+()]+$", "", clean_topic, flags=re.I).strip() m_with = re.search( r"\b(?:children and young people|children and adolescents|adolescents and adults|older adults|pregnant women|postpartum women|children|adolescents|adults|women|men|patients|individuals|infants|neonates)\s+with\s+" r"(?P[A-Za-z0-9][A-Za-z0-9\s,\-/+()]{6,90})$", trimmed_topic, flags=re.I, ) if m_with: c = _clean_extracted_entity(m_with.group("cond")) if 8 <= len(c) <= 90: return c m = COND_PREP_RE.search(trimmed_topic) if m: c = _clean_extracted_entity(m.group("cond")) if 8 <= len(c) <= 90 and c.lower() not in {"clinical practice", "routine care", "primary care", "the united states", "europe", "china", "japan", "turkey"}: return c m_of = re.search( r"\b(?:genetics|pathogenesis|diagnosis|management|treatment|epidemiology|prognosis|classification|biomarkers|monitoring)\s+of\s+" r"([A-Za-z0-9][A-Za-z0-9\s,\-/+()]{6,85})$", trimmed_topic, flags=re.I, ) if m_of: c = _clean_extracted_entity(m_of.group(1)) if 8 <= len(c) <= 90: return c return None def _strip_redundant_population_tail(topic_text: str, cond_name: str) -> str: """ Strip trailing ' in ' from a paper topic when it is embedded inside a sentence that already explicitly states 'In with '. """ trimmed_topic = re.sub(r"\s+in the (?:era|context|setting) of\s+[A-Za-z0-9\s,\-/+()]+$", "", topic_text, flags=re.I).strip() m_on_of = re.search( r"\s+(?:on|in|among|for)\s+(?:the\s+[a-z\s]{3,25}\s+of\s+)?(?:children|adolescents|adults|women|men|patients|individuals|infants|neonates)[A-Za-z0-9,\-\s/+()]{4,95}$", trimmed_topic, flags=re.I, ) if m_on_of: trimmed = trimmed_topic[: m_on_of.start()].strip() if len(trimmed) >= 14: return _clean_extracted_entity(trimmed) cond_words = set(_distinctive_condition_words(cond_name)) m = re.search(r"\s+(?:in|among)\s+([A-Za-z0-9,\-\s/+()]{8,85})$", trimmed_topic, flags=re.I) if m: tail = m.group(1).lower() if any(cw in tail for cw in cond_words) or any(k in tail for k in ("patients", "cancer", "disease", "carcinoma", "lymphoma", "leukemia", "amyloidosis", "syndrome", "dissection", "children", "women", "adults")): trimmed = trimmed_topic[: m.start()].strip() if len(trimmed) >= 14: return _clean_extracted_entity(trimmed) return _clean_extracted_entity(trimmed_topic) def select_coherent_outcomes(cat_id: int, raw_title: str, cond_name: str) -> tuple[str, str, str]: """ Return domain-coherent (prim_out, safe_out, pro_out) phrases matched to the category and specific disease/sub-specialty so no unrelated sub-domain scales (e.g. endometriosis scales on PCOS, or dental scales on stroke rehabilitation) ever appear in a question statement. """ tl = f"{raw_title} {cond_name}".lower() if cat_id == 1: if any(k in tl for k in ("thromboembol", "vte", "anticoagul", "thrombosis")): return ( "recurrent venous thromboembolism and clinically relevant bleeding", "ISTH major bleeding and clinically relevant non-major bleeding", "anticoagulation treatment burden and health-related quality of life", ) if any(k in tl for k in ("hemophilia", "haemophilia", "sickle cell", "thalassemia", "aplastic anemia", "hemoglobinuria", "pnh", "thrombocytopenic", "ttp", "itp", "von willebrand")): return ( "annualized bleeding or crisis rate, hemoglobin stabilization, and event-free survival", "thromboembolic events, hemolysis or bleeding breakthroughs, and immunogenicity", "FACIT-Fatigue score, physical function, and transfusion or infusion burden", ) return ( "overall survival and progression-free or disease-free survival", "Grade >=3 treatment-related and immune-mediated adverse events", "EORTC QLQ-C30 health-related quality of life and symptomatic toxicity burden", ) if cat_id == 2: if "aortic" in tl or "dissection" in tl or "aneurysm" in tl: return ( "aortic-related mortality, stroke, and reintervention-free survival", "spinal cord ischemia, stroke, and major perioperative bleeding", "functional independence and health-related quality of life", ) return ( "cardiovascular death, myocardial infarction, and ischemic stroke", "ISTH major bleeding, intracranial hemorrhage, and arrhythmia or conduction disturbances", "Kansas City Cardiomyopathy Questionnaire (KCCQ) score and functional independence", ) if cat_id == 3: if "epilep" in tl or "seizure" in tl: return ( "sustained seizure freedom and >=50% seizure frequency reduction", "neuropsychiatric and cognitive adverse events and treatment discontinuation", "Quality of Life in Epilepsy (QOLIE-31) score and cognitive function", ) return ( "confirmed disability progression and longitudinal neurological function", "treatment-related neurotoxicity, serious infection, and infusion or procedural complications", "cognitive function, fatigue, and patient-reported neurological quality of life (Neuro-QoL)", ) if cat_id == 4: return ( "sustained symptomatic remission and relapse prevention", "suicidal ideation or behavior, treatment-emergent adverse events, and withdrawal symptoms", "psychosocial functioning, social participation, and patient-reported mental health quality of life", ) if cat_id == 5: return ( "28-day and 90-day all-cause mortality and microbiological or clinical cure", "organ toxicity and treatment-emergent antimicrobial resistance selection", "time to symptom resolution, hospital-free days, and treatment completion", ) if cat_id == 6: if "sleep" in tl or "apnea" in tl: return ( "apnea-hypopnea index reduction, nocturnal oxygenation, and cardiovascular event rate", "treatment intolerance, mask or device complications, and daytime residual sedation", "Epworth Sleepiness Scale score, sleep quality, and daytime functional alertness", ) return ( "annualized severe exacerbation rate and lung function trajectory (FEV1 or FVC)", "pneumonia, airway infection, and treatment-related systemic adverse events", "St George's Respiratory Questionnaire (SGRQ) score and dyspnea symptom burden", ) if cat_id == 7: return ( "glycemic and cardiometabolic control, major adverse cardiovascular events, and organ preservation", "severe hypoglycemia, lean body mass loss, and gastrointestinal or hepatobiliary adverse events", "metabolic health-related quality of life, physical function, and treatment satisfaction", ) if cat_id == 8: if any(k in tl for k in ("liver", "hepat", "cirrhosis", "masld", "nafld", "nash", "biliary", "cholang")): return ( "liver-related event-free survival, histologic fibrosis regression, and decompensation rate", "hepatic decompensation, variceal bleeding, and serious infection", "Chronic Liver Disease Questionnaire (CLDQ) score and hospital-free days", ) return ( "steroid-free clinical and endoscopic or transmural remission", "serious opportunistic infection, gastrointestinal bleeding, and bowel perforation", "digestive symptom burden, IBD-Disk disability score, and quality of life", ) if cat_id == 9: return ( "sustained eGFR preservation, progression to kidney failure, and renal or patient survival", "hyperkalemia, acute kidney injury, volume overload, and serious infection", "Kidney Disease Quality of Life (KDQOL-36) score and symptom burden", ) if cat_id == 10: return ( "sustained steroid-free clinical remission and prevention of organ damage accrual", "serious opportunistic infection, thromboembolic events, and treatment-related toxicity", "HAQ-DI physical function, FACIT-Fatigue score, and cumulative glucocorticoid toxicity", ) if cat_id == 11: if any(k in tl for k in ("psoriasis", "dermatitis", "eczema", "hidradenitis", "alopecia", "vitiligo", "skin", "cutaneous", "pemphig", "urticaria", "acne", "melasma", "wound", "ulcer")): return ( "validated skin clearance or lesion resolution and durable disease control", "mucocutaneous or systemic infection and treatment-related adverse events", "Dermatology Life Quality Index (DLQI), pruritus or pain intensity, and patient satisfaction", ) return ( "pain intensity reduction, functional joint survival, and revision-free durability", "periprosthetic infection or fracture, thromboembolism, and procedural complications", "PROMIS pain interference, physical function, and return to independent mobility", ) if cat_id == 12: if any(k in tl for k in ("polycystic", "pcos", "ovary", "ovarian", "infertility", "fertility", "ivf", "menopaus", "endometriosis", "fibroid", "adenomyosis", "contracept", "menstrual", "gynecol", "pelvic")): return ( "reproductive, endocrine, and cardiometabolic health outcomes", "treatment-related thromboembolic, metabolic, and gynecologic adverse events", "validated condition-specific quality of life, symptom severity, and reproductive well-being", ) return ( "severe maternal morbidity and perinatal survival without severe morbidity", "preeclampsia, fetal growth restriction, neonatal complications, and maternal hemorrhage", "maternal functional recovery, postpartum depression (EPDS), and patient-reported birth experience", ) if cat_id == 13: if any(k in tl for k in ("neonat", "preterm", "infant", "necrotizing", "bronchopulmonary", "hypoxic-ischemic")): return ( "survival without neurodevelopmental impairment and major neonatal morbidity", "sepsis, necrotizing enterocolitis, and growth suppression", "neurodevelopmental trajectory and family caregiver burden", ) return ( "pediatric disease control, age-appropriate growth, and long-term organ function", "treatment-related toxicity, infection, and developmental or endocrine adverse effects", "Pediatric Quality of Life Inventory (PedsQL) score and family caregiver burden", ) if cat_id == 14: if any(k in tl for k in ("alzheimer", "dementia", "amyloid", "cognitive", "lewy", "frontotemporal")): return ( "CDR-SB cognitive and functional trajectory and days alive and independent at home", "amyloid-related imaging abnormalities (ARIA), intracerebral hemorrhage, and falls", "neuropsychiatric symptom burden, Zarit caregiver burden score, and quality of life", ) return ( "days alive and independent at home, functional preservation, and survival", "falls, delirium, polypharmacy-related adverse drug events, and emergency hospitalization", "symptom burden, Zarit caregiver burden score, and goal-concordant care", ) if cat_id == 15: return ( "30-day and 90-day all-cause mortality and organ support-free days", "major perioperative or critical care complications, organ ischemia, and reintervention", "EQ-5D-5L functional recovery, 6-minute walk distance, and return to independent living", ) if cat_id == 16: return ( "diagnostic accuracy, time to definitive diagnosis, and downstream clinical outcome impact", "false-positive invasive biopsy cascades, overdiagnosis, and diagnostic delay", "diagnostic yield, clinician decision confidence, and patient decisional regret", ) if cat_id == 17: return ( "all-cause and cause-specific mortality and incident disease rate", "overdiagnosis, false-positive interventions, and preventive regimen adverse events", "health equity gap reduction across socioeconomic strata and quality-adjusted life years", ) if cat_id == 18: return ( "30-day mortality, preventable adverse events, and guideline-concordant care delivery", "unintended care delays, missed diagnoses, and clinician workload burden", "patient-reported care coordination, equity disparity reduction, and implementation fidelity", ) if cat_id == 19: if any(k in tl for k in ("retinal", "macular", "glaucoma", "myopia", "visual", "ophthalm", "ocular", "cornea", "uveitis", "cataract", "optic")): return ( "best-corrected visual acuity (BCVA) and structural retinal or optic nerve preservation", "intraocular inflammation, endophthalmitis, and ocular hypertension", "National Eye Institute Visual Function Questionnaire (NEI VFQ-25) score and visual independence", ) if any(k in tl for k in ("dental", "periodont", "caries", "implant", "oral", "orthodont", "endodont", "maxillofacial", "tooth", "teeth")): return ( "tooth or implant survival, clinical attachment gain, and oral disease resolution", "peri-implantitis, alveolar bone loss, and postoperative infection", "Oral Health Impact Profile (OHIP-14) score, masticatory function, and patient comfort", ) if any(k in tl for k in ("hearing", "cochlear", "tinnitus", "vestibular", "speech", "aphasia", "dysphagia", "auditory", "deaf")): return ( "speech-in-noise recognition, communication recovery, and swallowing safety", "device failure, aspiration pneumonia, and vestibular dysfunction", "Tinnitus Functional Index, communication participation, and WHODAS 2.0 score", ) return ( "validated motor and functional recovery (Fugl-Meyer, ARAT, or FIM)", "musculoskeletal injury, falls, and autonomic or cardiovascular instability", "WHODAS 2.0 community participation, independent mobility, and quality of life", ) return ( "event-free survival, organ-specific disease stabilization, and validated functional response", "treatment-related immunogenicity, hepatotoxicity, and severe multisystem adverse events", "time to definitive diagnosis, functional independence, and patient or caregiver quality of life", ) def _check_subdomain_disease_match(raw_title: str, base_cond_name: str) -> bool: """ Verify whether `raw_title` genuinely addresses `base_cond_name` using whole-word token matching, subtype conflict checks (`type a` vs `type b`, `type 1` vs `type 2`), and qualifier checks for umbrella nouns. """ tl = raw_title.lower() bcl = base_cond_name.lower() if ("type a" in bcl and "type b" in tl) or ("type b" in bcl and "type a" in tl): return False if ("type 1" in bcl and "type 2" in tl) or ("type 2" in bcl and "type 1" in tl): return False title_tokens = set(re.findall(r"[a-z0-9]+", tl)) dist_words = _distinctive_condition_words(base_cond_name) if not dist_words: return True qualifiers = [w for w in dist_words if w not in UMBRELLA_DISEASE_NOUNS] umbrellas = [w for w in dist_words if w in UMBRELLA_DISEASE_NOUNS] if qualifiers and umbrellas: return any(q in title_tokens for q in qualifiers) and any(u in title_tokens for u in umbrellas) return any(dw in title_tokens for dw in dist_words) def extract_paper_pico( raw_title: str, clean_topic: str, qtype: str, cond_tuple: tuple, int_tuple: tuple, outcomes_list: list[dict], lower_fn, cat_display_name: str = "Clinical medicine", cat_id: int = 1, ) -> dict: """ Extract paper-specific PICO elements (`cond_name`, `int_name`, `int_details`, `comp_name`, `pop_desc`, `stage_sev`, `prio_sub`, `focus_clean`, `prim_out`, `safe_out`, `pro_out`) from the paper title and harmonize with the sub-domain clinical baseline. Guarantees zero cross-disease chimeras and zero mismatched outcome scales. """ base_cond_name, onto_ids, base_stage, phenotype, base_pop, age_stages, inc_feat, base_prio_sub = cond_tuple _, base_int_name, base_int_details, base_comp_name, horizon, settings, _ = int_tuple tl = raw_title.lower() matches_subdomain_disease = _check_subdomain_disease_match(raw_title, base_cond_name) if matches_subdomain_disease: cond_name = base_cond_name pop_desc = base_pop stage_sev = base_stage prio_sub = base_prio_sub else: # Paper addresses a specific condition in this medical category that differs from `base_cond_name` paper_cond = _extract_condition_from_paper(clean_topic, cat_display_name) if paper_cond: cond_name = paper_cond if any(p in paper_cond.lower() for p in ("children", "adolescents", "young people", "women", "adults", "patients", "infants", "neonates", "older adults")): pop_desc = paper_cond[0].upper() + paper_cond[1:] else: pop_desc = f"Patients with {lower_fn(paper_cond)}" else: cond_name = f"{clean_topic[:80].rsplit(' ', 1)[0]}" if len(clean_topic) > 80 else clean_topic pop_desc = f"Patients evaluated for {lower_fn(cond_name)} in {cat_display_name.lower()}" stage_sev = "Clinically characterized human cohort" prio_sub = ["high-risk clinical subgroups", "underrepresented age and comorbidity strata"] extracted_int = None extracted_comp = None # 1. Check explicit comparison in title ("X versus Y", "X compared with Y") m_comp = EXPLICIT_COMP_RE.search(clean_topic) if m_comp: a = _clean_extracted_entity(m_comp.group("arm_a")) b = _clean_extracted_entity(m_comp.group("arm_b")) if " of " in a.lower(): a = _clean_extracted_entity(a.split(" of ")[-1]) # Reconstruct shared head noun when `a` is a single modifier word (e.g., "hybrid versus total arch replacement") a_words = a.split() b_words = b.split() if len(a_words) == 1 and len(b_words) >= 2: a = f"{a} {' '.join(b_words[1:])}" if len(a) >= 6 and len(b) >= 6: extracted_int = a extracted_comp = b # 2. Check "Role/Value/Efficacy/Safety/Development of in/for " if not extracted_int: m_of = OF_PATTERN_RE.match(clean_topic) if m_of: focus = _clean_extracted_entity(m_of.group("focus")) if 8 <= len(focus) <= 95: extracted_int = focus # 3. Check " for/in the treatment/diagnosis/prediction of " if not extracted_int: m_for = FOR_ACTION_RE.match(clean_topic) if m_for: focus = _clean_extracted_entity(m_for.group("focus")) if 8 <= len(focus) <= 95: extracted_int = focus # 4. Check Gerund lead ("Targeting/Predicting/Stratifying in ") if not extracted_int: m_ger = GERUND_RE.match(clean_topic) if m_ger: focus = _clean_extracted_entity(m_ger.group("focus")) if 8 <= len(focus) <= 95: extracted_int = focus # 5. Check " and in " if not extracted_int: m_and = AND_IN_RE.match(clean_topic) if m_and: focus = _clean_extracted_entity(m_and.group("focus")) if 8 <= len(focus) <= 85: extracted_int = focus # 6. Split before " in ", " among ", " for ", " after ", " during " if not extracted_int: m_prep = re.split(r"\s+(?:in|among|for|after|during|following|across)\s+", clean_topic, maxsplit=1, flags=re.I) if len(m_prep) == 2 and 10 <= len(m_prep[0].strip()) <= 85: cand_focus = _clean_extracted_entity(m_prep[0]) if cand_focus.lower() != cond_name.lower() and len(cand_focus) >= 10: extracted_int = cand_focus # Guard against extracting the disease/condition name itself as `int_name` (e.g. from "Clinical Management of Acute GVHD") cond_tokens = set(_distinctive_condition_words(cond_name)) if extracted_int: int_no_parens = re.sub(r"\([^)]*\)", "", extracted_int).strip() int_tokens = set(_distinctive_condition_words(int_no_parens)) if not (int_tokens - cond_tokens) or int_no_parens.lower() in cond_name.lower(): extracted_int = None # Construct final paper-native `int_name` and `int_details` if extracted_int: int_name = extracted_int int_details = f"Clinical and translational evaluation of {lower_fn(extracted_int)} in {lower_fn(cond_name)}" elif matches_subdomain_disease: int_name = base_int_name int_details = base_int_details if not extracted_comp: extracted_comp = base_comp_name else: stripped_topic = _strip_redundant_population_tail(clean_topic, cond_name) st_no_parens = re.sub(r"\([^)]*\)", "", stripped_topic).strip() int_tokens = set(_distinctive_condition_words(st_no_parens)) if not (int_tokens - cond_tokens) or st_no_parens.lower() in cond_name.lower(): int_name = f"Guideline-directed clinical management and biomarker stratification in {lower_fn(cond_name)}" else: int_name = _balance_parens(stripped_topic if len(stripped_topic) <= 90 else stripped_topic[:88].rsplit(" ", 1)[0]) int_details = f"Evaluation of {lower_fn(int_name)} in {lower_fn(cond_name)}" # Concise, non-redundant focus phrase for embedding in sentences that already specify `pop_mid` focus_clean = _strip_redundant_population_tail(clean_topic, cond_name) fc_no_parens = re.sub(r"\([^)]*\)", "", focus_clean).strip() focus_tokens = set(_distinctive_condition_words(fc_no_parens)) if len(focus_clean) < 14 or not (focus_tokens - cond_tokens) or fc_no_parens.lower() in cond_name.lower(): focus_clean = int_name # Construct paper-native `comp_name` (avoiding the word "protocol" at the end so "protocol for" never occurs) if extracted_comp: comp_name = extracted_comp else: cond_short = lower_fn(cond_name) qtype_comparators = { "etiology": f"Unexposed or baseline reference risk cohort in {cond_short}", "mechanism": f"Canonical baseline pathway activity or treatment-sensitive phenotype in {cond_short}", "natural_history": f"Standard longitudinal clinical surveillance cohort in {cond_short}", "prevention": "Routine risk-factor modification or standard surveillance without targeted prophylaxis", "screening": "Symptom-prompted clinical evaluation or current guideline screening schedule", "diagnosis": "Conventional clinicopathologic, imaging, or laboratory reference standard", "classification": "Conventional clinicopathologic staging and consensus taxonomy", "prognosis": f"Standard clinical risk score without {lower_fn(int_name)} stratification", "treatment_effectiveness": f"Standard-of-care therapy or active control regimen in {cond_short}", "comparative_effectiveness": f"Current guideline-recommended standard regimen in {cond_short}", "treatment_strategy": f"Standard fixed-duration or unselected dosing regimen in {cond_short}", "safety": "Alternative active comparator or standard dose-monitoring regimen", "rehabilitation": "Usual physical and functional care without structured rehabilitation pathway", "supportive_palliative": "Usual symptom-directed care without integrated supportive pathway", "patient_experience": "Routine clinician-directed care without structured patient-reported decision tool", "implementation": "Usual guideline dissemination without multifaceted implementation strategy", "health_services": "Conventional specialty or hospital-centered care delivery model", "public_health": "Status-quo population health policy without targeted equity intervention", "measurement": "Legacy clinician-rated or unharmonized outcome assessment instrument", "methodology": "Conventional unadjusted analysis or traditional fixed-sample trial design", } comp_name = qtype_comparators.get(qtype, f"Standard-of-care management in {cond_short}") # Refine population and stage if paper title specifies a distinct clinical cohort modifier if "metastatic" in tl and "metastatic" not in stage_sev.lower(): stage_sev = f"Metastatic or advanced stage ({stage_sev})" elif ("relapsed" in tl or "refractory" in tl) and "relapsed" not in stage_sev.lower(): stage_sev = f"Relapsed or refractory stage ({stage_sev})" elif ("early-stage" in tl or "early stage" in tl) and "early" not in stage_sev.lower(): stage_sev = f"Early-stage disease ({stage_sev})" elif ("pediatric" in tl or "children" in tl or "neonat" in tl) and "pediatric" not in pop_desc.lower() and "children" not in pop_desc.lower(): if pop_desc.lower().startswith("adults "): pop_desc = "Children and adolescents " + pop_desc[7:] elif pop_desc.lower().startswith("patients "): pop_desc = "Pediatric and adolescent patients " + pop_desc[9:] else: pop_desc = f"Children and adolescents with {lower_fn(cond_name)}" elif ("elderly" in tl or "older adult" in tl or "geriatric" in tl) and "older" not in pop_desc.lower(): if pop_desc.lower().startswith("adults "): pop_desc = "Older adults " + pop_desc[7:] elif pop_desc.lower().startswith("patients "): pop_desc = "Older adults and geriatric patients " + pop_desc[9:] else: pop_desc = f"Older adults with {lower_fn(cond_name)}" prim_out, safe_out, pro_out = select_coherent_outcomes(cat_id, raw_title, cond_name) return { "cond_name": cond_name, "int_name": int_name, "int_details": int_details, "comp_name": comp_name, "pop_desc": pop_desc, "stage_sev": stage_sev, "prio_sub": prio_sub, "focus_clean": focus_clean, "prim_out": prim_out, "safe_out": safe_out, "pro_out": pro_out, } def build_natural_statements( prob_num: int, qtype: str, clean_topic: str, focus_clean: str, cond_name: str, pop_desc: str, stage_sev: str, int_name: str, comp_name: str, prim_out: str, safe_out: str, pro_out: str, horizon: str, settings: list[str], prio_sub: list[str], lower_fn, ) -> tuple[str, str, str, str]: """ Return `(title, statement, clean_statement, plain_language_statement)` using 100 natural clinical question templates (5 variants per question_type x 20 question_types) with zero awkward double-splicing. """ variant = prob_num % 5 focus_mid = lower_fn(focus_clean) cond_mid = lower_fn(cond_name) pop_mid = lower_fn(re.sub(r"\s*\([^)]{10,}\)", "", pop_desc).strip()) int_mid = lower_fn(int_name) comp_mid = lower_fn(re.sub(r"\s*\([^)]{10,}\)", "", comp_name).strip()) prio_mid = ", ".join(lower_fn(p) for p in prio_sub[:2]) setting_mid = ", ".join(s.replace("_", " ") for s in settings[:2]) cond_sig_words = _distinctive_condition_words(cond_name) q_label = qtype.replace("_", " ").title() if any(w in clean_topic.lower() for w in cond_sig_words) or cond_name.lower() in clean_topic.lower(): title = f"{clean_topic} — Open {q_label} Question" else: title = f"{clean_topic} in {cond_name} ({q_label})" clean_statement = ( f"In {pop_mid}, how does {int_mid} compare with {comp_mid} regarding {prim_out} over {horizon}?" ) templates = { "comparative_effectiveness": [ f"In {pop_mid}, does {focus_mid} improve {prim_out} and reduce {safe_out} over {horizon} compared with {comp_mid}?", f"Among {pop_mid}, what is the head-to-head comparative effectiveness of {focus_mid} versus {comp_mid} for achieving superior {prim_out} over {horizon}?", f"For {pop_mid} managed in {setting_mid} settings, does {focus_mid} provide a net clinical advantage over {comp_mid} on {prim_out} and {safe_out} through {horizon}?", f"When treating {pop_mid} (including {prio_mid}), is {focus_mid} superior or non-inferior to {comp_mid} with respect to {prim_out} at {horizon}?", f"Across diverse clinical cohorts of {pop_mid}, how does {focus_mid} compare against {comp_mid} in balancing {prim_out} against {safe_out} over {horizon}?", ], "treatment_effectiveness": [ f"Among {pop_mid} ({lower_fn(stage_sev)}), what is the confirmatory clinical efficacy of {focus_mid} compared with {comp_mid} on {prim_out} over {horizon}?", f"In {pop_mid}, does therapeutic intervention with {focus_mid} produce durable improvements in {prim_out} over {horizon} relative to {comp_mid}?", f"For {pop_mid}, can {focus_mid} significantly improve {prim_out} without unacceptable {safe_out} over {horizon} compared with {comp_mid}?", f"What is the magnitude and durability of treatment benefit from {focus_mid} versus {comp_mid} on {prim_out} over {horizon} in {pop_mid}?", f"In randomized evaluation of {pop_mid}, does {focus_mid} achieve clinically meaningful gains in {prim_out} and {pro_out} over {horizon} compared with {comp_mid}?", ], "treatment_strategy": [ f"For {pop_mid} in {setting_mid} settings, what is the optimal sequencing, dosing threshold, or treatment duration of {focus_mid} versus {comp_mid} over {horizon}?", f"In {pop_mid}, does a biomarker- or response-adapted strategy for {focus_mid} outperform {comp_mid} on {prim_out} and {safe_out} over {horizon}?", f"Among {pop_mid}, when can therapy be safely de-escalated, switched, or intensified using {focus_mid} compared with {comp_mid} over a {horizon} horizon?", f"What is the optimal clinical algorithm for initiating and sequencing {focus_mid} relative to {comp_mid} to maximize {prim_out} over {horizon} in {pop_mid}?", f"In {pop_mid}, does dynamic treatment adaptation guided by {focus_mid} improve {prim_out} over {horizon} compared with {comp_mid}?", ], "diagnosis": [ f"In {pop_mid} presenting for clinical evaluation, what is the diagnostic accuracy and clinical utility of {focus_mid} compared with {comp_mid} for improving {prim_out} over {horizon}?", f"Among {pop_mid}, does integrating {focus_mid} into the diagnostic pathway outperform {comp_mid} in sensitivity, specificity, and downstream {prim_out} over {horizon}?", f"For {pop_mid} in {setting_mid} care, can {focus_mid} reduce diagnostic delay and misclassification compared with {comp_mid} while improving {prim_out} over {horizon}?", f"What are the externally validated diagnostic performance characteristics of {focus_mid} versus {comp_mid} in {pop_mid}, and does testing improve {prim_out} over {horizon}?", f"In {pop_mid}, does diagnostic triage with {focus_mid} provide superior clinical net benefit over {comp_mid} across {horizon}?", ], "screening": [ f"In asymptomatic or at-risk {pop_mid}, does structured screening via {focus_mid} compared with {comp_mid} improve early detection and {prim_out} without excess {safe_out} over {horizon}?", f"Among {pop_mid} (including {prio_mid}), what is the net balance of benefits, false-positive burden, and overdiagnosis when screening with {focus_mid} versus {comp_mid} over {horizon}?", f"For risk-stratified {pop_mid}, does longitudinal surveillance using {focus_mid} reduce late-stage presentation and improve {prim_out} over {horizon} compared with {comp_mid}?", f"What screening interval and positivity threshold for {focus_mid} optimize {prim_out} and minimize {safe_out} compared with {comp_mid} in {pop_mid} over {horizon}?", f"In population and clinic-based cohorts of {pop_mid}, does early detection through {focus_mid} translate into improved {prim_out} over {horizon} relative to {comp_mid}?", ], "classification": [ f"In {pop_mid}, does biological endotyping or phenotypic classification via {focus_mid} outperform {comp_mid} for predicting {prim_out} and guiding therapy over {horizon}?", f"Among {pop_mid}, can a reproducible subphenotype taxonomy based on {focus_mid} resolve clinical heterogeneity and improve {prim_out} stratification over {horizon} versus {comp_mid}?", f"For {pop_mid}, do disease subtypes defined by {focus_mid} exhibit distinct treatment responses and {prim_out} trajectories over {horizon} compared with {comp_mid}?", f"Does integrating multi-modal classification from {focus_mid} refine risk categories beyond {comp_mid} for {prim_out} over {horizon} in {pop_mid}?", f"In {pop_mid}, how accurately do diagnostic and molecular criteria derived from {focus_mid} partition patients into actionable strata for {prim_out} over {horizon} versus {comp_mid}?", ], "prognosis": [ f"Among {pop_mid}, what is the externally validated prognostic discrimination, calibration, and decision utility of {focus_mid} versus {comp_mid} for stratifying {prim_out} over {horizon}?", f"In {pop_mid}, does prognostic modeling incorporating {focus_mid} provide incremental predictive value over {comp_mid} for {prim_out} through {horizon}?", f"Across independent cohorts of {pop_mid} (including {prio_mid}), how reliably does {focus_mid} predict long-term {prim_out} and {safe_out} over {horizon} compared with {comp_mid}?", f"For {pop_mid}, can baseline and serial assessment of {focus_mid} accurately stratify individual risk of {prim_out} over {horizon} relative to {comp_mid}?", f"What is the transportability and clinical net benefit of risk prediction using {focus_mid} compared with {comp_mid} for {prim_out} over {horizon} in {pop_mid}?", ], "natural_history": [ f"Across longitudinal cohorts of {pop_mid}, what is the natural trajectory, progression rate, and determinant profile of {prim_out} over {horizon} in relation to {focus_mid} versus {comp_mid}?", f"In {pop_mid}, how does the long-term clinical course of {prim_out} evolve over {horizon} when stratified by {focus_mid} compared with {comp_mid}?", f"Among {pop_mid}, what are the transition probabilities between clinical states and cumulative incidence of {prim_out} over {horizon} associated with {focus_mid}?", f"In unselected prospective follow-up of {pop_mid}, what factors modify longitudinal progression to {prim_out} over {horizon} under {focus_mid} versus {comp_mid}?", f"How do baseline phenotypic features and {focus_mid} shape the multi-year natural history of {prim_out} over {horizon} in {pop_mid}?", ], "etiology": [ f"In {pop_mid}, what is the causal contribution of {focus_mid}—and its interaction with host susceptibility—to disease development and {prim_out} over {horizon} compared with {comp_mid}?", f"Among {pop_mid}, does exposure or predisposition characterized by {focus_mid} independently increase disease incidence and {prim_out} over {horizon} after accounting for confounding?", f"Through what causal pathways and dose-response relationships does {focus_mid} drive disease onset and {prim_out} over {horizon} in {pop_mid} relative to {comp_mid}?", f"In longitudinal etiologic studies of {pop_mid}, what fraction of disease risk and {prim_out} over {horizon} is attributable to {focus_mid} versus {comp_mid}?", f"Using triangulated human causal inference in {pop_mid}, is {focus_mid} a modifiable causal driver of {prim_out} over {horizon}?", ], "mechanism": [ f"In human tissues and clinical cohorts of {pop_mid}, what cellular and molecular pathways link {focus_mid} to {prim_out} over {horizon}, and is this axis causally rate-limiting?", f"Among {pop_mid}, how does mechanistic perturbation of {focus_mid} alter downstream pathobiology and clinical {prim_out} over {horizon} compared with {comp_mid}?", f"In {pop_mid}, what are the primary immunologic, metabolic, or signaling drivers of treatment resistance and disease progression mediated by {focus_mid} over {horizon}?", f"Does target engagement of the biological pathway underlying {focus_mid} reverse pathological remodeling and improve {prim_out} over {horizon} in {pop_mid}?", f"In translational human studies of {pop_mid}, how do host-microenvironment or genetic interactions involving {focus_mid} govern {prim_out} over {horizon}?", ], "prevention": [ f"In at-risk {pop_mid}, does primary or secondary prevention with {focus_mid} compared with {comp_mid} reduce disease incidence and improve {prim_out} over {horizon}?", f"Among {pop_mid} (including {prio_mid}), what is the preventive efficacy and number needed to treat of {focus_mid} versus {comp_mid} for averting {prim_out} over {horizon}?", f"For high-risk {pop_mid}, does targeted prophylaxis or risk reduction via {focus_mid} durably lower disease incidence and {prim_out} over {horizon} without excess {safe_out}?", f"In {pop_mid}, what is the optimal timing and risk threshold for initiating preventive {focus_mid} compared with {comp_mid} to prevent {prim_out} over {horizon}?", f"Across community and clinical cohorts of {pop_mid}, does sustained preventive intervention with {focus_mid} reduce long-term {prim_out} over {horizon} relative to {comp_mid}?", ], "safety": [ f"Among {pop_mid} exposed to {focus_mid} versus {comp_mid}, what is the comparative incidence, severity, and reversibility of {safe_out} relative to {prim_out} benefit over {horizon}?", f"In {pop_mid} (especially {prio_mid}), what patient-level risk factors and monitoring thresholds predict severe {safe_out} during {focus_mid} over {horizon}?", f"For {pop_mid} receiving treatment in {setting_mid} settings, how does the long-term safety and pharmacovigilance profile of {focus_mid} compare with {comp_mid} over {horizon}?", f"What is the causal risk-benefit trade-off between gains in {prim_out} and cumulative {safe_out} over {horizon} when using {focus_mid} versus {comp_mid} in {pop_mid}?", f"In {pop_mid}, what mitigation or dose-modification strategy best prevents treatment-limiting {safe_out} from {focus_mid} while preserving {prim_out} over {horizon}?", ], "rehabilitation": [ f"In {pop_mid}, does structured rehabilitation incorporating {focus_mid} improve functional recovery and {prim_out} over {horizon} compared with {comp_mid}?", f"Among {pop_mid}, what intensity, timing, and modality of {focus_mid} maximize long-term functional independence and {pro_out} over {horizon} relative to {comp_mid}?", f"For {pop_mid} in {setting_mid} rehabilitation pathways, does individualized therapy with {focus_mid} produce durable gains in {prim_out} over {horizon} versus {comp_mid}?", f"In {pop_mid}, how does combining neuroplastic or physical conditioning via {focus_mid} compare against {comp_mid} in restoring mobility, function, and {prim_out} over {horizon}?", f"Across heterogeneous recovery profiles in {pop_mid}, which subgroups derive clinically meaningful functional benefit from {focus_mid} over {horizon} compared with {comp_mid}?", ], "supportive_palliative": [ f"For {pop_mid} experiencing symptom burden, does integrated supportive or palliative care via {focus_mid} improve {pro_out} and {prim_out} over {horizon} compared with {comp_mid}?", f"In {pop_mid}, what is the comparative effectiveness of early, structured {focus_mid} versus {comp_mid} for relieving refractory symptoms and improving {pro_out} over {horizon}?", f"Among {pop_mid} and their caregivers, does a multidisciplinary supportive pathway centered on {focus_mid} reduce acute care utilization and improve {pro_out} over {horizon}?", f"In managing complex symptom clusters in {pop_mid}, how does {focus_mid} compare against {comp_mid} with respect to symptom control, {safe_out}, and {pro_out} over {horizon}?", f"For {pop_mid} across {setting_mid} settings, does goal-concordant supportive care integrating {focus_mid} improve {pro_out} and {prim_out} over {horizon} relative to {comp_mid}?", ], "patient_experience": [ f"Among {pop_mid}, how does care delivery incorporating {focus_mid} compare with {comp_mid} in improving patient-reported {pro_out} and decision quality over {horizon}?", f"In {pop_mid} (including {prio_mid}), what treatment attributes, lived-experience priorities, and trade-offs between {prim_out} and {safe_out} govern preference for {focus_mid} versus {comp_mid}?", f"For {pop_mid}, does structured shared decision-making and symptom monitoring around {focus_mid} reduce treatment regret and improve {pro_out} over {horizon} compared with {comp_mid}?", f"Across diverse cultural and socioeconomic groups of {pop_mid}, how does {focus_mid} impact treatment burden, quality of life, and {pro_out} over {horizon} relative to {comp_mid}?", f"In {pop_mid}, do patient-reported outcomes ({pro_out}) over {horizon} favor {focus_mid} or {comp_mid} when accounting for daily treatment burden and {safe_out}?", ], "implementation": [ f"Across real-world {setting_mid} settings caring for {pop_mid}, which implementation strategies for {focus_mid} maximize guideline fidelity, equity across {prio_mid}, and {prim_out} over {horizon}?", f"In routine clinical practice for {pop_mid}, does a multifaceted implementation bundle for {focus_mid} outperform {comp_mid} in adoption, sustainment, and {prim_out} over {horizon}?", f"What health-system, clinician, and patient-level barriers limit real-world uptake of {focus_mid} in {pop_mid}, and do targeted implementation interventions improve {prim_out} over {horizon}?", f"Among {setting_mid} practices managing {pop_mid}, how does structured clinical pathway integration of {focus_mid} compare with {comp_mid} for achieving equitable {prim_out} over {horizon}?", f"In scaling evidence-based care for {pop_mid}, does audit-feedback and decision support for {focus_mid} close care gaps across {prio_mid} and improve {prim_out} over {horizon}?", ], "health_services": [ f"In health systems managing {pop_mid}, how does organizing care delivery around {focus_mid} compare with {comp_mid} on {prim_out}, resource utilization, and care coordination over {horizon}?", f"For {pop_mid} treated across {setting_mid} settings, does a redesigned service model incorporating {focus_mid} reduce avoidable hospitalizations and improve {prim_out} over {horizon} versus {comp_mid}?", f"Among {pop_mid} (especially {prio_mid}), what is the cost-effectiveness, capacity impact, and clinical effect on {prim_out} of deploying {focus_mid} compared with {comp_mid} over {horizon}?", f"Does multidisciplinary team triage and longitudinal care navigation for {focus_mid} improve {prim_out} and reduce {safe_out} over {horizon} compared with {comp_mid} in {pop_mid}?", f"Across regional healthcare networks serving {pop_mid}, how does decentralized or integrated delivery of {focus_mid} compare against {comp_mid} for {prim_out} over {horizon}?", ], "public_health": [ f"At the population level among {pop_mid} (including {prio_mid}), does scaling {focus_mid} compared with {comp_mid} reduce health disparities and improve population {prim_out} over {horizon}?", f"Across high-burden communities of {pop_mid}, what is the population-level effectiveness and equity impact of public health interventions based on {focus_mid} versus {comp_mid} over {horizon}?", f"In population surveillance of {pop_mid}, how do social determinants and policy implementation of {focus_mid} modify {prim_out} and disease burden over {horizon} compared with {comp_mid}?", f"For public health programs serving {pop_mid}, does community-wide deployment of {focus_mid} achieve sustainable improvements in {prim_out} over {horizon} relative to {comp_mid}?", f"Among underserved subpopulations ({prio_mid}) within {pop_mid}, can structural prevention and care linkage via {focus_mid} close outcome gaps in {prim_out} over {horizon}?", ], "measurement": [ f"In clinical research and care for {pop_mid}, what is the construct validity, responsiveness, and minimal clinically important difference of measurement via {focus_mid} for {prim_out} over {horizon}?", f"Among {pop_mid}, is {focus_mid} a validated surrogate or core outcome measure capable of reliably predicting {prim_out} over {horizon} compared with {comp_mid}?", f"Across multi-center studies of {pop_mid}, how can assay or instrument standardization for {focus_mid} eliminate inter-laboratory variability and improve {prim_out} assessment over {horizon}?", f"For evaluating interventions in {pop_mid}, does quantitative longitudinal tracking of {focus_mid} capture clinically meaningful change in {prim_out} and {pro_out} over {horizon} better than {comp_mid}?", f"In {pop_mid} (including {prio_mid}), does outcome measurement via {focus_mid} demonstrate cross-population measurement invariance and prognostic validity for {prim_out} over {horizon}?", ], "methodology": [ f"In clinical studies of {pop_mid} addressing {focus_mid}, which study design and causal-inference framework best resolves confounding, time-zero bias, and heterogeneity when comparing {int_mid} against {comp_mid} over {horizon}?", f"For evaluating {focus_mid} versus {comp_mid} in {pop_mid}, how should estimands, intercurrent events, and competing risks be specified to yield unbiased estimates of {prim_out} over {horizon}?", f"In synthesizing heterogeneous evidence on {focus_mid} in {pop_mid}, can individual participant data meta-analysis or target-trial emulation reconcile conflicting findings on {prim_out} over {horizon}?", f"What adaptive platform trial architecture or covariate-adjusted randomization scheme optimizes statistical power across {prio_mid} when testing {focus_mid} versus {comp_mid} over {horizon}?", f"When validating predictive or causal claims regarding {focus_mid} in {pop_mid}, what external transportability and bias-quantification standards are required to establish {prim_out} over {horizon}?", ], } statement = templates[qtype][variant] plain_variants = [ f"For people with {cond_mid}, how does {int_mid} compare with {comp_mid} for improving {prim_out} and minimizing {safe_out} over {horizon}?", f"In patients affected by {cond_mid}, what is the clearest medical evidence on whether {int_mid} works better than {comp_mid} over {horizon}?", f"Can {int_mid} safely improve {prim_out} and quality of life ({pro_out}) over {horizon} compared with {comp_mid} for people with {cond_mid}?", f"Among individuals with {cond_mid} (including {prio_mid}), does {int_mid} offer meaningful long-term benefits over {comp_mid} across {horizon}?", f"What are the real-world benefits and risks of {int_mid} versus {comp_mid} over {horizon} for patients managing {cond_mid}?", ] plain_stmt = plain_variants[variant] return title, statement, clean_statement, plain_stmt