Skip to main content

BarcodeScanPrompt

ComplexInpatient nursing<co-barcode-scan-prompt>

BarcodeScanPrompt asks for one barcode scan (wristband, medication or witness badge), checks it against the expected code and shows match, mismatch or skipped.

import { BarcodeScanPrompt } from 'health-components';

Examples​

States​

Storybook

Matched​

Storybook

Mismatch​

Storybook

Witness With Override​

Storybook

Usage​

<BarcodeScanPrompt step={2} target="medication" expected="NDC0409-7332" expectedLabel="cefTRIAXone 1 g" onScan={(c, ok) => ...} />

When to use​

  • Positive patient ID and drug scan in MAR, specimen collection, blood transfusion.

When not to use​

  • Typing an MRN to search: Combobox.

Variants and states​

VariantWhat it is
waitingDashed outline, input focused for the scanner.
matchedGreen, check icon, Rescan.
mismatchRed, says "Do not give", shows expected and scanned.
overrideSkipped with a reason (barcode damaged).
targetpatient, medication or witness.

Accessibility​

  • Group labelled by the instruction; result announced by a polite live region.
  • Scanner input is a labelled text field so keyboard entry works.
  • Mismatch uses an icon and words, not only red.

Do and don't​

  • Do: Match on the full code; compare case-insensitively.
  • Don't: Treat a match as proof the dose is right; it proves the barcode matches the order only.

Props​

PropTypeDefaultDescription
targetBarcodeScanTarget'medication''patient' (wristband) | 'medication' | 'witness' (badge)
expectedstringnone (any scan matches)Code to match (compared trimmed and case-insensitive)
expectedLabelstringnoneWhat it should be ('Marcus Hill, DOB 03/14/1959')
stepnumbernoneStep number shown before the prompt
stateBarcodeScanStateuncontrolledControlled state: 'waiting' | 'matched' | 'mismatch' | 'override'
defaultStateBarcodeScanState'waiting'Initial state (uncontrolled)
onStateChange(state: BarcodeScanState) => voidnoneCalled when the state changes (a scan is checked, Cannot scan, Rescan)
defaultCodestring''Scanned code shown in the field and the status line
allowOverridebooleanfalseShows a Cannot scan button
overrideReasonstring'barcode damaged'Reason shown in the override state
autoFocusbooleanfalseFocuses the field on mount (the scanner types into it)
matchedTextstring'Scan matches <expectedLabel>'Replaces the matched message
mismatchTextstring'Scan does not match. Do not give...'Replaces the mismatch message
onScan(code: string, ok: boolean) => voidnoneCalled with the code and whether it matched when a scan is checked
onOverride() => voidnoneCalled on Cannot scan
onReset() => voidnoneShows Rescan in the matched state and is called by it
rangeContextRangeContextId'inpatient'Accepted for API consistency with the nursing set (no values are flagged here)

Also accepts native attributes, including defaultChecked, defaultValue, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-barcode-scan-prompt>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-barcode-scan-prompt target="…" expected="…" [defaultValue]="defaultValue" (co-state-change)="onStateChange($event.detail)"></co-barcode-scan-prompt>
KindNameDescription
attributetarget'patient' (wristband) | 'medication' | 'witness' (badge); default 'medication'
attributeexpectedCode to match (compared trimmed and case-insensitive); default none (any scan matches)
attributeexpected-label / expectedLabelWhat it should be ('Marcus Hill, DOB 03/14/1959'); default none
attributestepStep number shown before the prompt; default none
attributestateControlled state: 'waiting' | 'matched' | 'mismatch' | 'override'; default uncontrolled
attributedefault-state / defaultStateInitial state (uncontrolled); default 'waiting'
attributedefault-code / defaultCodeScanned code shown in the field and the status line; default ''
attributeallow-override / allowOverrideShows a Cannot scan button; default false
attributeoverride-reason / overrideReasonReason shown in the override state; default 'barcode damaged'
attributeauto-focus / autoFocusFocuses the field on mount (the scanner types into it); default false
attributematched-text / matchedTextReplaces the matched message; default 'Scan matches <expectedLabel>'
attributemismatch-text / mismatchTextReplaces the mismatch message; default 'Scan does not match. Do not give...'
attributerange-context / rangeContextAccepted for API consistency with the nursing set (no values are flagged here); default 'inpatient'
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
eventco-state-changeCalled when the state changes (a scan is checked, Cannot scan, Rescan); default none (React: onStateChange)
eventco-scanCalled with the code and whether it matched when a scan is checked; default none (React: onScan)
eventco-overrideCalled on Cannot scan; default none (React: onOverride)
eventco-resetShows Rescan in the matched state and is called by it; default none (React: onReset)