From CodeStrokeApp

A TypeSafe-based decision engine for the first hours of stroke care

Every branch is built from the 2026 AHA/ASA guideline, CSBPR 2022 and its 2025 EVT update, and the Thrombosis Canada guide — with a verbatim citation, page number, and grade behind every recommendation. Free-text input is turned into a typed patient state with TypeSafe, then evaluated by the same engine that runs inside CodeStrokeApp.

Draft · decision support, not orders
The problem

Guidelines are thousands of pages. Bedside decisions happen in minutes.

The AHA/ASA and Canadian (CSBPR) stroke guidelines run to hundreds of pages combined, and they don't always agree with each other. A team standing at the bedside needs a fast, specific, defensible answer — and needs to know exactly which page of which guideline that answer came from.

What this is

A decision tree, every leaf on a branch traced back to its source

TypeSafeStroke pairs a small language model (TypeSafe) that turns free text — an EMS handover, a history, a medication list — into typed, confidence-scored inputs, with a decision tree authored directly from the guidelines, node by node. The tree's design draws directly on TypeSafe's System One primitives — typed Choice judgments, code owning the workflow while the model supplies the judgment, uncertainty tracked rather than collapsed into a guess — even though the tree itself never calls a model to decide. Within the bounded space of the guidelines, a decision framework can be deduced — not a clinician's judgment, only what the cited recommendations say. Nothing is inferred silently: unknown is never read as no. When the tree is missing something it needs, it stops and says exactly what. Run it yourself, or browse the 50 case scenarios that gate every change to it.

A second, experimental track asks a different question: instead of walking the authored tree, can a language model make the same calls directly? TypeSafe's System One models, including Jev, return typed judgments and probabilities rather than generated text. A separate evaluation (TypeSafeWorkJev) tested this live against Jev itself, using its own 42-case set — 24 hand-written plus 18 generated boundary cases, a different subset and approach from the 50 scenarios above. Asked for the final grade in one shot, it isn't usable — 42% accurate. Decomposed into small sub-questions and synthesized by this same deterministic engine, it reaches 95%, with one confirmed, narrow gap. See the method and results, or the 42 eval cases themselves, tree and Jev verdicts side by side.

…Modules
…Decision nodes
…Outcome paths
…Cited statements
…Full citation corpus
…Test scenarios
How it works

From free text to an evidence-linked outcome

1. Free text in

EMS handover, chart history, med list — whatever's on hand, unstructured.

2. Typed patient state

TypeSafe infers structured fields with asymmetric confidence thresholds; anything uncertain stays unconfirmed rather than guessed.

3. Decision engine

A three-valued tree — true, false, unknown — walks phase-ordered modules and stops rather than assumes.

4. Evidence-linked outcome

Every recommendation carries its source, section, page, and grade — ready to check against the guideline itself.

From CodeStrokeApp to the web

The same engine, running twice, agreeing every time

This tree runs in Swift inside CodeStrokeApp and in JavaScript on this page — two independent implementations of the same semantics, checked against each other on every one of the 50 test scenarios below. It's slated to replace CodeStrokeApp's current hard-coded EligibilityEngine, whose rules already differ from the sources in places this project corrects.

Dual-engine parity

Swift and JavaScript engines are parity-tested against the same scenario suite on every rebuild.

Unknown is never no

A missing input halts a decision and records what's needed — it never falls through to a false branch.

Draft, under clinical review

Every open question is tracked in the open below — nothing here is presented as finished.

Explore
Open questions

Where the guidelines disagree, or the tree isn't settled yet