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
Matched
Mismatch
Witness With Override
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
| Variant | What it is |
|---|---|
| waiting | Dashed outline, input focused for the scanner. |
| matched | Green, check icon, Rescan. |
| mismatch | Red, says "Do not give", shows expected and scanned. |
| override | Skipped with a reason (barcode damaged). |
| target | patient, 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
| Prop | Type | Default | Description |
|---|---|---|---|
target | BarcodeScanTarget | 'medication' | 'patient' (wristband) | 'medication' | 'witness' (badge) |
expected | string | none (any scan matches) | Code to match (compared trimmed and case-insensitive) |
expectedLabel | string | none | What it should be ('Marcus Hill, DOB 03/14/1959') |
step | number | none | Step number shown before the prompt |
state | BarcodeScanState | uncontrolled | Controlled state: 'waiting' | 'matched' | 'mismatch' | 'override' |
defaultState | BarcodeScanState | 'waiting' | Initial state (uncontrolled) |
onStateChange | (state: BarcodeScanState) => void | none | Called when the state changes (a scan is checked, Cannot scan, Rescan) |
defaultCode | string | '' | Scanned code shown in the field and the status line |
allowOverride | boolean | false | Shows a Cannot scan button |
overrideReason | string | 'barcode damaged' | Reason shown in the override state |
autoFocus | boolean | false | Focuses the field on mount (the scanner types into it) |
matchedText | string | 'Scan matches <expectedLabel>' | Replaces the matched message |
mismatchText | string | 'Scan does not match. Do not give...' | Replaces the mismatch message |
onScan | (code: string, ok: boolean) => void | none | Called with the code and whether it matched when a scan is checked |
onOverride | () => void | none | Called on Cannot scan |
onReset | () => void | none | Shows Rescan in the matched state and is called by it |
rangeContext | RangeContextId | '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>
| Kind | Name | Description |
|---|---|---|
| attribute | target | 'patient' (wristband) | 'medication' | 'witness' (badge); default 'medication' |
| attribute | expected | Code to match (compared trimmed and case-insensitive); default none (any scan matches) |
| attribute | expected-label / expectedLabel | What it should be ('Marcus Hill, DOB 03/14/1959'); default none |
| attribute | step | Step number shown before the prompt; default none |
| attribute | state | Controlled state: 'waiting' | 'matched' | 'mismatch' | 'override'; default uncontrolled |
| attribute | default-state / defaultState | Initial state (uncontrolled); default 'waiting' |
| attribute | default-code / defaultCode | Scanned code shown in the field and the status line; default '' |
| attribute | allow-override / allowOverride | Shows a Cannot scan button; default false |
| attribute | override-reason / overrideReason | Reason shown in the override state; default 'barcode damaged' |
| attribute | auto-focus / autoFocus | Focuses the field on mount (the scanner types into it); default false |
| attribute | matched-text / matchedText | Replaces the matched message; default 'Scan matches <expectedLabel>' |
| attribute | mismatch-text / mismatchText | Replaces the mismatch message; default 'Scan does not match. Do not give...' |
| attribute | range-context / rangeContext | Accepted for API consistency with the nursing set (no values are flagged here); default 'inpatient' |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| event | co-state-change | Called when the state changes (a scan is checked, Cannot scan, Rescan); default none (React: onStateChange) |
| event | co-scan | Called with the code and whether it matched when a scan is checked; default none (React: onScan) |
| event | co-override | Called on Cannot scan; default none (React: onOverride) |
| event | co-reset | Shows Rescan in the matched state and is called by it; default none (React: onReset) |