Community Triage build

HNZ Rad Tools · Workshop, 13 and 14 October 2026

Building Community Triage

How the national referral criteria PDF became a working triage app for PCRLs and GPs in two days, built in conversation with Claude Code.

85prompts
38exams turned into data
24½ hfirst prompt to last
≈ US$106of AI time at API prices

Use ← → or the bar above to move between slides.

Starting point

What was already in place

Community Triage is the sixth app on an existing platform. Two days was possible because none of this had to be built first.

Claude Code, set up for this repo

Project rules in CLAUDE.md, a memory of earlier decisions, and skills. Opus plans and reviews while Sonnet sub-agents build.

CLAUDE.md · memory · skills

GitHub and automatic deploys

A push to develop sends the app to beta and applies its database migrations. Production is promoted separately, per app.

GitHub Actions · develop · *-prod

Cloudflare, reachable by Claude

The Cloudflare MCP servers and wrangler let Claude create databases, sites, domains and secrets from the terminal.

MCP · wrangler · hnzradtools.nz

HNZ identity hub

One sign-in, with roles, across every HNZ Rad Tools app. A new app is a registration, not a new login system.

id.hnzradtools.nz

HNZ branding and style guide

Palette, Poppins and Open Sans, and layout rules written down once, so new screens match the other tools with no design work.

docs/hnz-design-system.md

The hospital triage tool

A working pattern to copy: browse the guidance, assess a referral with AI, review screens, shared code packages.

apps/triage

Prompt 1 of 85 · 22:43, 13 October

The first prompt

Typed as plain language, typos included. No code and no specification: an input, the users, three goals in order, and a request to research and plan before building.

parallel to the health nz radiology hospital scenario-based triage database which this app supports there is the community radiology referral project. start by researching this initiative and then review the document @"docs/National Primary Care Referral Criteria for Imaging.pdf" - it outlines the criteria-based triage guidelines which are a gateway for GP access to the newly funded diagnostic imaging pathway. Primary Care Referral Liasions act as triagers for referrals coming in and use this guide to accept or decline referrals if they meet or don't meet the guidelines. The goal for this next phase will be a complementary triage app for community radiology referrals that provides a similar resource for browsing the criteria to the current scenario based triage tool as well as an AI powered input for referrals to be pasted into that will assess the referral against the guidelines in a similar manner to the Referral Liasions. The ultimate endpoint will be a headless API that referrals could be sent to which would either accept or decline the refferal (with supplied reasons). Research first, assess the guidelines then make a plan to implement a community triage tool alongside our current one.

Claude came back with a plan and four questions

  1. Separate app or part of triage?"separate"
  2. Can we get real referrals with PCRL decisions on them?"we will be able to"
  3. Who uses the AI assessment, PCRLs only or GPs too?"PCRLs initially then open to GPs as a pre-referral check tool"
  4. Has Health NZ asked for the headless API?"proposal (but it will be)"

Answered 34 minutes later in one line. The plan became a shareable page, kept up to date through the build and served on beta at /plan.

The core input

From PDF to database

The criteria are 105 pages of Word tables. Pick a step to see what went in, what happened and what came out.

In

National Community Referral Criteria for Imaging, Part I, version 2.0. 105 pages, one four-column table per exam.

What happened

A Python script (PyMuPDF) pulled out the text layer, every hyperlink, the PDF's tagged table structure, and a picture of every page at 160 dpi.

Out

pages.json, links.json, structure.json and 105 page images.

scripts/extract_pdf_pages.py

The one rule: the dataset is an exact copy of a national clinical document. Text is copied verbatim, including the source's own typos. Nothing is paraphrased, summarised, corrected or merged.

38exams: CT, US and XR, adult and paediatric
758criteria in priority tiers
1,102rows loaded into the database
0validation failures

Infrastructure

Cloudflare: what Claude set up

Created from the terminal through the Cloudflare MCP servers and wrangler in the first hour. Every deploy after that went through GitHub.

Show
builds the screens deploys applies migrations serves the app API calls SQL PCRL sign-in referral + criteria verifies bot check Pagesbeta.community-triage.hnzradtools.nz GitHub Actionson push to develop BrowserGP or PCRL Worker (API)beta.api.community-triage.hnzradtools.nz D1 databasecommunity-triage-db-preview Identity hubbeta.id.hnzradtools.nz Claude APIOpus 5.5 · own workspace key Turnstilebot check on the GP page
Beta is live and is where everything in this deck runs. The Worker checks each hub sign-in token with a secret it shares with the hub.

Set up by Claude

  • Two D1 databases, production and preview, in Oceania
  • A Pages project for the screens
  • A Worker for the API, in production and preview
  • Four custom domains on hnzradtools.nz
  • A Turnstile bot check for the public GP page
  • A rate limit of 5 checks a minute per connection
  • Secrets: Anthropic key, hub signing key, Turnstile key
  • Registration in the identity hub as a new app
  • Workers Logs on every request
  • A deploy workflow that applies migrations first

Sequence

The build, step by step

Each step ended with a commit, a deploy to beta and an updated plan page. Open any step on the timeline to read the prompts behind it.

    Inside the app

    How a referral check works

    One step is the AI model. Everything around it is ordinary code that can be tested. Select a step to see what it does.

    Path for
    Person Worker(code) ClaudeAPI D1database GP answers the questions and re-checks, up to 4 checks referral + exam cleared 38 exams as text criteria + referral (criteria cached 1 h) JSON answer ids and counts only checked result Referralpasted by the GP Safety gatesNHI, DOB, bot check Build requestprompt for Claude Criteria1,102 rows Claude assessesOpus 5.5, JSON out Verify in codeids, quotes, tier Recordsno patient details Result+ questions to answer
    A check takes 11 to 17 seconds. About 4 US cents once the criteria are cached, about 60 cents for the first check after the cache expires.

    Two days of prompts

    Where the iteration happened

    Every prompt typed into Claude Code, by what it was about. Hover a marker to read it, or click to open it below. Drag to pan; pinch, or scroll with Ctrl or ⌘, to zoom.

    0 of the first 29

    prompts, up to 08:52 on day two, were about the interface. They went on the plan, Cloudflare and getting the criteria exactly right.

    19 of the last 36

    prompts, from 12:30 on day two, were interface and workflow changes: short, specific corrections to what GPs and PCRLs see.

    Measured from the session logs

    What it took

    The build ran on a Claude subscription. These are the costs the same work would have run up on the Anthropic API.

    85prompts typed by a person
    1,231model calls, by one main session and 20 sub-agents
    318 Mtokens processed, 98% re-read from cache
    ≈ US$106estimated at API prices

    Why caching matters

    Each step of an agent re-reads the conversation so far. Caching makes those re-reads cost a tenth to a twentieth of the normal price.

    As it ranwith prompt caching
    US$106
    Same tokenswithout caching
    ≈ US$1,108
    Cache reads, US$62Cache writes, US$26Input at full price, US$1,090Output, US$18
    Who did the workModelCallsTokensEst. cost
    Main session: research, design, specs, reviewOpus 5.5698225 MUS$74
    Sub-agents: building and criteria extractionSonnet 5.548590 MUS$30
    Sub-agents: reading the existing codeOpus 5.5484 MUS$2
    Total1,231318 MUS$106

    Output: 26 commits, about 13,600 lines of code and 17,700 lines of criteria data. Prices: Opus 5.5 US$4 in and US$20 out per million tokens, Sonnet 5.5 US$2 and US$10, cache reads US$0.20. Sub-agent output is under-recorded in the logs and was estimated from what the agents wrote, so the total could be a few dollars either way. Not counted: the session that made this page.

    To take away

    What made two days possible

    A clinician made the decisions

    Most of the 85 prompts were decisions or corrections: what goes in the database, who signs in, what a GP sees, what is never stored.

    The data came first

    The plan, Cloudflare and exact criteria came before any screen. Once the data was right, screens took minutes to change.

    Code checks the AI

    The model cites criteria and quotes the referral. Code confirms both and works out the priority itself.

    The platform was already built

    Claude Code set up for the repo, GitHub deploys, the Cloudflare MCPs, the identity hub and the HNZ style guide.

    Next: test against real referrals with PCRL decisions, then production

    Community Triage build · 13 and 14 October 2026 · times are NZ time