Skip to content

Patient identity

Beta

An avatar, a chip and a patient banner — with the pass that keeps two patients who share a name apart on the same worklist.

FHIR R4Patient
15 states12 propssince 0.1.0
pnpm add @zoblocks/identity
npm ↗

Why it exists

A patient banner is the most PHI-dense component in a healthcare product and the one nobody designs.

It is pinned to the top of every screen, read hundreds of times a shift, and it is the last thing standing between a clinician and someone else's chart. Adelman et al. (JAMIA 2013, 901,776 ordering sessions) found a dismissible 'check the patient' alert cut wrong-patient orders with an odds ratio of 0.84, while making the clinician re-enter the patient's initials cut them with an odds ratio of 0.60 — so a banner that is only read is worth a sixth of one that is answered, and both require the header to know what action is about to happen. Everything else follows from treating identity as a resolved value rather than a bag of booleans: absence of a photograph is five different facts, 'Inactive' is four unrelated ones, and two patients sharing a surname on a ward list is a problem a component can see and an application never will.

Playground

Change a prop and watch the component and its code change with it.

Design language
Amara Okonkwo Sensitive record
DOB08 Mar 1985Age41 yNHS number943 476 5919Identifier093-441-208Ward4B / bay 2
This record carries sensitivity labels. Revealing which ones is recorded against your account.
Props
Events
  • onReveal — nothing yet
Playground.tsx
import { PatientBanner } from "@zoblocks/identity";export default function Example() {  return (    <PatientBanner      patient={patient}      identifiers={[{ kind: "mrn" }, { kind: "nhs" }]}      context="action"      ward="4B / bay 2"    />  );}

Examples

The cases worth copying. Open one in StackBlitz to run it with its dependencies installed.

Identifying

Two patients, one name

A worklist wrapped in IdentitySet reads what is actually on screen and adds the minimum that separates each collided row — full given name, then date of birth, then identifier — stopping at the first rung that works. Rows with no collision are left untouched.

Confirm before ordering

Adelman et al. (JAMIA 2013, 901,776 ordering sessions): a dismissible 'check the patient' alert cut wrong-patient orders with an odds ratio of 0.84; making the clinician re-enter the patient's initials cut them with an odds ratio of 0.60. PatientVerify is the second one — a banner that is answered rather than only read.

Access

One resource, four audiences

The same record renders four ways under one IdentityProvider. A waiting-room screen carries enough for the named person to recognise themselves and no more; a clinician gets full clinical detail, with sensitivity categories held behind an audited reveal.

Wrong patient, refused

The coupling that makes a banner a control rather than a heading. The form knows which patient it was opened for; the banner knows which chart is on screen; PatientGuard refuses to render when those disagree, in every environment, not only a development build.

Installation

Terminal
pnpm add @zoblocks/identity

This one ships on npm rather than as copied source, because it carries a headless core you can take on its own. Ant Design is an optional peer: the component works without it. Import its stylesheet too: import "@zoblocks/identity/styles.css".

Dependencies@zoblocks/identity-core

Usage

Props are the FHIR resource.

usage.tsx
import {  IdentityProvider,  PatientBanner,  PatientGuard,} from "@zoblocks/identity";import "@zoblocks/identity/styles.css";<IdentityProvider disclosure="clinical" photos="allow" onSensitiveReveal={audit.write}>  {/* context="action" takes a two-or-more tuple: NPSG.01.01.01 as a compile error. */}  <PatientBanner    patient={patient}    context="action"    identifiers={[{ kind: "mrn" }, { kind: "nhs" }]}  >    {/* Refuses to render if the chart on screen is not the one this was opened for. */}    <PatientGuard expect={openedFor.id} expectName={openedFor.name}>      <OrderForm />    </PatientGuard>  </PatientBanner></IdentityProvider>;

Use it when

  • The pinned header of any chart, order screen or note editor — `context="action"` wherever a care action follows, which requires two person-specific identifiers at the type level.
  • Worklists and admissions lists, wrapped in an `IdentitySet`: the disambiguation pass only escalates rows that genuinely collide, and leaves the rest untouched.
  • Anywhere the record's own facts should drive the rendering — deceased, merged, test and restricted are read from the resource, never passed as props.
  • Reception and waiting-room surfaces, via `disclosure`: the same resource renders four ways, and a public screen shows enough for the named person to recognise themselves and no more.
  • Screenshots, sales demos and training environments — `demoMode` substitutes synthetic identities everywhere, deterministically keyed off the real record so collisions and name lengths survive.

Avoid it when

  • Rendering `Patient.gender`. It is administrative gender — correspondence and registries, not dosing — and it is absent from the `fields` union for that reason. Ask for `spcu` or `recorded-sex-or-gender`, which render labelled as what they are.
  • Reaching for the legal name without a reason. `nameContext="legal"` requires one, because chosen-name use across contexts is associated with substantially lower depression and suicidality among transgender young people, and `name[0]` is not a neutral default.
  • Two banners on one screen. Two authoritative answers to “whose chart is this” is the defect; use `PatientChip` to reference a second patient.
  • Keying the avatar swatch on a name. A marriage, a correction or a transition repaints the person, and a banner showing the chosen name will disagree with a worklist showing the legal one. A lint rule catches it.
  • Treating the disambiguation pass as record matching. It answers “would a reader in a hurry confuse these two rows”, which is a different and much narrower question than “are these the same person”.

API

Every prop is typed. Props not listed are forwarded to the root element.

PatientBanner

12 props

12 props

contextrequired
'navigation' | 'action' | 'verification'
Default—
Navigation and read-only surfaces. One identifier is enough. Anything that precedes a care action. Two identifiers, enforced.
actions
ReactNode
Default—
Rendered at the end of the banner — actions belong to the application.
children
ReactNode
Default—
Screen content rendered beneath the banner, inside its patient context. This is what lets `PatientGuard` compare a form against the chart on screen. React context needs nesting, and a banner that owns the region below it is the honest shape: the banner is not a decoration above the content, it is the statement the content is made under.
className
string
Default—
Applied to the banner element.
error
OperationOutcome | Error
Default—
The record could not be fetched. Rendered as an explicit failure, never as an empty banner: a blank identity strip above a chart is indistinguishable from a patient with no name, and one of those is safe to act under.
fields
Field[]
Default—
Priority order. The container query drops from the tail.
identifiers
TwoOrMore<IdentifierSpec> | readonly IdentifierSpec[]
Default—
Which identifiers to show. Optional here; a worklist row is not a care action. Two person-specific identifiers, enforced by the type. NPSG.01.01.01 asks for two before a care action, so supplying one is a compile error rather than a review comment — this is the whole reason `context` is a required prop.
identityKey
string
Default—
Overrides the swatch key. Prefer a stable record id, so the same patient keeps the same colour across sessions.
loading
true
Default—
The record has not arrived yet. Renders a placeholder that is unmistakably not a patient.
onReveal
(() => void)
Default—
Fired when a user reveals a withheld field. The app writes the audit.

Page 1 of 2

Accessibility

Screen readers and semantics

  • One region, one composed name. The default rendering of a banner is seven fragments — initials, a name, a status pill, a letter, an age, a date, a number — that a non-sighted user has to reassemble into a person. `identityLabel()` composes one string instead, and it lives in the engine precisely so the accessible name and the pixels are two projections of one value and cannot disagree.
  • The identifier is spelled out. Every major screen reader pronounces the unspaced form of MRN as “mern”, and digits run together as a quantity. The label emits “M R N 123, 456, 789”, because a clinician verifying an identifier by ear needs the letters and the grouping.
  • The patient changed and nobody said so. A sighted user gets a full visual repaint when the chart switches; a screen-reader user gets nothing, because focus is wherever it was and the DOM swapped underneath them. A polite live region announces the new patient — debounced, so a rapid list traversal does not queue up announcements, and polite so it never interrupts a value being read.
  • The avatar says nothing. `aria-hidden`, always, when it sits beside the name. It carries no information a non-sighted user can use, and alt text naming the patient is both noise and a small PHI leak into anything that scrapes alt attributes. The tint is decorative by definition and is never exposed as meaning.
  • Absence is distinguishable, not just visible. The five photo states produce five different accessible names as well as five different renderings, so “no photo on record” and “photo could not be loaded” are as distinct by ear as they are by eye.
  • A withheld category is withheld from everyone. Sensitivity codes are named only after an audited reveal, or at full disclosure — in the tag, in the row and in the accessible name alike. Naming them in the label alone would hand a screen-reader user the thing the reveal exists to record.
  • Nothing is ellipsised. There is no `text-overflow` on any name or identifier at any width. “Mohammed Al-Rash…” and “Mohammed Al-Rashid” are two people on the same ward, and a truncated MRN is not a shorter number — it is a different one. Fields leave whole in a declared priority order, so what disappears at 320px was a designer's decision rather than the layout engine's.
  • Colour is never the signal. Every state carries an icon and a word as well as a tone, and the six decorative swatches collapse to one value under forced colors — which is the argument for never relying on them: if a design stops working when the tint goes, it was already broken for the roughly 8% of men who cannot separate two of those hues.