Overview
The DocumentViewer provides a sophisticated interface for viewing multiple document types including PDFs and FHIR resources. It features tabbed navigation, search functionality, citation highlighting, and automatic document processing integration with the SampleHC workflow system.Basic Usage
API Reference
DocumentViewer (Async Results)
Array of async result IDs from document processing workflows. The viewer will automatically extract document IDs from these results.
Array of citations to highlight across documents. Defaults to empty array.
Filter FHIR documents to show only specific resource types (e.g., [“Observation”, “DiagnosticReport”]).
DocumentViewerBase (Direct Documents)
Array of document IDs to display directly.
Array of citations to highlight across documents. Defaults to empty array.
Dependencies that trigger document refetch when changed. Defaults to empty array.
Filter FHIR documents to show only specific resource types.
Citation Type
ID of the document containing the citation.
Index of the chunk within the document.
Index of the block within the chunk.
Supported Formats
- PDF Documents: Interactive PDF viewing with highlights, text selection, and page navigation
- FHIR JSON: Both single JSON documents and JSONL (line-delimited JSON) formats
Features
Document Management
- Tabbed Navigation: Switch between multiple documents with file name tabs
- Document Type Toggle: Switch between PDF and FHIR document sets
- Auto-loading: Automatic document fetching from async processing results
Search & Navigation
- Cross-document Search: Search text across all loaded documents
- Real-time Results: Instant search results with highlighted matches
- Search Highlighting: Blue highlights for search results with match scores
- Citation Navigation: Yellow highlights for referenced citations
PDF Features
- Page-based Viewing: Full PDF viewer with zoom, rotation, and page controls
- Highlight Overlays: Visual citation and search result highlighting
- Page Jump: Navigate directly to pages containing highlights
FHIR Features
- Categorized Display: Organize FHIR resources by type (Notes, Observations, etc.)
- Timeline View: Chronological organization by months and years
- Resource Filtering: Filter by specific FHIR resource types
- Collapsible Sections: Expandable/collapsible chunks with preview
- Patient Information: Dedicated patient info section
Highlight System
- Floating Navigation Panel: Navigate between all highlights with keyboard shortcuts
- Citation Highlighting: Automatic highlighting of referenced text passages
- Search Highlighting: Visual highlighting of search matches
- Cross-document Navigation: Jump between highlights across different documents
Keyboard Shortcuts
- Alt + →: Next highlight
- Alt + ←: Previous highlight
Advanced Examples
Workflow Integration with Citations
Filtered FHIR Resource Viewing
Direct Document Access
Citation Navigation Integration
Integration Notes
Workflow Integration: The DocumentViewer is designed to work with the SampleHC workflow system. Use
DocumentViewer
for async processing results and DocumentViewerBase
for direct document access.Performance: The component uses virtual scrolling for large documents and lazy loading for better performance. Documents are cached and refetched only when needed.
Document Processing: Ensure documents are fully processed before viewing. The component will show loading states while async results are being processed.
Best Practices
Citation Management
- Use
useTaskState
to persist citations across workflow steps - Implement citation navigation controls for better user experience
- Consider debouncing citation updates for performance
Search Integration
- The search functionality works across all loaded documents
- Search results are highlighted in blue, citations in yellow
- Use the floating navigation panel for efficient highlight traversal
FHIR Resource Filtering
- Filter by resource types to focus on specific medical data
- Common filters:
["Observation", "DiagnosticReport"]
for lab results - Use undefined/null to show all resource types
Document Loading
- Always handle loading states for better UX
- Consider showing document counts and processing status
- Implement error boundaries for failed document loads