ResultsTrendPanel
<co-results-trend-panel>ResultsTrendPanel shows many lab results over time, grouped by LOINC panel, as a grid of sparkline tiles or as a date-by-test table.
import { ResultsTrendPanel } from 'health-components';
Examples
Showcase
Table View
Last Three Draws
Empty
Usage
<ResultsTrendPanel groups={groups} defaultView="table" maxColumns={6} />
When to use
- Reviewing trends before a visit or a dose change: renal function on an ACE inhibitor, hemoglobin on chemotherapy, A1c over a year.
When not to use
- A single new result to sign: ResultsReview. One panel in one draw: LabResultTable.
Variants and states
| Variant | What it is |
|---|---|
| Sparklines | One tile per test: latest value, flag, sparkline, reference range, change since the previous draw. |
| Table | Rows are tests grouped by panel; columns are draw dates; "--" when not drawn. |
| flagged tile | Amber bar for H or L, red border for HH or LL. |
| empty | No results in the period. |
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
- The view switch is a radio group.
- The table has a hidden caption, row headers per test and column-group headers per panel.
- Each value carries its unit and flag in its accessible name.
Do and don't
- Do: Keep LOINC codes visible so outside results line up.
- Don't: Draw a sparkline across tests with different units.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
groups | ResultsTrendGroup[] | none (empty state) | Groups of trended tests |
view | ResultsTrendView | uncontrolled | Shown view (controlled): 'grid' (sparkline tiles) | 'table' (date by test) |
defaultView | ResultsTrendView | 'grid' | Initial view: 'grid' | 'table' |
onViewChange | (view: ResultsTrendView) => void | none | Called when the view changes |
maxColumns | number | all | Most recent dates shown as table columns |
title | string | 'Results Trend' | Card title |
subtitle | string | none | Card subtitle |
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, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-results-trend-panel>. 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-results-trend-panel view="…" default-view="…" [groups]="groups" (co-view-change)="onViewChange($event.detail)"></co-results-trend-panel>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | groups | Groups of trended tests; default none (empty state) |
| attribute | view | Shown view (controlled): 'grid' (sparkline tiles) | 'table' (date by test); default uncontrolled |
| attribute | default-view / defaultView | Initial view: 'grid' | 'table'; default 'grid' |
| attribute | max-columns / maxColumns | Most recent dates shown as table columns; default all |
| attribute | title | Card title; default 'Results Trend' |
| attribute | subtitle | Card subtitle; default none |
| 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-view-change | Called when the view changes; default none (React: onViewChange) |