Provenance Chip
StableWhere a value came from, how it got here, and how much of it a human has actually looked at.
Why it exists
A blood pressure typed by a medical assistant, streamed from a home cuff, pulled from an HIE document of unknown vintage, and extracted by a language model from a scanned fax all render as 128/76.
They are not the same fact and they do not support the same decision. As ambient AI and external exchange both scale, the proportion of chart content that no human ever typed is rising fast, and there is no widely used convention for saying so. Two distinctions carry the component. Observed-at is kept separate from recorded-at, because a C-CDA authored in March may carry a reading measured in January and rendering the document's date as the observation's is how a nine-week-old value is acted on as current. And patient-reported is a source class rather than a caveat: self-report is the primary instrument in behavioral health, so a patient-reported PHQ-9 is the correct provenance and rendering it as second-class is its own error — the same class standing in for a blood-pressure measurement is a different matter, and that judgement belongs to the caller.
- Provenance
- agent[].type and who, entity[].role, recorded and occurredDateTime as two separate fields, and activity. The adapter will not call an authorship an extraction on the strength of the agent type alone.
Playground
Change a prop and watch the component and its code change with it.
- onOpenChain, onOpenSpan — nothing yet
import { ProvenanceChip } from "@/components/zoblocks/provenance-chip";export default function Example() { return ( <ProvenanceChip record={record} stalenessPolicy={stalenessPolicy} glyphOnly={false} /> );}Examples
The cases worth copying. Open one in StackBlitz to run it with its dependencies installed.
DataobservationPotassiumCriticalprovenanceLateEntrypractitionerSignerdocumentLateEntry
One value, six provenances
observationPotassiumCriticalThe same 128/76, six times. Each supports a different decision, and only the affix says which — the clinic reading is actionable, the HIE row carries a document date rather than an observation date, and the extracted row states that nobody has looked at it.
import { ProvenanceChip } from "@/components/zoblocks/provenance-chip";// A fixed clock, so the chips' ages read the same on every render.const now = "2026-08-12T10:00:00Z";const t12min = "2026-08-12T09:48:00Z";const t4days = "2026-08-08T08:10:00Z";export default function SixProvenancesExample() { return ( <div className="flex flex-wrap gap-3"> <ProvenanceChip now={now} record={{ source: "clinic", observedAt: t12min, performer: { display: "M. Adeyemi", role: "MA" }, device: "Welch Allyn 6000", }} /> <ProvenanceChip now={now} record={{ source: "device", observedAt: t4days, device: "Omron BP7450", deviceNote: "unvalidated cuff size, median of 3", }} /> <ProvenanceChip now={now} record={{ source: "ai-extracted", observedAt: "2026-08-10T09:00:00Z", model: "zb-extract-3", span: { document: "Scanned referral", page: 2, line: 14 }, confirmed: false, }} /> </div> );}Document vintage is not observation vintage
documentLateEntryA C-CDA authored on 11 March may carry a reading measured in January. Rendering the document's date as the observation's is how a nine-week-old value is acted on as current, so the two are separate fields and the age is measured from the first.
import { ProvenanceChip } from "@/components/zoblocks/provenance-chip";const now = "2026-08-12T10:00:00Z";export default function DocumentVintageExample() { return ( <ProvenanceChip now={now} record={{ source: "external", organisation: "Northgate Family Med", exchange: "Carequality", document: "C-CDA, authored 11 Mar", observedAt: "2026-01-14T09:00:00Z", // the reading recordedAt: "2026-03-11T00:00:00Z", // the document }} /> );}One subscription, not two hundred requests
provenanceLateEntryComponents never fetch their own provenance. A chart with two hundred values would make two hundred requests and every chip would settle at a different moment, so the host subscribes once and the chips are pure.
import { ProvenanceChip, ledgerFrom } from "@/components/zoblocks/provenance-chip";const now = "2026-08-12T10:00:00Z";const t = "2026-08-10T09:00:00Z";// The host subscribes once; the chips read from the ledger and never fetch.const ledger = ledgerFrom({ "obs-1": { source: "clinic", observedAt: t }, // Versioned first: an amended value and its original are two provenances. "obs-1@2": { source: "amended", observedAt: t, supersedes: { value: "182/76", reason: "typo" } },});export default function LedgerExample() { return <ProvenanceChip resourceId="obs-1" versionId="2" ledger={ledger} now={now} />;}Four days differs by datum
practitionerSignerFour days is nothing for a problem list and a lot for a blood pressure, so the threshold is injected per datum type. Without a policy the chip says nothing about age rather than assuming one — a wrong threshold is worse than no threshold.
import { ProvenanceChip, type StalenessPolicy } from "@/components/zoblocks/provenance-chip";const now = "2026-08-12T10:00:00Z";const t4days = "2026-08-08T08:10:00Z";const policy: StalenessPolicy = (record) => { if (record.source === "device") return 48 * 3600_000; // two days if (record.source === "patient-reported") return 30 * 86400_000; return null; // no opinion, and the chip says nothing rather than guessing};export default function StalenessPolicyExample() { return ( <div className="flex flex-wrap gap-3"> <div className="grid gap-1"> <ProvenanceChip now={now} stalenessPolicy={policy} record={{ source: "device", observedAt: t4days, device: "Omron BP7450" }} /> <span className="text-xs opacity-60"> A device reading, 4 days old — past its 2-day threshold. </span> </div> <div className="grid gap-1"> <ProvenanceChip now={now} stalenessPolicy={policy} record={{ source: "clinic", observedAt: t4days, performer: { display: "M. Adeyemi", role: "MA" }, }} /> <span className="text-xs opacity-60"> A clinic reading, the same age — no policy opinion, so no staleness mark. </span> </div> </div> );}Variants
Every variant is the same accessibility contract and the same keyboard model. Pick by what the surface needs.
Default
Glyph, source word and age. The affix a value carries.
glyphOnly=false
Glyph only
For a dense grid where the column is entirely provenance. The word stays in the accessible name.
glyphOnly=true
Installation
npx @zoblocks/cli add provenance-chipFirst install? Run zoblocks init once to say where your @/ alias points. The source is copied into your repository, along with anything it depends on.
clsxtailwind-mergeUsage
Props are the FHIR resource.
import { ProvenanceChip, ledgerFrom } from "@/components/zoblocks/provenance-chip";import "@/styles/zoblocks-provenance.css";const ledger = ledgerFrom(records);<ProvenanceChip resourceId="obs-bp-1" ledger={ledger} now={serverTime} stalenessPolicy={(r) => (r.source === "device" ? 48 * 3600_000 : null)}/>Use it when
- Beside any value whose origin changes what a reader should do with it — vitals, medication lists, problem lists, external documents, anything a model produced.
- With a ledger rather than a record per call site, so every chip on a screen describes the same snapshot.
- With onOpenSpan wherever extracted values appear. Jumping to the source span is the single most requested behaviour from clinicians reviewing extraction.
- With a staleness policy per datum type. A shared threshold either screams about every diagnosis or stays silent about every vital.
Avoid it when
- As a headline. It is an affix; a provenance that competes with the value it qualifies has inverted the reading order.
- As a quality score. It says where a value came from, not whether it is right — a clinic measurement can be wrong and a patient-reported PHQ-9 is the instrument.
- Without `now` when age matters. Omitting it renders no age at all, which is honest; a client clock is not.
API
Every prop is typed. Props not listed are forwarded to the root element.
ProvenanceChip
9 propsglyphOnlyboolean- Default
false - Hides the source word, leaving the glyph and the age. For dense grids.
ledgerProvenanceLedger- Default
— - Read from a ledger instead. Components never fetch their own provenance: a chart with two hundred values would make two hundred requests and every chip would settle at a different moment. The host subscribes once and passes this down.
nowstring- Default
— - ISO 8601, supplied by the host. No relative age is shown without it.
onOpenChain((record: ProvenanceRecord) => void)- Default
— - Opens the chain: the agents, the device, the document, the versions.
onOpenSpan((span: NonNullable<ProvenanceRecord['span']>, record: ProvenanceRecord) => void)- Default
— - Jumps to the span an extracted value was lifted from. The single most requested behaviour from clinicians reviewing extraction, which is why it is its own handler rather than something folded into the chain.
recordProvenanceRecord- Default
— - The record, or a ledger lookup below. One of the two is required.
resourceIdstring- Default
— - The resource this provenance is about. Used to link back to the record rather than to re-fetch it.
stalenessPolicyStalenessPolicy- Default
— - How old is too old, per kind of datum. Four days differs by datum.
versionIdstring- Default
— - Which version was seen. Provenance for a value that has since changed is provenance for a different value.
Accessibility
Screen readers and semantics
- Six shapes, not six colours. Colour would put the source classes on a scale from better to worse, and they are not one. Each class is a CSS glyph in currentColor, so it survives greyscale and forced colours — where colour would have been the only channel, and where colour was never the right channel anyway.
- The name is the whole sentence. "Source: device, Omron BP7450, unvalidated cuff size, observed 4 d ago, stale." One string, in a fixed order: what kind of source, then who or what, then when, then whether anybody has looked. The confirmation clause is last because it decides whether to act, and a listener remembers the end of a sentence.
- A span when there is nothing to open. role="img" with a label by default; a real button only when the host supplies a chain. There is one of these beside every value on a chart, so a focusable element with no action is worse here than almost anywhere.
- Staleness is on the chip, not in the chain. A device reading from four days ago and one from four minutes ago carry different weight, and a reader who has to hover to learn which is a reader who will not. The threshold is injected per datum type: four days is nothing for a problem list and a lot for a blood pressure.
- Unreviewed is a word, not a dot. An unconfirmed extraction says so in text and in the accessible name. It is not a confidence score — a model can be very confident and wrong — and the fact a reader needs is whether a human has been involved at all.
Conformance · WCAG 2.2 AA · 7 of 8 pass
| Criterion | Status | How | Evidence |
|---|---|---|---|
| 1.4.1Use of colour | pass | Six CSS glyphs in currentColor rather than six hues, and a test asserts every source class renders a distinct glyph. Staleness and the unreviewed state carry words as well as backgrounds. | provenance-chip.test.tsx |
| 1.3.1Info and relationships | pass | The whole provenance is one composed name in a fixed order, with every inner node aria-hidden — so a screen reader hears a sentence rather than five fragments beside a value. | provenance-chip.test.tsx |
| 4.1.2Name, role, value | pass | role="img" with a label when static, a real button when a chain is supplied, and the span affordance is its own labelled button. | provenance-chip.test.tsx |
| 2.1.1Keyboard | pass | Both affordances are native buttons reached and activated by keyboard, with no handler of the component's own. | provenance-chip.test.tsx |
| 2.5.8Target size | pass | The chip and the span button hold a 20px box inside a 24px line, and the interactive form is padded to reach the floor without shifting the value beside it. | provenance-chip.test.tsx |
| 1.4.11Non-text contrast | pass | The glyph is drawn in the inherited text colour, so it meets whatever the surrounding text meets; the two tinted states route through gated status tokens. | contrast.gate |
| 1.4.12Text spacing | pass | An inline-flex row with no fixed height; increased line-height and letter-spacing grow the chip rather than clipping it. | provenance-chip.test.tsx |
| 2.2.1Timing adjustable | n/a | No timing. Staleness is computed against a `now` the host supplies. | — |
Clinical
Every surface where a value's origin changes the decision. Self-report is the primary instrument in behavioral health, so the component distinguishes self-report as the instrument from self-report standing in for a measurement — the same class, two different weights, and the caller's judgement rather than the component's.
- Industries
- healthcare, behavioral-health
- Workflows
- documentation, assessment, care-coordination, medication
- Terminology
- FHIR
- Permissions
- provenance.read
- Audit
- Emits AuditEvent
Protected health information
Handles PHI
Names the clinician who observed a value, the organisation that sent it and the document it arrived in. The chain is the disclosive part and it opens on request rather than rendering inline.
Source
Exactly what lands in your repository, read from the published registry so it can never drift from what the CLI installs.
Show sourceHide source217 lines
/** * ProvenanceChip — where a value came from, and how much of it a human has * actually looked at. * * <ProvenanceChip record={provenance} now={serverTime} /> * <ProvenanceChip resourceId="obs-1" ledger={ledger} now={serverTime} /> * * An affix, never a headline. It sits beside a value and does not compete with * it, because the value is what the reader came for and the provenance is what * decides whether they can act on it. * * Six source classes, each with a CSS glyph rather than a colour — colour * would put them on a scale from better to worse, and they are not one. A * patient-reported PHQ-9 is the correct provenance for a PHQ-9; the same class * standing in for a blood-pressure measurement is not, and that judgement * belongs to the caller. * * Styling lives in `styles/zoblocks-provenance.css`, installed alongside. */import * as React from "react";import { cn } from "@/lib/utils";import { SOURCE_GLYPH, SOURCE_LABEL, describeAgeShort, describeProvenance, staleness, type ProvenanceLedger, type ProvenanceRecord, type StalenessPolicy,} from "@/lib/zoblocks-provenance";export { SOURCE_GLYPH, SOURCE_LABEL, describeAgeShort, describeProvenance, fromProvenance, ledgerFrom, staleness, toSource, type ProvenanceAgent, type ProvenanceLedger, type ProvenanceRecord, type ProvenanceSource, type Staleness, type StalenessPolicy,} from "@/lib/zoblocks-provenance";type Base = Omit<React.HTMLAttributes<HTMLElement>, "children">;export interface ProvenanceChipProps extends Base { /** The record, or a ledger lookup below. One of the two is required. */ record?: ProvenanceRecord; /** * Read from a ledger instead. * * Components never fetch their own provenance: a chart with two hundred * values would make two hundred requests and every chip would settle at a * different moment. The host subscribes once and passes this down. */ ledger?: ProvenanceLedger; /** * The resource this provenance is about. Used to link back to the record rather than to * re-fetch it. */ resourceId?: string; /** * Which version was seen. Provenance for a value that has since changed is provenance for a * different value. */ versionId?: string; /** ISO 8601, supplied by the host. No relative age is shown without it. */ now?: string; /** How old is too old, per kind of datum. Four days differs by datum. */ stalenessPolicy?: StalenessPolicy; /** Hides the source word, leaving the glyph and the age. For dense grids. */ glyphOnly?: boolean; /** Opens the chain: the agents, the device, the document, the versions. */ onOpenChain?: (record: ProvenanceRecord) => void; /** * Jumps to the span an extracted value was lifted from. * * The single most requested behaviour from clinicians reviewing extraction, * which is why it is its own handler rather than something folded into the * chain. */ onOpenSpan?: (span: NonNullable<ProvenanceRecord["span"]>, record: ProvenanceRecord) => void;}export const ProvenanceChip = React.forwardRef<HTMLElement, ProvenanceChipProps>( function ProvenanceChip( { record: given, ledger, resourceId, versionId, now, stalenessPolicy, glyphOnly = false, onOpenChain, onOpenSpan, className, ...rest }, ref, ) { const record = given ?? (resourceId ? ledger?.get(resourceId, versionId) : undefined); // Nothing rather than a chip claiming an unknown origin. A chip that says // "unknown" on every value it has no ledger entry for teaches readers to // ignore the whole column. if (!record) return null; const age = now ? staleness(record, now, stalenessPolicy) : { state: "unknown" as const }; // The age is a fact and the staleness judgement is an opinion, so the age // shows whenever there is a date to measure from and only the highlight // waits for a policy. const at = record.observedAt ?? record.recordedAt; const elapsedMs = now && at ? Date.parse(now) - Date.parse(at) : Number.NaN; const showAge = Number.isFinite(elapsedMs) && elapsedMs >= 0; const label = describeProvenance(record, now, stalenessPolicy); const extracted = record.source === "ai-extracted"; const unconfirmed = extracted && !record.confirmed; const shared = { className: cn("zb-prov", className), "data-zb-provenance": "", "data-zb-source": record.source, "data-zb-staleness": age.state, "data-zb-unconfirmed": unconfirmed ? "" : undefined, "aria-label": label, ...rest, }; const body = ( <> <span className="zb-prov__glyph" data-zb-glyph={SOURCE_GLYPH[record.source]} aria-hidden="true" /> {glyphOnly ? null : ( <span className="zb-prov__word" aria-hidden="true"> {SOURCE_LABEL[record.source]} </span> )} {/* Staleness is folded in rather than kept in the chain. A device reading from four days ago and one from four minutes ago carry different weight, and the reader has to see that without hovering. */} {showAge ? ( <span className="zb-prov__age" data-zb-staleness={age.state} aria-hidden="true"> {describeAgeShort(elapsedMs)} </span> ) : null} {/* The confirmation state, for extracted values only. Absent means the question does not apply; a dot means nobody has looked, which is a different thing from a low-confidence score. */} {unconfirmed ? ( <span className="zb-prov__unconfirmed" aria-hidden="true"> unreviewed </span> ) : null} </> ); const chip = onOpenChain ? ( <button {...(shared as React.ButtonHTMLAttributes<HTMLButtonElement>)} ref={ref as React.Ref<HTMLButtonElement>} type="button" onClick={() => onOpenChain(record)} > {body} </button> ) : ( // A span when there is nothing to open. A focusable element with no // action is worse here than anywhere: there is one beside every value. <span {...(shared as React.HTMLAttributes<HTMLSpanElement>)} ref={ref as React.Ref<HTMLSpanElement>} role="img" > {body} </span> ); if (extracted && record.span && onOpenSpan) { const span = record.span; return ( <span className="zb-prov__pair"> {chip} <button type="button" className="zb-prov__span" onClick={() => onOpenSpan(span, record)} aria-label={`View the source span: ${span.document}${ typeof span.page === "number" ? `, page ${span.page}` : "" }`} > View span </button> </span> ); } return chip; },);