{
  "resourceType" : "OperationDefinition",
  "id" : "cql-library-evaluate",
  "language" : "en",
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: OperationDefinition cql-library-evaluate</b></p><a name=\"cql-library-evaluate\"> </a><a name=\"hccql-library-evaluate\"> </a><p>URL: [base]/Library/$evaluate</p><p>URL: [base]/Library/[id]/$evaluate</p><h3>Parameters</h3><table class=\"grid\"><tr><td><b>Use</b></td><td><b>Name</b></td><td><b>Scope</b></td><td><b>Cardinality</b></td><td><b>Type</b></td><td><b>Binding</b></td><td><b>Documentation</b></td></tr><tr><td>IN</td><td>url</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#canonical\">canonical</a></td><td/><td><div><p>The canonical url (with optional version) of the library to be evaluated. This parameter is only used when the operation is invoked at the type level, and is exclusive with the library parameter.</p>\n</div></td></tr><tr><td>IN</td><td>library</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/library.html\">Library</a></td><td/><td><div><p>The library to be evaluated, provided as an input. This parameter is only used when the operation is invoked at the type level, and is exclusive with the url parameter.</p>\n</div></td></tr><tr><td>IN</td><td>subject</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#string\">string</a><br/>(<a href=\"https://hl7.org/fhir/R4/search.html#reference\">reference</a>)</td><td/><td><div><p>Subject for which the library will be evaluated. This corresponds to the context in which the library will be evaluated and is represented as a relative FHIR id (e.g. Patient/123), which establishes both the context and context value for the evaluation</p>\n</div></td></tr><tr><td>IN</td><td>expression</td><td/><td>0..*</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#string\">string</a></td><td/><td><div><p>The identifier (optionally qualified) of the expression(s) to be evaluated, regardless of whether the declaration is private. If no expression names are provided, the operation evaluates all public expression definitions in the library (or all expressions if includePrivate is true). If an expression name is unqualified, it refers to the name of an expression defined in the library being evaluated. If the expression name is qualified, the name refers to an the identifier of an expression defined in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively). Note that this may result in expression results being included multiple times, as expressions in included libraries may be invoked multiple times from the library being evaluated.</p>\n</div></td></tr><tr><td>IN</td><td>includePrivate</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#boolean\">boolean</a></td><td/><td><div><p>Indicates whether to include private expression declarations in the result. Note that if expressions are named, this parameter is ignored. If this parameter is not provided, the default behavior is that only public expression declarations will be included.</p>\n</div></td></tr><tr><td>IN</td><td>parameters</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/parameters.html\">Parameters</a></td><td/><td><div><p>Any input parameters for the library. The Parameters resource provided in this input <strong>SHALL</strong> conform to the <a href=\"StructureDefinition-cql-parameters.html\">CQLParameters</a> profile. Parameters defined in this input will be bound by name to parameters defined in the CQL library (or included libraries, recursively). Parameter types are mapped to CQL as specified in the Using CQL section of this implementation guide. If a parameter appears more than once in the input Parameters resource, it is represented with a List in the input CQL. If a parameter has parts, it is represented as a Tuple in the input CQL. Note that parameters may be arbitrarily nested, for example, a list of tuples, or tuples that have list or interval valued elements. If parameter names are qualified, the parameter will be bound only to parameters in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively).</p>\n</div></td></tr><tr><td>IN</td><td>useServerData</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#boolean\">boolean</a></td><td/><td><div><p>Whether to use data from the server performing the evaluation. If this parameter is true (the default), then the operation will use data first from any bundles provided as parameters (through the data and prefetch parameters), second data from the server performing the operation, and third, data from the dataEndpoint parameter (if provided). If this parameter is false, the operation will use data first from the bundles provided in the data or prefetch parameters, and second from the dataEndpoint parameter (if provided).</p>\n</div></td></tr><tr><td>IN</td><td>data</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/bundle.html\">Bundle</a></td><td/><td><div><p>Data to be made available to the library evaluation. This parameter is exclusive with the prefetchData parameter (i.e. either provide all data as a single bundle, or provide data using multiple bundles with prefetch descriptions).</p>\n</div></td></tr><tr><td>IN</td><td>prefetchData</td><td/><td>0..*</td><td/><td/><td><div><p>Data to be made available to the library evaluation, organized as prefetch response bundles. Each prefetchData parameter specifies either the name of the prefetchKey it is satisfying, a DataRequirement describing the prefetch, or both.</p>\n</div></td></tr><tr><td>IN</td><td>prefetchData.key</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#string\">string</a></td><td/><td><div><p>The key of the prefetch item. When using this operation as part of a CDS Hooks implementation, this SHALL be the name of a prefetch item in a CDS Hooks discovery response. Prefetch data SHALL be made available to retrieve statements in the CQL and SHOULD NOT be provided as the value of any CQL parameters in the library being evaluated to avoid confusion between context parameters and retrieve data.</p>\n</div></td></tr><tr><td>IN</td><td>prefetchData.descriptor</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/metadatatypes.html#DataRequirement\">DataRequirement</a></td><td/><td><div><p>A DataRequirement describing the content of the prefetch item.</p>\n</div></td></tr><tr><td>IN</td><td>prefetchData.data</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/bundle.html\">Bundle</a></td><td/><td><div><p>The prefetch data as a Bundle. If this part is missing, it indicates there is no data associated with this prefetch item.</p>\n</div></td></tr><tr><td>IN</td><td>dataEndpoint</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/endpoint.html\">Endpoint</a></td><td/><td><div><p>An endpoint to use to access data referenced by retrieve operations in the library. If provided, this endpoint is used after the data or prefetchData bundles, and the server, if the useServerData parameter is true.</p>\n</div></td></tr><tr><td>IN</td><td>contentEndpoint</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/endpoint.html\">Endpoint</a></td><td/><td><div><p><strong>DEPRECATED: Use the artifactEndpointConfiguration parameter instead.</strong> An endpoint to use to access content (i.e. libraries) referenced by the library. If no content endpoint is supplied, the evaluation will attempt to retrieve content from the server on which the operation is being performed.</p>\n</div></td></tr><tr><td>IN</td><td>terminologyEndpoint</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/endpoint.html\">Endpoint</a></td><td/><td><div><p><strong>DEPRECATED: Use the artifactEndpointConfiguration parameter instead.</strong> An endpoint to use to access terminology (i.e. valuesets, codesystems, and membership testing) referenced by the library. If no terminology endpoint is supplied, the evaluation will attempt to use the server on which the operation is being performed as the terminology server.</p>\n</div></td></tr><tr><td>IN</td><td>artifactEndpointConfiguration</td><td/><td>0..*</td><td/><td/><td><div><p>Configuration information to resolve canonical artifacts</p>\n<ul>\n<li><code>artifactRoute</code>: An optional route used to determine whether this endpoint is expected to be able to resolve artifacts that match the route (i.e. start with the route, up to and including the entire url)</li>\n<li><code>endpointUri</code>: The URI of the endpoint, exclusive with the <code>endpoint</code> parameter</li>\n<li><code>endpoint</code>: An Endpoint resource describing the endpoint, exclusive with the <code>endpointUri</code> parameter</li>\n</ul>\n<p><strong>Processing semantics</strong>:</p>\n<p>Create a canonical-like reference (e.g.\n<code>{canonical.url}|{canonical.version}</code> or similar extensions for non-canonical artifacts).</p>\n<ul>\n<li>Given a single <code>artifactEndpointConfiguration</code>\n<ul>\n<li>When <code>artifactRoute</code> is present\n<ul>\n<li>And canonical or artifact reference <em>starts with</em> <code>artifactRoute</code></li>\n<li>Then attempt to resolve with <code>endpointUri</code> or <code>endpoint</code></li>\n</ul>\n</li>\n<li>When <code>artifactRoute</code> is not present\n<ul>\n<li>Then attempt to resolve with <code>endpointUri</code> or <code>endpoint</code></li>\n</ul>\n</li>\n</ul>\n</li>\n<li>Given multiple <code>artifactEndpointConfiguration</code>s\n<ul>\n<li>Then rank order each configuration (see below)</li>\n<li>And attempt to resolve with <code>endpointUri</code> or <code>endpoint</code> in order until resolved</li>\n</ul>\n</li>\n</ul>\n<p>Rank each <code>artifactEndpointConfiguration</code> such that:</p>\n<ul>\n<li>if <code>artifactRoute</code> is present <em>and</em> canonical or artifact reference <em>starts with</em> <code>artifactRoute</code>: rank based on number of matching characters</li>\n<li>if <code>artifactRoute</code> is <em>not</em> present: include but rank lower</li>\n</ul>\n<p>NOTE: For evenly ranked <code>artifactEndpointConfiguration</code>s, order as defined in the\nOperationDefinition.</p>\n</div></td></tr><tr><td>IN</td><td>artifactEndpointConfiguration.artifactRoute</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#uri\">uri</a></td><td/><td/></tr><tr><td>IN</td><td>artifactEndpointConfiguration.endpointUri</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#uri\">uri</a></td><td/><td/></tr><tr><td>IN</td><td>artifactEndpointConfiguration.endpoint</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/endpoint.html\">Endpoint</a></td><td/><td/></tr><tr><td>IN</td><td>timestamp</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#dateTime\">dateTime</a></td><td/><td><div><p>The timestamp of the evaluation request.</p>\n</div></td></tr><tr><td>OUT</td><td>return</td><td/><td>1..1</td><td><a href=\"http://hl7.org/fhir/R4/parameters.html\">Parameters</a></td><td/><td><div><p>The results of the library evaluation, returned as a Parameters resource with a parameter for each named expression requested by the expression input parameter (or all public (or all, if includePrivate is true) top-level expressions defined in the library if no expression input parameter was specified). Note that explicit request for evaluation of an expression does not respect the access modifier (i.e. even private expressions can be evaluated by directly requesting evaluation of the expression by name). In addition, the resulting Parameters resource <strong>SHALL</strong> conform to the <a href=\"StructureDefinition-cql-parameters.html\">CQLParameters</a> profile. As well, the result may include a <code>_messages</code> parameter this is an OperationOutcome resource containing any information, warning, and/or error messages that were generated while evaluating the CQL Library.</p>\n<p>Operation processing often generates information, warning, or error messages that don't necessarily stop processing (and so don't result in an OperationOutcome as the overall result of the operation) but still need to be communicated as part of the result. This parameter allows for these messages to be included as a reference to an OperationOutcome resource. Note that if the library already has an expression with the name <code>_messages</code>, this parameter will not overwrite that result (i.e. there is no way to retrieve the OperationOutcome messsages for the evaluation in that case).</p>\n</div></td></tr></table></div>"
  },
  "extension" : [{
    "url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm",
    "valueInteger" : 4
  },
  {
    "url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-wg",
    "valueCode" : "cds"
  },
  {
    "url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
    "valueCode" : "trial-use"
  }],
  "url" : "http://hl7.org/fhir/uv/cql/OperationDefinition/cql-library-evaluate",
  "version" : "3.0.0-ballot",
  "name" : "CQLLibraryEvaluate",
  "title" : "CQL Library Evaluate",
  "status" : "active",
  "kind" : "operation",
  "experimental" : false,
  "date" : "2023-11-27T16:26:11+00:00",
  "publisher" : "HL7 International / Clinical Decision Support",
  "contact" : [{
    "telecom" : [{
      "system" : "url",
      "value" : "http://www.hl7.org/Special/committees/dss"
    }]
  }],
  "description" : "Evaluates the contents of a library and returns the results as a Parameters resource. Results are returned as described in the FHIR Type Mapping section of the conformance page of this implementation guide. Unless specific expressions are named, the operation will provide the results for all public top-level expression declarations in the library. Use the includePrivate parameter to indicate that private expressions should be included as well.",
  "jurisdiction" : [{
    "coding" : [{
      "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
      "code" : "001",
      "display" : "World"
    }]
  }],
  "purpose" : "This operation is defined to support evaluating the contents of a library directly via an operation",
  "affectsState" : false,
  "code" : "evaluate",
  "resource" : ["Library"],
  "system" : false,
  "type" : true,
  "instance" : true,
  "parameter" : [{
    "name" : "url",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "The canonical url (with optional version) of the library to be evaluated. This parameter is only used when the operation is invoked at the type level, and is exclusive with the library parameter.",
    "type" : "canonical"
  },
  {
    "name" : "library",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "The library to be evaluated, provided as an input. This parameter is only used when the operation is invoked at the type level, and is exclusive with the url parameter.",
    "type" : "Library"
  },
  {
    "name" : "subject",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Subject for which the library will be evaluated. This corresponds to the context in which the library will be evaluated and is represented as a relative FHIR id (e.g. Patient/123), which establishes both the context and context value for the evaluation",
    "type" : "string",
    "searchType" : "reference"
  },
  {
    "name" : "expression",
    "use" : "in",
    "min" : 0,
    "max" : "*",
    "documentation" : "The identifier (optionally qualified) of the expression(s) to be evaluated, regardless of whether the declaration is private. If no expression names are provided, the operation evaluates all public expression definitions in the library (or all expressions if includePrivate is true). If an expression name is unqualified, it refers to the name of an expression defined in the library being evaluated. If the expression name is qualified, the name refers to an the identifier of an expression defined in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively). Note that this may result in expression results being included multiple times, as expressions in included libraries may be invoked multiple times from the library being evaluated.",
    "type" : "string"
  },
  {
    "name" : "includePrivate",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Indicates whether to include private expression declarations in the result. Note that if expressions are named, this parameter is ignored. If this parameter is not provided, the default behavior is that only public expression declarations will be included.",
    "type" : "boolean"
  },
  {
    "name" : "parameters",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Any input parameters for the library. The Parameters resource provided in this input **SHALL** conform to the [CQLParameters](StructureDefinition-cql-parameters.html) profile. Parameters defined in this input will be bound by name to parameters defined in the CQL library (or included libraries, recursively). Parameter types are mapped to CQL as specified in the Using CQL section of this implementation guide. If a parameter appears more than once in the input Parameters resource, it is represented with a List in the input CQL. If a parameter has parts, it is represented as a Tuple in the input CQL. Note that parameters may be arbitrarily nested, for example, a list of tuples, or tuples that have list or interval valued elements. If parameter names are qualified, the parameter will be bound only to parameters in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively).",
    "type" : "Parameters"
  },
  {
    "name" : "useServerData",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Whether to use data from the server performing the evaluation. If this parameter is true (the default), then the operation will use data first from any bundles provided as parameters (through the data and prefetch parameters), second data from the server performing the operation, and third, data from the dataEndpoint parameter (if provided). If this parameter is false, the operation will use data first from the bundles provided in the data or prefetch parameters, and second from the dataEndpoint parameter (if provided).",
    "type" : "boolean"
  },
  {
    "name" : "data",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Data to be made available to the library evaluation. This parameter is exclusive with the prefetchData parameter (i.e. either provide all data as a single bundle, or provide data using multiple bundles with prefetch descriptions).",
    "type" : "Bundle"
  },
  {
    "name" : "prefetchData",
    "use" : "in",
    "min" : 0,
    "max" : "*",
    "documentation" : "Data to be made available to the library evaluation, organized as prefetch response bundles. Each prefetchData parameter specifies either the name of the prefetchKey it is satisfying, a DataRequirement describing the prefetch, or both.",
    "part" : [{
      "name" : "key",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "documentation" : "The key of the prefetch item. When using this operation as part of a CDS Hooks implementation, this SHALL be the name of a prefetch item in a CDS Hooks discovery response. Prefetch data SHALL be made available to retrieve statements in the CQL and SHOULD NOT be provided as the value of any CQL parameters in the library being evaluated to avoid confusion between context parameters and retrieve data.",
      "type" : "string"
    },
    {
      "name" : "descriptor",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "documentation" : "A DataRequirement describing the content of the prefetch item.",
      "type" : "DataRequirement"
    },
    {
      "name" : "data",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "documentation" : "The prefetch data as a Bundle. If this part is missing, it indicates there is no data associated with this prefetch item.",
      "type" : "Bundle"
    }]
  },
  {
    "name" : "dataEndpoint",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "An endpoint to use to access data referenced by retrieve operations in the library. If provided, this endpoint is used after the data or prefetchData bundles, and the server, if the useServerData parameter is true.",
    "type" : "Endpoint"
  },
  {
    "name" : "contentEndpoint",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "**DEPRECATED: Use the artifactEndpointConfiguration parameter instead.** An endpoint to use to access content (i.e. libraries) referenced by the library. If no content endpoint is supplied, the evaluation will attempt to retrieve content from the server on which the operation is being performed.",
    "type" : "Endpoint"
  },
  {
    "name" : "terminologyEndpoint",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "**DEPRECATED: Use the artifactEndpointConfiguration parameter instead.** An endpoint to use to access terminology (i.e. valuesets, codesystems, and membership testing) referenced by the library. If no terminology endpoint is supplied, the evaluation will attempt to use the server on which the operation is being performed as the terminology server.",
    "type" : "Endpoint"
  },
  {
    "name" : "artifactEndpointConfiguration",
    "use" : "in",
    "min" : 0,
    "max" : "*",
    "documentation" : "Configuration information to resolve canonical artifacts\n* `artifactRoute`: An optional route used to determine whether this endpoint is expected to be able to resolve artifacts that match the route (i.e. start with the route, up to and including the entire url)\n* `endpointUri`: The URI of the endpoint, exclusive with the `endpoint` parameter\n* `endpoint`: An Endpoint resource describing the endpoint, exclusive with the `endpointUri` parameter\n\n**Processing semantics**:\n\nCreate a canonical-like reference (e.g.\n`{canonical.url}|{canonical.version}` or similar extensions for non-canonical artifacts).\n\n* Given a single `artifactEndpointConfiguration`\n  * When `artifactRoute` is present\n    * And canonical or artifact reference *starts with* `artifactRoute`\n    * Then attempt to resolve with `endpointUri` or `endpoint`\n  * When `artifactRoute` is not present\n    * Then attempt to resolve with `endpointUri` or `endpoint`\n* Given multiple `artifactEndpointConfiguration`s\n  * Then rank order each configuration (see below)\n  * And attempt to resolve with `endpointUri` or `endpoint` in order until resolved\n\nRank each `artifactEndpointConfiguration` such that:\n* if `artifactRoute` is present *and* canonical or artifact reference *starts with* `artifactRoute`: rank based on number of matching characters \n* if `artifactRoute` is *not* present: include but rank lower\n\nNOTE: For evenly ranked `artifactEndpointConfiguration`s, order as defined in the\nOperationDefinition.",
    "part" : [{
      "name" : "artifactRoute",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "type" : "uri"
    },
    {
      "name" : "endpointUri",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "type" : "uri"
    },
    {
      "name" : "endpoint",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "type" : "Endpoint"
    }]
  },
  {
    "name" : "timestamp",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "The timestamp of the evaluation request.",
    "type" : "dateTime"
  },
  {
    "name" : "return",
    "use" : "out",
    "min" : 1,
    "max" : "1",
    "documentation" : "The results of the library evaluation, returned as a Parameters resource with a parameter for each named expression requested by the expression input parameter (or all public (or all, if includePrivate is true) top-level expressions defined in the library if no expression input parameter was specified). Note that explicit request for evaluation of an expression does not respect the access modifier (i.e. even private expressions can be evaluated by directly requesting evaluation of the expression by name). In addition, the resulting Parameters resource **SHALL** conform to the [CQLParameters](StructureDefinition-cql-parameters.html) profile. As well, the result may include a `_messages` parameter this is an OperationOutcome resource containing any information, warning, and/or error messages that were generated while evaluating the CQL Library.\n\nOperation processing often generates information, warning, or error messages that don't necessarily stop processing (and so don't result in an OperationOutcome as the overall result of the operation) but still need to be communicated as part of the result. This parameter allows for these messages to be included as a reference to an OperationOutcome resource. Note that if the library already has an expression with the name `_messages`, this parameter will not overwrite that result (i.e. there is no way to retrieve the OperationOutcome messsages for the evaluation in that case).",
    "type" : "Parameters"
  }]
}