Skip to main content

ResultsTrendPanel

ComplexChart panels<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​

Storybook

Table View​

Storybook

Last Three Draws​

Storybook

Empty​

Storybook

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​

VariantWhat it is
SparklinesOne tile per test: latest value, flag, sparkline, reference range, change since the previous draw.
TableRows are tests grouped by panel; columns are draw dates; "--" when not drawn.
flagged tileAmber bar for H or L, red border for HH or LL.
emptyNo 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​

PropTypeDefaultDescription
groupsResultsTrendGroup[]none (empty state)Groups of trended tests
viewResultsTrendViewuncontrolledShown view (controlled): 'grid' (sparkline tiles) | 'table' (date by test)
defaultViewResultsTrendView'grid'Initial view: 'grid' | 'table'
onViewChange(view: ResultsTrendView) => voidnoneCalled when the view changes
maxColumnsnumberallMost recent dates shown as table columns
titlestring'Results Trend'Card title
subtitlestringnoneCard subtitle
rangeContextRangeContextIdthe 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.

Angular template
<co-results-trend-panel view="…" default-view="…" [groups]="groups" (co-view-change)="onViewChange($event.detail)"></co-results-trend-panel>
KindNameDescription
property / JSON attributegroupsGroups of trended tests; default none (empty state)
attributeviewShown view (controlled): 'grid' (sparkline tiles) | 'table' (date by test); default uncontrolled
attributedefault-view / defaultViewInitial view: 'grid' | 'table'; default 'grid'
attributemax-columns / maxColumnsMost recent dates shown as table columns; default all
attributetitleCard title; default 'Results Trend'
attributesubtitleCard subtitle; default none
attributerange-context / rangeContextWhich shared reference range flags use; the lab range on a result still wins; default the global context, else 'outpatient'
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
eventco-view-changeCalled when the view changes; default none (React: onViewChange)