StructuredDataGrid
<co-structured-data-grid>StructuredDataGrid is a spreadsheet-like flowsheet for entering many numbers at once, with checks that block impossible values and warn on out-of-range ones.
import { StructuredDataGrid } from 'health-components';
Examples
Showcase
Inpatient Ranges
Read Only
Usage
<StructuredDataGrid title="ICU hourly vitals" columns={cols} rows={rows} onSave={save} />
When to use
- Nursing flowsheets, intake and output, dialysis runs, infusion vitals, ICU hourly charting.
When not to use
- One set of vitals: VitalsPanel. Free text: SOAPSection.
Variants and states
| Variant | What it is |
|---|---|
| valid | Green All valid tag. |
| out of range | Amber cell with the flag and reference range. Saving is allowed. |
| not possible | Red cell: not a number or outside the hard limits. Saving is blocked. |
| required empty | Red after the first save attempt. |
| readOnly | Formatted values with units, no inputs. |
Clinical values
Every number renders through CareOS.ClinicalValue and CareOS.fmt (the clinical-values builder), matched by LOINC; measures that table lacks (NT-proBNP, lactate, vancomycin trough, CrCl, PHQ-9, per-kg doses) use a local table with the same rules: tabular figures, the unit always shown, fixed decimals per measure (potassium 1, sodium 0, creatinine 2), the reference range in the title or beside it, and H, L, HH or LL flags in words for screen readers. The flag says where the number sits against the adult reference range in the rules table; it does not say the number was measured correctly.
Accessibility
- role grid with a label per cell (column, row and unit).
- Errors use role alert; aria-invalid on the input.
- Enter and Down move down a column.
Do and don't
- Do: Set hard limits per column (SpO2 0 to 100).
- Don't: Treat an in-range value as checked: the checks catch typing errors, not wrong measurements.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columns * | StructuredDataGridColumn[] | — | Columns; required |
rows | StructuredDataGridRow[] | none | Initial rows; the grid keeps its own copy as the user types |
title | string | none | Card title, also the grid's accessible name |
subtitle | string | none | Card subtitle |
readOnly | boolean | false | Whole grid read only |
onSave | (rows: StructuredDataGridRow[]) => void | none | Called with the rows when Save passes the checks |
onRowsChange | (rows: StructuredDataGridRow[]) => void | none | Called with the rows after every edit |
rangeContext | RangeContextId | the global context, else 'outpatient' | Which shared reference range flags use; the lab range on a result still wins |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, onChange, onInput, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-structured-data-grid>. 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.
<co-structured-data-grid title="…" subtitle="…" [columns]="columns" (co-save)="onSave($event.detail)"></co-structured-data-grid>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | columns | Columns; required |
| property / JSON attribute | rows | Initial rows; the grid keeps its own copy as the user types; default none |
| attribute | title | Card title, also the grid's accessible name; default none |
| attribute | subtitle | Card subtitle; default none |
| attribute | read-only / readOnly | Whole grid read only; default false |
| attribute | range-context / rangeContext | Which shared reference range flags use; the lab range on a result still wins; default the global context, else 'outpatient' |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-save | Called with the rows when Save passes the checks; default none (React: onSave) |
| event | co-rows-change | Called with the rows after every edit; default none (React: onRowsChange) |
| event | co-change | (React: onChange) |
| event | co-input | (React: onInput) |