Skip to content

About

Turn clinical guidance text into reviewable, SNOMED-bound rules

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

guideline-rules

Turn clinical guidance text into draft rules a clinician can review: who each recommendation applies to, what should happen, and which SNOMED CT codes identify each condition and action.

You bring three things:

  1. Guidance text you are licensed to use, for example a NICE guideline.
  2. A SNOMED CT release you downloaded from NHS TRUD, loaded into a local Hermes terminology server.
  3. A frontier LLM endpoint (Anthropic, any OpenAI-compatible API, or Azure AI Foundry).

You get one rules.yaml per guideline, validated against a published JSON Schema, ready to open in guideline-review, where a clinician checks, corrects and signs off each recommendation.

The output is a draft. Nothing this tool writes should be used on patient data until a clinician has reviewed it. See How good are the drafts?.

What a rule looks like

== 1.1.3   Assessment > Adults with new knee pain   (restricted to: Adults)
Rule 1: CONSIDER one of:
    * MRI scan
    * referral to physiotherapy
  when
    - all of:
      - group: Adults (from the heading)
      - X-ray gave the result: normal (from an earlier recommendation)
      - the pain continues: present
Not mapped (left for a clinician to read):
  - "an X-ray can miss early cartilage damage": caveat, no action
  • Every phrase is quoted from the guidance and carries its position in the text, so a reviewer can see where it came from. Quotes are checked mechanically; invented wording is flagged.
  • Conditions carry a status from a fixed list (present, absent, suspected, declined, tried and not worked, and so on). The code set names the thing; the status says how to read it.
  • What the format cannot state is listed under "not mapped" for a human to read; it is never silently dropped.
  • A sign-off covers one exact revision. Editing the rules, the code sets, the headings or the guideline population, or loading a SNOMED release that changes a code set, shows the recommendation as needing review again.

Quick start

pip install "guideline-rules @ git+https://github.com/Cnote-Healthtech/guideline-rules"

# 1. Read the guidance (see docs/input-formats.md)
guideline-rules ingest markdown guidance.md --id kp1 --title "Knee pain" --work work/kp1

# 2. See exactly what would be sent to the model, without sending anything
export ANTHROPIC_API_KEY=...
guideline-rules run --work work/kp1 --model anthropic/claude-sonnet-5-5 --dry-run

# 3. Draft the rules
guideline-rules run --work work/kp1 --model anthropic/claude-sonnet-5-5

# 4. Propose and check code sets against your SNOMED release (docs/terminology.md)
guideline-rules bind --work work/kp1 --model anthropic/claude-sonnet-5-5 --terminology http://localhost:8080

# 5. Read the result, or hand the folder to guideline-review
guideline-rules show work/kp1/rules.yaml
guideline-rules validate work/kp1/rules.yaml

tests/fixtures/knee_pain.md is a small invented guideline you can try this on.

What leaves your machine

Stored Sent to the LLM endpoint you configure
Guidance text work folder only yes: recommendation text and headings
SNOMED CT release your Hermes server only yes, during bind: names of candidate concepts and samples of each code set
Rules file work folder no
API keys your environment used to authenticate only

Check that your guidance licence and your SNOMED/TRUD licence allow that processing by the endpoint you choose. --dry-run on run and bind writes every request to dry_run_requests.jsonl and sends nothing. The work folder gets a .gitignore that keeps everything except rules.yaml out of version control; rules.yaml itself holds short quotes from the guidance and SNOMED expressions and identifiers (no SNOMED descriptions), so decide whether your licences let you share it.

How it works

Stage What it does
ingest Splits the guidance into numbered recommendations with their heading paths.
triage Decides which recommendations are rules about a patient; the rest are listed without rules.
structure One pass over the whole guideline: states the population, and which heading words narrow it.
extract Writes rules for each recommendation, reading its headings and the earlier recommendations in its section.
check Mechanical checks (every sentence used, no malformed conditions), a model review, and one correction. A correction may never drop a "not mapped" note or invent wording.
assemble Locates every quote in the text, attaches flags for the reviewer, writes rules.yaml. Reviewed work is never overwritten.
bind Proposes an ECL code set per condition and action and expands it on your terminology server.
rebind After loading a new SNOMED release: re-expands every code set, no model calls, and shows which sign-offs it affects.

--samples 3 on run drafts each recommendation three times and flags the ones where the drafts disagree, which is a cheap way to tell a reviewer where to look first.

How good are the drafts?

Measured on NICE guidelines during development, with two other LLMs as graders against a checklist (see docs/evaluation.md):

  • On recommendations the prompts had never been tuned on, about three in four drafts passed every checklist item for both graders; the more lenient grader passed about nine in ten.
  • There is no clinician-reviewed gold standard yet. The graders disagree with each other, and neither is a clinician. Treat these as a guide to how much review to expect, not as an accuracy claim.
  • Typical remaining faults: a condition left out, a qualifier left out, context from an earlier recommendation carried when it should not be.
  • Code sets: the proposer for diseases was measured against QOF register code sets in development. The proposers for procedures, medicines and measurements are new and unmeasured. Every code set is a proposal until a clinician confirms it.

Status

Version 0.1, research software. Not a medical device and not for use in direct care. The rule-drafting stages were checked to reproduce the development experiments request for request; four short example phrases in two prompts were then reworded before publication, and a re-measurement on 84 recommendations showed no difference (72% against 74% passing both graders, within run-to-run noise). The terminology client is written to Hermes's documented API and tested against recorded responses, not yet against a live server: run bind on a few recommendations and read the results before relying on it.

Repository layout

  • core/ – guideline-rules-core: the schema, validation, quote location, sign-off rules and terminology client shared with guideline-review.
  • src/guideline_rules/ – the pipeline and its frozen prompts.
  • docs/ – input formats, terminology setup, binding rules, evaluation.

Licence

MIT. Guidance text and SNOMED CT are not included and have their own licences. SNOMED CT is owned by SNOMED International; UK releases are distributed by NHS England through TRUD.

About

Turn clinical guidance text into reviewable, SNOMED-bound rules

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages