DrugSearch
ComplexMedications
<co-drug-search>DrugSearch finds a medication with form, RxNorm, plan coverage and DEA schedule shown in each result.
import { DrugSearch } from 'health-components';
Examples
Open
No Matches
Unknown Plan
Usage
<DrugSearch payer="Aetna" options={drugs} onSelect={setDrug} />
When to use
- Starting a new prescription.
When not to use
- Picking from the current list: MedicationList.
Variants and states
| Variant | What it is |
|---|---|
| covered / prior auth | Coverage text in meta. |
| controlled | Schedule badge. |
Accessibility
- Combobox pattern.
Do and don't
- Do: Show coverage before the provider picks.
- Don't: Hide the schedule.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options * | DrugOption[] | — | Array<{label, form?, rxnorm?, coverage?, schedule?}>; required |
label | string | "Medication" | Field label |
payer | string | "the patient's plan" | Payer whose formulary is shown, in the footer |
onSelect | (drug: DrugOption) => void | none | Called with the chosen drug |
style | CSSProperties | — | Inline style of the root |
error | string | none | Error message (as TextField) |
open | boolean | undefined (uncontrolled) | Controlled open state of the list |
placeholder | string | none | Example text in the empty input |
required | boolean | false | Red asterisk plus aria-required |
query | string | undefined (uncontrolled) | Controlled query text |
defaultQuery | string | "" | Initial query (uncontrolled) |
onQueryChange | (query: string) => void | — | Called when the query text changes |
defaultOpen | boolean | false | Open on first render (uncontrolled) |
onOpenChange | (open: boolean) => void | — | Called when the list opens or closes |
limit | number | 8 | Maximum results shown |
emptyText | string | "No matches. Check the spelling or search by MRN." | Text when nothing matches |
helper | string | none | Muted hint under the field |
Also accepts native attributes, including defaultChecked, autoFocus, onInput, readOnly, type, disabled, name, max, step, accept, autoComplete, checked, maxLength, min, multiple, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-drug-search>. 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-drug-search label="…" payer="…" [options]="options" (co-select)="onSelect($event.detail)"></co-drug-search>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | options | Array<{label, form?, rxnorm?, coverage?, schedule?}>; required |
| attribute | label | Field label; default "Medication" |
| attribute | payer | Payer whose formulary is shown, in the footer; default "the patient's plan" |
| attribute | default-checked / defaultChecked | |
| attribute | auto-focus / autoFocus | |
| property / JSON attribute | style | Inline style of the root |
| attribute | read-only / readOnly | |
| attribute | error | Error message (as TextField); default none |
| property / JSON attribute | type | |
| attribute | disabled | |
| attribute | name | |
| property / JSON attribute | max | |
| property / JSON attribute | step | |
| attribute | open | Controlled open state of the list; default undefined (uncontrolled) |
| attribute | placeholder | Example text in the empty input; default none |
| attribute | accept | |
| property / JSON attribute | auto-complete / autoComplete | |
| attribute | checked | |
| attribute | max-length / maxLength | |
| property / JSON attribute | min | |
| attribute | multiple | |
| attribute | required | Red asterisk plus aria-required; default false |
| attribute | query | Controlled query text; default undefined (uncontrolled) |
| attribute | default-query / defaultQuery | Initial query (uncontrolled); default "" |
| attribute | default-open / defaultOpen | Open on first render (uncontrolled); default false |
| attribute | limit | Maximum results shown; default 8 |
| attribute | empty-text / emptyText | Text when nothing matches; default "No matches. Check the spelling or search by MRN." |
| attribute | helper | Muted hint under the field; default none |
| event | co-select | Called with the chosen drug; default none (React: onSelect) |
| event | co-input | (React: onInput) |
| event | co-query-change | Called when the query text changes (React: onQueryChange) |
| event | co-open-change | Called when the list opens or closes (React: onOpenChange) |