CHAPTER 19

🏥 Clinical AI & Computable Decision Logic

From Guidelines to Executable Logic, Red Flags to Verification

Learning Objectives:
Learn to transform clinical practice guidelines into computable logic, implement red flag detection, evaluate reasoning behavior in medical AI, and build verification systems for safe clinical decision support.

From Clinical Guidelines to Computable Logic

Clinical Practice Guidelines (CPGs) are evidence-based recommendations that standardize decision-making. The challenge: they're written in prose for humans. To build trustworthy AI, we must make them executable.

Example: Sepsis Guideline → Computable Logic

Natural Language Guideline (Surviving Sepsis Campaign):

"Sepsis is a life-threatening condition caused by a dysregulated host response to infection.
Clinicians should recognize early signs: fever or hypothermia, tachycardia, tachypnea,
evidence of infection (positive culture, localizing signs). Immediate interventions include:
antibiotics (within 1 hour), IV fluids (30 mL/kg), vasopressors if hypotensive after fluids,
and investigation of infection source. Lactate >2 mmol/L indicates tissue hypoperfusion."
                

Computable Logic (IF-THEN rules):

# RULE 1: Recognize Early Sepsis (≥2 of these + evidence of infection)
IF (
    (temp < 36 OR temp > 38.3) OR
    (heart_rate > 90) OR
    (respiratory_rate > 20)
) AND
(blood_culture_positive OR
 imaging_shows_infection OR
 localizing_signs_present)
THEN diagnosis = "SEPSIS"

# RULE 2: RED FLAG - Severe Sepsis
IF diagnosis = "SEPSIS" AND (
    (systolic_BP < 90) OR
    (lactate > 2) OR
    (urine_output < 0.5 mL/kg/hr) OR
    (altered_mental_status)
)
THEN severity = "SEVERE"
      recommendation = "🚨 ICU admission required"

# RULE 3: Immediate Interventions
IF diagnosis = "SEPSIS"
THEN
    action1: "Antibiotics WITHIN 1 HOUR"
    action2: "IV fluid bolus: 30 mL/kg"
    action3: "Obtain blood cultures before antibiotics"
    action4: "Investigate infection source (imaging, etc.)"
    action5: "IF severe: add vasopressor (target MAP ≥ 65)"

# RULE 4: Timing is Critical
IF diagnosis = "SEPSIS" AND time_since_onset > 3_hours AND
   no_antibiotics_yet
THEN escalate = TRUE
      notify_physician_urgently = TRUE
      confidence_in_decision = 0.5  # Delayed treatment reduces confidence
                

Building Decision Support Systems

CareTrace Architecture: End-to-End Clinical AI

The system receives: Patient symptoms (natural language)

The system outputs: Actionable plan with clear escalation criteria

# STEP 1: Input (Natural Language)
patient_report = """
Child: 18 months old
Symptoms: Fever 101.5F for 2 days, mild cough, no difficulty breathing
Activity: Playful, alert
Prior: No serious illnesses, up-to-date vaccines
                

→ STEP 2: Lifting (Neural + Extraction)

extracted_facts = {
    'age': '18 months',
    'symptom_fever': True,
    'fever_temp': 101.5,
    'symptom_cough': True,
    'symptom_dyspnea': False,
    'mental_status': 'alert',
    'activity': 'playful',
    'risk_factors': []
}
                

→ STEP 3: Red Flag Detection (Safety Layer)

RED_FLAGS = {
    'respiratory_distress': False,
    'lethargy': False,
    'cyanosis': False,
    'severe_dehydration': False,
    'rash': False,
    'seizure': False
}

# ALL RED FLAGS NEGATIVE → No emergency escalation
confidence_in_low_severity = 0.95
                

→ STEP 4: Reasoning (Production System)

# Apply clinical guidelines as rules
IF fever AND cough AND no_dyspnea AND alert AND playful
THEN diagnosis_likely = "viral_upper_respiratory"
     severity = "mild"

IF age < 3_years AND fever AND alert
THEN consider = "febrile_seizure_risk"
     recommendation = "educate_parent_on_fever_management"

IF no_red_flags AND mild_illness_presentation
THEN disposition = "home_care"
     safety_plan = "monitor_for_48_hours"
                

→ STEP 5: Verification (Constraint Checking)

# Before outputting decision, verify:
verify_checklist = {
    'all_red_flags_checked': True,
    'age_appropriate_reasoning': True,
    'guideline_applied': True,
    'escalation_criteria_met': False,
    'confidence_high_enough': True  # 0.95 > threshold of 0.70
}

if all(verify_checklist.values()):
    decision_ready = True
else:
    escalate_to_physician = True
                

→ STEP 6: Output (Actionable Plan)

RECOMMENDATION FOR TONIGHT:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ Most likely: Viral fever with cough

TONIGHT'S PLAN:
1. Monitor fever (acetaminophen or ibuprofen for comfort)
2. Ensure adequate hydration
3. Watch for respiratory distress (rapid/labored breathing)
4. Keep environment cool (reduce fever risk)

🚨 GO TO ER IMMEDIATELY IF:
• Difficulty breathing
• Difficulty staying awake or unusual behavior
• Purple or blue spots on skin
• Difficulty swallowing or drooling

📋 CALL DOCTOR IF:
• Fever > 104F
• Fever lasts > 5 days
• Appears much worse
• You're very concerned

Confidence: HIGH (0.95)
This recommendation based on: mild symptoms + no red flags + alert behavior
Time-sensitive: No urgency based on current presentation
                

Evaluating Reasoning in Medical AI

How do we know if a medical AI's reasoning is sound? We evaluate four dimensions:

Dimension What We Measure Example
Consistency Same input → Same output (repeatability) Presenting same symptoms multiple times yields same diagnosis
Reliability Correct answers on test cases 80% accuracy on 500 test cases from clinical dataset
Explainability Can we trace reasoning to rules/data? "Diagnosis X because: symptom A matched rule 3, symptom B matched rule 3"
Safety Red flags caught, escalation works, no critical misses 100% of severe cases escalated to physician; zero missed red flags

Red Flag Detection: The Safety Net

Definition:
Red flags are critical indicators that override all other reasoning and demand immediate escalation. In medicine, missing a red flag can mean patient harm.

Red Flags in Pediatric Fever Assessment

# CRITICAL RED FLAGS - if ANY are present, escalate immediately
CRITICAL_RED_FLAGS = [
    'difficulty_breathing',
    'severe_distress',
    'unresponsiveness_or_severe_lethargy',
    'signs_of_meningitis',  # stiff neck, rash, sensitivity to light
    'seizure',
    'cyanosis',
    'severe_dehydration',
    'altered_mental_status'
]

# IMPORTANT RED FLAGS - warrant urgent evaluation
IMPORTANT_RED_FLAGS = [
    'age < 3_months AND fever',  # Neonates have different threshold
    'fever > 40C (104F)',
    'fever > 7_days_duration',
    'cannot_tolerate_fluids',
    'appears_very_sick'
]

# Implementation:
def assess_fever(patient):
    # CHECK CRITICAL FIRST
    for flag in CRITICAL_RED_FLAGS:
        if patient[flag]:
            return {
                'action': '🚨 GO TO ER IMMEDIATELY',
                'reason': f'RED FLAG DETECTED: {flag}',
                'confidence': 1.0
            }

    # Then check important
    for flag in IMPORTANT_RED_FLAGS:
        if patient[flag]:
            return {
                'action': '📞 CALL DOCTOR NOW',
                'reason': f'IMPORTANT FLAG: {flag}',
                'confidence': 1.0
            }

    # Only after red flags checked, proceed with normal reasoning
    return routine_assessment(patient)
                

Chain-of-Verification in Medical AI

Medical AI should explicitly verify its decisions against safety constraints before output.

# Medical Decision Verification Checklist
verification = {
    'patient_allergies_checked': check_allergies(),
    'drug_interactions_verified': check_interactions(),
    'contraindications_excluded': check_contraindications(),
    'dosing_age_appropriate': check_age_dosing(),
    'red_flags_not_missed': check_red_flags(),
    'emergency_criteria_met': check_emergency_criteria(),
    'follow_up_plan_clear': check_followup(),
    'escalation_criteria_explicit': check_escalation()
}

# Only output if ALL verification checks pass
if all(verification.values()):
    output_recommendation()
else:
    # If any check fails:
    failed_checks = [k for k, v in verification.items() if not v]
    escalate_to_physician(reason=failed_checks)
            

Key Takeaways

  • Clinical guidelines must be converted to computable logic (rules)
  • Red flag detection is the safety net: critical conditions override all other reasoning
  • Reasoning evaluation requires 4 dimensions: consistency, reliability, explainability, safety
  • Chain-of-verification checks decisions against safety constraints
  • Escalation criteria must be explicit: when to alert human experts
  • Trust in medical AI comes from transparent reasoning + proven safety record

Conclusion: You've Learned Neuro-Symbolic AI!

What You've Mastered:
  • Ch 1-4: Foundations and practical projects
  • Ch 5-8: Real-world applications (healthcare, legal, insurance, pharmacy)
  • Ch 9-10: Trustworthiness and rule-based reasoning
  • Ch 11-12: Types of reasoning and logic programming
  • Ch 13-14: Graph embeddings and neural-symbolic integration
  • Ch 15-16: Advanced LLM reasoning and clinical AI
Your Next Steps:
  • Build your own neuro-symbolic system using these techniques
  • Start with a domain you know well (healthcare, finance, law, etc.)
  • Combine neural perception with symbolic reasoning
  • Test rigorously on edge cases and red flag scenarios
  • Make your system auditable and explainable
  • Deploy with human oversight in high-consequence domains

🎯 Ready for Assessment?

10 Questions
~10 mins
70% to Pass
Take Quiz Now →