Write Clinical Quality Language (CQL) logic in a text file, defining a library declaration, using statements for FHIR model and terminology, and named expressions for measure populations (e.g., Initial Population, Denominator, Numerator)
Compile the CQL to ELM JSON using the CQL-to-ELM translator (available as a Java tool or via cqf-ruler endpoint) to generate machine-executable logic
Create a FHIR Library resource with content[0].contentType=text/cql and content[0].data containing the base64-encoded CQL text, and content[1].contentType=application/elm+json with the base64-encoded ELM JSON
Set Library.type.coding to logic-library, populate Library.url with the canonical, and add relatedArtifact entries for any dependent Libraries or ValueSets
POST the Library resource to the FHIR server, then reference it from a Measure resource via Measure.library[] with the Library canonical URL
Invoke $evaluate-measure to confirm the embedded CQL logic executes correctly against test patient data
Known gotchas
ELM JSON must be regenerated whenever the CQL text changes; deploying mismatched CQL and ELM content causes the execution engine to silently use the ELM while the CQL text suggests different logic
CQL using-statement model versions must match the FHIR version on the server (e.g., using FHIR version '4.0.1'); version mismatches cause model resolution failures at runtime
Terminology references in CQL (valueset declarations) must point to value set canonical URLs that are resolvable on the server's terminology service at evaluation time, or the population expression will return empty
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp