Retrieve clinical notes via DocumentReference and fetch CDA or PDF attachments

domain: fhir · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Search for clinical notes: GET [base]/DocumentReference?patient=[id]&status=current&type=[LOINC-doc-type-code]; common LOINC document type codes include 34133-9 (Continuity of Care Document) and 11506-3 (Progress note).
  2. Extract content[].attachment.url for each document; this may be a direct URL to retrieve the binary content or a reference to a Binary resource.
  3. Retrieve the binary: if attachment.url is a relative or absolute FHIR URL, perform GET [url] with the same bearer token; the response is the raw document (PDF bytes or CDA XML).
  4. Check attachment.contentType: 'application/pdf' for PDFs, 'text/xml' or 'application/xml' for CDA documents, 'text/plain' for plain text notes.
  5. For CDA documents, parse the XML to extract the structured body or narrative text; the ClinicalDocument/component/structuredBody path contains coded section content.
  6. Inspect context.encounter to link the note to its associated Encounter resource and context.period for the note's relevant date range.

Known gotchas

Related routes

Invoke the FHIR $docref operation to retrieve clinical documents for a patient in DocumentReference form
hl7.org · 6 steps · unrated
Create a FHIR DocumentReference and Binary resource to store and expose a clinical document
healthcare-fhir · 6 steps · unrated
Invoke the FHIR $docref operation to retrieve clinical documents for a patient per US Core
healthcare-fhir · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans