Skip to main content

DocumentViewer

ComplexChart panels<co-document-viewer>

DocumentViewer shows a scanned or outside document page by page with zoom, and lets staff highlight a line or comment on it, listing the annotations beside the page.

import { DocumentViewer } from 'health-components';

Examples​

Showcase​

Storybook

Read Only​

Storybook

Could Not Open​

Storybook

Usage​

<DocumentViewer title="Discharge summary" pages={pages} annotations={notes} />

When to use​

  • Outside records, discharge summaries, faxed consult letters, prior-auth packets.

When not to use​

  • Incoming fax triage: FaxDocumentViewer.

Variants and states​

VariantWhat it is
viewingPage, zoom 50 to 200 %, page count.
highlightYellow mark on a line.
commentBlue mark with the text in the side list.
addingClick a line, then type a comment or Highlight.
readOnlyLock note; no adding.
error / emptyEmpty state with the reason.

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​

  • Page changes are announced (aria-live).
  • Marks are focusable.

Do and don't​

  • Do: Say who annotated and when.
  • Don't: Change the source document: annotations sit on top.

Props​

PropTypeDefaultDescription
pagesDocumentPage[]none (empty state)Pages
annotationsDocumentAnnotation[]noneInitial annotations; the viewer keeps its own copy
onAnnotationsChange(annotations: DocumentAnnotation[]) => voidnoneCalled with all annotations after one is added
pagenumberuncontrolledShown page index (controlled), from 0
defaultPagenumber0Initial page index
onPageChange(page: number) => voidnoneCalled with the new page index
onDownload() => voidnoneCalled by Download
titlestringnoneCard title
subtitlestringnoneCard subtitle (source, received)
userstring'You'Author name on new annotations
readOnlybooleanfalseNo adding annotations
errorstringnoneWhy the document could not be opened; shows the error state
maxHeightnumber520Height of the page area in px
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-document-viewer>. 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-document-viewer page="…" default-page="…" [pages]="pages" (co-annotations-change)="onAnnotationsChange($event.detail)"></co-document-viewer>
KindNameDescription
property / JSON attributepagesPages; default none (empty state)
property / JSON attributeannotationsInitial annotations; the viewer keeps its own copy; default none
attributepageShown page index (controlled), from 0; default uncontrolled
attributedefault-page / defaultPageInitial page index; default 0
attributetitleCard title; default none
attributesubtitleCard subtitle (source, received); default none
attributeuserAuthor name on new annotations; default 'You'
attributeread-only / readOnlyNo adding annotations; default false
attributeerrorWhy the document could not be opened; shows the error state; default none
attributemax-height / maxHeightHeight of the page area in px; default 520
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-annotations-changeCalled with all annotations after one is added; default none (React: onAnnotationsChange)
eventco-page-changeCalled with the new page index; default none (React: onPageChange)
eventco-downloadCalled by Download; default none (React: onDownload)