Skip to main content

Medical Records

Route: /reports
File: memberportal/src/pages/ReportsNotesPage.tsx
FHIR Resources: DiagnosticReport, DocumentReference

This page shows the patient's medical documents, clinical notes, and diagnostic reports — things like discharge summaries, imaging reports, and clinical visit notes.

Data sources and deduplication​

Both DiagnosticReport and DocumentReference resources are fetched in parallel via searchResourcePages (streaming, renders incrementally as pages arrive). They are merged into a single unified ReportRow list.

To avoid duplicates, any DocumentReference whose attachment URL is already referenced by a DiagnosticReport.presentedForm entry is suppressed.

Category classification​

Each row is classified into one of four categories:

CategoryFHIR sourceCriteria
LabDiagnosticReportcategory code: lab, laboratory, ch, hm; also default for uncategorised DiagnosticReports
RadiologyDiagnosticReport / DocumentReferencecategory code: rad, radiology, rx / type LOINC codes 18748-4, 18726-0, 24606-4
NoteDocumentReferenceDefault for DocumentReferences not matched as Radiology
OtherEitherFallback

What is displayed per row​

  • Report title / note name (with patient-mode plain-language translation via usePatientTranslate)
  • Type badge (Lab / Radiology / Note / Other)
  • Date
  • Author / performer
  • EHR source badge (left-border colour + badge)
  • Ask ChartChat button per row

Category tabs​

The toolbar shows tabs for All / Lab / Radiology / Note / Other with per-tab counts.

Filtering​

  • Date range: Last 30 days / Last 3 months / Last year
  • Search: by document title
  • Sorting: by title, type, date, or status

Detail modal​

Clicking any row opens a detail modal displaying the document content. The modal header shows title, date, category badge, EHR source, status, and performer.

Document viewer​

The content is fetched via the server's binary proxy (authenticated), then routed to the appropriate viewer:

Content typeViewer
application/pdfOpens in a new browser tab; modal shows a confirmation card with re-open button
text/htmlWrapped in a full HTML document with dark-mode styles, rendered in a sandboxed <iframe>
text/rtf / application/mswordRTF control words stripped, rendered as plain text in an <iframe>
text/plainHTML-escaped, rendered in a monospace <iframe>
application/xml (C-CDA)Parsed into sections by parseCcda(), rendered by CcdaViewer

Binary proxy endpoints​

ProxyUsed when
GET /fhir/binary-proxy/{binaryId}Binary ID is extractable from the attachment URL
GET /fhir/url-proxy?url={encodedUrl}Attachment is a pre-signed storage URL

C-CDA parser​

C-CDA (Consolidated Clinical Document Architecture) XML is parsed client-side:

  • Each <section> element is extracted with its <title> and <text> child nodes
  • HL7 v3 element names are translated to HTML equivalents (<paragraph> → <p>, <content> → <span>)
  • Output is sanitised with DOMPurify before rendering

If a DiagnosticReport.conclusion text is present, it is shown below the document content in a "Conclusion" block.

Aborting in-flight fetches​

Each row click cancels any in-flight binary fetch from a previous row via AbortController. Blob URLs are revoked when the modal closes to free memory.

AI Chat​

  • A Ask about Medical Records icon in the page header opens a ResourceChatDrawer for general questions.
  • Each row has an Ask ChartChat column for per-report questions.
  • The detail modal also has an Ask ChartChat button that closes the modal and opens the per-row chat drawer.

Stat card​

One summary card: total document count (DiagnosticReport count + DocumentReference count).

FHIR resources used​

ResourcePurpose
DocumentReferenceClinical notes, scanned documents, visit summaries
DiagnosticReportStructured diagnostic reports (radiology, pathology, etc.)