Launch a SMART app from a CDS Hooks card link action and pass hook context to the app so it can pre-populate clinical data without a redundant FHIR query
domain: cds-hooks.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
In the CDS Hooks card response, add a links array entry with type set to smart, url set to the SMART app launch URL, and appContext set to a JSON-serialized string containing the relevant hook context data such as the draft order resource ID, encounter ID, and any payer response data
In the SMART app, parse the appContext parameter from the launch token after the EHR completes the SMART EHR launch handshake; the appContext is delivered as a claim in the launch token or as a query parameter depending on the EHR implementation
Validate the appContext content before trusting it: verify that the resource IDs in appContext exist on the FHIR server using the access token obtained during the SMART launch, since appContext is EHR-supplied and may contain stale or invalid references
Use the FHIR access token from the SMART launch to fetch the full resources referenced in appContext rather than accepting the appContext data as authoritative; the appContext is a hint, not a verified data payload
Display the pre-populated data to the clinician immediately on app load using the appContext hints while background FHIR fetches complete, then update the display when the authoritative FHIR data arrives
Handle the case where appContext is absent or malformed gracefully by falling back to standard FHIR queries using the patient and encounter context from the SMART launch token
Known gotchas
The appContext string is passed through the EHR's launch mechanism and may be URL-encoded or base64-encoded depending on the EHR; failing to decode appContext before JSON parsing produces a parse error that leaves the app without context
Not all EHRs that implement CDS Hooks also implement the smart link type; some EHRs will render the link as an absolute URL instead of initiating a SMART EHR launch, which means the app will not receive a patient context and cannot access the FHIR server
The appContext is limited in size by the EHR's URL or token length limits; embedding large JSON payloads such as full FHIR resources in appContext will cause the launch to fail; pass only identifiers and let the app fetch the full resources
Give your agent this knowledge — and 15,600+ 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?