Fix compound diagnosis splitting, section boundaries, and attribute matching for secondary completeness
This commit is contained in:
@@ -107,6 +107,7 @@ METADATA_PATTERNS = [
|
||||
r"^\s*(?:bp|hr|pulse|rr|temp|spo2|gcs|creatinine|cbc|wbc|hemoglobin|hgb|platelets?)\s*(?::|=|\s+\d)\b",
|
||||
r"^\s*[\d\.\,\/]+\s*(?:mg/dl|mmol/l|g/dl|mmhg|bpm|%|cells/cumm)?\s*$",
|
||||
r"^\s*(?:ecg|ekg|cxr|chest\s+x[\s\-]?ray|ct\s+scan|mri|ultrasound|usg|2d\s+echo|cbc|bmp|cmp|lft|kft|rft|urinalysis|blood\s+culture|troponin|hba1c)\s*(?:normal|clear|pending|done|negative|reviewed)?\s*$",
|
||||
r"^\s*(?:patient\s+name|mrn|admission\s+date|discharge\s+date|admit\s+date|date\s+of\s+admission|date\s+of\s+discharge|dob|age|sex|gender)\s*[:\-–—]",
|
||||
]
|
||||
|
||||
# 5. Tumor attributes / Staging markers (attributes of a neoplasm, not standalone diagnoses)
|
||||
@@ -131,13 +132,66 @@ ISOLATED_ANATOMY_PATTERNS = [
|
||||
# Pathological condition words that validate an anatomical mention into a true disease entity
|
||||
PATHOLOGY_KEYWORDS = {
|
||||
"fracture", "sprain", "strain", "pain", "cellulitis", "arthritis", "arthropathy",
|
||||
"swelling", "edema", "lesion", "mass", "tumor", "carcinoma", "cancer", "neoplasm",
|
||||
"swelling", "edema", "lesion", "mass", "tumor", "tumour", "carcinoma", "cancer", "neoplasm",
|
||||
"infection", "calculus", "stone", "lithiasis", "stenosis", "effusion", "laceration",
|
||||
"wound", "contusion", "deformity", "syndrome", "disease", "disorder", "ulcer",
|
||||
"gangrene", "ischemia", "infarction", "tear", "rupture", "dislocation", "subluxation",
|
||||
"injury", "trauma", "abscess", "impairment", "failure", "colic", "bacteremia",
|
||||
"hypertension", "diabetes", "asthma", "copd", "cirrhosis", "hepatitis", "pancreatitis",
|
||||
"gastritis", "colitis", "enteritis", "appendicitis", "cholecystitis", "pyelonephritis",
|
||||
"nephritis", "sepsis", "shock", "pneumonia", "bronchitis", "anemia", "acidosis",
|
||||
"alkalosis", "ischemia", "stenosis", "thrombosis", "embolism", "atherosclerosis",
|
||||
"cardiomyopathy", "arrhythmia", "fibrillation", "leukemia", "lymphoma", "sarcoma",
|
||||
"melanoma", "adenoma", "polyp", "cyst", "perforation", "obstruction", "ileus",
|
||||
"fistula", "diverticulitis", "diverticulosis", "fibrosis", "osteomyelitis",
|
||||
"gout", "neuropathy", "radiculopathy", "dementia", "adenitis", "spasm",
|
||||
"metastasis", "metastases", "metastatic", "malignancy", "malignant", "carcinomatosis",
|
||||
"effusion", "atelectasis", "pneumothorax", "hemothorax", "consolidation", "ascites",
|
||||
"hernia", "herniation", "hernias", "dehydration", "hypovolemia", "hypervolemia",
|
||||
"urticaria", "urticarial", "dermatitis", "eczema", "psoriasis", "anaphylaxis", "angioedema",
|
||||
"hypothyroidism", "hyperthyroidism", "thyroiditis", "goiter", "epilepsy", "seizure",
|
||||
"convulsion", "parkinson", "alzheimer", "dementia", "reflux", "gerd", "esophagitis",
|
||||
"regurgitation", "insufficiency", "prolapse", "incompetence", "lupus", "erythematosus",
|
||||
"sjogren", "scleroderma", "sarcoidosis", "amyloidosis", "hemophilia", "thalassemia",
|
||||
"cataract", "glaucoma", "retinopathy", "tuberculosis", "malaria", "dengue", "typhoid",
|
||||
"depression", "anxiety", "bipolar", "schizophrenia", "psychosis", "malformation", "anomaly",
|
||||
"deviation", "deviated", "hypertrophy", "hypertrophic", "hyperplasia", "atrophy", "atrophic",
|
||||
"hypoplasia", "dysplasia", "thickening", "narrowing", "collapse", "perforation", "calcification",
|
||||
"sclerosis", "fibrosis", "adhesions", "dns", "mastoiditis",
|
||||
}
|
||||
|
||||
# Clinical symptoms, signs, and patient complaints
|
||||
SYMPTOM_KEYWORDS = {
|
||||
"pain", "colic", "discomfort", "ache", "aching", "soreness", "tenderness",
|
||||
"fever", "pyrexia", "chill", "chills", "rigor", "rigors", "sweating", "diaphoresis",
|
||||
"cough", "coughing", "hemoptysis", "dyspnea", "breathlessness", "tachypnea",
|
||||
"wheeze", "wheezing", "stridor", "rhonchi", "rales", "crackles",
|
||||
"nausea", "vomiting", "emesis", "dyspepsia", "indigestion", "heartburn",
|
||||
"dysphagia", "odynophagia", "diarrhea", "constipation", "obstipation",
|
||||
"hematochezia", "melena", "hematemesis", "jaundice", "icterus",
|
||||
"dizziness", "vertigo", "syncope", "presyncope", "lightheadedness",
|
||||
"headache", "migraine", "cephalea", "fatigue", "malaise", "lethargy",
|
||||
"weakness", "asthenia", "somnolence", "drowsiness", "insomnia",
|
||||
"edema", "swelling", "swollen", "distension", "bloating", "ascites",
|
||||
"rash", "erythema", "pruritus", "itching", "lesion", "lesions",
|
||||
"cyanosis", "pallor", "flushing", "palpitation", "palpitations",
|
||||
"tachycardia", "bradycardia", "arrhythmia", "hypotension", "hypertension",
|
||||
"oliguria", "anuria", "polyuria", "hematuria", "dysuria", "nocturia",
|
||||
"incontinence", "retention", "urgency", "frequency",
|
||||
"confusion", "delirium", "altered", "encephalopathy", "seizure", "seizures", "convulsion",
|
||||
"tremor", "ataxia", "numbness", "paresthesia", "tingling", "hypesthesia",
|
||||
"paralysis", "paresis", "plegia", "spasticity", "rigidity", "stiffness",
|
||||
"anorexia", "cachexia", "weight loss", "weight gain",
|
||||
}
|
||||
|
||||
# Recognized medical pathology, morphology, and clinical suffixes
|
||||
MEDICAL_CONDITION_SUFFIXES = (
|
||||
"itis", "oma", "osis", "emia", "aemia", "pathy", "algia", "dynia",
|
||||
"pnea", "uria", "stenosis", "megaly", "penia", "cytosis", "iasis",
|
||||
"spasm", "derma", "ectasis", "malacia", "necrosis", "rrhea", "rrhagia",
|
||||
"cele", "ptosis", "lysis", "plegia", "paresis", "sclerosis",
|
||||
"ism", "ia", "ence", "ency", "lapse",
|
||||
)
|
||||
|
||||
# 7. Procedure and surgical keywords (Section 11 Procedure Firewall)
|
||||
PROCEDURE_TERMS = {
|
||||
@@ -151,12 +205,31 @@ PROCEDURE_TERMS = {
|
||||
"lymphadenectomy", "axillary dissection", "lymph node dissection",
|
||||
"sentinel node biopsy", "sentinel lymph node biopsy", "cystectomy",
|
||||
"adhesiolysis", "lysis of adhesions", "ablation", "cauterization",
|
||||
"procedure", "surgery", "operation", "intervention", "surgical procedure",
|
||||
"surgical intervention", "procedure done", "surgery done", "operation done",
|
||||
}
|
||||
|
||||
PROCEDURE_SUFFIXES = (
|
||||
"ectomy", "otomy", "ostomy", "plasty", "pexy", "scopy", "centesis", "rrhaphy",
|
||||
)
|
||||
|
||||
# Generic procedural completion / performance notices lacking underlying disease
|
||||
GENERIC_PROCEDURE_PATTERNS = [
|
||||
r"^\s*(?:elective\s+|major\s+|minor\s+|surgical\s+|operative\s+|bedside\s+|diagnostic\s+)?(?:procedure|surgery|operation|intervention)\s*(?:done|performed|completed|tolerated|undertaken|successful|finished|noted)?\s*$",
|
||||
r"\b(?:procedure\s+done|surgery\s+done|operation\s+done|procedure\s+performed|surgery\s+performed|operation\s+performed|intervention\s+done)\b",
|
||||
r"^\s*(?:procedure|surgery|operation|intervention)\s*$",
|
||||
]
|
||||
|
||||
# Non-clinical activities, everyday events, personal actions, and bodily functions without pathology
|
||||
NON_CLINICAL_ACTIVITY_PATTERNS = [
|
||||
r"\b(?:towel|blanket|bedsheet|pillow|napkin|tissue|clothes|linen|tray|remote|phone|call\s*bell)\b",
|
||||
r"\b(?:picked\s*up|picking\s*up|pick\s*up|put\s*down|dropped|wiped|cleaned|folded|reached\s*for)\b",
|
||||
r"\b(?:i\s+)?(?:pooped|pooping|bowel\s*movement|peed|peeing|urinated|urination|voided|defecated)\b",
|
||||
r"\b(?:i\s+pooped|patient\s+pooped|i\s+peed|patient\s+peed|towel\s+picked\s+up|picked\s+up\s+towel)\b",
|
||||
r"^\s*(?:i|we|he|she|pt|patient)?\s*(?:ate|eating|eats|drank|drinking|drinks|slept|sleeping|sleeps|walked|walking|walks|ambulated|ambulating|sat|sitting|sits|stood|standing|stands|woke|waking|bathed|bathing|showered|showering|brushed|brushing|dressed|dressing)\b",
|
||||
r"^\s*(?:i|we)\s+[a-z]+",
|
||||
]
|
||||
|
||||
# 8. Investigation names lacking pathological findings
|
||||
INVESTIGATION_TERMS = {
|
||||
"ct", "ct scan", "mri", "cxr", "chest x-ray", "ultrasound", "usg",
|
||||
@@ -207,6 +280,16 @@ class HardClinicalCandidateGate:
|
||||
if len(clean_term) < 2:
|
||||
return False, "Term is too short to be a clinical condition"
|
||||
|
||||
# Check 0a: Non-clinical activities, daily living actions, and personal events
|
||||
for pat in NON_CLINICAL_ACTIVITY_PATTERNS:
|
||||
if re.search(pat, term_lower):
|
||||
return False, f"Non-clinical activity, everyday personal action, or household event: '{clean_term}'"
|
||||
|
||||
# Check 0b: Generic procedural completion or intervention statements
|
||||
for pat in GENERIC_PROCEDURE_PATTERNS:
|
||||
if re.search(pat, term_lower):
|
||||
return False, f"Generic procedure statement or completion notice: '{clean_term}'"
|
||||
|
||||
# Check 1: Absence statements
|
||||
for pat in ABSENCE_PATTERNS:
|
||||
if re.search(pat, term_lower):
|
||||
@@ -219,11 +302,10 @@ class HardClinicalCandidateGate:
|
||||
|
||||
# Check 3: Pharmaceutical dosage forms or prescription syntax (Section 9)
|
||||
is_dosage_form = any(re.search(pat, term_lower) for pat in DOSAGE_FORM_PATTERNS)
|
||||
has_prescription_syntax = (
|
||||
any(re.search(pat, term_lower) for pat in PRESCRIPTION_SYNTAX_PATTERNS)
|
||||
or any(re.search(pat, evidence_text.lower()) for pat in PRESCRIPTION_SYNTAX_PATTERNS)
|
||||
)
|
||||
if is_dosage_form or (has_prescription_syntax and any(w in evidence_text.lower() for w in ["medication", "dose", "tablet", "syrup", "capsule", "injection", "take", "prn"])):
|
||||
has_prescription_syntax = any(re.search(pat, term_lower) for pat in PRESCRIPTION_SYNTAX_PATTERNS)
|
||||
if is_dosage_form or has_prescription_syntax:
|
||||
return False, f"Pharmaceutical dosage form or prescription instruction: '{clean_term}'"
|
||||
if any(w in term_lower for w in ["tablet", "syrup", "capsule", "injection", "mg po", "mg iv", "mcg", "tablets", "capsules", "lozenges"]):
|
||||
return False, f"Pharmaceutical dosage form or prescription instruction: '{clean_term}'"
|
||||
|
||||
# Check 4: Section headings, metadata, allergy statements, lab values
|
||||
@@ -258,7 +340,12 @@ class HardClinicalCandidateGate:
|
||||
return False, f"Negative finding / absence clause: '{clean_term}'"
|
||||
|
||||
# Check 8: Explicit metadata keywords
|
||||
if any(term_lower == meta for meta in ["classification of fracture", "classification of fracture: not applicable", "not applicable", "n/a", "na", "biomarkers & receptor status", "biomarkers", "receptor status"]):
|
||||
term_no_punct = re.sub(r"[:\s]+$", "", term_lower).strip()
|
||||
if (
|
||||
term_no_punct.startswith("classification of")
|
||||
or term_no_punct.startswith("type of fracture")
|
||||
or any(term_no_punct == meta for meta in ["classification", "not applicable", "n/a", "na", "biomarkers & receptor status", "biomarkers", "receptor status"])
|
||||
):
|
||||
return False, f"Metadata or template header artifact: '{clean_term}'"
|
||||
|
||||
# Check 9: Pure surgical or procedural interventions (Section 11 Procedure Firewall)
|
||||
@@ -288,8 +375,120 @@ class HardClinicalCandidateGate:
|
||||
if re.search(pat, term_lower):
|
||||
return False, f"Hypothetical or contingent clinical statement: '{clean_term}'"
|
||||
|
||||
# Check 13: Clinical Medical Entity Validation (Strict Disease or Symptom Requirement)
|
||||
# Every candidate MUST carry a disease, disorder, pathology, infection, neoplasm, injury, or clinical symptom/sign.
|
||||
term_words = set(re.findall(r"[a-z0-9]+", term_lower))
|
||||
has_pathology = bool(term_words.intersection(PATHOLOGY_KEYWORDS))
|
||||
has_symptom = bool(term_words.intersection(SYMPTOM_KEYWORDS))
|
||||
has_med_suffix = any(any(w.endswith(sfx) for sfx in MEDICAL_CONDITION_SUFFIXES) for w in term_words if len(w) > 4)
|
||||
has_microbiology = any(org in term_lower for org in ["e. coli", "escherichia coli", "klebsiella", "pseudomonas", "staphylococcus", "streptococcus", "candida", "h. pylori", "helicobacter", "rhinovirus", "influenza", "coronavirus", "bacteremia"])
|
||||
has_lab_abnormality = any(lab in term_lower for lab in ["leukocytosis", "thrombocytopenia", "hypokalemia", "hyperkalemia", "hyponatremia", "acidosis", "alkalosis", "anemia", "creatinine", "troponin", "hyperglycemia", "hypoglycemia", "elevated"])
|
||||
|
||||
CLINICAL_ROOTS = (
|
||||
"stone", "calcul", "lithias", "itis", "oma", "osis", "emia", "pathy", "algia",
|
||||
"pnea", "uria", "stenos", "megaly", "penia", "cytos", "spasm", "infect",
|
||||
"fractur", "sprain", "strain", "ulcer", "injur", "trauma", "wound", "syndrom",
|
||||
"diseas", "disorder", "failur", "ischemi", "infarct", "cancer", "carcinom",
|
||||
"tumor", "tumour", "neoplasm", "abscess", "cellulit", "aneurysm", "thrombos",
|
||||
"embol", "anemi", "diabet", "asthma", "copd", "cirrhos", "fibros", "gout",
|
||||
"neuropath", "pain", "fever", "cough", "nausea", "vomit", "dyspnea", "headache",
|
||||
"edema", "swelling", "rash", "bleed", "hemorrhag", "diarrhea", "constipat",
|
||||
"colic", "jaundic", "syncope", "dizzin", "vertigo", "fatigue", "malaise",
|
||||
"seizur", "convuls", "tremor", "ataxia", "paralys", "paresis", "hypertens",
|
||||
"hypotens", "arrhythm", "tachycard", "bradycard", "fibrillat", "cardiomyopath",
|
||||
"adenit", "gangren", "necros", "perforat", "obstruct", "ileus", "fistul",
|
||||
"deform", "impair", "calculi", "polyp", "cyst", "adenom", "sarcom", "lymphom",
|
||||
"leukem", "melanom", "dementi", "deliri", "encephalopath", "acidosis", "alkalosis",
|
||||
"shock", "sepsis", "bacteremi", "pyelonephrit", "cholecystit", "pancreatit",
|
||||
"gastrit", "colit", "enterit", "hepatit", "appendicit", "pneumon", "spasm",
|
||||
"lacerat", "contus", "ruptur", "dislocat", "subluxat", "metasta", "malignan",
|
||||
"effus", "atelecta", "pneumothor", "hemothor", "ascit", "herni", "dehydrat", "hypovolem",
|
||||
"urticar", "dermatit", "eczema", "psorias", "anaphyla", "angioedem",
|
||||
"thyroid", "goiter", "epilep", "parkinson", "alzheimer", "reflux", "esophag",
|
||||
"regurgitat", "insufficien", "prolaps", "incompeten", "lupus", "erythemat",
|
||||
"hemophil", "thalassem", "cataract", "glaucom", "retinopath", "tuberculos",
|
||||
"malari", "dengue", "typhoid", "depress", "anxiet", "bipolar", "schizophren",
|
||||
"psychos", "malformat", "anomal", "dysplas", "deviat", "hypertroph", "hyperplas",
|
||||
"atroph", "thicken", "narrow", "calcif",
|
||||
)
|
||||
has_clinical_root = any(r in term_lower for r in CLINICAL_ROOTS)
|
||||
|
||||
if not (has_pathology or has_symptom or has_med_suffix or has_microbiology or has_lab_abnormality or has_clinical_root):
|
||||
# If the phrase has no clinical terms at all, reject it as a non-diagnostic statement
|
||||
return False, f"Phrase does not describe a clinical disease, disorder, pathology, or symptom: '{clean_term}'"
|
||||
|
||||
return True, "Valid clinical diagnosis entity"
|
||||
|
||||
@classmethod
|
||||
def is_symptom_integral_to_primary(
|
||||
cls, symptom_term: str, primary_term: str, evidence: str = ""
|
||||
) -> bool:
|
||||
"""Evaluate whether a clinical symptom is an expected integral manifestation of a primary diagnosis under CMS Guideline I.B.4.
|
||||
|
||||
Principles:
|
||||
1. A symptom is ONLY integral if it is a standard physiological manifestation within the SAME organ system as the primary disease.
|
||||
2. Cross-system conditions (e.g. chest pain in skin disease, epigastric pain in urticaria, rash in heart disease) are NOT integral.
|
||||
3. If a symptom was explicitly evaluated, investigated (e.g. ECG changes, endoscopy), or diagnosed, it is not integral.
|
||||
"""
|
||||
sym = symptom_term.lower().strip()
|
||||
pri = primary_term.lower().strip()
|
||||
|
||||
# Check if sym is even a symptom
|
||||
symptom_indicators = [
|
||||
"pain", "colic", "fever", "cough", "dyspnea", "shortness of breath",
|
||||
"nausea", "vomiting", "dyspepsia", "indigestion", "heartburn",
|
||||
"discomfort", "wheezing", "fatigue", "malaise", "respiratory distress",
|
||||
"rash", "pruritus", "itching", "edema", "swelling", "cyanosis",
|
||||
]
|
||||
is_sym = any(s in sym for s in symptom_indicators)
|
||||
has_definitive_dx = (
|
||||
any(sym.endswith(sfx) or f"{sfx} " in sym for sfx in ("itis", "oma", "osis", "emia", "pathy"))
|
||||
or any(dx in sym for dx in ["syndrome", "failure", "infarction", "disease", "disorder", "calculus", "lithiasis", "ulcer", "pneumonia", "dermatitis"])
|
||||
)
|
||||
if not is_sym or has_definitive_dx:
|
||||
return False
|
||||
|
||||
# Organ system mapping
|
||||
# 1. Skin
|
||||
is_skin_sym = any(w in sym for w in ["rash", "pruritus", "itching", "erythema", "hive", "wheal"])
|
||||
is_skin_pri = any(w in pri for w in ["urticaria", "dermatitis", "eczema", "psoriasis", "cellulitis", "impetigo"])
|
||||
if is_skin_sym and is_skin_pri:
|
||||
return True
|
||||
|
||||
# 2. Heart failure (dyspnea, shortness of breath, fluid overload, peripheral edema)
|
||||
is_hf_sym = any(w in sym for w in ["dyspnea", "shortness of breath", "edema", "peripheral edema", "fluid overload", "orthopnea"])
|
||||
is_hf_pri = any(w in pri for w in ["heart failure", "chf", "congestive heart", "systolic heart", "diastolic heart"])
|
||||
if is_hf_sym and is_hf_pri:
|
||||
return True
|
||||
|
||||
# 3. Gastrointestinal & Acute Abdominal Inflammation
|
||||
is_gi_sym = any(w in sym for w in ["abdominal pain", "rlq pain", "llq pain", "ruq pain", "luq pain", "pain", "colic", "epigastric pain", "epigastric discomfort", "dyspepsia", "nausea", "vomiting", "heartburn", "indigestion", "diarrhea"])
|
||||
is_gi_pri = any(w in pri for w in ["gastritis", "appendicitis", "cholecystitis", "pancreatitis", "ulcer", "diverticulitis", "gastroenteritis", "colitis", "crohn", "ileus"])
|
||||
if is_gi_sym and is_gi_pri:
|
||||
return True
|
||||
if "fever" in sym and any(w in pri for w in ["appendicitis", "cholecystitis", "diverticulitis", "pyelonephritis", "abscess"]):
|
||||
return True
|
||||
|
||||
# 4. Respiratory
|
||||
is_resp_sym = any(w in sym for w in ["cough", "wheezing", "dyspnea", "shortness of breath", "stridor", "sputum", "hemoptysis", "respiratory distress"])
|
||||
is_resp_pri = any(w in pri for w in ["pneumonia", "asthma", "copd", "bronchitis", "pneumothorax", "pulmonary edema", "respiratory failure"])
|
||||
if is_resp_sym and is_resp_pri:
|
||||
return True
|
||||
|
||||
# 5. Cardiovascular
|
||||
is_cardiac_sym = any(w in sym for w in ["chest pain", "angina", "palpitation", "palpitations"])
|
||||
is_cardiac_pri = any(w in pri for w in ["infarction", "stemi", "nstemi", "angina", "coronary", "pericarditis", "myocarditis", "ischemic heart"])
|
||||
if is_cardiac_sym and is_cardiac_pri:
|
||||
return True
|
||||
|
||||
# 6. Genitourinary
|
||||
is_gu_sym = any(w in sym for w in ["dysuria", "hematuria", "flank pain", "frequency", "urgency"])
|
||||
is_gu_pri = any(w in pri for w in ["pyelonephritis", "cystitis", "calculus", "lithiasis", "uti", "urinary tract infection", "nephritis"])
|
||||
if is_gu_sym and is_gu_pri:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def classify_entity_type(cls, term: str, evidence_text: str = "") -> ClinicalEntityType:
|
||||
"""Classify any clinical phrase into the Universal Clinical Entity Taxonomy (Section 2)."""
|
||||
@@ -382,6 +581,10 @@ class HardClinicalCandidateGate:
|
||||
def get_rejection_category(cls, term: str, _evidence_text: str = "") -> str:
|
||||
"""Classify the deterministic rejection category for audit reporting."""
|
||||
term_lower = term.strip().lower()
|
||||
if any(re.search(pat, term_lower) for pat in NON_CLINICAL_ACTIVITY_PATTERNS):
|
||||
return "NON_CLINICAL"
|
||||
if any(re.search(pat, term_lower) for pat in GENERIC_PROCEDURE_PATTERNS) or any(re.search(rf"\b{re.escape(proc)}\b", term_lower) for proc in PROCEDURE_TERMS) or any(term_lower.endswith(sfx) for sfx in PROCEDURE_SUFFIXES):
|
||||
return "PROCEDURE"
|
||||
if any(term_lower == m or re.search(pat, term_lower) for pat in METADATA_PATTERNS for m in ["classification of fracture", "not applicable", "n/a", "biomarkers & receptor status", "biomarkers", "receptor status"]):
|
||||
return "METADATA"
|
||||
if any(re.search(pat, term_lower) for pat in STANDALONE_ATTRIBUTE_PATTERNS):
|
||||
@@ -392,13 +595,21 @@ class HardClinicalCandidateGate:
|
||||
return "MEDICATION"
|
||||
if any(re.search(pat, term_lower) for pat in INSTRUCTION_PATTERNS):
|
||||
return "INSTRUCTION"
|
||||
if any(re.search(rf"\b{re.escape(proc)}\b", term_lower) for proc in PROCEDURE_TERMS) or any(term_lower.endswith(sfx) for sfx in PROCEDURE_SUFFIXES):
|
||||
return "PROCEDURE"
|
||||
if any(re.search(pat, term_lower) for pat in ISOLATED_ANATOMY_PATTERNS):
|
||||
return "ANATOMY"
|
||||
if any(sym in term_lower for sym in ["pain", "cough", "fever", "dyspnea", "wheezing", "discomfort"]):
|
||||
return "SYMPTOM"
|
||||
return "METADATA"
|
||||
return "NON_CLINICAL"
|
||||
|
||||
@classmethod
|
||||
def is_non_clinical_activity(cls, text: str) -> bool:
|
||||
t = text.strip().lower()
|
||||
return any(bool(re.search(pat, t)) for pat in NON_CLINICAL_ACTIVITY_PATTERNS)
|
||||
|
||||
@classmethod
|
||||
def is_generic_procedure(cls, text: str) -> bool:
|
||||
t = text.strip().lower()
|
||||
return any(bool(re.search(pat, t)) for pat in GENERIC_PROCEDURE_PATTERNS)
|
||||
|
||||
@classmethod
|
||||
def is_absence_statement(cls, text: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user