RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Healthcare AI with Local Models
  6. /Ch. 8
Healthcare AI with Local Models

08. Decision Support Systems

Chapter 8 of 18 · 15 min
KEY INSIGHT

Decision support that generates more alerts doesn't improve care—it generates noise. Local models enable contextual, patient-specific alerts but require rigorous tuning against actual clinical decisions.

Clinical Decision Support Systems (CDSS) provide clinicians with knowledge and patient-specific information to improve decision-making. Rules-based systems have dominated for decades; AI-based systems offer greater flexibility but require careful validation.

Local deployment suits CDSS well because the "knowledge base" is prompt-based rather than encoded in separate systems. The LLM applies clinical knowledge to specific patient scenarios without external data transmission.

# decision_support.py
from dataclasses import dataclass
from typing import List, Optional, Dict
from enum import Enum

class AlertSeverity(Enum):
    CRITICAL = "critical"
    WARNING = "warning"
    INFO = "info"

@dataclass
class DecisionSupportAlert:
    alert_type: str
    severity: AlertSeverity
    message: str
    supporting_evidence: List[str]
    recommended_action: str

class ClinicalDecisionSupport:
    """Provide clinical decision support using local LLM."""
    
    def __init__(self, ollama_client, clinical_guidelines: Dict):
        self.ollama = ollama_client
        self.guidelines = clinical_guidelines
    
    def evaluate_patient(self, patient_data: dict, 
                         context: str) -> List[DecisionSupportAlert]:
        """Evaluate patient data and generate relevant alerts."""
        
        # Build patient summary for context
        patient_summary = self._build_patient_summary(patient_data)
        
        prompt = f"""You are a clinical decision support system.
        Evaluate this patient case against established guidelines.
        Generate alerts for:
        1. Guideline deviations
        2. Potential drug interactions
        3. Abnormal lab values
        4. Missing preventive care
        
        Patient Summary:
        {patient_summary}
        
        Clinical Context: {context}
        
        Guidelines to apply:
        {self._format_guidelines()}
        
        Return alerts as JSON array with severity (critical/warning/info).
        Only generate alerts directly supported by the patient data."""
        
        response = self.ollama.generate(prompt)
        return self._parse_alerts(response)
    
    def suggest_differential_diagnoses(self, presentation: dict,
                                        relevant_history: List[dict]) -> List[dict]:
        """Generate differential diagnosis suggestions."""
        
        prompt = f"""Generate differential diagnoses for this presentation.
        Consider patient history when relevant.
        Prioritize by likelihood given available information.
        
        Chief Complaint: {presentation.get('chief_complaint')}
        Associated Symptoms: {presentation.get('symptoms', [])}
        Duration: {presentation.get('duration')}
        
        Relevant History:
        {self._format_history(relevant_history)}
        
        Format as JSON array with diagnosis, likelihood (high/medium/low), and key supporting features."""
        
        response = self.ollama.generate(prompt)
        return json.loads(response)
    
    def _build_patient_summary(self, patient_data: dict) -> str:
        """Create compact patient summary for prompts."""
        sections = []
        if patient_data.get("demographics"):
            demo = patient_data["demographics"]
            sections.append(f"Age: {demo.get('age')}, Sex: {demo.get('sex')}")
        if patient_data.get("medications"):
            sections.append(f"Medications: {', '.join(patient_data['medications'])}")
        if patient_data.get("allergies"):
            sections.append(f"Allergies: {', '.join(patient_data['allergies'])}")
        if patient_data.get("conditions"):
            sections.append(f"Active Conditions: {', '.join(patient_data['conditions'])}")
        return "\n".join(sections)
    
    def _format_guidelines(self) -> str:
        return json.dumps(self.guidelines, indent=2)
    
    def _parse_alerts(self, response: str) -> List[DecisionSupportAlert]:
        try:
            data = json.loads(response)
            alerts = []
            for item in data:
                severity_map = {
                    "critical": AlertSeverity.CRITICAL,
                    "warning": AlertSeverity.WARNING,
                    "info": AlertSeverity.INFO
                }
                alerts.append(DecisionSupportAlert(
                    alert_type=item.get("type", "general"),
                    severity=severity_map.get(item.get("severity", "info")),
                    message=item.get("message", ""),
                    supporting_evidence=item.get("evidence", []),
                    recommended_action=item.get("action", "")
                ))
            return alerts
        except:
            return []
    
    def _format_history(self, history: List[dict]) -> str:
        if not history:
            return "No relevant history documented"
        return "\n".join([
            f"- {h.get('condition')}: {h.get('status')} (onset: {h.get('onset')})"
            for h in history
        ])

CDSS alerts face alert fatigue problems: too many alerts cause clinicians to ignore them all. Local LLMs can generate highly specific alerts based on full patient context, but must be tuned to minimize false positives. Integration with existing CDSS infrastructure leverages established alert frameworks.

EXERCISE

Define five patient scenarios spanning different chief complaints. Run each through the decision support system and evaluate alert relevance. Track false positive rate over 50 evaluations.

← Chapter 7
Medical Coding Assistance
Chapter 9 →
Drug Interaction Checking