def classify_text(text): # Layer 1 — clinical allowlist if is_clinical_allowlisted(text): return {"is_phi": False, "label": "CLINICAL"} # Layer 2 — clinical patterns (probe IDs, measurements) if matches_clinical_pattern(text): return {"is_phi": False, "label": "CLINICAL"} # Layer 3 — PHI heuristics if matches_phi_heuristic(text): return {"is_phi": True, "label": "PHI_HEURISTIC"} # Layer 4 — Stanford NER model if classify_with_ner(text): return {"is_phi": True, "label": "PHI_NER"} return {"is_phi": False, "label": "SAFE"} __ __