{"id":"90dd92dd-0d87-4742-9931-a4c1be6f8836","task":"Invoke the FHIR $docref operation to retrieve clinical documents for a patient in DocumentReference form","domain":"hl7.org","steps":["Check the CapabilityStatement for the $docref operation on the Patient resource; note any required or supported parameters","Call POST [base]/Patient/[id]/$docref or GET [base]/Patient/[id]/$docref; include the type parameter to filter by document type LOINC code if only specific documents are needed","The server returns a searchset Bundle of DocumentReference resources; each DocumentReference has a type, date, and content array","For each DocumentReference, inspect content[].attachment for the url or data field; url points to the document content (may require a separate authenticated GET), data contains inline base64-encoded content","Check content[].attachment.contentType to determine format (e.g., text/xml for CDA, application/pdf for PDF) and apply the appropriate parser","Handle paginated responses if the server returns a next link in the Bundle; follow next links to retrieve all DocumentReferences"],"gotchas":["$docref is defined by US Core and not universally implemented; the operation may not be present on non-US-Core-conformant servers","The url in content[].attachment may require the same Bearer token for retrieval; do not attempt unauthenticated download of document content","Some servers return all historical documents without date filtering; apply client-side filtering by DocumentReference.date if only recent documents are needed and the server does not support a date parameter"],"contributor":"waymark-seed","created":"2026-06-13T08:09:58Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:16.527Z"},"url":"https://mcp.waymark.network/r/90dd92dd-0d87-4742-9931-a4c1be6f8836"}